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.
- examples/__init__.py +0 -0
- examples/minimal+pid.py +82 -0
- examples/minimal.py +32 -0
- examples/minimal_recipe.py +117 -0
- examples/pea_alarm_base.py +47 -0
- examples/pea_minimal.py +258 -0
- mtppy/__init__.py +1 -0
- mtppy/part1/__init__.py +4 -0
- mtppy/part1/empty_folder_test.py +7 -0
- mtppy/part3/__init__.py +4 -0
- mtppy/part3/data_assembly_set/__init__.py +4 -0
- mtppy/part3/data_assembly_set/active_elements/__init__.py +4 -0
- mtppy/part3/data_assembly_set/active_elements/active_element.py +22 -0
- mtppy/part3/data_assembly_set/active_elements/drives/__init__.py +4 -0
- mtppy/part3/data_assembly_set/active_elements/drives/ana_drv.py +446 -0
- mtppy/part3/data_assembly_set/active_elements/drives/ana_drv_test.py +567 -0
- mtppy/part3/data_assembly_set/active_elements/drives/bin_drv.py +365 -0
- mtppy/part3/data_assembly_set/active_elements/drives/bin_drv_test.py +503 -0
- mtppy/part3/data_assembly_set/active_elements/drives/mon_ana_drv.py +469 -0
- mtppy/part3/data_assembly_set/active_elements/drives/mon_ana_drv_test.py +418 -0
- mtppy/part3/data_assembly_set/active_elements/drives/mon_bin_drv.py +295 -0
- mtppy/part3/data_assembly_set/active_elements/drives/mon_bin_drv_test.py +265 -0
- mtppy/part3/data_assembly_set/active_elements/pid/__init__.py +4 -0
- mtppy/part3/data_assembly_set/active_elements/pid/pid_ctrl.py +333 -0
- mtppy/part3/data_assembly_set/active_elements/pid/pid_ctrl_test.py +156 -0
- mtppy/part3/data_assembly_set/active_elements/valves/__init__.py +4 -0
- mtppy/part3/data_assembly_set/active_elements/valves/ana_vlv.py +402 -0
- mtppy/part3/data_assembly_set/active_elements/valves/ana_vlv_test.py +732 -0
- mtppy/part3/data_assembly_set/active_elements/valves/bin_vlv.py +279 -0
- mtppy/part3/data_assembly_set/active_elements/valves/bin_vlv_test.py +585 -0
- mtppy/part3/data_assembly_set/active_elements/valves/mon_ana_vlv.py +402 -0
- mtppy/part3/data_assembly_set/active_elements/valves/mon_ana_vlv_test.py +270 -0
- mtppy/part3/data_assembly_set/active_elements/valves/mon_bin_vlv.py +286 -0
- mtppy/part3/data_assembly_set/active_elements/valves/mon_bin_vlv_test.py +224 -0
- mtppy/part3/data_assembly_set/base_functions/__init__.py +4 -0
- mtppy/part3/data_assembly_set/base_functions/operation_mode.py +252 -0
- mtppy/part3/data_assembly_set/base_functions/operation_mode_test.py +260 -0
- mtppy/part3/data_assembly_set/base_functions/oslevel.py +35 -0
- mtppy/part3/data_assembly_set/base_functions/source_mode.py +189 -0
- mtppy/part3/data_assembly_set/base_functions/source_mode_test.py +112 -0
- mtppy/part3/data_assembly_set/base_functions/wqc.py +75 -0
- mtppy/part3/data_assembly_set/base_functions/wqc_test.py +86 -0
- mtppy/part3/data_assembly_set/data_assembly.py +65 -0
- mtppy/part3/data_assembly_set/diagnostic_elements/__init__.py +4 -0
- mtppy/part3/data_assembly_set/diagnostic_elements/diagnostic_element.py +19 -0
- mtppy/part3/data_assembly_set/indicator_elements/__init__.py +4 -0
- mtppy/part3/data_assembly_set/indicator_elements/indicator_element.py +22 -0
- mtppy/part3/data_assembly_set/indicator_elements/views/__init__.py +4 -0
- mtppy/part3/data_assembly_set/indicator_elements/views/ana_view.py +68 -0
- mtppy/part3/data_assembly_set/indicator_elements/views/bin_view.py +73 -0
- mtppy/part3/data_assembly_set/indicator_elements/views/dint_view.py +76 -0
- mtppy/part3/data_assembly_set/indicator_elements/views/string_view.py +55 -0
- mtppy/part3/data_assembly_set/operation_elements/__init__.py +4 -0
- mtppy/part3/data_assembly_set/operation_elements/operation_element.py +19 -0
- mtppy/part3/data_assembly_set/pea_elements/__init__.py +4 -0
- mtppy/part3/data_assembly_set/pea_elements/pea_element.py +28 -0
- mtppy/part3/data_assembly_set/pea_elements/pea_information_label/__init__.py +4 -0
- mtppy/part3/data_assembly_set/pea_elements/pea_information_label/pea_information_label.py +231 -0
- mtppy/part3/data_assembly_set/pea_elements/web_server_url_info/__init__.py +4 -0
- mtppy/part3/data_assembly_set/pea_elements/web_server_url_info/web_server_url_info.py +42 -0
- mtppy/part3/definitions/__init__.py +4 -0
- mtppy/part3/definitions/mtp_access.py +15 -0
- mtppy/part4/__init__.py +4 -0
- mtppy/part4/automation_services/__init__.py +4 -0
- mtppy/part4/automation_services/base_functions/__init__.py +4 -0
- mtppy/part4/automation_services/base_functions/service_operation_mode.py +368 -0
- mtppy/part4/automation_services/base_functions/service_operation_mode_test.py +242 -0
- mtppy/part4/automation_services/base_functions/service_operator_interaction.py +62 -0
- mtppy/part4/automation_services/base_functions/service_source_mode.py +138 -0
- mtppy/part4/automation_services/base_functions/service_source_mode_test.py +179 -0
- mtppy/part4/automation_services/helpers/__init__.py +4 -0
- mtppy/part4/automation_services/helpers/command_en_control.py +330 -0
- mtppy/part4/automation_services/helpers/command_en_control_test.py +302 -0
- mtppy/part4/automation_services/helpers/state_machine.py +167 -0
- mtppy/part4/automation_services/helpers/state_machine_test.py +294 -0
- mtppy/part4/automation_services/helpers/thread_control.py +39 -0
- mtppy/part4/automation_services/helpers/thread_control_test.py +80 -0
- mtppy/part4/automation_services/procedure.py +111 -0
- mtppy/part4/automation_services/procedure_test.py +185 -0
- mtppy/part4/automation_services/service.py +463 -0
- mtppy/part4/automation_services/service_elements/__init__.py +4 -0
- mtppy/part4/automation_services/service_elements/parameter_elements/__init__.py +4 -0
- mtppy/part4/automation_services/service_elements/parameter_elements/ana_serv_param.py +108 -0
- mtppy/part4/automation_services/service_elements/parameter_elements/ana_serv_param_test.py +59 -0
- mtppy/part4/automation_services/service_elements/parameter_elements/bin_serv_param.py +70 -0
- mtppy/part4/automation_services/service_elements/parameter_elements/bin_serv_param_test.py +39 -0
- mtppy/part4/automation_services/service_elements/parameter_elements/common_serv_param.py +111 -0
- mtppy/part4/automation_services/service_elements/parameter_elements/dint_serv_param.py +77 -0
- mtppy/part4/automation_services/service_elements/parameter_elements/dint_serv_param_test.py +58 -0
- mtppy/part4/automation_services/service_elements/parameter_elements/parameter_element.py +175 -0
- mtppy/part4/automation_services/service_elements/parameter_elements/parameter_element_test.py +246 -0
- mtppy/part4/automation_services/service_elements/parameter_elements/string_serv_param.py +48 -0
- mtppy/part4/automation_services/service_elements/parameter_elements/string_serv_param_test.py +37 -0
- mtppy/part4/automation_services/service_elements/procedure_health_view.py +36 -0
- mtppy/part4/automation_services/service_elements/service_control.py +473 -0
- mtppy/part4/automation_services/service_elements/service_control_test.py +150 -0
- mtppy/part4/automation_services/service_elements/service_element.py +20 -0
- mtppy/part4/automation_services/service_test.py +407 -0
- mtppy/part4/definitions/__init__.py +4 -0
- mtppy/part4/definitions/command_codes.py +58 -0
- mtppy/part4/definitions/command_codes_test.py +44 -0
- mtppy/part4/definitions/state_codes.py +65 -0
- mtppy/part4/definitions/state_codes_test.py +44 -0
- mtppy/part4/process_values/__init__.py +4 -0
- mtppy/part4/process_values/base_functions/__init__.py +4 -0
- mtppy/part4/process_values/base_functions/vqc.py +48 -0
- mtppy/part4/process_values/input_elements/__init__.py +4 -0
- mtppy/part4/process_values/input_elements/ana_process_value_in.py +160 -0
- mtppy/part4/process_values/input_elements/bin_process_value_in.py +83 -0
- mtppy/part4/process_values/input_elements/dint_process_value_in.py +159 -0
- mtppy/part4/process_values/input_elements/input_element.py +40 -0
- mtppy/part4/process_values/input_elements/string_process_value_in.py +45 -0
- mtppy/part5/__init__.py +4 -0
- mtppy/part5/communication_object.py +99 -0
- mtppy/part5/communication_object_test.py +59 -0
- mtppy/part5/definitions/__init__.py +4 -0
- mtppy/part5/definitions/iec61131_data_types.py +31 -0
- mtppy/part5/definitions/iec61131_data_types_test.py +82 -0
- mtppy/part5/definitions/opcua_data_types.py +36 -0
- mtppy/part5/definitions/opcua_data_types_test.py +90 -0
- mtppy/part5/definitions/w3c_xml_data_types.py +177 -0
- mtppy/part5/definitions/w3c_xml_data_types_test.py +143 -0
- mtppy/part5/server_assembly_set/__init__.py +5 -0
- mtppy/part6/__init__.py +4 -0
- mtppy/part6/alarm_set/__init__.py +4 -0
- mtppy/part6/alarm_set/alarm.py +132 -0
- mtppy/part6/alarm_set/alarm_test.py +265 -0
- mtppy/pea/__init__.py +19 -0
- mtppy/pea/data_assembly_factory.py +124 -0
- mtppy/pea/data_assembly_factory_test.py +229 -0
- mtppy/pea/mtp_generator/__init__.py +4 -0
- mtppy/pea/mtp_generator/mtp_generator.py +1183 -0
- mtppy/pea/mtp_generator/mtp_generator_test.py +518 -0
- mtppy/pea/pea.py +139 -0
- mtppy/pea/pea_opcua_server/__init__.py +4 -0
- mtppy/pea/pea_opcua_server/marshalling.py +60 -0
- mtppy/pea/pea_opcua_server/opcua_options_provider/__init__.py +4 -0
- mtppy/pea/pea_opcua_server/opcua_options_provider/instances/basic_opcua_options_provider.py +50 -0
- mtppy/pea/pea_opcua_server/opcua_options_provider/opcua_options_provider.py +103 -0
- mtppy/pea/pea_opcua_server/pea_opcua_server.py +492 -0
- mtppy/pea/pea_opcua_server/subscription_list.py +55 -0
- mtppy/pea/pea_test.py +59 -0
- mtppy/pea/rmtp_pea.py +155 -0
- mtppy/pea/rmtp_pea_test.py +27 -0
- mtppy/pea/service_factory.py +178 -0
- mtppy/pea/service_factory_test.py +156 -0
- mtppy/pea/user_logic/__init__.py +4 -0
- mtppy/pea/user_logic/user_logic_pea.py +72 -0
- mtppy/pea/user_logic/user_logic_registry.py +106 -0
- mtppy/pea/user_logic/user_logic_registry_test.py +167 -0
- mtppy/pea/user_logic/user_logic_service.py +228 -0
- mtppy/pea/user_logic/user_logic_service_test.py +289 -0
- mtppy/utils/__init__.py +4 -0
- mtppy/utils/data_assembly_dict.py +61 -0
- mtppy/utils/data_assembly_dict_test.py +107 -0
- mtppy/utils/data_item.py +446 -0
- mtppy/utils/data_item_com_test.py +82 -0
- mtppy/utils/data_item_test.py +325 -0
- mtppy/utils/logging.py +23 -0
- mtppy/utils/logging_test.py +26 -0
- mtppy/utils/mtp_file_handling/__init__.py +4 -0
- mtppy/utils/mtp_file_handling/extract_manifest_from_mtp_file.py +22 -0
- mtppy/utils/mtp_file_handling/extract_mtp_file.py +22 -0
- mtppy/utils/mtp_file_handling/is_valid_mtp.py +22 -0
- mtppy/utils/mtp_file_handling/is_valid_path_for_manifest.py +15 -0
- mtppy/utils/mtp_file_handling/is_valid_path_to_manifest.py +17 -0
- mtppy/utils/mtp_file_handling/is_valid_path_to_mtp.py +17 -0
- mtppy/utils/mtp_file_handling/load_manifest_file.py +24 -0
- mtppy/utils/mtp_file_handling/mtp_reader/__init__.py +4 -0
- mtppy/utils/mtp_file_handling/mtp_reader/mtp_reader.py +103 -0
- mtppy/utils/mtp_file_handling/mtp_reader/mtp_reader_test.py +96 -0
- mtppy/utils/mtp_file_handling/mtp_reader/mtp_xml.py +226 -0
- mtppy/utils/mtp_file_handling/mtp_reader/mtp_xml_test.py +108 -0
- mtppy/utils/mtp_file_handling/mtp_writer/__init__.py +4 -0
- mtppy/utils/mtp_file_handling/mtp_writer/mtp_writer.py +77 -0
- mtppy/utils/mtp_file_handling/mtp_writer/ressources/get_content_types.py +10 -0
- mtppy/utils/mtp_file_handling/mtp_writer/ressources/get_rels.py +11 -0
- mtppy/utils/mtp_file_handling/mtp_writer/test_mtp_writer.py +25 -0
- mtppy/utils/mtp_file_handling/write_manifest_file.py +29 -0
- mtppy/utils/mtp_file_handling/write_manifest_file_test.py +22 -0
- mtppy/utils/mtp_file_handling/write_mtp_file.py +43 -0
- mtppy/utils/mtp_file_handling/write_mtp_file_test.py +22 -0
- mtppy/utils/testing.py +31 -0
- mtppy2_0-0.1.5.dist-info/METADATA +75 -0
- mtppy2_0-0.1.5.dist-info/RECORD +214 -0
- mtppy2_0-0.1.5.dist-info/WHEEL +5 -0
- mtppy2_0-0.1.5.dist-info/entry_points.txt +3 -0
- mtppy2_0-0.1.5.dist-info/licenses/LICENSE +21 -0
- mtppy2_0-0.1.5.dist-info/top_level.txt +4 -0
- tools/__init__.py +0 -0
- tools/create_bugreport.py +150 -0
- tools/inspect_mtp.py +110 -0
- utils/__init__.py +1 -0
- utils/file_handling/__init__.py +4 -0
- utils/file_handling/cleanup_folder.py +9 -0
- utils/file_handling/get_utc_foldername_with_ms.py +15 -0
- utils/file_handling/get_work_dir.py +9 -0
- utils/file_handling/is_valid_path_for_json.py +11 -0
- utils/file_handling/is_valid_path_to_json.py +17 -0
- utils/file_handling/load_json_file.py +18 -0
- utils/file_handling/read_file_from_file_archive.py +43 -0
- utils/file_handling/read_file_string.py +10 -0
- utils/file_handling/validate_json_data.py +28 -0
- utils/file_handling/write_json_file.py +23 -0
- utils/get_uuid.py +18 -0
- utils/get_uuid_test.py +17 -0
- utils/logging.py +100 -0
- utils/logging_test.py +67 -0
- utils/opcua/check_node.py +79 -0
- utils/resolve_unit/resolve_unit.py +11 -0
- utils/resolve_unit/unit_lib.py +2101 -0
- utils/resolve_unit/unit_lib_test.py +36 -0
- utils/type_conversion.py +236 -0
- utils/type_conversion_test.py +114 -0
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
"""Implementation of BinDrv.
|
|
2
|
+
|
|
3
|
+
This module implements the BinDrv class which represents a binary drive
|
|
4
|
+
element in accordance with the MTP 2.0 specification.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
__copyright__ = (
|
|
8
|
+
"Copyright (c) 2026 Dresden University of Technology, Process-to-Order Group"
|
|
9
|
+
)
|
|
10
|
+
__license__ = "MIT"
|
|
11
|
+
from typing import ClassVar
|
|
12
|
+
|
|
13
|
+
from mtppy.utils.logging import logger
|
|
14
|
+
from mtppy.utils.data_item import DataItem
|
|
15
|
+
from mtppy.part3.definitions.mtp_access import MTPAccess
|
|
16
|
+
from mtppy.part5.definitions.w3c_xml_data_types import W3cXmlDataTypes
|
|
17
|
+
from mtppy.part3.data_assembly_set.active_elements.active_element import ActiveElement
|
|
18
|
+
from mtppy.part3.data_assembly_set.base_functions.operation_mode import OperationMode
|
|
19
|
+
from mtppy.part3.data_assembly_set.base_functions.source_mode import SourceMode
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class BinDrv(ActiveElement):
|
|
23
|
+
"""Binary Drive (BinDrv).
|
|
24
|
+
|
|
25
|
+
Implements a binary drive element according to MTP 2.0 specification.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
SAFE_POS = "SafePos"
|
|
29
|
+
SAFE_POS_ACT = "SafePosAct"
|
|
30
|
+
FWD_EN = "FwdEn"
|
|
31
|
+
REV_EN = "RevEn"
|
|
32
|
+
STOP_OP = "StopOp"
|
|
33
|
+
FWD_OP = "FwdOp"
|
|
34
|
+
REV_OP = "RevOp"
|
|
35
|
+
STOP_AUT = "StopAut"
|
|
36
|
+
FWD_AUT = "FwdAut"
|
|
37
|
+
REV_AUT = "RevAut"
|
|
38
|
+
FWD_CTRL = "FwdCtrl"
|
|
39
|
+
REV_CTRL = "RevCtrl"
|
|
40
|
+
REV_FBK_CALC = "RevFbkCalc"
|
|
41
|
+
REV_FBK = "RevFbk"
|
|
42
|
+
FWD_FBK_CALC = "FwdFbkCalc"
|
|
43
|
+
FWD_FBK = "FwdFbk"
|
|
44
|
+
TRIP_ = "Trip"
|
|
45
|
+
PERM_EN = "PermEn"
|
|
46
|
+
PERMIT_ = "Permit"
|
|
47
|
+
INTL_EN = "IntlEn"
|
|
48
|
+
INTERLOCK_ = "Interlock"
|
|
49
|
+
PROT_EN = "ProtEn"
|
|
50
|
+
PROTECT_ = "Protect"
|
|
51
|
+
RESET_OP = "ResetOp"
|
|
52
|
+
RESET_AUT = "ResetAut"
|
|
53
|
+
|
|
54
|
+
# Class-level data items dictionary
|
|
55
|
+
CLASS_DATA_ITEMS: ClassVar = {
|
|
56
|
+
SAFE_POS: DataItem(SAFE_POS, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, 0),
|
|
57
|
+
SAFE_POS_ACT: DataItem(
|
|
58
|
+
SAFE_POS_ACT, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, False
|
|
59
|
+
),
|
|
60
|
+
FWD_EN: DataItem(FWD_EN, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, True),
|
|
61
|
+
REV_EN: DataItem(REV_EN, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, False),
|
|
62
|
+
STOP_OP: DataItem(
|
|
63
|
+
STOP_OP, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadWriteAccess, 0
|
|
64
|
+
),
|
|
65
|
+
FWD_OP: DataItem(FWD_OP, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadWriteAccess, 0),
|
|
66
|
+
REV_OP: DataItem(REV_OP, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadWriteAccess, 0),
|
|
67
|
+
STOP_AUT: DataItem(STOP_AUT, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, 0),
|
|
68
|
+
FWD_AUT: DataItem(FWD_AUT, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, 0),
|
|
69
|
+
REV_AUT: DataItem(REV_AUT, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, 0),
|
|
70
|
+
FWD_CTRL: DataItem(FWD_CTRL, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, 0),
|
|
71
|
+
REV_CTRL: DataItem(REV_CTRL, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, 0),
|
|
72
|
+
REV_FBK_CALC: DataItem(
|
|
73
|
+
REV_FBK_CALC, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, True
|
|
74
|
+
),
|
|
75
|
+
REV_FBK: DataItem(
|
|
76
|
+
REV_FBK, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, False
|
|
77
|
+
),
|
|
78
|
+
FWD_FBK_CALC: DataItem(
|
|
79
|
+
FWD_FBK_CALC, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, True
|
|
80
|
+
),
|
|
81
|
+
FWD_FBK: DataItem(
|
|
82
|
+
FWD_FBK, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, False
|
|
83
|
+
),
|
|
84
|
+
TRIP_: DataItem(TRIP_, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, True),
|
|
85
|
+
PERM_EN: DataItem(
|
|
86
|
+
PERM_EN, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, False
|
|
87
|
+
),
|
|
88
|
+
PERMIT_: DataItem(PERMIT_, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, 0),
|
|
89
|
+
INTL_EN: DataItem(
|
|
90
|
+
INTL_EN, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, False
|
|
91
|
+
),
|
|
92
|
+
INTERLOCK_: DataItem(
|
|
93
|
+
INTERLOCK_, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, 0
|
|
94
|
+
),
|
|
95
|
+
PROT_EN: DataItem(
|
|
96
|
+
PROT_EN, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, False
|
|
97
|
+
),
|
|
98
|
+
PROTECT_: DataItem(PROTECT_, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, 0),
|
|
99
|
+
RESET_OP: DataItem(
|
|
100
|
+
RESET_OP, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadWriteAccess, 0
|
|
101
|
+
),
|
|
102
|
+
RESET_AUT: DataItem(
|
|
103
|
+
RESET_AUT, W3cXmlDataTypes.BOOLEAN, MTPAccess.ReadAccess, 0
|
|
104
|
+
),
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
op_mode: OperationMode
|
|
108
|
+
src_mode: SourceMode
|
|
109
|
+
|
|
110
|
+
rev_fbk_calc: bool
|
|
111
|
+
fwd_fbk_calc: bool
|
|
112
|
+
|
|
113
|
+
safe_pos: int
|
|
114
|
+
fwd_en: bool
|
|
115
|
+
rev_en: bool
|
|
116
|
+
perm_en: bool
|
|
117
|
+
intl_en: bool
|
|
118
|
+
prot_en: bool
|
|
119
|
+
|
|
120
|
+
def __init__(
|
|
121
|
+
self,
|
|
122
|
+
tag_name: str,
|
|
123
|
+
tag_description: str = "",
|
|
124
|
+
rev_fbk_calc: bool = True,
|
|
125
|
+
fwd_fbk_calc: bool = True,
|
|
126
|
+
safe_pos: int = 0,
|
|
127
|
+
fwd_en: bool = True,
|
|
128
|
+
rev_en: bool = False,
|
|
129
|
+
perm_en: bool = False,
|
|
130
|
+
intl_en: bool = False,
|
|
131
|
+
prot_en: bool = False,
|
|
132
|
+
) -> None:
|
|
133
|
+
"""Initialize the BinDrv element.
|
|
134
|
+
|
|
135
|
+
Args:
|
|
136
|
+
tag_name: Name of the tag.
|
|
137
|
+
tag_description: Description of the tag.
|
|
138
|
+
rev_fbk_calc: Reverse feedback calculation flag.
|
|
139
|
+
fwd_fbk_calc: Forward feedback calculation flag.
|
|
140
|
+
safe_pos: Safe position value.
|
|
141
|
+
fwd_en: Forward enable flag.
|
|
142
|
+
rev_en: Reverse enable flag.
|
|
143
|
+
perm_en: Permission enable flag.
|
|
144
|
+
intl_en: Interlock enable flag.
|
|
145
|
+
prot_en: Protection enable flag.
|
|
146
|
+
"""
|
|
147
|
+
super().__init__(tag_name, tag_description)
|
|
148
|
+
self.mtpObjectType = "MTPDataObjectSUCLib/DataAssembly/ActiveElement/BinDrv"
|
|
149
|
+
|
|
150
|
+
self.op_mode = OperationMode()
|
|
151
|
+
self.src_mode = SourceMode()
|
|
152
|
+
|
|
153
|
+
self.rev_fbk_calc = rev_fbk_calc
|
|
154
|
+
self.fwd_fbk_calc = fwd_fbk_calc
|
|
155
|
+
|
|
156
|
+
self.safe_pos = safe_pos
|
|
157
|
+
self.fwd_en = fwd_en
|
|
158
|
+
self.rev_en = rev_en
|
|
159
|
+
self.perm_en = perm_en
|
|
160
|
+
self.intl_en = intl_en
|
|
161
|
+
self.prot_en = prot_en
|
|
162
|
+
|
|
163
|
+
# Set initial values for data items
|
|
164
|
+
self[BinDrv.SAFE_POS] = safe_pos
|
|
165
|
+
self[BinDrv.SAFE_POS_ACT] = True
|
|
166
|
+
self[BinDrv.FWD_EN] = fwd_en
|
|
167
|
+
self[BinDrv.REV_EN] = rev_en
|
|
168
|
+
self[BinDrv.STOP_AUT] = 0
|
|
169
|
+
self[BinDrv.FWD_AUT] = 0
|
|
170
|
+
self[BinDrv.REV_AUT] = 0
|
|
171
|
+
self[BinDrv.FWD_CTRL] = 0
|
|
172
|
+
self[BinDrv.REV_CTRL] = 0
|
|
173
|
+
self[BinDrv.REV_FBK_CALC] = rev_fbk_calc
|
|
174
|
+
self[BinDrv.REV_FBK] = False
|
|
175
|
+
self[BinDrv.FWD_FBK_CALC] = fwd_fbk_calc
|
|
176
|
+
self[BinDrv.FWD_FBK] = False
|
|
177
|
+
self[BinDrv.TRIP_] = True
|
|
178
|
+
self[BinDrv.PERM_EN] = perm_en
|
|
179
|
+
self[BinDrv.PERMIT_] = 0
|
|
180
|
+
self[BinDrv.INTL_EN] = intl_en
|
|
181
|
+
self[BinDrv.INTERLOCK_] = 0
|
|
182
|
+
self[BinDrv.PROT_EN] = prot_en
|
|
183
|
+
self[BinDrv.PROTECT_] = 0
|
|
184
|
+
self[BinDrv.RESET_OP] = 0
|
|
185
|
+
self[BinDrv.RESET_AUT] = 0
|
|
186
|
+
|
|
187
|
+
# Setup callbacks after initialization
|
|
188
|
+
self.get_item(BinDrv.STOP_OP).ext_wrt_cb = self.set_stop_op
|
|
189
|
+
self.get_item(BinDrv.FWD_OP).ext_wrt_cb = self.set_fwd_op
|
|
190
|
+
self.get_item(BinDrv.REV_OP).ext_wrt_cb = self.set_rev_op
|
|
191
|
+
self.get_item(BinDrv.RESET_OP).ext_wrt_cb = self.set_reset_op
|
|
192
|
+
|
|
193
|
+
def _expect_save_pos(self) -> None:
|
|
194
|
+
"""Check if safe position is expected and update accordingly."""
|
|
195
|
+
if self._run_allowed():
|
|
196
|
+
self[BinDrv.SAFE_POS_ACT] = False
|
|
197
|
+
else:
|
|
198
|
+
self._go_safe_pos()
|
|
199
|
+
self[BinDrv.SAFE_POS_ACT] = True
|
|
200
|
+
|
|
201
|
+
def _go_safe_pos(self) -> None:
|
|
202
|
+
"""Move to safe position."""
|
|
203
|
+
if self[BinDrv.SAFE_POS]:
|
|
204
|
+
self._run_fwd_drv()
|
|
205
|
+
else:
|
|
206
|
+
self._stop_drv()
|
|
207
|
+
|
|
208
|
+
def _run_allowed(self) -> bool:
|
|
209
|
+
"""Check if driving is allowed."""
|
|
210
|
+
if self[BinDrv.PERM_EN] and self[BinDrv.PERMIT_] == 0:
|
|
211
|
+
logger.debug("Permission is not given")
|
|
212
|
+
return False
|
|
213
|
+
if self[BinDrv.INTL_EN] and self[BinDrv.INTERLOCK_] == 0:
|
|
214
|
+
logger.debug("Interlock is active")
|
|
215
|
+
return False
|
|
216
|
+
if self[BinDrv.PROT_EN] and self[BinDrv.PROTECT_] == 0:
|
|
217
|
+
logger.debug("Protect is active")
|
|
218
|
+
return False
|
|
219
|
+
if not self[BinDrv.TRIP_]:
|
|
220
|
+
logger.debug("Drive protection triggered")
|
|
221
|
+
return False
|
|
222
|
+
return True
|
|
223
|
+
|
|
224
|
+
def set_fwd_op(self, value: bool) -> None:
|
|
225
|
+
"""Set forward operation command."""
|
|
226
|
+
logger.debug(f"FwdOp set to {value}")
|
|
227
|
+
if self.op_mode[OperationMode.STATE_OP_ACT] and self.fwd_en:
|
|
228
|
+
if value and self._run_allowed():
|
|
229
|
+
self._run_fwd_drv()
|
|
230
|
+
self[BinDrv.FWD_OP] = False
|
|
231
|
+
|
|
232
|
+
def set_rev_op(self, value: bool) -> None:
|
|
233
|
+
"""Set reverse operation command."""
|
|
234
|
+
logger.debug(f"RevOp set to {value}")
|
|
235
|
+
if self.op_mode[OperationMode.STATE_OP_ACT] and self.rev_en:
|
|
236
|
+
if value and self._run_allowed():
|
|
237
|
+
self._run_rev_drv()
|
|
238
|
+
self[BinDrv.REV_OP] = False
|
|
239
|
+
|
|
240
|
+
def set_stop_op(self, value: bool) -> None:
|
|
241
|
+
"""Set stop operation command."""
|
|
242
|
+
logger.debug(f"StopOp set to {value}")
|
|
243
|
+
if self.op_mode[OperationMode.STATE_OP_ACT] and value:
|
|
244
|
+
self._stop_drv()
|
|
245
|
+
self[BinDrv.STOP_OP] = False
|
|
246
|
+
|
|
247
|
+
def set_reset_op(self, value: bool) -> None:
|
|
248
|
+
"""Set reset operation command."""
|
|
249
|
+
logger.debug(f"ResetOp set to {value}")
|
|
250
|
+
if self.op_mode[OperationMode.STATE_OP_ACT] and value:
|
|
251
|
+
self._reset_drv()
|
|
252
|
+
self[BinDrv.RESET_OP] = False
|
|
253
|
+
|
|
254
|
+
def set_fwd_aut(self, value: bool) -> None:
|
|
255
|
+
"""Set forward automatic command."""
|
|
256
|
+
logger.debug(f"FwdAut set to {value}")
|
|
257
|
+
if self.op_mode[OperationMode.STATE_AUT_ACT] and self.fwd_en:
|
|
258
|
+
if value and self._run_allowed():
|
|
259
|
+
self._run_fwd_drv()
|
|
260
|
+
|
|
261
|
+
def set_rev_aut(self, value: bool) -> None:
|
|
262
|
+
"""Set reverse automatic command."""
|
|
263
|
+
logger.debug(f"RevAut set to {value}")
|
|
264
|
+
if self.op_mode[OperationMode.STATE_AUT_ACT] and self.rev_en:
|
|
265
|
+
if value and self._run_allowed():
|
|
266
|
+
self._run_rev_drv()
|
|
267
|
+
|
|
268
|
+
def set_stop_aut(self, value: bool) -> None:
|
|
269
|
+
"""Set stop automatic command."""
|
|
270
|
+
logger.debug(f"StopAut set to {value}")
|
|
271
|
+
if self.op_mode[OperationMode.STATE_AUT_ACT] and value:
|
|
272
|
+
self._stop_drv()
|
|
273
|
+
|
|
274
|
+
def set_reset_aut(self, value: bool) -> None:
|
|
275
|
+
"""Set reset automatic command."""
|
|
276
|
+
logger.debug(f"ResetAut set to {value}")
|
|
277
|
+
if self.op_mode[OperationMode.STATE_AUT_ACT] and value:
|
|
278
|
+
self._reset_drv()
|
|
279
|
+
|
|
280
|
+
def _run_fwd_drv(self) -> None:
|
|
281
|
+
"""Run the driver forward."""
|
|
282
|
+
self[BinDrv.FWD_CTRL] = True
|
|
283
|
+
if self[BinDrv.FWD_FBK_CALC]:
|
|
284
|
+
self[BinDrv.FWD_FBK] = True
|
|
285
|
+
self[BinDrv.REV_CTRL] = False
|
|
286
|
+
if self[BinDrv.REV_FBK_CALC]:
|
|
287
|
+
self[BinDrv.REV_FBK] = False
|
|
288
|
+
|
|
289
|
+
def _run_rev_drv(self) -> None:
|
|
290
|
+
"""Run the driver in reverse."""
|
|
291
|
+
self[BinDrv.FWD_CTRL] = False
|
|
292
|
+
if self[BinDrv.FWD_FBK_CALC]:
|
|
293
|
+
self[BinDrv.FWD_FBK] = False
|
|
294
|
+
self[BinDrv.REV_CTRL] = True
|
|
295
|
+
if self[BinDrv.REV_FBK_CALC]:
|
|
296
|
+
self[BinDrv.REV_FBK] = True
|
|
297
|
+
|
|
298
|
+
def _stop_drv(self) -> None:
|
|
299
|
+
"""Stop the driver."""
|
|
300
|
+
self[BinDrv.FWD_CTRL] = False
|
|
301
|
+
if self[BinDrv.FWD_FBK_CALC]:
|
|
302
|
+
self[BinDrv.FWD_FBK] = False
|
|
303
|
+
self[BinDrv.REV_CTRL] = False
|
|
304
|
+
if self[BinDrv.REV_FBK_CALC]:
|
|
305
|
+
self[BinDrv.REV_FBK] = False
|
|
306
|
+
|
|
307
|
+
def _reset_drv(self) -> None:
|
|
308
|
+
"""Reset the driver."""
|
|
309
|
+
if self[BinDrv.PROT_EN] and self[BinDrv.PROTECT_] == 0:
|
|
310
|
+
self[BinDrv.PROTECT_] = True
|
|
311
|
+
self[BinDrv.SAFE_POS_ACT] = False
|
|
312
|
+
self._stop_drv()
|
|
313
|
+
|
|
314
|
+
def set_rev_fbk(self, value: bool) -> None:
|
|
315
|
+
"""Set reverse feedback."""
|
|
316
|
+
if not self[BinDrv.REV_FBK_CALC]:
|
|
317
|
+
self[BinDrv.REV_FBK] = value
|
|
318
|
+
logger.debug(f"RevFbk set to {value}")
|
|
319
|
+
|
|
320
|
+
def set_fwd_fbk(self, value: bool) -> None:
|
|
321
|
+
"""Set forward feedback."""
|
|
322
|
+
if not self[BinDrv.FWD_FBK_CALC]:
|
|
323
|
+
self[BinDrv.FWD_FBK] = value
|
|
324
|
+
logger.debug(f"FwdFbk set to {value}")
|
|
325
|
+
|
|
326
|
+
def set_trip(self, value: bool) -> None:
|
|
327
|
+
"""Set trip status."""
|
|
328
|
+
self[BinDrv.TRIP_] = value
|
|
329
|
+
logger.debug(f"Trip set to {value}")
|
|
330
|
+
self._expect_save_pos()
|
|
331
|
+
|
|
332
|
+
def set_permit(self, value: bool) -> None:
|
|
333
|
+
"""Set permit status."""
|
|
334
|
+
if not self[BinDrv.PERM_EN]:
|
|
335
|
+
value = True
|
|
336
|
+
self[BinDrv.PERMIT_] = value
|
|
337
|
+
logger.debug(f"Permit set to {value}")
|
|
338
|
+
self._expect_save_pos()
|
|
339
|
+
# self[self.SAFE_POS_ACT] = False
|
|
340
|
+
|
|
341
|
+
def set_interlock(self, value: bool) -> None:
|
|
342
|
+
"""Set interlock status."""
|
|
343
|
+
if not self[BinDrv.INTL_EN]:
|
|
344
|
+
value = True
|
|
345
|
+
self[BinDrv.INTERLOCK_] = value
|
|
346
|
+
logger.debug(f"Interlock set to {value}")
|
|
347
|
+
self._expect_save_pos()
|
|
348
|
+
|
|
349
|
+
def set_protect(self, value: bool) -> None:
|
|
350
|
+
"""Set protection status."""
|
|
351
|
+
if not self[BinDrv.PROT_EN]:
|
|
352
|
+
value = True
|
|
353
|
+
if value:
|
|
354
|
+
self._reset_drv()
|
|
355
|
+
self[BinDrv.PROTECT_] = value
|
|
356
|
+
logger.debug(f"Protect set to {value}")
|
|
357
|
+
self._expect_save_pos()
|
|
358
|
+
|
|
359
|
+
def get_fwd_fbk(self) -> bool:
|
|
360
|
+
"""Get forward feedback status."""
|
|
361
|
+
return self[BinDrv.FWD_FBK]
|
|
362
|
+
|
|
363
|
+
def get_rev_fbk(self) -> bool:
|
|
364
|
+
"""Get reverse feedback status."""
|
|
365
|
+
return self[BinDrv.REV_FBK]
|