g3projects 0.2.3__tar.gz → 0.2.5__tar.gz

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.
Files changed (38) hide show
  1. {g3projects-0.2.3 → g3projects-0.2.5}/PKG-INFO +1 -1
  2. {g3projects-0.2.3 → g3projects-0.2.5}/pyproject.toml +1 -1
  3. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects/logical/_logical.py +31 -2
  4. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects/main/_main.py +24 -3
  5. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects/physical/_physical.py +22 -8
  6. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects/physical/templates/config_sfdomain.tpl +1 -1
  7. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects/physical/templates/physical_pkg.tpl +3 -3
  8. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects/utils/__init__.py +4 -2
  9. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects/utils/_utils.py +14 -0
  10. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects.egg-info/PKG-INFO +1 -1
  11. {g3projects-0.2.3 → g3projects-0.2.5}/LICENCE +0 -0
  12. {g3projects-0.2.3 → g3projects-0.2.5}/README.md +0 -0
  13. {g3projects-0.2.3 → g3projects-0.2.5}/setup.cfg +0 -0
  14. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects/__init__.py +0 -0
  15. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects/logical/__init__.py +0 -0
  16. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects/logical/templates/ansic_prg.tpl +0 -0
  17. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects/logical/templates/autogenerated_block.tpl +0 -0
  18. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects/logical/templates/config_txt.tpl +0 -0
  19. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects/logical/templates/main_c.tpl +0 -0
  20. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects/logical/templates/main_c_system.tpl +0 -0
  21. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects/logical/templates/package_pkg_logical.tpl +0 -0
  22. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects/logical/templates/package_pkg_project.tpl +0 -0
  23. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects/logical/templates/package_pkg_system.tpl +0 -0
  24. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects/logical/templates/variables_var.tpl +0 -0
  25. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects/logical/templates/variables_var_system.tpl +0 -0
  26. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects/main/__init__.py +0 -0
  27. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects/physical/__init__.py +0 -0
  28. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects/physical/templates/config_pkg.tpl +0 -0
  29. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects/physical/templates/cpu_pkg.tpl +0 -0
  30. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects/physical/templates/hardware_hw.tpl +0 -0
  31. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects/physical/templates/iomap_iom.tpl +0 -0
  32. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects/physical/templates/zone_sw.tpl +0 -0
  33. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects/py.typed +0 -0
  34. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects.egg-info/SOURCES.txt +0 -0
  35. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects.egg-info/dependency_links.txt +0 -0
  36. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects.egg-info/entry_points.txt +0 -0
  37. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects.egg-info/requires.txt +0 -0
  38. {g3projects-0.2.3 → g3projects-0.2.5}/src/g3projects.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: g3projects
3
- Version: 0.2.3
3
+ Version: 0.2.5
4
4
  Summary: System G3 Project PLC files generator
5
5
  Author: Elektroline a.s.
6
6
  Project-URL: Homepage, https://gitlab.elektroline.cz/plc/systemg3-py/SystemG3ProjectBuilder
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "g3projects"
3
- version = "0.2.3"
3
+ version = "0.2.5"
4
4
  description = "System G3 Project PLC files generator"
5
5
  readme = "README.md"
6
6
  license = {file = "LICENSE"}
@@ -14,7 +14,7 @@ from g3tables.system_config.type_hinting import SystemDict, SWDeviceDict
14
14
 
15
15
 
16
16
  from ..utils import (
17
- format_template, combine_str, remove_multiple_newlines, write_to_file
17
+ format_template, combine_str, remove_multiple_newlines, write_to_file, read_existing_file
18
18
  )
19
19
 
20
20
 
@@ -280,7 +280,26 @@ def generate_zone_files_contents(
280
280
  ) -> tuple[str, str]:
281
281
  varibales_var = ''
282
282
  main_c = ''
283
+
284
+ zone_devices = []
285
+ gate_devices = []
286
+ route_devices = []
287
+ other_devices = []
288
+
283
289
  for _, path, device_data in system_config.iter_devices_zone(zone_name):
290
+ if 'Zone' in path:
291
+ zone_devices.append((path, device_data))
292
+ elif 'Gate' in path:
293
+ gate_devices.append((path, device_data))
294
+ elif 'Route' in path:
295
+ route_devices.append((path, device_data))
296
+ else:
297
+ other_devices.append((path, device_data))
298
+
299
+ sorted_devices = zone_devices + gate_devices + route_devices + other_devices
300
+
301
+ for path, device_data in sorted_devices:
302
+
284
303
  if not system_config.get_device_control_fb(device_data):
285
304
  logger.warning('function block type is missing for "%s"', path)
286
305
  continue
@@ -511,7 +530,16 @@ def generate_logical_files(
511
530
  env, 'package_pkg_system.tpl', zone_names=zone_tasknames
512
531
  )
513
532
  )
514
- system_names = [sw_system_wrapper.get_system_name()]
533
+
534
+ object_type_package = ".//ns:Object[@Type='Package']"
535
+ namespace_type_package = {'ns': 'http://br-automation.co.at/AS/Package'}
536
+
537
+
538
+ system_names = read_existing_file(project_folder_path+"\Package.pkg", object_type_package, namespace_type_package)
539
+
540
+ if sw_system_wrapper.get_system_name() not in system_names:
541
+ system_names += [sw_system_wrapper.get_system_name()]
542
+
515
543
  write_to_file(
516
544
  project_folder_path,
517
545
  'Package.pkg',
@@ -527,6 +555,7 @@ def generate_logical_files(
527
555
  env, 'package_pkg_logical.tpl', project_names=project_names
528
556
  )
529
557
  )
558
+
530
559
  # remove the "Logical/Project" directory
531
560
  logical_default_project_path = os.path.join(logical_folder_path, 'Project')
532
561
  if os.path.isdir(logical_default_project_path):
@@ -46,6 +46,24 @@ def parse_arguments() -> argparse.Namespace:
46
46
  'to the control devices. This option requires --gen-logical.'
47
47
  )
48
48
  )
49
+ parser.add_argument(
50
+ "--ftp1-pswd-hash",
51
+ type=str,
52
+ required=False,
53
+ help="'ftp' user password hash for PLC FTP server",
54
+ )
55
+ parser.add_argument(
56
+ "--ftp2-pswd-hash",
57
+ type=str,
58
+ required=False,
59
+ help="'ellmaster' user password hash for PLC FTP server",
60
+ )
61
+ parser.add_argument(
62
+ "--sfdomain_pswd_hash",
63
+ type=str,
64
+ required=False,
65
+ help="SafeDomain password hash",
66
+ )
49
67
  parser.add_argument(
50
68
  '--log-level',
51
69
  type=str,
@@ -67,12 +85,15 @@ def generate_project_files(
67
85
  system_config_path: str,
68
86
  gen_physical: bool = True,
69
87
  gen_logical: bool = True,
70
- gen_test: bool = False
88
+ gen_test: bool = False,
89
+ ftp1_pswd_hash: str = '',
90
+ ftp2_pswd_hash: str = '',
91
+ sfdomain_pswd_hash: str = ''
71
92
  ) -> None:
72
93
  if gen_logical:
73
94
  generate_logical_files(system_config_path, gen_test)
74
95
  if gen_physical:
75
- generate_physical_files(system_config_path)
96
+ generate_physical_files(system_config_path, ftp1_pswd_hash, ftp2_pswd_hash, sfdomain_pswd_hash)
76
97
 
77
98
 
78
99
  def main() -> None:
@@ -82,5 +103,5 @@ def main() -> None:
82
103
  format='[%(name)s] %(levelname)s:%(message)s'
83
104
  )
84
105
  generate_project_files(
85
- args.system_config, args.gen_physical, args.gen_logical, args.gen_test
106
+ args.system_config, args.gen_physical, args.gen_logical, args.gen_test, args.ftp1_pswd_hash, args.ftp2_pswd_hash, args.sfdomain_pswd_hash
86
107
  )
@@ -11,7 +11,7 @@ from g3tables.system_config import SWSystemDictWrapper
11
11
  from g3tables.system_config.type_hinting import SystemDict
12
12
 
13
13
  from ..utils import (
14
- format_template, write_to_file
14
+ format_template, write_to_file, read_existing_file
15
15
  )
16
16
 
17
17
  from g3hardware import HardwareModule, HardwareIsle, format_type, is_cpu_type
@@ -118,12 +118,14 @@ def create_hw_isles(config_hw: dict, **kwargs) -> HardwareIsle | None:
118
118
 
119
119
 
120
120
  def generate_hardware_hw_contents(
121
- config_hw: dict, system_name: str, cp1584_name: str
121
+ config_hw: dict, project_name: str, system_name: str, cp1584_name: str, ftp1_pswd_hash: str, ftp2_pswd_hash: str
122
122
  ) -> str:
123
123
  kwargs = {
124
124
  'cpuname': cp1584_name,
125
- 'cpuhostname': system_name,
126
- 'cpuconfigurationid': system_name
125
+ 'cpuhostname': ("plc-"+project_name+"-"+system_name).lower(),
126
+ 'cpuconfigurationid': (project_name+"-"+system_name).lower(),
127
+ 'ftpuserpassword1': ftp1_pswd_hash,
128
+ 'ftpuserpassword2': ftp2_pswd_hash
127
129
  }
128
130
  if not (hw_isle := create_hw_isles(config_hw, **kwargs)):
129
131
  return ''
@@ -175,7 +177,7 @@ def generate_iomap_iom_contents(system: SWSystemDictWrapper) -> list[str]:
175
177
  # END Iomap.iom #
176
178
 
177
179
 
178
- def generate_physical_files(system_config_path: str) -> None:
180
+ def generate_physical_files(system_config_path: str, ftp1_pswd_hash: str, ftp2_pswd_hash: str, sfdomain_pswd_hash: str) -> None:
179
181
  system = get_system_dict(system_config_path)
180
182
  sw_system_wrapper = SWSystemDictWrapper(system['Software'])
181
183
  project_name = sw_system_wrapper.get_project_name()
@@ -183,10 +185,22 @@ def generate_physical_files(system_config_path: str) -> None:
183
185
  zone_tasknames = sw_system_wrapper.zone_tasknames
184
186
  physical_path = makedirs_physical(system_name)
185
187
  # create Physical.pkg file
188
+
189
+ object_type_configuration = ".//ns:Object[@Type='Configuration']"
190
+ namespace_type_configuraiton = {'ns': 'http://br-automation.co.at/AS/Physical'}
191
+
192
+ system_names = read_existing_file(os.path.dirname(physical_path)+"\Physical.pkg", object_type_configuration, namespace_type_configuraiton)
193
+
194
+ if system_name not in system_names:
195
+ system_names += [system_name]
196
+
197
+ if 'Core' in system_names:
198
+ system_names.remove('Core')
199
+
186
200
  write_to_file(
187
201
  os.path.dirname(physical_path),
188
202
  'Physical.pkg',
189
- format_template(env, 'physical_pkg.tpl', system_names=[system_name])
203
+ format_template(env, 'physical_pkg.tpl', system_names=system_names)
190
204
  )
191
205
  # create Config.pkg file
192
206
  write_to_file(
@@ -200,7 +214,7 @@ def generate_physical_files(system_config_path: str) -> None:
200
214
  'cp1584', system['Hardware'] # type: ignore
201
215
  )
202
216
  hardware_hw = generate_hardware_hw_contents(
203
- system['Hardware'], system_name, cpu_name # type: ignore
217
+ system['Hardware'], project_name, system_name, cpu_name, ftp1_pswd_hash, ftp2_pswd_hash # type: ignore
204
218
  )
205
219
  except ValueError:
206
220
  logger.warning(
@@ -249,7 +263,7 @@ def generate_physical_files(system_config_path: str) -> None:
249
263
  write_to_file(
250
264
  mapp_safety_path_dst,
251
265
  'Config.sfdomain',
252
- format_template(env, 'config_sfdomain.tpl', sl8101_name=sl_name)
266
+ format_template(env, 'config_sfdomain.tpl', sl8101_name=sl_name, sfdomainpassword=sfdomain_pswd_hash)
253
267
  )
254
268
  # create IoMap.iom file
255
269
  iomap = generate_iomap_iom_contents(sw_system_wrapper)
@@ -10,7 +10,7 @@
10
10
  <Property ID="SafeLOGICName" Value="{{ sl8101_name }}" />
11
11
  <Property ID="SafeLOGICProductId" Value="X20cSL8101" />
12
12
  <Property ID="SafeLOGICModulePath" Value="IF3.ST32" />
13
- <Property ID="Password" Value="e10adc3949ba59abbe56e057f20f883e" />
13
+ <Property ID="Password" Value="{{ sfdomainpassword }}" />
14
14
  <Property ID="SafeProject" Value="safeZone" />
15
15
  </Group>
16
16
  <Group ID="DefaultFiles">
@@ -6,9 +6,9 @@
6
6
  <Physical xmlns="http://br-automation.co.at/AS/Physical">
7
7
  <Objects>
8
8
  <Object Type="Configuration">Core</Object>
9
- {% for name in system_names %}
10
- <Object Type="Configuration">{{ name }}</Object>
11
- {% endfor %}
9
+ {% for name in system_names %}
10
+ <Object Type="Configuration">{{ name }}</Object>
11
+ {% endfor %}
12
12
  </Objects>
13
13
  </Physical>
14
14
  <!--end of autogenerated-->
@@ -2,7 +2,8 @@ from ._utils import (
2
2
  format_template,
3
3
  combine_str,
4
4
  remove_multiple_newlines,
5
- write_to_file
5
+ write_to_file,
6
+ read_existing_file
6
7
  )
7
8
 
8
9
 
@@ -10,5 +11,6 @@ __all__ = [
10
11
  'format_template',
11
12
  'combine_str',
12
13
  'remove_multiple_newlines',
13
- 'write_to_file'
14
+ 'write_to_file',
15
+ 'read_existing_file'
14
16
  ]
@@ -1,5 +1,6 @@
1
1
  import os
2
2
  import re
3
+ import xml.etree.ElementTree as ET
3
4
 
4
5
  from jinja2 import Environment
5
6
 
@@ -21,3 +22,16 @@ def format_template(env: Environment, tpl_name: str, **kwargs) -> str:
21
22
  def write_to_file(path: str, name: str, contents: str) -> None:
22
23
  with open(os.path.join(path, name), 'w', encoding='utf-8') as file:
23
24
  file.write(contents)
25
+
26
+ def read_existing_file(file_path: str, object_type: str, namespace: str) -> str:
27
+ if not os.path.exists(file_path):
28
+ return []
29
+
30
+ tree = ET.parse(file_path)
31
+ root = tree.getroot()
32
+
33
+ existing_names = []
34
+ for obj in root.findall(object_type, namespace):
35
+ existing_names.append(obj.text)
36
+
37
+ return existing_names
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: g3projects
3
- Version: 0.2.3
3
+ Version: 0.2.5
4
4
  Summary: System G3 Project PLC files generator
5
5
  Author: Elektroline a.s.
6
6
  Project-URL: Homepage, https://gitlab.elektroline.cz/plc/systemg3-py/SystemG3ProjectBuilder
File without changes
File without changes
File without changes