MTPPy2.0 0.1.5__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.
Files changed (214) hide show
  1. examples/__init__.py +0 -0
  2. examples/minimal+pid.py +82 -0
  3. examples/minimal.py +32 -0
  4. examples/minimal_recipe.py +117 -0
  5. examples/pea_alarm_base.py +47 -0
  6. examples/pea_minimal.py +258 -0
  7. mtppy/__init__.py +1 -0
  8. mtppy/part1/__init__.py +4 -0
  9. mtppy/part1/empty_folder_test.py +7 -0
  10. mtppy/part3/__init__.py +4 -0
  11. mtppy/part3/data_assembly_set/__init__.py +4 -0
  12. mtppy/part3/data_assembly_set/active_elements/__init__.py +4 -0
  13. mtppy/part3/data_assembly_set/active_elements/active_element.py +22 -0
  14. mtppy/part3/data_assembly_set/active_elements/drives/__init__.py +4 -0
  15. mtppy/part3/data_assembly_set/active_elements/drives/ana_drv.py +446 -0
  16. mtppy/part3/data_assembly_set/active_elements/drives/ana_drv_test.py +567 -0
  17. mtppy/part3/data_assembly_set/active_elements/drives/bin_drv.py +365 -0
  18. mtppy/part3/data_assembly_set/active_elements/drives/bin_drv_test.py +503 -0
  19. mtppy/part3/data_assembly_set/active_elements/drives/mon_ana_drv.py +469 -0
  20. mtppy/part3/data_assembly_set/active_elements/drives/mon_ana_drv_test.py +418 -0
  21. mtppy/part3/data_assembly_set/active_elements/drives/mon_bin_drv.py +295 -0
  22. mtppy/part3/data_assembly_set/active_elements/drives/mon_bin_drv_test.py +265 -0
  23. mtppy/part3/data_assembly_set/active_elements/pid/__init__.py +4 -0
  24. mtppy/part3/data_assembly_set/active_elements/pid/pid_ctrl.py +333 -0
  25. mtppy/part3/data_assembly_set/active_elements/pid/pid_ctrl_test.py +156 -0
  26. mtppy/part3/data_assembly_set/active_elements/valves/__init__.py +4 -0
  27. mtppy/part3/data_assembly_set/active_elements/valves/ana_vlv.py +402 -0
  28. mtppy/part3/data_assembly_set/active_elements/valves/ana_vlv_test.py +732 -0
  29. mtppy/part3/data_assembly_set/active_elements/valves/bin_vlv.py +279 -0
  30. mtppy/part3/data_assembly_set/active_elements/valves/bin_vlv_test.py +585 -0
  31. mtppy/part3/data_assembly_set/active_elements/valves/mon_ana_vlv.py +402 -0
  32. mtppy/part3/data_assembly_set/active_elements/valves/mon_ana_vlv_test.py +270 -0
  33. mtppy/part3/data_assembly_set/active_elements/valves/mon_bin_vlv.py +286 -0
  34. mtppy/part3/data_assembly_set/active_elements/valves/mon_bin_vlv_test.py +224 -0
  35. mtppy/part3/data_assembly_set/base_functions/__init__.py +4 -0
  36. mtppy/part3/data_assembly_set/base_functions/operation_mode.py +252 -0
  37. mtppy/part3/data_assembly_set/base_functions/operation_mode_test.py +260 -0
  38. mtppy/part3/data_assembly_set/base_functions/oslevel.py +35 -0
  39. mtppy/part3/data_assembly_set/base_functions/source_mode.py +189 -0
  40. mtppy/part3/data_assembly_set/base_functions/source_mode_test.py +112 -0
  41. mtppy/part3/data_assembly_set/base_functions/wqc.py +75 -0
  42. mtppy/part3/data_assembly_set/base_functions/wqc_test.py +86 -0
  43. mtppy/part3/data_assembly_set/data_assembly.py +65 -0
  44. mtppy/part3/data_assembly_set/diagnostic_elements/__init__.py +4 -0
  45. mtppy/part3/data_assembly_set/diagnostic_elements/diagnostic_element.py +19 -0
  46. mtppy/part3/data_assembly_set/indicator_elements/__init__.py +4 -0
  47. mtppy/part3/data_assembly_set/indicator_elements/indicator_element.py +22 -0
  48. mtppy/part3/data_assembly_set/indicator_elements/views/__init__.py +4 -0
  49. mtppy/part3/data_assembly_set/indicator_elements/views/ana_view.py +68 -0
  50. mtppy/part3/data_assembly_set/indicator_elements/views/bin_view.py +73 -0
  51. mtppy/part3/data_assembly_set/indicator_elements/views/dint_view.py +76 -0
  52. mtppy/part3/data_assembly_set/indicator_elements/views/string_view.py +55 -0
  53. mtppy/part3/data_assembly_set/operation_elements/__init__.py +4 -0
  54. mtppy/part3/data_assembly_set/operation_elements/operation_element.py +19 -0
  55. mtppy/part3/data_assembly_set/pea_elements/__init__.py +4 -0
  56. mtppy/part3/data_assembly_set/pea_elements/pea_element.py +28 -0
  57. mtppy/part3/data_assembly_set/pea_elements/pea_information_label/__init__.py +4 -0
  58. mtppy/part3/data_assembly_set/pea_elements/pea_information_label/pea_information_label.py +231 -0
  59. mtppy/part3/data_assembly_set/pea_elements/web_server_url_info/__init__.py +4 -0
  60. mtppy/part3/data_assembly_set/pea_elements/web_server_url_info/web_server_url_info.py +42 -0
  61. mtppy/part3/definitions/__init__.py +4 -0
  62. mtppy/part3/definitions/mtp_access.py +15 -0
  63. mtppy/part4/__init__.py +4 -0
  64. mtppy/part4/automation_services/__init__.py +4 -0
  65. mtppy/part4/automation_services/base_functions/__init__.py +4 -0
  66. mtppy/part4/automation_services/base_functions/service_operation_mode.py +368 -0
  67. mtppy/part4/automation_services/base_functions/service_operation_mode_test.py +242 -0
  68. mtppy/part4/automation_services/base_functions/service_operator_interaction.py +62 -0
  69. mtppy/part4/automation_services/base_functions/service_source_mode.py +138 -0
  70. mtppy/part4/automation_services/base_functions/service_source_mode_test.py +179 -0
  71. mtppy/part4/automation_services/helpers/__init__.py +4 -0
  72. mtppy/part4/automation_services/helpers/command_en_control.py +330 -0
  73. mtppy/part4/automation_services/helpers/command_en_control_test.py +302 -0
  74. mtppy/part4/automation_services/helpers/state_machine.py +167 -0
  75. mtppy/part4/automation_services/helpers/state_machine_test.py +294 -0
  76. mtppy/part4/automation_services/helpers/thread_control.py +39 -0
  77. mtppy/part4/automation_services/helpers/thread_control_test.py +80 -0
  78. mtppy/part4/automation_services/procedure.py +111 -0
  79. mtppy/part4/automation_services/procedure_test.py +185 -0
  80. mtppy/part4/automation_services/service.py +463 -0
  81. mtppy/part4/automation_services/service_elements/__init__.py +4 -0
  82. mtppy/part4/automation_services/service_elements/parameter_elements/__init__.py +4 -0
  83. mtppy/part4/automation_services/service_elements/parameter_elements/ana_serv_param.py +108 -0
  84. mtppy/part4/automation_services/service_elements/parameter_elements/ana_serv_param_test.py +59 -0
  85. mtppy/part4/automation_services/service_elements/parameter_elements/bin_serv_param.py +70 -0
  86. mtppy/part4/automation_services/service_elements/parameter_elements/bin_serv_param_test.py +39 -0
  87. mtppy/part4/automation_services/service_elements/parameter_elements/common_serv_param.py +111 -0
  88. mtppy/part4/automation_services/service_elements/parameter_elements/dint_serv_param.py +77 -0
  89. mtppy/part4/automation_services/service_elements/parameter_elements/dint_serv_param_test.py +58 -0
  90. mtppy/part4/automation_services/service_elements/parameter_elements/parameter_element.py +175 -0
  91. mtppy/part4/automation_services/service_elements/parameter_elements/parameter_element_test.py +246 -0
  92. mtppy/part4/automation_services/service_elements/parameter_elements/string_serv_param.py +48 -0
  93. mtppy/part4/automation_services/service_elements/parameter_elements/string_serv_param_test.py +37 -0
  94. mtppy/part4/automation_services/service_elements/procedure_health_view.py +36 -0
  95. mtppy/part4/automation_services/service_elements/service_control.py +473 -0
  96. mtppy/part4/automation_services/service_elements/service_control_test.py +150 -0
  97. mtppy/part4/automation_services/service_elements/service_element.py +20 -0
  98. mtppy/part4/automation_services/service_test.py +407 -0
  99. mtppy/part4/definitions/__init__.py +4 -0
  100. mtppy/part4/definitions/command_codes.py +58 -0
  101. mtppy/part4/definitions/command_codes_test.py +44 -0
  102. mtppy/part4/definitions/state_codes.py +65 -0
  103. mtppy/part4/definitions/state_codes_test.py +44 -0
  104. mtppy/part4/process_values/__init__.py +4 -0
  105. mtppy/part4/process_values/base_functions/__init__.py +4 -0
  106. mtppy/part4/process_values/base_functions/vqc.py +48 -0
  107. mtppy/part4/process_values/input_elements/__init__.py +4 -0
  108. mtppy/part4/process_values/input_elements/ana_process_value_in.py +160 -0
  109. mtppy/part4/process_values/input_elements/bin_process_value_in.py +83 -0
  110. mtppy/part4/process_values/input_elements/dint_process_value_in.py +159 -0
  111. mtppy/part4/process_values/input_elements/input_element.py +40 -0
  112. mtppy/part4/process_values/input_elements/string_process_value_in.py +45 -0
  113. mtppy/part5/__init__.py +4 -0
  114. mtppy/part5/communication_object.py +99 -0
  115. mtppy/part5/communication_object_test.py +59 -0
  116. mtppy/part5/definitions/__init__.py +4 -0
  117. mtppy/part5/definitions/iec61131_data_types.py +31 -0
  118. mtppy/part5/definitions/iec61131_data_types_test.py +82 -0
  119. mtppy/part5/definitions/opcua_data_types.py +36 -0
  120. mtppy/part5/definitions/opcua_data_types_test.py +90 -0
  121. mtppy/part5/definitions/w3c_xml_data_types.py +177 -0
  122. mtppy/part5/definitions/w3c_xml_data_types_test.py +143 -0
  123. mtppy/part5/server_assembly_set/__init__.py +5 -0
  124. mtppy/part6/__init__.py +4 -0
  125. mtppy/part6/alarm_set/__init__.py +4 -0
  126. mtppy/part6/alarm_set/alarm.py +132 -0
  127. mtppy/part6/alarm_set/alarm_test.py +265 -0
  128. mtppy/pea/__init__.py +19 -0
  129. mtppy/pea/data_assembly_factory.py +124 -0
  130. mtppy/pea/data_assembly_factory_test.py +229 -0
  131. mtppy/pea/mtp_generator/__init__.py +4 -0
  132. mtppy/pea/mtp_generator/mtp_generator.py +1183 -0
  133. mtppy/pea/mtp_generator/mtp_generator_test.py +518 -0
  134. mtppy/pea/pea.py +139 -0
  135. mtppy/pea/pea_opcua_server/__init__.py +4 -0
  136. mtppy/pea/pea_opcua_server/marshalling.py +60 -0
  137. mtppy/pea/pea_opcua_server/opcua_options_provider/__init__.py +4 -0
  138. mtppy/pea/pea_opcua_server/opcua_options_provider/instances/basic_opcua_options_provider.py +50 -0
  139. mtppy/pea/pea_opcua_server/opcua_options_provider/opcua_options_provider.py +103 -0
  140. mtppy/pea/pea_opcua_server/pea_opcua_server.py +492 -0
  141. mtppy/pea/pea_opcua_server/subscription_list.py +55 -0
  142. mtppy/pea/pea_test.py +59 -0
  143. mtppy/pea/rmtp_pea.py +155 -0
  144. mtppy/pea/rmtp_pea_test.py +27 -0
  145. mtppy/pea/service_factory.py +178 -0
  146. mtppy/pea/service_factory_test.py +156 -0
  147. mtppy/pea/user_logic/__init__.py +4 -0
  148. mtppy/pea/user_logic/user_logic_pea.py +72 -0
  149. mtppy/pea/user_logic/user_logic_registry.py +106 -0
  150. mtppy/pea/user_logic/user_logic_registry_test.py +167 -0
  151. mtppy/pea/user_logic/user_logic_service.py +228 -0
  152. mtppy/pea/user_logic/user_logic_service_test.py +289 -0
  153. mtppy/utils/__init__.py +4 -0
  154. mtppy/utils/data_assembly_dict.py +61 -0
  155. mtppy/utils/data_assembly_dict_test.py +107 -0
  156. mtppy/utils/data_item.py +446 -0
  157. mtppy/utils/data_item_com_test.py +82 -0
  158. mtppy/utils/data_item_test.py +325 -0
  159. mtppy/utils/logging.py +23 -0
  160. mtppy/utils/logging_test.py +26 -0
  161. mtppy/utils/mtp_file_handling/__init__.py +4 -0
  162. mtppy/utils/mtp_file_handling/extract_manifest_from_mtp_file.py +22 -0
  163. mtppy/utils/mtp_file_handling/extract_mtp_file.py +22 -0
  164. mtppy/utils/mtp_file_handling/is_valid_mtp.py +22 -0
  165. mtppy/utils/mtp_file_handling/is_valid_path_for_manifest.py +15 -0
  166. mtppy/utils/mtp_file_handling/is_valid_path_to_manifest.py +17 -0
  167. mtppy/utils/mtp_file_handling/is_valid_path_to_mtp.py +17 -0
  168. mtppy/utils/mtp_file_handling/load_manifest_file.py +24 -0
  169. mtppy/utils/mtp_file_handling/mtp_reader/__init__.py +4 -0
  170. mtppy/utils/mtp_file_handling/mtp_reader/mtp_reader.py +103 -0
  171. mtppy/utils/mtp_file_handling/mtp_reader/mtp_reader_test.py +96 -0
  172. mtppy/utils/mtp_file_handling/mtp_reader/mtp_xml.py +226 -0
  173. mtppy/utils/mtp_file_handling/mtp_reader/mtp_xml_test.py +108 -0
  174. mtppy/utils/mtp_file_handling/mtp_writer/__init__.py +4 -0
  175. mtppy/utils/mtp_file_handling/mtp_writer/mtp_writer.py +77 -0
  176. mtppy/utils/mtp_file_handling/mtp_writer/ressources/get_content_types.py +10 -0
  177. mtppy/utils/mtp_file_handling/mtp_writer/ressources/get_rels.py +11 -0
  178. mtppy/utils/mtp_file_handling/mtp_writer/test_mtp_writer.py +25 -0
  179. mtppy/utils/mtp_file_handling/write_manifest_file.py +29 -0
  180. mtppy/utils/mtp_file_handling/write_manifest_file_test.py +22 -0
  181. mtppy/utils/mtp_file_handling/write_mtp_file.py +43 -0
  182. mtppy/utils/mtp_file_handling/write_mtp_file_test.py +22 -0
  183. mtppy/utils/testing.py +31 -0
  184. mtppy2_0-0.1.5.dist-info/METADATA +75 -0
  185. mtppy2_0-0.1.5.dist-info/RECORD +214 -0
  186. mtppy2_0-0.1.5.dist-info/WHEEL +5 -0
  187. mtppy2_0-0.1.5.dist-info/entry_points.txt +3 -0
  188. mtppy2_0-0.1.5.dist-info/licenses/LICENSE +21 -0
  189. mtppy2_0-0.1.5.dist-info/top_level.txt +4 -0
  190. tools/__init__.py +0 -0
  191. tools/create_bugreport.py +150 -0
  192. tools/inspect_mtp.py +110 -0
  193. utils/__init__.py +1 -0
  194. utils/file_handling/__init__.py +4 -0
  195. utils/file_handling/cleanup_folder.py +9 -0
  196. utils/file_handling/get_utc_foldername_with_ms.py +15 -0
  197. utils/file_handling/get_work_dir.py +9 -0
  198. utils/file_handling/is_valid_path_for_json.py +11 -0
  199. utils/file_handling/is_valid_path_to_json.py +17 -0
  200. utils/file_handling/load_json_file.py +18 -0
  201. utils/file_handling/read_file_from_file_archive.py +43 -0
  202. utils/file_handling/read_file_string.py +10 -0
  203. utils/file_handling/validate_json_data.py +28 -0
  204. utils/file_handling/write_json_file.py +23 -0
  205. utils/get_uuid.py +18 -0
  206. utils/get_uuid_test.py +17 -0
  207. utils/logging.py +100 -0
  208. utils/logging_test.py +67 -0
  209. utils/opcua/check_node.py +79 -0
  210. utils/resolve_unit/resolve_unit.py +11 -0
  211. utils/resolve_unit/unit_lib.py +2101 -0
  212. utils/resolve_unit/unit_lib_test.py +36 -0
  213. utils/type_conversion.py +236 -0
  214. utils/type_conversion_test.py +114 -0
@@ -0,0 +1,446 @@
1
+ """Implementation of AnaDrv."""
2
+
3
+ __copyright__ = (
4
+ "Copyright (c) 2026 Dresden University of Technology, Process-to-Order Group"
5
+ )
6
+ __license__ = "MIT"
7
+ from typing import ClassVar
8
+
9
+ from mtppy.utils.logging import logger
10
+ from mtppy.utils.data_item import DataItem
11
+ from mtppy.part3.definitions.mtp_access import MTPAccess
12
+ from mtppy.part5.definitions.w3c_xml_data_types import W3cXmlDataTypes
13
+ from mtppy.part3.data_assembly_set.active_elements.active_element import ActiveElement
14
+ from mtppy.part3.data_assembly_set.base_functions.operation_mode import OperationMode
15
+ from mtppy.part3.data_assembly_set.base_functions.source_mode import SourceMode
16
+
17
+
18
+ class AnaDrv(ActiveElement):
19
+ # DataItem constant definitions
20
+ SAFE_POS = "SafePos"
21
+ SAFE_POS_ACT = "SafePosAct"
22
+ FWD_EN = "FwdEn"
23
+ REV_EN = "RevEn"
24
+ STOP_OP = "StopOp"
25
+ FWD_OP = "FwdOp"
26
+ REV_OP = "RevOp"
27
+ STOP_AUT = "StopAut"
28
+ FWD_AUT = "FwdAut"
29
+ REV_AUT = "RevAut"
30
+ FWD_CTRL = "FwdCtrl"
31
+ REV_CTRL = "RevCtrl"
32
+ RPM_SCL_MIN = "RpmSclMin"
33
+ RPM_SCL_MAX = "RpmSclMax"
34
+ RPM_UNIT = "RpmUnit"
35
+ RPM_MIN = "RpmMin"
36
+ RPM_MAX = "RpmMax"
37
+ RPM_INT = "RpmInt"
38
+ RPM_MAN = "RpmMan"
39
+ RPM_ = "Rpm"
40
+ RPM_RBK = "RpmRbk"
41
+ REV_FBK_CALC = "RevFbkCalc"
42
+ REV_FBK = "RevFbk"
43
+ FWD_FBK_CALC = "FwdFbkCalc"
44
+ FWD_FBK = "FwdFbk"
45
+ RPM_FBK_CALC = "RpmFbkCalc"
46
+ RPM_FBK = "RpmFbk"
47
+ TRIP_ = "Trip"
48
+ PERM_EN = "PermEn"
49
+ PERMIT_ = "Permit"
50
+ INTL_EN = "IntlEn"
51
+ INTERLOCK_ = "Interlock"
52
+ PROT_EN = "ProtEn"
53
+ PROTECT_ = "Protect"
54
+ RESET_OP = "ResetOp"
55
+ RESET_AUT = "ResetAut"
56
+
57
+ # Class-level data items dictionary
58
+ CLASS_DATA_ITEMS: ClassVar = {
59
+ SAFE_POS: DataItem(
60
+ SAFE_POS, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None
61
+ ),
62
+ SAFE_POS_ACT: DataItem(
63
+ SAFE_POS_ACT, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None
64
+ ),
65
+ FWD_EN: DataItem(FWD_EN, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None),
66
+ REV_EN: DataItem(REV_EN, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None),
67
+ STOP_OP: DataItem(
68
+ STOP_OP, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadWriteAccess, None
69
+ ),
70
+ FWD_OP: DataItem(
71
+ FWD_OP, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadWriteAccess, None
72
+ ),
73
+ REV_OP: DataItem(
74
+ REV_OP, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadWriteAccess, None
75
+ ),
76
+ STOP_AUT: DataItem(
77
+ STOP_AUT, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None
78
+ ),
79
+ FWD_AUT: DataItem(FWD_AUT, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None),
80
+ REV_AUT: DataItem(REV_AUT, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None),
81
+ FWD_CTRL: DataItem(
82
+ FWD_CTRL, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None
83
+ ),
84
+ REV_CTRL: DataItem(
85
+ REV_CTRL, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None
86
+ ),
87
+ RPM_SCL_MIN: DataItem(
88
+ RPM_SCL_MIN, W3cXmlDataTypes.FLOAT, MTPAccess.ReadAccess, None
89
+ ),
90
+ RPM_SCL_MAX: DataItem(
91
+ RPM_SCL_MAX, W3cXmlDataTypes.FLOAT, MTPAccess.ReadAccess, None
92
+ ),
93
+ RPM_UNIT: DataItem(RPM_UNIT, W3cXmlDataTypes.SHORT, MTPAccess.ReadAccess, None),
94
+ RPM_MIN: DataItem(RPM_MIN, W3cXmlDataTypes.FLOAT, MTPAccess.ReadAccess, None),
95
+ RPM_MAX: DataItem(RPM_MAX, W3cXmlDataTypes.FLOAT, MTPAccess.ReadAccess, None),
96
+ RPM_INT: DataItem(RPM_INT, W3cXmlDataTypes.FLOAT, MTPAccess.ReadAccess, None),
97
+ RPM_MAN: DataItem(RPM_MAN, W3cXmlDataTypes.FLOAT, MTPAccess.ReadAccess, None),
98
+ RPM_: DataItem(RPM_, W3cXmlDataTypes.FLOAT, MTPAccess.ReadAccess, None),
99
+ RPM_RBK: DataItem(RPM_RBK, W3cXmlDataTypes.FLOAT, MTPAccess.ReadAccess, None),
100
+ REV_FBK_CALC: DataItem(
101
+ REV_FBK_CALC, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None
102
+ ),
103
+ REV_FBK: DataItem(REV_FBK, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None),
104
+ FWD_FBK_CALC: DataItem(
105
+ FWD_FBK_CALC, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None
106
+ ),
107
+ FWD_FBK: DataItem(FWD_FBK, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None),
108
+ RPM_FBK_CALC: DataItem(
109
+ RPM_FBK_CALC, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None
110
+ ),
111
+ RPM_FBK: DataItem(RPM_FBK, W3cXmlDataTypes.FLOAT, MTPAccess.ReadAccess, None),
112
+ TRIP_: DataItem(TRIP_, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None),
113
+ PERM_EN: DataItem(PERM_EN, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None),
114
+ PERMIT_: DataItem(PERMIT_, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None),
115
+ INTL_EN: DataItem(INTL_EN, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None),
116
+ INTERLOCK_: DataItem(
117
+ INTERLOCK_, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None
118
+ ),
119
+ PROT_EN: DataItem(PROT_EN, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None),
120
+ PROTECT_: DataItem(
121
+ PROTECT_, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None
122
+ ),
123
+ RESET_OP: DataItem(
124
+ RESET_OP, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadWriteAccess, None
125
+ ),
126
+ RESET_AUT: DataItem(
127
+ RESET_AUT, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None
128
+ ),
129
+ }
130
+
131
+ op_mode: OperationMode
132
+ src_mode: SourceMode
133
+
134
+ rpm_min: float
135
+ rpm_max: float
136
+ rpm_scl_min: float
137
+ rpm_scl_max: float
138
+ rpm_unit: int
139
+ rev_fbk_calc: bool
140
+ fwd_fbk_calc: bool
141
+ rpm_fbk_calc: bool
142
+
143
+ safe_pos: int
144
+ fwd_en: bool
145
+ rev_en: bool
146
+ perm_en: bool
147
+ intl_en: bool
148
+ prot_en: bool
149
+
150
+ def __init__(
151
+ self,
152
+ tag_name: str,
153
+ tag_description: str = "",
154
+ rpm_min: float = 0,
155
+ rpm_max: float = 1000,
156
+ rpm_scl_min: float = 0,
157
+ rpm_scl_max: float = 1000,
158
+ rpm_unit: int = 0,
159
+ rev_fbk_calc: bool = True,
160
+ fwd_fbk_calc: bool = True,
161
+ rpm_fbk_calc: bool = True,
162
+ safe_pos: int = 0,
163
+ fwd_en: bool = True,
164
+ rev_en: bool = False,
165
+ perm_en: bool = False,
166
+ intl_en: bool = False,
167
+ prot_en: bool = False,
168
+ ):
169
+ """
170
+ Analog Drive (AnaDrv).
171
+ """
172
+ super().__init__(tag_name, tag_description)
173
+ self.mtpObjectType = "MTPDataObjectSUCLib/DataAssembly/ActiveElement/AnaDrv"
174
+
175
+ self.op_mode = OperationMode()
176
+ self.src_mode = SourceMode()
177
+
178
+ self.rpm_min = rpm_min
179
+ self.rpm_max = rpm_max
180
+ self.rpm_scl_min = rpm_scl_min
181
+ self.rpm_scl_max = rpm_scl_max
182
+ self.rpm_unit = rpm_unit
183
+ self.rev_fbk_calc = rev_fbk_calc
184
+ self.fwd_fbk_calc = fwd_fbk_calc
185
+ self.rpm_fbk_calc = rpm_fbk_calc
186
+
187
+ self.safe_pos = safe_pos
188
+ self.fwd_en = fwd_en
189
+ self.rev_en = rev_en
190
+ self.perm_en = perm_en
191
+ self.intl_en = intl_en
192
+ self.prot_en = prot_en
193
+
194
+ # Initialize data items with dynamic values (using class-defined data items)
195
+ self[AnaDrv.SAFE_POS] = safe_pos
196
+ self[AnaDrv.SAFE_POS_ACT] = True
197
+ self[AnaDrv.FWD_EN] = fwd_en
198
+ self[AnaDrv.REV_EN] = rev_en
199
+ self[AnaDrv.STOP_OP] = 0
200
+ self[AnaDrv.FWD_OP] = 0
201
+ self[AnaDrv.REV_OP] = 0
202
+ self[AnaDrv.STOP_AUT] = 0
203
+ self[AnaDrv.FWD_AUT] = 0
204
+ self[AnaDrv.REV_AUT] = 0
205
+ self[AnaDrv.FWD_CTRL] = 0
206
+ self[AnaDrv.REV_CTRL] = 0
207
+ self[AnaDrv.RPM_SCL_MIN] = self.rpm_scl_min
208
+ self[AnaDrv.RPM_SCL_MAX] = self.rpm_scl_max
209
+ self[AnaDrv.RPM_UNIT] = self.rpm_unit
210
+ self[AnaDrv.RPM_MIN] = self.rpm_min
211
+ self[AnaDrv.RPM_MAX] = self.rpm_max
212
+ self[AnaDrv.RPM_INT] = 0
213
+ self[AnaDrv.RPM_MAN] = 0
214
+ self[AnaDrv.RPM_] = rpm_min
215
+ self[AnaDrv.RPM_RBK] = rpm_min
216
+ self[AnaDrv.REV_FBK_CALC] = rev_fbk_calc
217
+ self[AnaDrv.REV_FBK] = False
218
+ self[AnaDrv.FWD_FBK_CALC] = fwd_fbk_calc
219
+ self[AnaDrv.FWD_FBK] = False
220
+ self[AnaDrv.RPM_FBK_CALC] = rpm_fbk_calc
221
+ self[AnaDrv.RPM_FBK] = rpm_min
222
+ self[AnaDrv.TRIP_] = True
223
+ self[AnaDrv.PERM_EN] = perm_en
224
+ self[AnaDrv.PERMIT_] = 0
225
+ self[AnaDrv.INTL_EN] = intl_en
226
+ self[AnaDrv.INTERLOCK_] = 0
227
+ self[AnaDrv.PROT_EN] = prot_en
228
+ self[AnaDrv.PROTECT_] = 0
229
+ self[AnaDrv.RESET_OP] = 0
230
+ self[AnaDrv.RESET_AUT] = 0
231
+
232
+ # Set callbacks for writable items
233
+ self.get_item(AnaDrv.STOP_OP).ext_wrt_cb = self.set_stop_op
234
+ self.get_item(AnaDrv.FWD_OP).ext_wrt_cb = self.set_fwd_op
235
+ self.get_item(AnaDrv.REV_OP).ext_wrt_cb = self.set_rev_op
236
+ self.get_item(AnaDrv.RPM_INT).ext_wrt_cb = self.set_rpm_int
237
+ self.get_item(AnaDrv.RPM_MAN).ext_wrt_cb = self.set_rpm_man
238
+ self.get_item(AnaDrv.RESET_OP).ext_wrt_cb = self.set_reset_op
239
+
240
+ def _expect_save_pos(self):
241
+ if self._run_allowed():
242
+ self[AnaDrv.SAFE_POS_ACT] = False
243
+ else:
244
+ self._go_save_pos()
245
+ self[AnaDrv.SAFE_POS_ACT] = True
246
+
247
+ def _go_save_pos(self):
248
+ if self[AnaDrv.SAFE_POS]:
249
+ self._run_fwd_drv()
250
+ else:
251
+ self._stop_drv()
252
+
253
+ def _run_allowed(self):
254
+ if self[AnaDrv.PERM_EN] and self[AnaDrv.PERMIT_] == 0:
255
+ logger.debug("Permission is not given")
256
+ return False
257
+ if self[AnaDrv.INTL_EN] and self[AnaDrv.INTERLOCK_] == 0:
258
+ logger.debug("Interlock is active")
259
+ return False
260
+ if self[AnaDrv.PROT_EN] and self[AnaDrv.PROTECT_] == 0:
261
+ logger.debug("Protect is active")
262
+ return False
263
+ if not self[AnaDrv.TRIP_]:
264
+ logger.debug("Drive protection triggered")
265
+ return False
266
+ return True
267
+
268
+ def set_fwd_op(self, value: bool):
269
+ logger.debug(f"FwdOp set to {value}")
270
+ if self.op_mode[OperationMode.STATE_OP_ACT] and self.fwd_en:
271
+ if value and self._run_allowed():
272
+ self._run_fwd_drv()
273
+ self[AnaDrv.FWD_OP] = False
274
+
275
+ def set_rev_op(self, value: bool):
276
+ logger.debug(f"RevOp set to {value}")
277
+ if self.op_mode[OperationMode.STATE_OP_ACT] and self.rev_en:
278
+ if value and self._run_allowed():
279
+ self._run_rev_drv()
280
+ self[AnaDrv.REV_OP] = False
281
+
282
+ def set_stop_op(self, value: bool):
283
+ logger.debug(f"StopOp set to {value}")
284
+ if self.op_mode[OperationMode.STATE_OP_ACT] and value:
285
+ self._stop_drv()
286
+ self[AnaDrv.STOP_OP] = False
287
+
288
+ def set_reset_op(self, value: bool):
289
+ logger.debug(f"ResetOp set to {value}")
290
+ if self.op_mode[OperationMode.STATE_OP_ACT] and value:
291
+ self._reset_drv()
292
+ self[AnaDrv.RESET_OP] = False
293
+
294
+ def set_fwd_aut(self, value: bool):
295
+ logger.debug(f"FwdAut set to {value}")
296
+ if self.op_mode[OperationMode.STATE_AUT_ACT] and self.fwd_en:
297
+ if value and self._run_allowed():
298
+ self._run_fwd_drv()
299
+
300
+ def set_rev_aut(self, value: bool):
301
+ logger.debug(f"RevAut set to {value}")
302
+ if self.op_mode[OperationMode.STATE_AUT_ACT] and self.rev_en:
303
+ if value and self._run_allowed():
304
+ self._run_rev_drv()
305
+
306
+ def set_stop_aut(self, value: bool):
307
+ logger.debug(f"StopAut set to {value}")
308
+ if self.op_mode[OperationMode.STATE_AUT_ACT] and value:
309
+ self._stop_drv()
310
+
311
+ def set_reset_aut(self, value: bool):
312
+ logger.debug(f"ResetAut set to {value}")
313
+ if self.op_mode[OperationMode.STATE_AUT_ACT] and value:
314
+ self._reset_drv()
315
+
316
+ def _run_fwd_drv(self) -> None:
317
+ """Run the driver forward."""
318
+ self[AnaDrv.FWD_CTRL] = True
319
+ if self[AnaDrv.FWD_FBK_CALC]:
320
+ self[AnaDrv.FWD_FBK] = True
321
+ self[AnaDrv.REV_CTRL] = False
322
+ if self[AnaDrv.REV_FBK_CALC]:
323
+ self[AnaDrv.REV_FBK] = False
324
+
325
+ def _run_rev_drv(self):
326
+ self[AnaDrv.FWD_CTRL] = False
327
+ if self[AnaDrv.FWD_FBK_CALC]:
328
+ self[AnaDrv.FWD_FBK] = False
329
+ self[AnaDrv.REV_CTRL] = True
330
+ if self[AnaDrv.REV_FBK_CALC]:
331
+ self[AnaDrv.REV_FBK] = True
332
+
333
+ def _stop_drv(self):
334
+ self[AnaDrv.FWD_CTRL] = False
335
+ if self[AnaDrv.FWD_FBK_CALC]:
336
+ self[AnaDrv.FWD_FBK] = False
337
+ self[AnaDrv.REV_CTRL] = False
338
+ if self[AnaDrv.REV_FBK_CALC]:
339
+ self[AnaDrv.REV_FBK] = False
340
+
341
+ def _reset_drv(self):
342
+ if self[AnaDrv.PROT_EN] and self[AnaDrv.PROTECT_] == 0:
343
+ self[AnaDrv.PROTECT_] = True
344
+ self[AnaDrv.SAFE_POS_ACT] = False
345
+ self._stop_drv()
346
+
347
+ def set_rpm_int(self, value: float):
348
+ logger.debug(f"RpmInt set to {value}")
349
+ if (
350
+ self.src_mode[SourceMode.SRC_INT_ACT]
351
+ and self.op_mode[OperationMode.STATE_AUT_ACT]
352
+ ):
353
+ self._set_rpm(value)
354
+
355
+ def set_rpm_man(self, value: float):
356
+ logger.debug(f"RpmIntMan set to {value}")
357
+
358
+ if self.op_mode[OperationMode.STATE_OP_ACT]:
359
+ self._set_rpm(value)
360
+
361
+ def valid_value(self, value: float):
362
+ if value < self.rpm_min or value > self.rpm_max:
363
+ return False
364
+ else:
365
+ return True
366
+
367
+ def _correct_value(self, value: float):
368
+ if value > self.rpm_max:
369
+ return self.rpm_max
370
+ elif value < self.rpm_min:
371
+ return self.rpm_min
372
+ else:
373
+ return value
374
+
375
+ def _set_rpm(self, value: float):
376
+ if self.valid_value(value):
377
+ self[AnaDrv.RPM_] = value
378
+ logger.debug(f"Rpm set to {value}")
379
+ if self[AnaDrv.RPM_FBK_CALC]:
380
+ self[AnaDrv.RPM_FBK] = value
381
+ else:
382
+ logger.debug(f"Rpm cannot be set to {value} (out of range)")
383
+
384
+ def set_rpm_rbk(self, value: float):
385
+ corr_value = self._correct_value(value)
386
+ self[AnaDrv.RPM_RBK] = corr_value
387
+ logger.debug(f"RpmRbk set to {corr_value}")
388
+
389
+ def set_rpm_fbk(self, value: float):
390
+ if not self[AnaDrv.RPM_FBK_CALC]:
391
+ corr_value = self._correct_value(value)
392
+ self[AnaDrv.RPM_FBK] = corr_value
393
+ logger.debug(f"RpmFbk set to {corr_value}")
394
+
395
+ def set_rev_fbk(self, value: bool):
396
+ if not self[AnaDrv.REV_FBK_CALC]:
397
+ self[AnaDrv.REV_FBK] = value
398
+ logger.debug(f"RevFbk set to {value}")
399
+
400
+ def set_fwd_fbk(self, value: bool):
401
+ if not self[AnaDrv.FWD_FBK_CALC]:
402
+ self[AnaDrv.FWD_FBK] = value
403
+ logger.debug(f"FwdFbk set to {value}")
404
+
405
+ def set_trip(self, value: bool):
406
+ self[AnaDrv.TRIP_] = value
407
+ logger.debug(f"Trip set to {value}")
408
+ self._expect_save_pos()
409
+
410
+ def set_permit(self, value: bool):
411
+ if not self[AnaDrv.PERM_EN]:
412
+ value = True
413
+ self[AnaDrv.PERMIT_] = value
414
+ logger.debug(f"Permit set to {value}")
415
+ self._expect_save_pos()
416
+
417
+ def set_interlock(self, value: bool):
418
+ if not self[AnaDrv.INTL_EN]:
419
+ value = True
420
+ self[AnaDrv.INTERLOCK_] = value
421
+ logger.debug(f"Interlock set to {value}")
422
+ self._expect_save_pos()
423
+
424
+ def set_protect(self, value: bool):
425
+ if not self[AnaDrv.PROT_EN]:
426
+ value = True
427
+ if value:
428
+ self._reset_drv()
429
+ self[AnaDrv.PROTECT_] = value
430
+ logger.debug(f"Protect set to {value}")
431
+ self._expect_save_pos()
432
+
433
+ def get_rpm(self):
434
+ return self[AnaDrv.RPM_]
435
+
436
+ def get_rpm_rbk(self):
437
+ return self[AnaDrv.RPM_RBK]
438
+
439
+ def get_rpm_fbk(self):
440
+ return self[AnaDrv.RPM_FBK]
441
+
442
+ def get_fwd_fbk(self):
443
+ return self[AnaDrv.FWD_FBK]
444
+
445
+ def get_rev_fbk(self):
446
+ return self[AnaDrv.REV_FBK]