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,503 @@
|
|
|
1
|
+
"""Test Suite for BinDrv."""
|
|
2
|
+
|
|
3
|
+
__copyright__ = (
|
|
4
|
+
"Copyright (c) 2026 Dresden University of Technology, Process-to-Order Group"
|
|
5
|
+
)
|
|
6
|
+
__license__ = "MIT"
|
|
7
|
+
import pytest
|
|
8
|
+
|
|
9
|
+
from mtppy.utils.testing import data_object_set_modes
|
|
10
|
+
from mtppy.part3.data_assembly_set.active_elements.drives.bin_drv import BinDrv
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def init_bin_drv(
|
|
14
|
+
init_op_mode="off",
|
|
15
|
+
init_src_mode="int",
|
|
16
|
+
rev_fbk_calc=True,
|
|
17
|
+
fwd_fbk_calc=True,
|
|
18
|
+
safe_pos=0,
|
|
19
|
+
fwd_en=True,
|
|
20
|
+
rev_en=False,
|
|
21
|
+
perm_en=False,
|
|
22
|
+
intl_en=False,
|
|
23
|
+
prot_en=False,
|
|
24
|
+
):
|
|
25
|
+
instance = BinDrv(
|
|
26
|
+
"tag",
|
|
27
|
+
tag_description="",
|
|
28
|
+
rev_fbk_calc=rev_fbk_calc,
|
|
29
|
+
fwd_fbk_calc=fwd_fbk_calc,
|
|
30
|
+
safe_pos=safe_pos,
|
|
31
|
+
fwd_en=fwd_en,
|
|
32
|
+
rev_en=rev_en,
|
|
33
|
+
perm_en=perm_en,
|
|
34
|
+
intl_en=intl_en,
|
|
35
|
+
prot_en=prot_en,
|
|
36
|
+
)
|
|
37
|
+
data_object_set_modes(instance, init_op_mode, init_src_mode)
|
|
38
|
+
return instance
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
test_scenario = [
|
|
42
|
+
("off", "int", "set_fwd_op", False),
|
|
43
|
+
("off", "man", "set_fwd_op", False),
|
|
44
|
+
("op", "int", "set_fwd_op", True),
|
|
45
|
+
("op", "man", "set_fwd_op", True),
|
|
46
|
+
("aut", "int", "set_fwd_op", False),
|
|
47
|
+
("aut", "man", "set_fwd_op", False),
|
|
48
|
+
("off", "int", "set_fwd_aut", False),
|
|
49
|
+
("off", "man", "set_fwd_aut", False),
|
|
50
|
+
("op", "int", "set_fwd_aut", False),
|
|
51
|
+
("op", "man", "set_fwd_aut", False),
|
|
52
|
+
("aut", "int", "set_fwd_aut", True),
|
|
53
|
+
("aut", "man", "set_fwd_aut", True),
|
|
54
|
+
("off", "int", "set_rev_op", False),
|
|
55
|
+
("off", "man", "set_rev_op", False),
|
|
56
|
+
("op", "int", "set_rev_op", True),
|
|
57
|
+
("op", "man", "set_rev_op", True),
|
|
58
|
+
("aut", "int", "set_rev_op", False),
|
|
59
|
+
("aut", "man", "set_rev_op", False),
|
|
60
|
+
("off", "int", "set_rev_aut", False),
|
|
61
|
+
("off", "man", "set_rev_aut", False),
|
|
62
|
+
("op", "int", "set_rev_aut", False),
|
|
63
|
+
("op", "man", "set_rev_aut", False),
|
|
64
|
+
("aut", "int", "set_rev_aut", True),
|
|
65
|
+
("aut", "man", "set_rev_aut", True),
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def test_fwd_rev():
|
|
70
|
+
for op_mode, src_mode, set_command, expected_result in test_scenario:
|
|
71
|
+
for command in [True, False]:
|
|
72
|
+
bin_drv = init_bin_drv(
|
|
73
|
+
init_op_mode=op_mode, init_src_mode=src_mode, fwd_en=True, rev_en=True
|
|
74
|
+
)
|
|
75
|
+
eval(f"bin_drv.{set_command}({command})")
|
|
76
|
+
print(
|
|
77
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected: {expected_result}"
|
|
78
|
+
)
|
|
79
|
+
if set_command in ["set_fwd_op", "set_fwd_aut"]:
|
|
80
|
+
if command:
|
|
81
|
+
assert bin_drv["FwdCtrl"] == expected_result
|
|
82
|
+
assert bin_drv.get_fwd_fbk() == expected_result
|
|
83
|
+
assert bin_drv["RevCtrl"] == False
|
|
84
|
+
assert bin_drv.get_rev_fbk() == False
|
|
85
|
+
else:
|
|
86
|
+
assert bin_drv["FwdCtrl"] == False
|
|
87
|
+
assert bin_drv.get_fwd_fbk() == False
|
|
88
|
+
assert bin_drv["RevCtrl"] == False
|
|
89
|
+
assert bin_drv.get_rev_fbk() == False
|
|
90
|
+
elif set_command in ["set_rev_op", "set_rev_aut"]:
|
|
91
|
+
if command:
|
|
92
|
+
assert bin_drv["FwdCtrl"] == False
|
|
93
|
+
assert bin_drv.get_fwd_fbk() == False
|
|
94
|
+
assert bin_drv["RevCtrl"] == expected_result
|
|
95
|
+
assert bin_drv.get_rev_fbk() == expected_result
|
|
96
|
+
else:
|
|
97
|
+
assert bin_drv["FwdCtrl"] == False
|
|
98
|
+
assert bin_drv.get_fwd_fbk() == False
|
|
99
|
+
assert bin_drv["RevCtrl"] == False
|
|
100
|
+
assert bin_drv.get_rev_fbk() == False
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def test_fwd_rev_en():
|
|
104
|
+
for op_mode, src_mode, set_command, _ in test_scenario:
|
|
105
|
+
for command in [True, False]:
|
|
106
|
+
bin_drv = init_bin_drv(
|
|
107
|
+
init_op_mode=op_mode, init_src_mode=src_mode, fwd_en=False, rev_en=False
|
|
108
|
+
)
|
|
109
|
+
eval(f"bin_drv.{set_command}({command})")
|
|
110
|
+
print(
|
|
111
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected: False"
|
|
112
|
+
)
|
|
113
|
+
assert bin_drv["FwdCtrl"] == False
|
|
114
|
+
assert bin_drv["RevCtrl"] == False
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def test_fwd_rev_trip():
|
|
118
|
+
for op_mode, src_mode, set_command, _ in test_scenario:
|
|
119
|
+
for command in [True, False]:
|
|
120
|
+
bin_drv = init_bin_drv(
|
|
121
|
+
init_op_mode=op_mode, init_src_mode=src_mode, fwd_en=True, rev_en=True
|
|
122
|
+
)
|
|
123
|
+
bin_drv.set_trip(False)
|
|
124
|
+
eval(f"bin_drv.{set_command}({command})")
|
|
125
|
+
print(
|
|
126
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected: False"
|
|
127
|
+
)
|
|
128
|
+
assert bin_drv["SafePosAct"] == True
|
|
129
|
+
assert bin_drv["Trip"] == False
|
|
130
|
+
assert bin_drv["FwdCtrl"] == False
|
|
131
|
+
assert bin_drv["RevCtrl"] == False
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
@pytest.mark.parametrize(
|
|
135
|
+
"op_mode, src_mode, set_command, expected_result", test_scenario
|
|
136
|
+
)
|
|
137
|
+
def test_fwd_rev_permit_en_true(op_mode, src_mode, set_command, expected_result):
|
|
138
|
+
for command in [True, False]:
|
|
139
|
+
bin_drv = init_bin_drv(
|
|
140
|
+
init_op_mode=op_mode,
|
|
141
|
+
init_src_mode=src_mode,
|
|
142
|
+
fwd_en=True,
|
|
143
|
+
rev_en=True,
|
|
144
|
+
perm_en=True,
|
|
145
|
+
)
|
|
146
|
+
bin_drv.set_permit(False)
|
|
147
|
+
eval(f"bin_drv.{set_command}({command})")
|
|
148
|
+
print(f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected: False")
|
|
149
|
+
assert bin_drv["SafePosAct"] == True
|
|
150
|
+
assert bin_drv["Permit"] == False
|
|
151
|
+
assert bin_drv["FwdCtrl"] == False
|
|
152
|
+
assert bin_drv["RevCtrl"] == False
|
|
153
|
+
assert bin_drv.get_fwd_fbk() == False
|
|
154
|
+
assert bin_drv.get_rev_fbk() == False
|
|
155
|
+
|
|
156
|
+
for command_2 in [True, False]:
|
|
157
|
+
bin_drv = init_bin_drv(
|
|
158
|
+
init_op_mode=op_mode,
|
|
159
|
+
init_src_mode=src_mode,
|
|
160
|
+
fwd_en=True,
|
|
161
|
+
rev_en=True,
|
|
162
|
+
perm_en=True,
|
|
163
|
+
)
|
|
164
|
+
bin_drv.set_permit(True)
|
|
165
|
+
eval(f"bin_drv.{set_command}({command_2})")
|
|
166
|
+
print(
|
|
167
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected: {expected_result}"
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
assert bin_drv["Permit"] == True
|
|
171
|
+
assert bin_drv["SafePosAct"] == False
|
|
172
|
+
if set_command in ["set_fwd_op", "set_fwd_aut"]:
|
|
173
|
+
if command_2:
|
|
174
|
+
assert bin_drv["FwdCtrl"] == expected_result
|
|
175
|
+
assert bin_drv.get_fwd_fbk() == expected_result
|
|
176
|
+
assert bin_drv["RevCtrl"] == False
|
|
177
|
+
assert bin_drv.get_rev_fbk() == False
|
|
178
|
+
else:
|
|
179
|
+
assert bin_drv["FwdCtrl"] == False
|
|
180
|
+
assert bin_drv.get_fwd_fbk() == False
|
|
181
|
+
assert bin_drv["RevCtrl"] == False
|
|
182
|
+
assert bin_drv.get_rev_fbk() == False
|
|
183
|
+
elif set_command in ["set_rev_op", "set_rev_aut"]:
|
|
184
|
+
if command_2:
|
|
185
|
+
assert bin_drv["FwdCtrl"] == False
|
|
186
|
+
assert bin_drv.get_fwd_fbk() == False
|
|
187
|
+
assert bin_drv["RevCtrl"] == expected_result
|
|
188
|
+
assert bin_drv.get_rev_fbk() == expected_result
|
|
189
|
+
else:
|
|
190
|
+
assert bin_drv["FwdCtrl"] == False
|
|
191
|
+
assert bin_drv.get_fwd_fbk() == False
|
|
192
|
+
assert bin_drv["RevCtrl"] == False
|
|
193
|
+
assert bin_drv.get_rev_fbk() == False
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def test_fwd_rev_permit_en_false():
|
|
197
|
+
for op_mode, src_mode, set_command, expected_result in test_scenario:
|
|
198
|
+
for command in [True, False]:
|
|
199
|
+
ana_drv = init_bin_drv(
|
|
200
|
+
init_op_mode=op_mode,
|
|
201
|
+
init_src_mode=src_mode,
|
|
202
|
+
fwd_en=True,
|
|
203
|
+
rev_en=True,
|
|
204
|
+
perm_en=False,
|
|
205
|
+
)
|
|
206
|
+
ana_drv.set_permit(True)
|
|
207
|
+
eval(f"ana_drv.{set_command}({command})")
|
|
208
|
+
print(
|
|
209
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected: {expected_result}"
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
assert ana_drv["Permit"] == True
|
|
213
|
+
assert ana_drv["SafePosAct"] == False
|
|
214
|
+
if set_command in ["set_fwd_op", "set_fwd_aut"]:
|
|
215
|
+
if command:
|
|
216
|
+
assert ana_drv["FwdCtrl"] == expected_result
|
|
217
|
+
assert ana_drv["RevCtrl"] == False
|
|
218
|
+
else:
|
|
219
|
+
assert ana_drv["FwdCtrl"] == False
|
|
220
|
+
assert ana_drv["RevCtrl"] == False
|
|
221
|
+
elif set_command in ["set_rev_op", "set_rev_aut"]:
|
|
222
|
+
if command:
|
|
223
|
+
assert ana_drv["FwdCtrl"] == False
|
|
224
|
+
assert ana_drv["RevCtrl"] == expected_result
|
|
225
|
+
else:
|
|
226
|
+
assert ana_drv["FwdCtrl"] == False
|
|
227
|
+
assert ana_drv["RevCtrl"] == False
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def test_fwd_rev_interlock_en_true():
|
|
231
|
+
for op_mode, src_mode, set_command, _ in test_scenario:
|
|
232
|
+
for command in [True, False]:
|
|
233
|
+
bin_drv = init_bin_drv(
|
|
234
|
+
init_op_mode=op_mode,
|
|
235
|
+
init_src_mode=src_mode,
|
|
236
|
+
fwd_en=True,
|
|
237
|
+
rev_en=True,
|
|
238
|
+
intl_en=True,
|
|
239
|
+
)
|
|
240
|
+
bin_drv.set_interlock(False)
|
|
241
|
+
eval(f"bin_drv.{set_command}({command})")
|
|
242
|
+
print(
|
|
243
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected: False"
|
|
244
|
+
)
|
|
245
|
+
|
|
246
|
+
assert bin_drv["Interlock"] == False
|
|
247
|
+
assert bin_drv["SafePosAct"] == True
|
|
248
|
+
assert bin_drv["FwdCtrl"] == False
|
|
249
|
+
assert bin_drv["RevCtrl"] == False
|
|
250
|
+
|
|
251
|
+
for op_mode, src_mode, set_command, expected_result in test_scenario:
|
|
252
|
+
for command in [True, False]:
|
|
253
|
+
bin_drv = init_bin_drv(
|
|
254
|
+
init_op_mode=op_mode,
|
|
255
|
+
init_src_mode=src_mode,
|
|
256
|
+
fwd_en=True,
|
|
257
|
+
rev_en=True,
|
|
258
|
+
intl_en=True,
|
|
259
|
+
)
|
|
260
|
+
bin_drv.set_interlock(True)
|
|
261
|
+
eval(f"bin_drv.{set_command}({command})")
|
|
262
|
+
print(
|
|
263
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected: {expected_result}"
|
|
264
|
+
)
|
|
265
|
+
|
|
266
|
+
assert bin_drv["Interlock"] == True
|
|
267
|
+
assert bin_drv["SafePosAct"] == False
|
|
268
|
+
if set_command in ["set_fwd_op", "set_fwd_aut"]:
|
|
269
|
+
if command:
|
|
270
|
+
assert bin_drv["FwdCtrl"] == expected_result
|
|
271
|
+
assert bin_drv["RevCtrl"] == False
|
|
272
|
+
else:
|
|
273
|
+
assert bin_drv["FwdCtrl"] == False
|
|
274
|
+
assert bin_drv["RevCtrl"] == False
|
|
275
|
+
elif set_command in ["set_rev_op", "set_rev_aut"]:
|
|
276
|
+
if command:
|
|
277
|
+
assert bin_drv["FwdCtrl"] == False
|
|
278
|
+
assert bin_drv["RevCtrl"] == expected_result
|
|
279
|
+
else:
|
|
280
|
+
assert bin_drv["FwdCtrl"] == False
|
|
281
|
+
assert bin_drv["RevCtrl"] == False
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
def test_fwd_rev_interlock_en_false():
|
|
285
|
+
for op_mode, src_mode, set_command, expected_result in test_scenario:
|
|
286
|
+
for command in [True, False]:
|
|
287
|
+
bin_drv = init_bin_drv(
|
|
288
|
+
init_op_mode=op_mode,
|
|
289
|
+
init_src_mode=src_mode,
|
|
290
|
+
fwd_en=True,
|
|
291
|
+
rev_en=True,
|
|
292
|
+
intl_en=False,
|
|
293
|
+
)
|
|
294
|
+
bin_drv.set_interlock(True)
|
|
295
|
+
eval(f"bin_drv.{set_command}({command})")
|
|
296
|
+
print(
|
|
297
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected: {expected_result}"
|
|
298
|
+
)
|
|
299
|
+
|
|
300
|
+
assert bin_drv["Interlock"] == True
|
|
301
|
+
assert bin_drv["SafePosAct"] == False
|
|
302
|
+
if set_command in ["set_fwd_op", "set_fwd_aut"]:
|
|
303
|
+
if command:
|
|
304
|
+
assert bin_drv["FwdCtrl"] == expected_result
|
|
305
|
+
assert bin_drv["RevCtrl"] == False
|
|
306
|
+
else:
|
|
307
|
+
assert bin_drv["FwdCtrl"] == False
|
|
308
|
+
assert bin_drv["RevCtrl"] == False
|
|
309
|
+
elif set_command in ["set_rev_op", "set_rev_aut"]:
|
|
310
|
+
if command:
|
|
311
|
+
assert bin_drv["FwdCtrl"] == False
|
|
312
|
+
assert bin_drv["RevCtrl"] == expected_result
|
|
313
|
+
else:
|
|
314
|
+
assert bin_drv["FwdCtrl"] == False
|
|
315
|
+
assert bin_drv["RevCtrl"] == False
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
def test_fwd_rev_protect_en_true():
|
|
319
|
+
for op_mode, src_mode, set_command, _ in test_scenario:
|
|
320
|
+
for command in [True, False]:
|
|
321
|
+
bin_drv = init_bin_drv(
|
|
322
|
+
init_op_mode=op_mode,
|
|
323
|
+
init_src_mode=src_mode,
|
|
324
|
+
fwd_en=True,
|
|
325
|
+
rev_en=True,
|
|
326
|
+
prot_en=True,
|
|
327
|
+
)
|
|
328
|
+
bin_drv.set_protect(False)
|
|
329
|
+
eval(f"bin_drv.{set_command}({command})")
|
|
330
|
+
print(
|
|
331
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected: False"
|
|
332
|
+
)
|
|
333
|
+
|
|
334
|
+
assert bin_drv["Protect"] == False
|
|
335
|
+
assert bin_drv["SafePosAct"] == True
|
|
336
|
+
assert bin_drv["FwdCtrl"] == False
|
|
337
|
+
assert bin_drv["RevCtrl"] == False
|
|
338
|
+
|
|
339
|
+
for op_mode, src_mode, set_command, expected_result in test_scenario:
|
|
340
|
+
for command in [True, False]:
|
|
341
|
+
bin_drv = init_bin_drv(
|
|
342
|
+
init_op_mode=op_mode,
|
|
343
|
+
init_src_mode=src_mode,
|
|
344
|
+
fwd_en=True,
|
|
345
|
+
rev_en=True,
|
|
346
|
+
prot_en=True,
|
|
347
|
+
)
|
|
348
|
+
bin_drv.set_protect(True)
|
|
349
|
+
eval(f"bin_drv.{set_command}({command})")
|
|
350
|
+
print(
|
|
351
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected: {expected_result}"
|
|
352
|
+
)
|
|
353
|
+
|
|
354
|
+
assert bin_drv["Protect"] == True
|
|
355
|
+
assert bin_drv["SafePosAct"] == False
|
|
356
|
+
if set_command in ["set_fwd_op", "set_fwd_aut"]:
|
|
357
|
+
if command:
|
|
358
|
+
assert bin_drv["FwdCtrl"] == expected_result
|
|
359
|
+
assert bin_drv["RevCtrl"] == False
|
|
360
|
+
else:
|
|
361
|
+
assert bin_drv["FwdCtrl"] == False
|
|
362
|
+
assert bin_drv["RevCtrl"] == False
|
|
363
|
+
elif set_command in ["set_rev_op", "set_rev_aut"]:
|
|
364
|
+
if command:
|
|
365
|
+
assert bin_drv["FwdCtrl"] == False
|
|
366
|
+
assert bin_drv["RevCtrl"] == expected_result
|
|
367
|
+
else:
|
|
368
|
+
assert bin_drv["FwdCtrl"] == False
|
|
369
|
+
assert bin_drv["RevCtrl"] == False
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
def test_fwd_rev_protect_en_false():
|
|
373
|
+
for op_mode, src_mode, set_command, expected_result in test_scenario:
|
|
374
|
+
for command in [True, False]:
|
|
375
|
+
bin_drv = init_bin_drv(
|
|
376
|
+
init_op_mode=op_mode,
|
|
377
|
+
init_src_mode=src_mode,
|
|
378
|
+
fwd_en=True,
|
|
379
|
+
rev_en=True,
|
|
380
|
+
prot_en=False,
|
|
381
|
+
)
|
|
382
|
+
bin_drv.set_protect(True)
|
|
383
|
+
eval(f"bin_drv.{set_command}({command})")
|
|
384
|
+
print(
|
|
385
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected: {expected_result}"
|
|
386
|
+
)
|
|
387
|
+
|
|
388
|
+
assert bin_drv["Protect"] == True
|
|
389
|
+
assert bin_drv["SafePosAct"] == False
|
|
390
|
+
if set_command in ["set_fwd_op", "set_fwd_aut"]:
|
|
391
|
+
if command:
|
|
392
|
+
assert bin_drv["FwdCtrl"] == expected_result
|
|
393
|
+
assert bin_drv["RevCtrl"] == False
|
|
394
|
+
else:
|
|
395
|
+
assert bin_drv["FwdCtrl"] == False
|
|
396
|
+
assert bin_drv["RevCtrl"] == False
|
|
397
|
+
elif set_command in ["set_rev_op", "set_rev_aut"]:
|
|
398
|
+
if command:
|
|
399
|
+
assert bin_drv["FwdCtrl"] == False
|
|
400
|
+
assert bin_drv["RevCtrl"] == expected_result
|
|
401
|
+
else:
|
|
402
|
+
assert bin_drv["FwdCtrl"] == False
|
|
403
|
+
assert bin_drv["RevCtrl"] == False
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
test_scenario_reset = [
|
|
407
|
+
("off", "int", "set_reset_op", False),
|
|
408
|
+
("off", "man", "set_reset_op", False),
|
|
409
|
+
("op", "int", "set_reset_op", True),
|
|
410
|
+
("op", "man", "set_reset_op", True),
|
|
411
|
+
("aut", "int", "set_reset_op", False),
|
|
412
|
+
("aut", "man", "set_reset_op", False),
|
|
413
|
+
("off", "int", "set_reset_aut", False),
|
|
414
|
+
("off", "man", "set_reset_aut", False),
|
|
415
|
+
("op", "int", "set_reset_aut", False),
|
|
416
|
+
("op", "man", "set_reset_aut", False),
|
|
417
|
+
("aut", "int", "set_reset_aut", True),
|
|
418
|
+
("aut", "man", "set_reset_aut", True),
|
|
419
|
+
]
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
def test_reset():
|
|
423
|
+
for op_mode, src_mode, set_command, result in test_scenario_reset:
|
|
424
|
+
for command in [True, False]:
|
|
425
|
+
bin_drv = init_bin_drv(
|
|
426
|
+
init_op_mode=op_mode,
|
|
427
|
+
init_src_mode=src_mode,
|
|
428
|
+
fwd_en=True,
|
|
429
|
+
rev_en=True,
|
|
430
|
+
prot_en=True,
|
|
431
|
+
)
|
|
432
|
+
|
|
433
|
+
bin_drv.set_protect(False)
|
|
434
|
+
assert bin_drv["Protect"] == False
|
|
435
|
+
assert bin_drv["SafePosAct"] == True
|
|
436
|
+
|
|
437
|
+
eval(f"bin_drv.{set_command}({command})")
|
|
438
|
+
print(
|
|
439
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected: {result}"
|
|
440
|
+
)
|
|
441
|
+
|
|
442
|
+
if command:
|
|
443
|
+
assert bin_drv["Protect"] == result
|
|
444
|
+
assert bin_drv["SafePosAct"] != result
|
|
445
|
+
else:
|
|
446
|
+
assert bin_drv["Protect"] == False
|
|
447
|
+
assert bin_drv["SafePosAct"] == True
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
test_scenario_stop = [
|
|
451
|
+
("op", "int", "set_stop_op", True),
|
|
452
|
+
("op", "man", "set_stop_op", True),
|
|
453
|
+
("aut", "int", "set_stop_op", False),
|
|
454
|
+
("aut", "man", "set_stop_op", False),
|
|
455
|
+
("op", "int", "set_stop_aut", False),
|
|
456
|
+
("op", "man", "set_stop_aut", False),
|
|
457
|
+
("aut", "int", "set_stop_aut", True),
|
|
458
|
+
("aut", "man", "set_stop_aut", True),
|
|
459
|
+
]
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
def test_stop():
|
|
463
|
+
for op_mode, src_mode, set_command, changes_expected in test_scenario_stop:
|
|
464
|
+
for command in [True, False]:
|
|
465
|
+
bin_drv = init_bin_drv(
|
|
466
|
+
init_op_mode=op_mode, init_src_mode=src_mode, fwd_en=True, rev_en=True
|
|
467
|
+
)
|
|
468
|
+
if op_mode == "op": # open valve
|
|
469
|
+
bin_drv.set_fwd_op(True)
|
|
470
|
+
elif op_mode == "aut":
|
|
471
|
+
bin_drv.set_fwd_aut(True)
|
|
472
|
+
|
|
473
|
+
print(
|
|
474
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected: {changes_expected}"
|
|
475
|
+
)
|
|
476
|
+
if changes_expected:
|
|
477
|
+
assert bin_drv["FwdCtrl"] == True
|
|
478
|
+
eval(f"bin_drv.{set_command}({command})")
|
|
479
|
+
if command:
|
|
480
|
+
assert bin_drv["FwdCtrl"] == False
|
|
481
|
+
else:
|
|
482
|
+
assert bin_drv["FwdCtrl"] == True
|
|
483
|
+
else:
|
|
484
|
+
assert bin_drv["FwdCtrl"] == True
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
def test_fwd_fbk():
|
|
488
|
+
bin_drv = init_bin_drv(fwd_fbk_calc=False, rev_fbk_calc=False)
|
|
489
|
+
assert bin_drv.get_fwd_fbk() == False
|
|
490
|
+
bin_drv.set_fwd_fbk(True)
|
|
491
|
+
assert bin_drv.get_fwd_fbk() == True
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
def test_rev_fbk():
|
|
495
|
+
bin_drv = init_bin_drv(fwd_fbk_calc=False, rev_fbk_calc=False)
|
|
496
|
+
assert bin_drv.get_rev_fbk() == False
|
|
497
|
+
bin_drv.set_rev_fbk(True)
|
|
498
|
+
assert bin_drv.get_rev_fbk() == True
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
if __name__ == "__main__":
|
|
502
|
+
# This allows running the tests directly if needed
|
|
503
|
+
pytest.main([__file__, "-v"])
|