| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- from __future__ import annotations
- from .base import ProtocolSpec
- S7_REGISTER_TYPE_ALIASES = {
- "i": 1,
- "input": 1,
- "输入": 1,
- "q": 2,
- "output": 2,
- "输出": 2,
- "m": 3,
- "memory": 3,
- "位存储": 3,
- "db": 4,
- "data_block": 4,
- "数据块": 4,
- "v": 5,
- "v_memory": 5,
- "v区": 5,
- "ai": 6,
- "analog_input": 6,
- "模拟输入": 6,
- }
- S7_POINT_TYPE_ALIASES = {
- "bool": "bool",
- "boolean": "bool",
- "BOOL": "bool",
- "byte": "uint8",
- "BYTE": "uint8",
- "uint8": "uint8",
- "UINT8": "uint8",
- "sint": "int8",
- "SINT": "int8",
- "int8": "int8",
- "INT8": "int8",
- "word": "uint16",
- "WORD": "uint16",
- "uint16": "uint16",
- "UINT16": "uint16",
- "int": "int16",
- "INT": "int16",
- "short": "int16",
- "SHORT": "int16",
- "int16": "int16",
- "INT16": "int16",
- "dword": "uint32",
- "DWORD": "uint32",
- "uint32": "uint32",
- "UINT32": "uint32",
- "dint": "int32",
- "DINT": "int32",
- "long": "int32",
- "LONG": "int32",
- "int32": "int32",
- "INT32": "int32",
- "real": "float32",
- "REAL": "float32",
- "float": "float32",
- "FLOAT": "float32",
- "float32": "float32",
- "FLOAT32": "float32",
- "lreal": "float64",
- "LREAL": "float64",
- "double": "float64",
- "DOUBLE": "float64",
- "float64": "float64",
- "FLOAT64": "float64",
- }
- S7_SPEC = ProtocolSpec(
- protocol="s7",
- create_device_path="/api/collector/device",
- create_point_path="/api/collector/s7/point/add",
- point_test_path="/api/dc-gateway/s7/read_points",
- raw_read_path="/api/dc-gateway/s7/read",
- connect_scan_path="/api/dc-gateway/s7/connect_scan",
- device_defaults={
- "type": "s7",
- "device_type": 1,
- "port": 102,
- "tsap_conn_type": "PG",
- "timeout": 3,
- "is_persistent": True,
- "device_group_id": 0,
- "alarm_interval": 90,
- "collect_interval": 5,
- },
- point_defaults={
- "point_id": "",
- "scale_ratio": 1,
- "value_offset": 0,
- "group_Id": 0,
- "invalid_values": "",
- "valid_range_start": None,
- "valid_range_end": None,
- },
- )
|