core.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # -*- coding: utf-8 -*-
  2. from demeter.core import *
  3. class Core(object):
  4. def agreement(self):
  5. return [
  6. {'id':1,'name':'mqtt'}
  7. ,{'id':2,'name':'modbus'}]
  8. def register_type(self):
  9. return [
  10. {'id':1,'name':'线圈寄存器'}
  11. ,{'id':2,'name':'离散输入寄存器'}
  12. ,{'id':3,'name':'保持寄存器'}
  13. ,{'id':4,'name':'输入寄存器'}]
  14. def oper_type(self):
  15. return [{'id':1,'name':'读取'},{'id':2,'name':'写入'}]
  16. def data_type(self):
  17. return [
  18. {'id':1,'name':'输入框'}
  19. ,{'id':2,'name':'单选框'}
  20. ,{'id':3,'name':'多选框'}
  21. ,{'id':4,'name':'按钮'}]
  22. def server_type(self):
  23. return [{'id':1,'name':'mqtt'},{'id':2,'name':'modbus_tcp'},{'id':3,'name':'modbus_rtu'}]
  24. # 根据oper_type判断是传感器还是控制器
  25. def hardware_type(self, oper_type):
  26. if oper_type == 1:
  27. return 2
  28. elif oper_type == 2:
  29. return 3
  30. elif oper_type == 3:
  31. return 6
  32. elif oper_type == 4:
  33. return 7