pymscada 0.0.15__py3-none-any.whl → 0.1.0__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.

Potentially problematic release.


This version of pymscada might be problematic. Click here for more details.

pymscada/checkout.py CHANGED
@@ -1,4 +1,5 @@
1
1
  """Create base config folder and check out demo files."""
2
+ import difflib
2
3
  from pathlib import Path
3
4
  import sys
4
5
  from pymscada.config import get_demo_files, get_pdf_files
@@ -36,7 +37,7 @@ def make_pdf():
36
37
  target.write_bytes(pdf_file.read_bytes())
37
38
 
38
39
 
39
- def make_config(overwrite):
40
+ def make_config(overwrite: bool):
40
41
  """Make the config folder, if missing, and copy files in."""
41
42
  config_dir = PATH['__DIR__'].joinpath('config')
42
43
  if not config_dir.exists():
@@ -62,11 +63,43 @@ def make_config(overwrite):
62
63
  target.write_bytes(config_file.read_bytes())
63
64
 
64
65
 
65
- def checkout(overwrite=False):
66
+ def read_with_subst(file: Path):
67
+ """Read the file and replace DIR markers."""
68
+ rd = file.read_bytes().decode()
69
+ if str(file).endswith('service'):
70
+ for k, v in PATH.items():
71
+ rd = rd.replace(k, str(v.absolute()))
72
+ lines = rd.splitlines()
73
+ return lines
74
+
75
+
76
+ def compare_config():
77
+ """Compare old and new config."""
78
+ config_dir = PATH['__DIR__'].joinpath('config')
79
+ if not config_dir.exists():
80
+ print('No config dir, are you in the right directory')
81
+ return
82
+ for config_file in get_demo_files():
83
+ target = config_dir.joinpath(config_file.name)
84
+ if target.exists():
85
+ new_lines = read_with_subst(config_file)
86
+ old_lines = read_with_subst(target)
87
+ diff = list(difflib.unified_diff(old_lines, new_lines,
88
+ fromfile=str(target), tofile=str(config_file)))
89
+ if len(diff):
90
+ print('\n'.join(diff), '\n')
91
+ else:
92
+ print(f'\n--- MISSING FILE\n\n+++ {config_file}')
93
+
94
+
95
+ def checkout(overwrite=False, diff=False):
66
96
  """Do it."""
67
97
  for name in PATH:
68
98
  if not PATH[name].exists():
69
99
  raise SystemExit(f'{PATH[name]} is missing')
70
- make_history()
71
- make_pdf()
72
- make_config(overwrite)
100
+ if diff:
101
+ compare_config()
102
+ else:
103
+ make_history()
104
+ make_pdf()
105
+ make_config(overwrite)
@@ -4,14 +4,10 @@ rtus:
4
4
  - name: Ani
5
5
  ip: 172.26.7.196
6
6
  rate: 0.2
7
- read:
7
+ poll:
8
8
  - {addr: Fout, type: 'REAL[]', start: 0, end: 99}
9
9
  - {addr: Iout, type: 'DINT[]', start: 0, end: 99}
10
10
  - {addr: OutVar, type: REAL}
11
- writeok:
12
- - {addr: Fin, type: 'REAL[]', start: 0, end: 99}
13
- - {addr: Iin, type: 'REAL[]', start: 0, end: 99}
14
- - {addr: InVar, type: REAL}
15
11
  tags:
16
12
  Ani_Fin_20:
17
13
  type: float32
@@ -19,32 +15,32 @@ tags:
19
15
  write: 'Ani:Fin[20]'
20
16
  Ani_Fout_20:
21
17
  type: float32
22
- addr: 'Ani:Fout[20]'
18
+ read: 'Ani:Fout[20]'
23
19
  Ani_Iin_20:
24
20
  type: int32
25
21
  read: 'Ani:Iout[20]'
26
22
  write: 'Ani:Iin[20]'
27
23
  Ani_Iout_20:
28
24
  type: int32
29
- addr: 'Ani:Iout[20]'
25
+ read: 'Ani:Iout[20]'
30
26
  Ani_Iin_21_0:
31
27
  type: bool
32
28
  read: 'Ani:Iout[21].0'
33
29
  write: 'Ani:Iin[21].0'
34
30
  Ani_Iout_21_0:
35
31
  type: bool
36
- addr: 'Ani:Iout[21].0'
32
+ read: 'Ani:Iout[21].0'
37
33
  Ani_Iin_21_1:
38
34
  type: bool
39
35
  read: 'Ani:Iout[21].1'
40
36
  write: 'Ani:Iin[21].1'
41
37
  Ani_Iout_21_1:
42
38
  type: bool
43
- addr: 'Ani:Iout[21].1'
39
+ read: 'Ani:Iout[21].1'
44
40
  InVar:
45
41
  type: float32
46
42
  read: Ani:OutVar
47
43
  write: Ani:InVar
48
44
  OutVar:
49
45
  type: float32
50
- addr: Ani:OutVar
46
+ read: Ani:OutVar
@@ -6,54 +6,58 @@ rtus:
6
6
  port: 1502
7
7
  tcp_udp: tcp
8
8
  rate: 0.2
9
- read:
9
+ poll:
10
10
  - {unit: 1, file: 4x, start: 1, end: 50}
11
11
  - {unit: 1, file: 4x, start: 51, end: 100}
12
- writeok:
13
- - {unit: 1, file: 4x, start: 1, end: 100}
14
12
  tags:
15
13
  IntSet:
16
14
  type: int16
17
- addr: RTU:1:4x:1
15
+ read: RTU:1:4x:1
16
+ write: RTU:1:4x:1
18
17
  IntVal:
19
18
  type: int16
20
- addr: RTU:1:4x:2
19
+ read: RTU:1:4x:2
21
20
  FloatSet:
22
21
  type: float32
23
- addr: RTU:1:4x:3
22
+ read: RTU:1:4x:3
23
+ write: RTU:1:4x:3
24
24
  FloatVal:
25
25
  type: float32
26
- addr: RTU:1:4x:5
26
+ read: RTU:1:4x:5
27
27
  MultiSet:
28
28
  type: int16
29
- addr: RTU:1:4x:7
29
+ read: RTU:1:4x:7
30
+ write: RTU:1:4x:7
30
31
  MultiVal:
31
32
  type: int16
32
- addr: RTU:1:4x:8
33
+ read: RTU:1:4x:8
33
34
  TimeSet:
34
35
  type: uint64
35
- addr: RTU:1:4x:9
36
+ read: RTU:1:4x:9
37
+ write: RTU:1:4x:9
36
38
  TimeVal:
37
39
  type: uint64
38
- addr: RTU:1:4x:13
40
+ read: RTU:1:4x:13
39
41
  DateSet:
40
42
  type: uint64
41
- addr: RTU:1:4x:17
43
+ read: RTU:1:4x:17
44
+ write: RTU:1:4x:17
42
45
  DateVal:
43
46
  type: uint64
44
- addr: RTU:1:4x:21
47
+ read: RTU:1:4x:21
45
48
  DateTimeSet:
46
49
  type: uint64
47
- addr: RTU:1:4x:25
50
+ read: RTU:1:4x:25
51
+ write: RTU:1:4x:25
48
52
  DateTimeVal:
49
53
  type: uint64
50
- addr: RTU:1:4x:29
54
+ read: RTU:1:4x:29
51
55
  cpu_temp:
52
56
  type: float32
53
- addr: RTU:1:4x:33
57
+ read: RTU:1:4x:33
54
58
  cpu_load:
55
59
  type: float32
56
- addr: RTU:1:4x:35
60
+ read: RTU:1:4x:35
57
61
  disk_use:
58
62
  type: float32
59
- addr: RTU:1:4x:37
63
+ read: RTU:1:4x:37
@@ -1,5 +1,5 @@
1
- bus_ip: 192.168.1.100 # for the demo PLC make empty (None)
2
- bus_port: 2345 # for the demo PLC make empty (None)
1
+ bus_ip:
2
+ bus_port:
3
3
  rtus:
4
4
  - name: RTU
5
5
  ip: 0.0.0.0
@@ -7,10 +7,18 @@ rtus:
7
7
  tcp_udp: tcp
8
8
  serve:
9
9
  - {unit: 1, file: 4x, start: 1, end: 100}
10
+ - {unit: 2, file: 4x, start: 1, end: 100}
11
+ - {unit: 3, file: 4x, start: 1, end: 100}
10
12
  tags:
11
13
  sim_IntSet:
12
14
  type: int16
13
15
  addr: RTU:1:4x:1
16
+ sim_IntSet2:
17
+ type: int16
18
+ addr: RTU:2:4x:1
19
+ sim_IntSet3:
20
+ type: int16
21
+ addr: RTU:3:4x:1
14
22
  sim_IntVal:
15
23
  type: int16
16
24
  addr: RTU:1:4x:2
@@ -0,0 +1,12 @@
1
+ bus_ip: 127.0.0.1
2
+ bus_port: 1324
3
+ tags:
4
+ localhost_ping:
5
+ type: ping
6
+ addr: '127.0.0.1'
7
+ electronet_ping:
8
+ type: ping
9
+ addr: electronet.co.nz
10
+ google_ping:
11
+ type: ping
12
+ addr: www.google.com
@@ -0,0 +1,15 @@
1
+ [Unit]
2
+ Description=pymscada - Ping client
3
+ BindsTo=pymscada-bus.service
4
+ After=pymscada-bus.service
5
+
6
+ [Service]
7
+ WorkingDirectory=__DIR__
8
+ ExecStart=__PYMSCADA__ ping --config __DIR__/config/ping.yaml
9
+ Restart=always
10
+ RestartSec=5
11
+ User=mscada
12
+ Group=mscada
13
+
14
+ [Install]
15
+ WantedBy=multi-user.target
@@ -5,7 +5,7 @@ rtus:
5
5
  ip: 172.26.3.254
6
6
  community: public
7
7
  rate: 10
8
- read:
8
+ poll:
9
9
  - '1.3.6.1.2.1.31.1.1.1.6.1'
10
10
  - '1.3.6.1.2.1.31.1.1.1.6.2'
11
11
  - '1.3.6.1.2.1.31.1.1.1.6.3'
@@ -25,49 +25,49 @@ rtus:
25
25
  tags:
26
26
  Router_eth1_bytes_in:
27
27
  type: int_roc
28
- addr: 'router:1.3.6.1.2.1.31.1.1.1.6.1'
28
+ read: 'router:1.3.6.1.2.1.31.1.1.1.6.1'
29
29
  Router_eth1_bytes_out:
30
30
  type: int_roc
31
- addr: 'router:1.3.6.1.2.1.31.1.1.1.10.1'
31
+ read: 'router:1.3.6.1.2.1.31.1.1.1.10.1'
32
32
  Router_eth2_bytes_in:
33
33
  type: int_roc
34
- addr: 'router:1.3.6.1.2.1.31.1.1.1.6.2'
34
+ read: 'router:1.3.6.1.2.1.31.1.1.1.6.2'
35
35
  Router_eth2_bytes_out:
36
36
  type: int_roc
37
- addr: 'router:1.3.6.1.2.1.31.1.1.1.10.2'
37
+ read: 'router:1.3.6.1.2.1.31.1.1.1.10.2'
38
38
  Router_eth3_bytes_in:
39
39
  type: int_roc
40
- addr: 'router:1.3.6.1.2.1.31.1.1.1.6.3'
40
+ read: 'router:1.3.6.1.2.1.31.1.1.1.6.3'
41
41
  Router_eth3_bytes_out:
42
42
  type: int_roc
43
- addr: 'router:1.3.6.1.2.1.31.1.1.1.10.3'
43
+ read: 'router:1.3.6.1.2.1.31.1.1.1.10.3'
44
44
  Router_eth4_bytes_in:
45
45
  type: int_roc
46
- addr: 'router:1.3.6.1.2.1.31.1.1.1.6.4'
46
+ read: 'router:1.3.6.1.2.1.31.1.1.1.6.4'
47
47
  Router_eth4_bytes_out:
48
48
  type: int_roc
49
- addr: 'router:1.3.6.1.2.1.31.1.1.1.10.4'
49
+ read: 'router:1.3.6.1.2.1.31.1.1.1.10.4'
50
50
  Router_eth5_bytes_in:
51
51
  type: int_roc
52
- addr: 'router:1.3.6.1.2.1.31.1.1.1.6.5'
52
+ read: 'router:1.3.6.1.2.1.31.1.1.1.6.5'
53
53
  Router_eth5_bytes_out:
54
54
  type: int_roc
55
- addr: 'router:1.3.6.1.2.1.31.1.1.1.10.5'
55
+ read: 'router:1.3.6.1.2.1.31.1.1.1.10.5'
56
56
  Router_eth6_bytes_in:
57
57
  type: int_roc
58
- addr: 'router:1.3.6.1.2.1.31.1.1.1.6.6'
58
+ read: 'router:1.3.6.1.2.1.31.1.1.1.6.6'
59
59
  Router_eth6_bytes_out:
60
60
  type: int_roc
61
- addr: 'router:1.3.6.1.2.1.31.1.1.1.10.6'
61
+ read: 'router:1.3.6.1.2.1.31.1.1.1.10.6'
62
62
  Router_eth7_bytes_in:
63
63
  type: int_roc
64
- addr: 'router:1.3.6.1.2.1.31.1.1.1.6.7'
64
+ read: 'router:1.3.6.1.2.1.31.1.1.1.6.7'
65
65
  Router_eth7_bytes_out:
66
66
  type: int_roc
67
- addr: 'router:1.3.6.1.2.1.31.1.1.1.10.7'
67
+ read: 'router:1.3.6.1.2.1.31.1.1.1.10.7'
68
68
  Router_eth8_bytes_in:
69
69
  type: int_roc
70
- addr: 'router:1.3.6.1.2.1.31.1.1.1.6.8'
70
+ read: 'router:1.3.6.1.2.1.31.1.1.1.6.8'
71
71
  Router_eth8_bytes_out:
72
72
  type: int_roc
73
- addr: 'router:1.3.6.1.2.1.31.1.1.1.10.8'
73
+ read: 'router:1.3.6.1.2.1.31.1.1.1.10.8'
pymscada/demo/tags.yaml CHANGED
@@ -166,6 +166,46 @@ sim_DateTimeSet:
166
166
  sim_DateTimeVal:
167
167
  desc: Simulation tag
168
168
  type: int
169
+ Ani_Fin_20:
170
+ desc: 'Logix Fin[20]'
171
+ type: float
172
+ dp: 2
173
+ Ani_Fout_20:
174
+ desc: 'Logix Fout[20]'
175
+ type: float
176
+ dp: 2
177
+ Ani_Iin_20:
178
+ desc: 'Logix Iin[20]'
179
+ type: int
180
+ Ani_Iout_20:
181
+ desc: 'Logix Iout[20]'
182
+ type: int
183
+ Ani_Iout_21_0:
184
+ desc: 'Logix Iout[21].0'
185
+ multi:
186
+ - 'Off'
187
+ - 'On'
188
+ Ani_Iout_21_1:
189
+ desc: 'Logix Iout[21].1'
190
+ multi:
191
+ - 'Off'
192
+ - 'On'
193
+ Ani_Iin_21_0:
194
+ desc: 'Logix Iin[21].0'
195
+ multi:
196
+ - 'Off'
197
+ - 'On'
198
+ Ani_Iin_21_1:
199
+ desc: 'Logix Iin[21].1'
200
+ multi:
201
+ - 'Off'
202
+ - 'On'
203
+ InVar:
204
+ desc: InVar
205
+ type: float
206
+ OutVar:
207
+ desc: OutVar
208
+ type: float
169
209
  Router_eth1_bytes_in:
170
210
  desc: eth1 bytes in
171
211
  type: int
@@ -213,4 +253,13 @@ Router_eth8_bytes_in:
213
253
  type: int
214
254
  Router_eth8_bytes_out:
215
255
  desc: eth8 bytes out
216
- type: int
256
+ type: int
257
+ localhost_ping:
258
+ desc: Ping time to localhost
259
+ units: ms
260
+ google_ping:
261
+ desc: Ping time to google
262
+ units: ms
263
+ electronet_ping:
264
+ desc: Ping time to electronet
265
+ units: ms