modbus.py 776 B

12345678910111213141516171819202122232425262728293031323334
  1. # -*- coding: utf-8 -*-
  2. """
  3. demeter web
  4. name:admin.py
  5. author:rabin
  6. """
  7. from demeter.core import *
  8. param = {}
  9. param['method'] = 'm'
  10. param['id'] = 'i'
  11. Demeter.getopt(param)
  12. Demeter.echo(Demeter.option['method'])
  13. method = ''
  14. if 'tcp' in Demeter.option['method']:
  15. method = 'tcp'
  16. else:
  17. method = 'rtu'
  18. if Demeter.option['method'] == method + '_client' and Demeter.option['id']:
  19. # 测试某一个客户端
  20. Demeter.service(method, 'modbus').client(Demeter.option['id'])
  21. elif Demeter.option['method'] == method + '_start':
  22. # 启动所有客户端
  23. Demeter.service(method, 'modbus').start()
  24. elif Demeter.option['method'] == method + 'server':
  25. # 启动服务端
  26. Demeter.service(method, 'modbus').server()
  27. else:
  28. # 测试
  29. Demeter.service('old', 'modbus').server()