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,402 @@
1
+ """Implementation of AnaVlv."""
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 AnaVlv(ActiveElement):
19
+ # DataItem constant definitions
20
+ SAFE_POS = "SafePos"
21
+ SAFE_POS_EN = "SafePosEn"
22
+ SAFE_POS_ACT = "SafePosAct"
23
+ OPEN_AUT = "OpenAut"
24
+ CLOSE_AUT = "CloseAut"
25
+ OPEN_OP = "OpenOp"
26
+ CLOSE_OP = "CloseOp"
27
+ OPEN_ACT = "OpenAct"
28
+ CLOSE_ACT = "CloseAct"
29
+ POS_SCL_MIN = "PosSclMin"
30
+ POS_SCL_MAX = "PosSclMax"
31
+ POS_UNIT = "PosUnit"
32
+ POS_MIN = "PosMin"
33
+ POS_MAX = "PosMax"
34
+ POS_INT = "PosInt"
35
+ POS_MAN = "PosMan"
36
+ POS_RBK = "PosRbk"
37
+ POS_ = "Pos"
38
+ OPEN_FBK_CALC = "OpenFbkCalc"
39
+ OPEN_FBK = "OpenFbk"
40
+ CLOSE_FBK_CALC = "CloseFbkCalc"
41
+ CLOSE_FBK = "CloseFbk"
42
+ POS_FBK_CALC = "PosFbkCalc"
43
+ POS_FBK = "PosFbk"
44
+ PERM_EN = "PermEn"
45
+ PERMIT_ = "Permit"
46
+ INTL_EN = "IntlEn"
47
+ INTERLOCK = "Interlock"
48
+ PROT_EN = "ProtEn"
49
+ PROTECT_ = "Protect"
50
+ RESET_OP = "ResetOp"
51
+ RESET_AUT = "ResetAut"
52
+
53
+ # Class-level data items dictionary
54
+ CLASS_DATA_ITEMS: ClassVar = {
55
+ SAFE_POS: DataItem(
56
+ SAFE_POS, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None
57
+ ),
58
+ SAFE_POS_EN: DataItem(
59
+ SAFE_POS_EN, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None
60
+ ),
61
+ SAFE_POS_ACT: DataItem(
62
+ SAFE_POS_ACT, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None
63
+ ),
64
+ OPEN_AUT: DataItem(
65
+ OPEN_AUT, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None
66
+ ),
67
+ CLOSE_AUT: DataItem(
68
+ CLOSE_AUT, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None
69
+ ),
70
+ OPEN_OP: DataItem(OPEN_OP, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None),
71
+ CLOSE_OP: DataItem(
72
+ CLOSE_OP, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None
73
+ ),
74
+ OPEN_ACT: DataItem(
75
+ OPEN_ACT, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None
76
+ ),
77
+ CLOSE_ACT: DataItem(
78
+ CLOSE_ACT, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None
79
+ ),
80
+ POS_SCL_MIN: DataItem(
81
+ POS_SCL_MIN, W3cXmlDataTypes.FLOAT, MTPAccess.ReadAccess, None
82
+ ),
83
+ POS_SCL_MAX: DataItem(
84
+ POS_SCL_MAX, W3cXmlDataTypes.FLOAT, MTPAccess.ReadAccess, None
85
+ ),
86
+ POS_UNIT: DataItem(POS_UNIT, W3cXmlDataTypes.SHORT, MTPAccess.ReadAccess, None),
87
+ POS_MIN: DataItem(POS_MIN, W3cXmlDataTypes.FLOAT, MTPAccess.ReadAccess, None),
88
+ POS_MAX: DataItem(POS_MAX, W3cXmlDataTypes.FLOAT, MTPAccess.ReadAccess, None),
89
+ POS_INT: DataItem(POS_INT, W3cXmlDataTypes.FLOAT, MTPAccess.ReadAccess, None),
90
+ POS_MAN: DataItem(
91
+ POS_MAN, W3cXmlDataTypes.FLOAT, MTPAccess.ReadWriteAccess, None
92
+ ),
93
+ POS_RBK: DataItem(POS_RBK, W3cXmlDataTypes.FLOAT, MTPAccess.ReadAccess, None),
94
+ POS_: DataItem(POS_, W3cXmlDataTypes.FLOAT, MTPAccess.ReadAccess, None),
95
+ OPEN_FBK_CALC: DataItem(
96
+ OPEN_FBK_CALC, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None
97
+ ),
98
+ OPEN_FBK: DataItem(
99
+ OPEN_FBK, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None
100
+ ),
101
+ CLOSE_FBK_CALC: DataItem(
102
+ CLOSE_FBK_CALC, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None
103
+ ),
104
+ CLOSE_FBK: DataItem(
105
+ CLOSE_FBK, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None
106
+ ),
107
+ POS_FBK_CALC: DataItem(
108
+ POS_FBK_CALC, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None
109
+ ),
110
+ POS_FBK: DataItem(POS_FBK, W3cXmlDataTypes.FLOAT, MTPAccess.ReadAccess, None),
111
+ PERM_EN: DataItem(PERM_EN, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None),
112
+ PERMIT_: DataItem(PERMIT_, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None),
113
+ INTL_EN: DataItem(INTL_EN, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None),
114
+ INTERLOCK: DataItem(
115
+ INTERLOCK, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None
116
+ ),
117
+ PROT_EN: DataItem(PROT_EN, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None),
118
+ PROTECT_: DataItem(
119
+ PROTECT_, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None
120
+ ),
121
+ RESET_OP: DataItem(
122
+ RESET_OP, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadWriteAccess, None
123
+ ),
124
+ RESET_AUT: DataItem(
125
+ RESET_AUT, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, None
126
+ ),
127
+ }
128
+
129
+ op_mode: OperationMode
130
+ src_mode: SourceMode
131
+
132
+ def __init__(
133
+ self,
134
+ tag_name,
135
+ tag_description="",
136
+ pos_min=0,
137
+ pos_max=100,
138
+ pos_scl_min=0,
139
+ pos_scl_max=100,
140
+ pos_unit=1342,
141
+ open_fbk_calc=True,
142
+ close_fbk_calc=True,
143
+ pos_fbk_calc=True,
144
+ safe_pos=0,
145
+ safe_pos_en=False,
146
+ perm_en=False,
147
+ intl_en=False,
148
+ prot_en=False,
149
+ ):
150
+ """
151
+ Analog Valve (AnaVlv).
152
+ """
153
+ super().__init__(tag_name, tag_description)
154
+ self.mtpObjectType = "MTPDataObjectSUCLib/DataAssembly/ActiveElement/AnaVlv"
155
+
156
+ self.op_mode = OperationMode()
157
+ self.src_mode = SourceMode()
158
+
159
+ # Initialize data items with dynamic values (using class-defined data items)
160
+ self[AnaVlv.SAFE_POS] = safe_pos
161
+ self[AnaVlv.SAFE_POS_EN] = safe_pos_en
162
+ self[AnaVlv.SAFE_POS_ACT] = False
163
+ self[AnaVlv.OPEN_AUT] = 0
164
+ self[AnaVlv.CLOSE_AUT] = 0
165
+ self[AnaVlv.OPEN_OP] = 0
166
+ self[AnaVlv.CLOSE_OP] = 0
167
+ self[AnaVlv.OPEN_ACT] = 0
168
+ self[AnaVlv.CLOSE_ACT] = 0
169
+ self[AnaVlv.POS_SCL_MIN] = pos_scl_min
170
+ self[AnaVlv.POS_SCL_MAX] = pos_scl_max
171
+ self[AnaVlv.POS_UNIT] = pos_unit
172
+ self[AnaVlv.POS_MIN] = pos_min
173
+ self[AnaVlv.POS_MAX] = pos_max
174
+ self[AnaVlv.POS_INT] = 0
175
+ self[AnaVlv.POS_MAN] = 0
176
+ self[AnaVlv.POS_RBK] = pos_min
177
+ self[AnaVlv.POS_] = pos_min
178
+ self[AnaVlv.OPEN_FBK_CALC] = open_fbk_calc
179
+ self[AnaVlv.OPEN_FBK] = False
180
+ self[AnaVlv.CLOSE_FBK_CALC] = close_fbk_calc
181
+ self[AnaVlv.CLOSE_FBK] = False
182
+ self[AnaVlv.POS_FBK_CALC] = pos_fbk_calc
183
+ self[AnaVlv.POS_FBK] = pos_min
184
+ self[AnaVlv.PERM_EN] = perm_en
185
+ self[AnaVlv.PERMIT_] = 0
186
+ self[AnaVlv.INTL_EN] = intl_en
187
+ self[AnaVlv.INTERLOCK] = 0
188
+ self[AnaVlv.PROT_EN] = prot_en
189
+ self[AnaVlv.PROTECT_] = 0
190
+ self[AnaVlv.RESET_OP] = 0
191
+ self[AnaVlv.RESET_AUT] = 0
192
+
193
+ # Set callbacks for writable items
194
+ self.get_item(AnaVlv.OPEN_OP).ext_wrt_cb = self.set_open_op
195
+ self.get_item(AnaVlv.CLOSE_OP).ext_wrt_cb = self.set_close_op
196
+ self.get_item(AnaVlv.POS_MAN).ext_wrt_cb = self.set_pos_man
197
+ self.get_item(AnaVlv.RESET_OP).ext_wrt_cb = self.set_reset_op
198
+
199
+ def _expect_save_pos(self):
200
+ if self._run_allowed():
201
+ self[AnaVlv.SAFE_POS_ACT] = False
202
+ else:
203
+ if self[AnaVlv.SAFE_POS_EN]:
204
+ self._go_save_pos()
205
+ else: # hold position
206
+ logger.debug("Device has no safe position")
207
+ self[AnaVlv.SAFE_POS_ACT] = True
208
+
209
+ def _go_save_pos(self):
210
+ if self[AnaVlv.SAFE_POS] == 1:
211
+ self._run_open_vlv()
212
+ safe_pos = self[AnaVlv.POS_MAX]
213
+
214
+ else:
215
+ self._run_close_vlv()
216
+ safe_pos = self[AnaVlv.POS_MIN]
217
+
218
+ self[AnaVlv.POS_] = safe_pos
219
+ logger.debug(f"Pos set to safe position {safe_pos}")
220
+
221
+ if self[AnaVlv.POS_FBK_CALC]:
222
+ self[AnaVlv.POS_FBK] = safe_pos
223
+
224
+ def set_open_aut(self, value: bool):
225
+ logger.debug(f"OpenAut set to {value}")
226
+ if self.op_mode[OperationMode.STATE_AUT_ACT]:
227
+ if value and self._run_allowed():
228
+ self._run_open_vlv()
229
+
230
+ def set_close_aut(self, value: bool):
231
+ logger.debug(f"CloseAut set to {value}")
232
+ if self.op_mode[OperationMode.STATE_AUT_ACT]:
233
+ if value and self._run_allowed():
234
+ self._run_close_vlv()
235
+
236
+ def set_reset_aut(self, value: bool):
237
+ logger.debug(f"ResetAut set to {value}")
238
+ if self.op_mode[OperationMode.STATE_AUT_ACT] and value:
239
+ self._reset_vlv()
240
+
241
+ def set_open_op(self, value: bool):
242
+ logger.debug(f"OpenOp set to {value}")
243
+ if self.op_mode[OperationMode.STATE_OP_ACT]:
244
+ if value and self._run_allowed():
245
+ self._run_open_vlv()
246
+ self[AnaVlv.OPEN_OP] = False
247
+
248
+ def set_close_op(self, value: bool):
249
+ logger.debug(f"CloseOp set to {value}")
250
+ if self.op_mode[OperationMode.STATE_OP_ACT]:
251
+ if value and self._run_allowed():
252
+ self._run_close_vlv()
253
+ self[AnaVlv.CLOSE_OP] = False
254
+
255
+ def set_reset_op(self, value: bool):
256
+ logger.debug(f"ResetOp set to {value}")
257
+ if self.op_mode[OperationMode.STATE_OP_ACT] and value:
258
+ self._reset_vlv()
259
+ self[AnaVlv.RESET_OP] = False
260
+
261
+ def _run_allowed(self):
262
+ if self[AnaVlv.PERM_EN] and self[AnaVlv.PERMIT_] == 0:
263
+ logger.debug(f"Permission is not given")
264
+ return False
265
+ if self[AnaVlv.INTL_EN] and self[AnaVlv.INTERLOCK] == 0:
266
+ logger.debug(f"Interlock is active")
267
+ return False
268
+ if self[AnaVlv.PROT_EN] and self[AnaVlv.PROTECT_] == 0:
269
+ logger.debug(f"Protect is active")
270
+ return False
271
+ return True
272
+
273
+ def _run_open_vlv(self):
274
+ self[AnaVlv.OPEN_ACT] = True
275
+ if self[AnaVlv.OPEN_FBK_CALC]:
276
+ self[AnaVlv.OPEN_FBK] = True
277
+ self[AnaVlv.CLOSE_ACT] = False
278
+ if self[AnaVlv.CLOSE_FBK_CALC]:
279
+ self[AnaVlv.CLOSE_FBK] = False
280
+
281
+ def _run_close_vlv(self):
282
+ self[AnaVlv.OPEN_ACT] = False
283
+ if self[AnaVlv.OPEN_FBK_CALC]:
284
+ self[AnaVlv.OPEN_FBK] = False
285
+ self[AnaVlv.CLOSE_ACT] = True
286
+ if self[AnaVlv.CLOSE_FBK_CALC]:
287
+ self[AnaVlv.CLOSE_FBK] = True
288
+
289
+ def _reset_vlv(self):
290
+ if self[AnaVlv.PROT_EN] and self[AnaVlv.PROTECT_] == 0:
291
+ self[AnaVlv.PROTECT_] = True
292
+ self[AnaVlv.SAFE_POS_ACT] = False
293
+ self[AnaVlv.OPEN_ACT] = False
294
+ if self[AnaVlv.OPEN_FBK_CALC]:
295
+ self[AnaVlv.OPEN_FBK] = False
296
+ self[AnaVlv.CLOSE_ACT] = False
297
+ if self[AnaVlv.CLOSE_FBK_CALC]:
298
+ self[AnaVlv.CLOSE_FBK] = False
299
+
300
+ def set_pos_int(self, value: float):
301
+ logger.debug(f"PosInt set to {value}")
302
+ if self.src_mode[SourceMode.SRC_INT_ACT]:
303
+ self._set_pos(value)
304
+
305
+ def set_pos_man(self, value: float):
306
+ logger.debug(f"PosMan set to {value}")
307
+ if self.src_mode[SourceMode.SRC_MAN_ACT]:
308
+ self._set_pos(value)
309
+
310
+ def _correct_value(self, value: float):
311
+ if value > self[AnaVlv.POS_MAX]:
312
+ return self[AnaVlv.POS_MAX]
313
+ elif value < self[AnaVlv.POS_MIN]:
314
+ return self[AnaVlv.POS_MIN]
315
+ else:
316
+ return value
317
+
318
+ def valid_value(self, value: float):
319
+ return self[AnaVlv.POS_MIN] <= value <= self[AnaVlv.POS_MAX]
320
+
321
+ def _set_pos(self, value: float):
322
+ if not self._run_allowed():
323
+ logger.debug("No position change is allowed")
324
+ return
325
+
326
+ if self[AnaVlv.SAFE_POS_ACT] or (
327
+ self[AnaVlv.PERM_EN] and self[AnaVlv.PERMIT_] == 0
328
+ ):
329
+ logger.debug("manual or internal position specification inactive")
330
+ return
331
+
332
+ if self.valid_value(value):
333
+ if self[AnaVlv.CLOSE_ACT]:
334
+ value = self[AnaVlv.POS_MIN]
335
+
336
+ self[AnaVlv.POS_] = value
337
+ logger.debug(f"Pos set to {value}")
338
+ if self[AnaVlv.POS_FBK_CALC]:
339
+ self[AnaVlv.POS_FBK] = value
340
+ else:
341
+ logger.debug(f"Pos cannot be set to {value} (out of range)")
342
+
343
+ def set_pos_rbk(self, value: float):
344
+ corr_value = self._correct_value(value)
345
+ self[AnaVlv.POS_RBK] = corr_value
346
+ logger.debug(f"PosRbk set to {value}")
347
+
348
+ def set_pos_fbk(self, value: float):
349
+ if not self[AnaVlv.POS_FBK_CALC]:
350
+ corr_value = self._correct_value(value)
351
+ self[AnaVlv.POS_FBK] = corr_value
352
+ logger.debug(f"PosFbk set to {value}")
353
+
354
+ def set_open_fbk(self, value: bool):
355
+ if not self[AnaVlv.OPEN_FBK_CALC]:
356
+ self[AnaVlv.OPEN_FBK] = value
357
+ logger.debug(f"OpenFbk set to {value}")
358
+
359
+ def set_close_fbk(self, value: bool):
360
+ if not self[AnaVlv.CLOSE_FBK_CALC]:
361
+ self[AnaVlv.CLOSE_FBK] = value
362
+ logger.debug(f"CloseFbk set to {value}")
363
+
364
+ def set_permit(self, value: bool):
365
+ if not self[AnaVlv.PERM_EN]:
366
+ value = True
367
+ self[AnaVlv.PERMIT_] = value
368
+ logger.debug(f"Permit set to {value}")
369
+ self[AnaVlv.SAFE_POS_ACT] = (
370
+ False # safety position should not be activated for permit mode
371
+ )
372
+
373
+ def set_interlock(self, value: bool):
374
+ if not self[AnaVlv.INTL_EN]:
375
+ value = True
376
+ self[AnaVlv.INTERLOCK] = value
377
+ logger.debug(f"Interlock set to {value}")
378
+ self._expect_save_pos()
379
+
380
+ def set_protect(self, value: bool):
381
+ if not self[AnaVlv.PROT_EN]:
382
+ value = True
383
+ if value:
384
+ self._reset_vlv()
385
+ self[AnaVlv.PROTECT_] = value
386
+ logger.debug(f"Protect set to {value}")
387
+ self._expect_save_pos()
388
+
389
+ def get_pos(self):
390
+ return self[AnaVlv.POS_]
391
+
392
+ def get_pos_rbk(self):
393
+ return self[AnaVlv.POS_RBK]
394
+
395
+ def get_pos_fbk(self):
396
+ return self[AnaVlv.POS_FBK]
397
+
398
+ def get_open_fbk(self):
399
+ return self[AnaVlv.OPEN_FBK]
400
+
401
+ def get_close_fbk(self):
402
+ return self[AnaVlv.CLOSE_FBK]