s7.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. from __future__ import annotations
  2. from .base import ProtocolSpec
  3. S7_REGISTER_TYPE_ALIASES = {
  4. "i": 1,
  5. "input": 1,
  6. "输入": 1,
  7. "q": 2,
  8. "output": 2,
  9. "输出": 2,
  10. "m": 3,
  11. "memory": 3,
  12. "位存储": 3,
  13. "db": 4,
  14. "data_block": 4,
  15. "数据块": 4,
  16. "v": 5,
  17. "v_memory": 5,
  18. "v区": 5,
  19. "ai": 6,
  20. "analog_input": 6,
  21. "模拟输入": 6,
  22. }
  23. S7_POINT_TYPE_ALIASES = {
  24. "bool": "bool",
  25. "boolean": "bool",
  26. "BOOL": "bool",
  27. "byte": "uint8",
  28. "BYTE": "uint8",
  29. "uint8": "uint8",
  30. "UINT8": "uint8",
  31. "sint": "int8",
  32. "SINT": "int8",
  33. "int8": "int8",
  34. "INT8": "int8",
  35. "word": "uint16",
  36. "WORD": "uint16",
  37. "uint16": "uint16",
  38. "UINT16": "uint16",
  39. "int": "int16",
  40. "INT": "int16",
  41. "short": "int16",
  42. "SHORT": "int16",
  43. "int16": "int16",
  44. "INT16": "int16",
  45. "dword": "uint32",
  46. "DWORD": "uint32",
  47. "uint32": "uint32",
  48. "UINT32": "uint32",
  49. "dint": "int32",
  50. "DINT": "int32",
  51. "long": "int32",
  52. "LONG": "int32",
  53. "int32": "int32",
  54. "INT32": "int32",
  55. "real": "float32",
  56. "REAL": "float32",
  57. "float": "float32",
  58. "FLOAT": "float32",
  59. "float32": "float32",
  60. "FLOAT32": "float32",
  61. "lreal": "float64",
  62. "LREAL": "float64",
  63. "double": "float64",
  64. "DOUBLE": "float64",
  65. "float64": "float64",
  66. "FLOAT64": "float64",
  67. }
  68. S7_SPEC = ProtocolSpec(
  69. protocol="s7",
  70. create_device_path="/api/collector/device",
  71. create_point_path="/api/collector/s7/point/add",
  72. point_test_path="/api/dc-gateway/s7/read_points",
  73. raw_read_path="/api/dc-gateway/s7/read",
  74. connect_scan_path="/api/dc-gateway/s7/connect_scan",
  75. device_defaults={
  76. "type": "s7",
  77. "device_type": 1,
  78. "port": 102,
  79. "tsap_conn_type": "PG",
  80. "timeout": 3,
  81. "is_persistent": True,
  82. "device_group_id": 0,
  83. "alarm_interval": 90,
  84. "collect_interval": 5,
  85. },
  86. point_defaults={
  87. "point_id": "",
  88. "scale_ratio": 1,
  89. "value_offset": 0,
  90. "group_Id": 0,
  91. "invalid_values": "",
  92. "valid_range_start": None,
  93. "valid_range_end": None,
  94. },
  95. )