g3projects 0.2.4__tar.gz → 0.2.6__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.4 → g3projects-0.2.6}/PKG-INFO +1 -1
  2. {g3projects-0.2.4 → g3projects-0.2.6}/pyproject.toml +1 -1
  3. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects/logical/_logical.py +31 -2
  4. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects/main/_main.py +3 -3
  5. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects/physical/_physical.py +18 -6
  6. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects/physical/templates/physical_pkg.tpl +3 -3
  7. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects/utils/__init__.py +4 -2
  8. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects/utils/_utils.py +14 -0
  9. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects.egg-info/PKG-INFO +1 -1
  10. {g3projects-0.2.4 → g3projects-0.2.6}/LICENCE +0 -0
  11. {g3projects-0.2.4 → g3projects-0.2.6}/README.md +0 -0
  12. {g3projects-0.2.4 → g3projects-0.2.6}/setup.cfg +0 -0
  13. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects/__init__.py +0 -0
  14. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects/logical/__init__.py +0 -0
  15. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects/logical/templates/ansic_prg.tpl +0 -0
  16. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects/logical/templates/autogenerated_block.tpl +0 -0
  17. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects/logical/templates/config_txt.tpl +0 -0
  18. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects/logical/templates/main_c.tpl +0 -0
  19. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects/logical/templates/main_c_system.tpl +0 -0
  20. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects/logical/templates/package_pkg_logical.tpl +0 -0
  21. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects/logical/templates/package_pkg_project.tpl +0 -0
  22. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects/logical/templates/package_pkg_system.tpl +0 -0
  23. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects/logical/templates/variables_var.tpl +0 -0
  24. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects/logical/templates/variables_var_system.tpl +0 -0
  25. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects/main/__init__.py +0 -0
  26. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects/physical/__init__.py +0 -0
  27. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects/physical/templates/config_pkg.tpl +0 -0
  28. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects/physical/templates/config_sfdomain.tpl +0 -0
  29. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects/physical/templates/cpu_pkg.tpl +0 -0
  30. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects/physical/templates/hardware_hw.tpl +0 -0
  31. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects/physical/templates/iomap_iom.tpl +0 -0
  32. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects/physical/templates/zone_sw.tpl +0 -0
  33. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects/py.typed +0 -0
  34. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects.egg-info/SOURCES.txt +0 -0
  35. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects.egg-info/dependency_links.txt +0 -0
  36. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects.egg-info/entry_points.txt +0 -0
  37. {g3projects-0.2.4 → g3projects-0.2.6}/src/g3projects.egg-info/requires.txt +0 -0
  38. {g3projects-0.2.4 → g3projects-0.2.6}/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.4
3
+ Version: 0.2.6
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.4"
3
+ version = "0.2.6"
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):
@@ -49,19 +49,19 @@ def parse_arguments() -> argparse.Namespace:
49
49
  parser.add_argument(
50
50
  "--ftp1-pswd-hash",
51
51
  type=str,
52
- required=False,
52
+ required=True,
53
53
  help="'ftp' user password hash for PLC FTP server",
54
54
  )
55
55
  parser.add_argument(
56
56
  "--ftp2-pswd-hash",
57
57
  type=str,
58
- required=False,
58
+ required=True,
59
59
  help="'ellmaster' user password hash for PLC FTP server",
60
60
  )
61
61
  parser.add_argument(
62
62
  "--sfdomain_pswd_hash",
63
63
  type=str,
64
- required=False,
64
+ required=True,
65
65
  help="SafeDomain password hash",
66
66
  )
67
67
  parser.add_argument(
@@ -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,12 @@ 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, ftp1_pswd_hash: str, ftp2_pswd_hash: 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
127
  'ftpuserpassword1': ftp1_pswd_hash,
128
128
  'ftpuserpassword2': ftp2_pswd_hash
129
129
  }
@@ -185,10 +185,22 @@ def generate_physical_files(system_config_path: str, ftp1_pswd_hash: str, ftp2_p
185
185
  zone_tasknames = sw_system_wrapper.zone_tasknames
186
186
  physical_path = makedirs_physical(system_name)
187
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
+
188
200
  write_to_file(
189
201
  os.path.dirname(physical_path),
190
202
  'Physical.pkg',
191
- format_template(env, 'physical_pkg.tpl', system_names=[system_name])
203
+ format_template(env, 'physical_pkg.tpl', system_names=system_names)
192
204
  )
193
205
  # create Config.pkg file
194
206
  write_to_file(
@@ -202,7 +214,7 @@ def generate_physical_files(system_config_path: str, ftp1_pswd_hash: str, ftp2_p
202
214
  'cp1584', system['Hardware'] # type: ignore
203
215
  )
204
216
  hardware_hw = generate_hardware_hw_contents(
205
- system['Hardware'], system_name, cpu_name, ftp1_pswd_hash, ftp2_pswd_hash # type: ignore
217
+ system['Hardware'], project_name, system_name, cpu_name, ftp1_pswd_hash, ftp2_pswd_hash # type: ignore
206
218
  )
207
219
  except ValueError:
208
220
  logger.warning(
@@ -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.4
3
+ Version: 0.2.6
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