slmp-connect-python 0.1.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- slmp/__init__.py +119 -0
- slmp/async_client.py +1368 -0
- slmp/cli.py +6193 -0
- slmp/client.py +1943 -0
- slmp/constants.py +167 -0
- slmp/core.py +975 -0
- slmp/errors.py +25 -0
- slmp/py.typed +1 -0
- slmp/utils.py +893 -0
- slmp_connect_python-0.1.4.dist-info/METADATA +247 -0
- slmp_connect_python-0.1.4.dist-info/RECORD +15 -0
- slmp_connect_python-0.1.4.dist-info/WHEEL +5 -0
- slmp_connect_python-0.1.4.dist-info/entry_points.txt +20 -0
- slmp_connect_python-0.1.4.dist-info/licenses/LICENSE +21 -0
- slmp_connect_python-0.1.4.dist-info/top_level.txt +1 -0
slmp/constants.py
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"""SLMP 4E binary constants and command/device definitions."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from enum import Enum, IntEnum
|
|
7
|
+
|
|
8
|
+
FRAME_3E_REQUEST_SUBHEADER = b"\x50\x00"
|
|
9
|
+
FRAME_3E_RESPONSE_SUBHEADER = b"\xd0\x00"
|
|
10
|
+
FRAME_4E_REQUEST_SUBHEADER = b"\x54\x00"
|
|
11
|
+
FRAME_4E_RESPONSE_SUBHEADER = b"\xd4\x00"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class FrameType(str, Enum):
|
|
15
|
+
"""SLMP frame type (3E or 4E)."""
|
|
16
|
+
|
|
17
|
+
FRAME_3E = "3e"
|
|
18
|
+
FRAME_4E = "4e"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class PLCSeries(str, Enum):
|
|
22
|
+
"""Series option for subcommand compatibility."""
|
|
23
|
+
|
|
24
|
+
QL = "ql" # MELSEC-Q/L compatible (0000/0001)
|
|
25
|
+
IQR = "iqr" # MELSEC iQ-R/iQ-L (0002/0003)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class DeviceUnit(IntEnum):
|
|
29
|
+
"""Device unit (bit or word)."""
|
|
30
|
+
|
|
31
|
+
BIT = 0
|
|
32
|
+
WORD = 1
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class ModuleIONo(IntEnum):
|
|
36
|
+
"""Request destination module I/O No. from SH080956ENGN 4.2."""
|
|
37
|
+
|
|
38
|
+
OWN_STATION = 0x03FF
|
|
39
|
+
CONTROL_CPU = 0x03FF
|
|
40
|
+
MULTIPLE_CPU_1 = 0x03E0
|
|
41
|
+
MULTIPLE_CPU_2 = 0x03E1
|
|
42
|
+
MULTIPLE_CPU_3 = 0x03E2
|
|
43
|
+
MULTIPLE_CPU_4 = 0x03E3
|
|
44
|
+
CONTROL_SYSTEM_CPU = 0x03D0
|
|
45
|
+
STANDBY_SYSTEM_CPU = 0x03D1
|
|
46
|
+
SYSTEM_A_CPU = 0x03D2
|
|
47
|
+
SYSTEM_B_CPU = 0x03D3
|
|
48
|
+
|
|
49
|
+
# Remote head aliases
|
|
50
|
+
REMOTE_HEAD_1 = 0x03E0
|
|
51
|
+
REMOTE_HEAD_2 = 0x03E1
|
|
52
|
+
CONTROL_SYSTEM_REMOTE_HEAD = 0x03D0
|
|
53
|
+
STANDBY_SYSTEM_REMOTE_HEAD = 0x03D1
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class Command(IntEnum):
|
|
57
|
+
"""Command list from SH080956ENGN 5.1."""
|
|
58
|
+
|
|
59
|
+
# Device
|
|
60
|
+
DEVICE_READ = 0x0401
|
|
61
|
+
DEVICE_WRITE = 0x1401
|
|
62
|
+
DEVICE_READ_RANDOM = 0x0403
|
|
63
|
+
DEVICE_WRITE_RANDOM = 0x1402
|
|
64
|
+
DEVICE_ENTRY_MONITOR = 0x0801
|
|
65
|
+
DEVICE_EXECUTE_MONITOR = 0x0802
|
|
66
|
+
DEVICE_READ_BLOCK = 0x0406
|
|
67
|
+
DEVICE_WRITE_BLOCK = 0x1406
|
|
68
|
+
|
|
69
|
+
# Label
|
|
70
|
+
LABEL_ARRAY_READ = 0x041A
|
|
71
|
+
LABEL_ARRAY_WRITE = 0x141A
|
|
72
|
+
LABEL_READ_RANDOM = 0x041C
|
|
73
|
+
LABEL_WRITE_RANDOM = 0x141B
|
|
74
|
+
|
|
75
|
+
# Memory / Extend unit
|
|
76
|
+
MEMORY_READ = 0x0613
|
|
77
|
+
MEMORY_WRITE = 0x1613
|
|
78
|
+
EXTEND_UNIT_READ = 0x0601
|
|
79
|
+
EXTEND_UNIT_WRITE = 0x1601
|
|
80
|
+
|
|
81
|
+
# Remote control
|
|
82
|
+
REMOTE_RUN = 0x1001
|
|
83
|
+
REMOTE_STOP = 0x1002
|
|
84
|
+
REMOTE_PAUSE = 0x1003
|
|
85
|
+
REMOTE_LATCH_CLEAR = 0x1005
|
|
86
|
+
REMOTE_RESET = 0x1006
|
|
87
|
+
READ_TYPE_NAME = 0x0101
|
|
88
|
+
|
|
89
|
+
# Remote password
|
|
90
|
+
REMOTE_PASSWORD_LOCK = 0x1631
|
|
91
|
+
REMOTE_PASSWORD_UNLOCK = 0x1630
|
|
92
|
+
|
|
93
|
+
# Other
|
|
94
|
+
SELF_TEST = 0x0619
|
|
95
|
+
CLEAR_ERROR = 0x1617
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
SUBCOMMAND_DEVICE_WORD_QL = 0x0000
|
|
99
|
+
SUBCOMMAND_DEVICE_BIT_QL = 0x0001
|
|
100
|
+
SUBCOMMAND_DEVICE_WORD_IQR = 0x0002
|
|
101
|
+
SUBCOMMAND_DEVICE_BIT_IQR = 0x0003
|
|
102
|
+
|
|
103
|
+
SUBCOMMAND_DEVICE_WORD_QL_EXT = 0x0080
|
|
104
|
+
SUBCOMMAND_DEVICE_BIT_QL_EXT = 0x0081
|
|
105
|
+
SUBCOMMAND_DEVICE_WORD_IQR_EXT = 0x0082
|
|
106
|
+
SUBCOMMAND_DEVICE_BIT_IQR_EXT = 0x0083
|
|
107
|
+
|
|
108
|
+
# Direct memory specification (binary, Extended Device)
|
|
109
|
+
DIRECT_MEMORY_NORMAL = 0x00
|
|
110
|
+
DIRECT_MEMORY_MODULE_ACCESS = 0xF8
|
|
111
|
+
DIRECT_MEMORY_LINK_DIRECT = 0xF9
|
|
112
|
+
DIRECT_MEMORY_CPU_BUFFER = 0xFA
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
@dataclass(frozen=True)
|
|
116
|
+
class DeviceCode:
|
|
117
|
+
"""Device code and number radix."""
|
|
118
|
+
|
|
119
|
+
code: int
|
|
120
|
+
radix: int # 10 or 16
|
|
121
|
+
unit: DeviceUnit = DeviceUnit.WORD
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
# Device codes from SH080956ENGN 5.2 (binary code column).
|
|
125
|
+
DEVICE_CODES: dict[str, DeviceCode] = {
|
|
126
|
+
"SM": DeviceCode(0x0091, 10, DeviceUnit.BIT),
|
|
127
|
+
"SD": DeviceCode(0x00A9, 10, DeviceUnit.WORD),
|
|
128
|
+
"X": DeviceCode(0x009C, 16, DeviceUnit.BIT),
|
|
129
|
+
"Y": DeviceCode(0x009D, 16, DeviceUnit.BIT),
|
|
130
|
+
"M": DeviceCode(0x0090, 10, DeviceUnit.BIT),
|
|
131
|
+
"L": DeviceCode(0x0092, 10, DeviceUnit.BIT),
|
|
132
|
+
"F": DeviceCode(0x0093, 10, DeviceUnit.BIT),
|
|
133
|
+
"V": DeviceCode(0x0094, 10, DeviceUnit.BIT),
|
|
134
|
+
"B": DeviceCode(0x00A0, 16, DeviceUnit.BIT),
|
|
135
|
+
"D": DeviceCode(0x00A8, 10, DeviceUnit.WORD),
|
|
136
|
+
"W": DeviceCode(0x00B4, 16, DeviceUnit.WORD),
|
|
137
|
+
"TS": DeviceCode(0x00C1, 10, DeviceUnit.BIT),
|
|
138
|
+
"TC": DeviceCode(0x00C0, 10, DeviceUnit.BIT),
|
|
139
|
+
"TN": DeviceCode(0x00C2, 10, DeviceUnit.WORD),
|
|
140
|
+
"LTS": DeviceCode(0x0051, 10, DeviceUnit.BIT),
|
|
141
|
+
"LTC": DeviceCode(0x0050, 10, DeviceUnit.BIT),
|
|
142
|
+
"LTN": DeviceCode(0x0052, 10, DeviceUnit.WORD),
|
|
143
|
+
"STS": DeviceCode(0x00C7, 10, DeviceUnit.BIT),
|
|
144
|
+
"STC": DeviceCode(0x00C6, 10, DeviceUnit.BIT),
|
|
145
|
+
"STN": DeviceCode(0x00C8, 10, DeviceUnit.WORD),
|
|
146
|
+
"LSTS": DeviceCode(0x0059, 10, DeviceUnit.BIT),
|
|
147
|
+
"LSTC": DeviceCode(0x0058, 10, DeviceUnit.BIT),
|
|
148
|
+
"LSTN": DeviceCode(0x005A, 10, DeviceUnit.WORD),
|
|
149
|
+
"CS": DeviceCode(0x00C4, 10, DeviceUnit.BIT),
|
|
150
|
+
"CC": DeviceCode(0x00C3, 10, DeviceUnit.BIT),
|
|
151
|
+
"CN": DeviceCode(0x00C5, 10, DeviceUnit.WORD),
|
|
152
|
+
"LCS": DeviceCode(0x0055, 10, DeviceUnit.BIT),
|
|
153
|
+
"LCC": DeviceCode(0x0054, 10, DeviceUnit.BIT),
|
|
154
|
+
"LCN": DeviceCode(0x0056, 10, DeviceUnit.WORD),
|
|
155
|
+
"SB": DeviceCode(0x00A1, 16, DeviceUnit.BIT),
|
|
156
|
+
"SW": DeviceCode(0x00B5, 16, DeviceUnit.WORD),
|
|
157
|
+
"DX": DeviceCode(0x00A2, 16, DeviceUnit.BIT),
|
|
158
|
+
"DY": DeviceCode(0x00A3, 16, DeviceUnit.BIT),
|
|
159
|
+
"Z": DeviceCode(0x00CC, 10, DeviceUnit.WORD),
|
|
160
|
+
"LZ": DeviceCode(0x0062, 10, DeviceUnit.WORD),
|
|
161
|
+
"R": DeviceCode(0x00AF, 10, DeviceUnit.WORD),
|
|
162
|
+
"ZR": DeviceCode(0x00B0, 10, DeviceUnit.WORD),
|
|
163
|
+
"RD": DeviceCode(0x002C, 10, DeviceUnit.WORD),
|
|
164
|
+
# Extended Device extension device codes
|
|
165
|
+
"G": DeviceCode(0x00AB, 10, DeviceUnit.WORD),
|
|
166
|
+
"HG": DeviceCode(0x002E, 10, DeviceUnit.WORD),
|
|
167
|
+
}
|