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,585 @@
|
|
|
1
|
+
"""Test Suite for BinVlv."""
|
|
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.valves.bin_vlv import BinVlv
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def init_bin_vlv(
|
|
14
|
+
init_op_mode="off",
|
|
15
|
+
init_src_mode="int",
|
|
16
|
+
open_fbk_calc=True,
|
|
17
|
+
close_fbk_calc=True,
|
|
18
|
+
safe_pos=0,
|
|
19
|
+
safe_pos_en=True,
|
|
20
|
+
perm_en=False,
|
|
21
|
+
intl_en=False,
|
|
22
|
+
prot_en=False,
|
|
23
|
+
):
|
|
24
|
+
bin_vlv = BinVlv(
|
|
25
|
+
"tag",
|
|
26
|
+
tag_description="",
|
|
27
|
+
open_fbk_calc=open_fbk_calc,
|
|
28
|
+
close_fbk_calc=close_fbk_calc,
|
|
29
|
+
safe_pos=safe_pos,
|
|
30
|
+
safe_pos_en=safe_pos_en,
|
|
31
|
+
perm_en=perm_en,
|
|
32
|
+
intl_en=intl_en,
|
|
33
|
+
prot_en=prot_en,
|
|
34
|
+
)
|
|
35
|
+
data_object_set_modes(bin_vlv, init_op_mode, init_src_mode)
|
|
36
|
+
return bin_vlv
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
test_scenario = [
|
|
40
|
+
("off", "int", "set_open_op", False, False),
|
|
41
|
+
("off", "man", "set_open_op", False, False),
|
|
42
|
+
("op", "int", "set_open_op", True, True),
|
|
43
|
+
("op", "man", "set_open_op", True, True),
|
|
44
|
+
("aut", "int", "set_open_op", False, False),
|
|
45
|
+
("aut", "man", "set_open_op", False, False),
|
|
46
|
+
("off", "int", "set_open_aut", False, False),
|
|
47
|
+
("off", "man", "set_open_aut", False, False),
|
|
48
|
+
("op", "int", "set_open_aut", False, False),
|
|
49
|
+
("op", "man", "set_open_aut", False, False),
|
|
50
|
+
("aut", "int", "set_open_aut", True, True),
|
|
51
|
+
("aut", "man", "set_open_aut", True, True),
|
|
52
|
+
("off", "int", "set_close_op", False, False),
|
|
53
|
+
("off", "man", "set_close_op", False, False),
|
|
54
|
+
("op", "int", "set_close_op", False, True),
|
|
55
|
+
("op", "man", "set_close_op", False, True),
|
|
56
|
+
("aut", "int", "set_close_op", False, False),
|
|
57
|
+
("aut", "man", "set_close_op", False, False),
|
|
58
|
+
("off", "int", "set_close_aut", False, False),
|
|
59
|
+
("off", "man", "set_close_aut", False, False),
|
|
60
|
+
("op", "int", "set_close_aut", False, False),
|
|
61
|
+
("op", "man", "set_close_aut", False, False),
|
|
62
|
+
("aut", "int", "set_close_aut", False, True),
|
|
63
|
+
("aut", "man", "set_close_aut", False, True),
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@pytest.mark.parametrize(
|
|
68
|
+
"op_mode, src_mode, set_command, expected_ctrl, expected_fbk", test_scenario
|
|
69
|
+
)
|
|
70
|
+
def test_open_close(op_mode, src_mode, set_command, expected_ctrl, expected_fbk):
|
|
71
|
+
for command in [True, False]:
|
|
72
|
+
bin_vlv = init_bin_vlv(init_op_mode=op_mode, init_src_mode=src_mode)
|
|
73
|
+
eval(f"bin_vlv.{set_command}({command})")
|
|
74
|
+
print(
|
|
75
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected: {expected_ctrl}"
|
|
76
|
+
)
|
|
77
|
+
if set_command in ["set_open_op", "set_open_aut"]:
|
|
78
|
+
if command:
|
|
79
|
+
assert bin_vlv["Ctrl"] == expected_ctrl
|
|
80
|
+
assert bin_vlv.get_open_fbk() == expected_fbk
|
|
81
|
+
assert bin_vlv.get_close_fbk() == False
|
|
82
|
+
else:
|
|
83
|
+
assert bin_vlv["Ctrl"] == False
|
|
84
|
+
assert bin_vlv.get_open_fbk() == False
|
|
85
|
+
assert bin_vlv.get_close_fbk() == False
|
|
86
|
+
elif set_command in ["set_close_op", "set_close_aut"]:
|
|
87
|
+
if command:
|
|
88
|
+
assert bin_vlv.get_open_fbk() == False
|
|
89
|
+
assert bin_vlv["Ctrl"] == expected_ctrl
|
|
90
|
+
assert bin_vlv.get_close_fbk() == expected_fbk
|
|
91
|
+
else:
|
|
92
|
+
assert bin_vlv.get_open_fbk() == False
|
|
93
|
+
assert bin_vlv["Ctrl"] == False
|
|
94
|
+
assert bin_vlv.get_close_fbk() == False
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
@pytest.mark.parametrize(
|
|
98
|
+
"op_mode, src_mode, set_command, expected_ctrl, expected_fbk", test_scenario
|
|
99
|
+
)
|
|
100
|
+
def test_open_close_permit_en_true(
|
|
101
|
+
op_mode, src_mode, set_command, expected_ctrl, expected_fbk
|
|
102
|
+
):
|
|
103
|
+
for command in [True, False]:
|
|
104
|
+
bin_vlv = init_bin_vlv(
|
|
105
|
+
init_op_mode=op_mode, init_src_mode=src_mode, perm_en=True
|
|
106
|
+
)
|
|
107
|
+
bin_vlv.set_permit(False)
|
|
108
|
+
eval(f"bin_vlv.{set_command}({command})")
|
|
109
|
+
print(f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected: False")
|
|
110
|
+
assert bin_vlv["SafePosAct"] == False
|
|
111
|
+
assert bin_vlv["Permit"] == False
|
|
112
|
+
assert bin_vlv["Ctrl"] == False
|
|
113
|
+
assert bin_vlv.get_open_fbk() == False
|
|
114
|
+
assert bin_vlv.get_close_fbk() == False
|
|
115
|
+
|
|
116
|
+
for command in [True, False]:
|
|
117
|
+
bin_vlv = init_bin_vlv(
|
|
118
|
+
init_op_mode=op_mode, init_src_mode=src_mode, perm_en=True
|
|
119
|
+
)
|
|
120
|
+
bin_vlv.set_permit(True)
|
|
121
|
+
eval(f"bin_vlv.{set_command}({command})")
|
|
122
|
+
print(
|
|
123
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected_ctrl: {expected_ctrl}, "
|
|
124
|
+
f"expected_fbk: {expected_fbk}"
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
assert bin_vlv["Permit"] == True
|
|
128
|
+
assert bin_vlv["SafePosAct"] == False
|
|
129
|
+
if set_command in ["set_open_op", "set_open_aut"]:
|
|
130
|
+
if command:
|
|
131
|
+
assert bin_vlv["Ctrl"] == expected_ctrl
|
|
132
|
+
assert bin_vlv.get_open_fbk() == expected_fbk
|
|
133
|
+
assert bin_vlv.get_close_fbk() == False
|
|
134
|
+
else:
|
|
135
|
+
assert bin_vlv["Ctrl"] == False
|
|
136
|
+
assert bin_vlv.get_open_fbk() == False
|
|
137
|
+
assert bin_vlv.get_close_fbk() == False
|
|
138
|
+
elif set_command in ["set_close_op", "set_close_aut"]:
|
|
139
|
+
if command:
|
|
140
|
+
assert bin_vlv["Ctrl"] == expected_ctrl
|
|
141
|
+
assert bin_vlv.get_open_fbk() == False
|
|
142
|
+
assert bin_vlv.get_close_fbk() == expected_fbk
|
|
143
|
+
else:
|
|
144
|
+
assert bin_vlv["Ctrl"] == False
|
|
145
|
+
assert bin_vlv.get_open_fbk() == False
|
|
146
|
+
assert bin_vlv.get_close_fbk() == False
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
@pytest.mark.parametrize(
|
|
150
|
+
"op_mode, src_mode, set_command, expected_ctrl, expected_fbk", test_scenario
|
|
151
|
+
)
|
|
152
|
+
def test_open_close_permit_en_false(
|
|
153
|
+
op_mode, src_mode, set_command, expected_ctrl, expected_fbk
|
|
154
|
+
):
|
|
155
|
+
for command in [True, False]:
|
|
156
|
+
bin_vlv = init_bin_vlv(
|
|
157
|
+
init_op_mode=op_mode, init_src_mode=src_mode, perm_en=False
|
|
158
|
+
)
|
|
159
|
+
bin_vlv.set_permit(True)
|
|
160
|
+
eval(f"bin_vlv.{set_command}({command})")
|
|
161
|
+
print(
|
|
162
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected_ctrl: {expected_ctrl}, "
|
|
163
|
+
f"expected_fbk: {expected_fbk}"
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
assert bin_vlv["Permit"] == True
|
|
167
|
+
assert bin_vlv["SafePosAct"] == False
|
|
168
|
+
if set_command in ["set_open_op", "set_open_aut"]:
|
|
169
|
+
if command:
|
|
170
|
+
assert bin_vlv["Ctrl"] == expected_ctrl
|
|
171
|
+
assert bin_vlv.get_open_fbk() == expected_fbk
|
|
172
|
+
assert bin_vlv.get_close_fbk() == False
|
|
173
|
+
else:
|
|
174
|
+
assert bin_vlv["Ctrl"] == False
|
|
175
|
+
assert bin_vlv.get_open_fbk() == False
|
|
176
|
+
assert bin_vlv.get_close_fbk() == False
|
|
177
|
+
elif set_command in ["set_close_op", "set_close_aut"]:
|
|
178
|
+
if command:
|
|
179
|
+
assert bin_vlv["Ctrl"] == expected_ctrl
|
|
180
|
+
assert bin_vlv.get_open_fbk() == False
|
|
181
|
+
assert bin_vlv.get_close_fbk() == expected_fbk
|
|
182
|
+
else:
|
|
183
|
+
assert bin_vlv["Ctrl"] == False
|
|
184
|
+
assert bin_vlv.get_open_fbk() == False
|
|
185
|
+
assert bin_vlv.get_close_fbk() == False
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
@pytest.mark.parametrize(
|
|
189
|
+
"op_mode, src_mode, set_command, expected_ctrl, expected_fbk", test_scenario
|
|
190
|
+
)
|
|
191
|
+
def test_open_close_interlock_en_true(
|
|
192
|
+
op_mode, src_mode, set_command, expected_ctrl, expected_fbk
|
|
193
|
+
):
|
|
194
|
+
for command in [True, False]:
|
|
195
|
+
bin_vlv = init_bin_vlv(
|
|
196
|
+
init_op_mode=op_mode, init_src_mode=src_mode, intl_en=True
|
|
197
|
+
)
|
|
198
|
+
bin_vlv.set_interlock(False)
|
|
199
|
+
eval(f"bin_vlv.{set_command}({command})")
|
|
200
|
+
print(f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected: False")
|
|
201
|
+
|
|
202
|
+
assert bin_vlv["Interlock"] == False
|
|
203
|
+
assert bin_vlv["SafePosAct"] == True
|
|
204
|
+
assert bin_vlv["Ctrl"] == False
|
|
205
|
+
assert bin_vlv.get_open_fbk() == False
|
|
206
|
+
assert bin_vlv.get_close_fbk() == True
|
|
207
|
+
|
|
208
|
+
for command in [True, False]:
|
|
209
|
+
bin_vlv = init_bin_vlv(
|
|
210
|
+
init_op_mode=op_mode, init_src_mode=src_mode, intl_en=True
|
|
211
|
+
)
|
|
212
|
+
bin_vlv.set_interlock(True)
|
|
213
|
+
eval(f"bin_vlv.{set_command}({command})")
|
|
214
|
+
print(
|
|
215
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected_ctrl: {expected_ctrl}, "
|
|
216
|
+
f"expected_fbk: {expected_fbk}"
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
assert bin_vlv["Interlock"] == True
|
|
220
|
+
assert bin_vlv["SafePosAct"] == False
|
|
221
|
+
if set_command in ["set_open_op", "set_open_aut"]:
|
|
222
|
+
if command:
|
|
223
|
+
assert bin_vlv["Ctrl"] == expected_ctrl
|
|
224
|
+
assert bin_vlv.get_open_fbk() == expected_fbk
|
|
225
|
+
assert bin_vlv.get_close_fbk() == False
|
|
226
|
+
else:
|
|
227
|
+
assert bin_vlv["Ctrl"] == False
|
|
228
|
+
assert bin_vlv.get_open_fbk() == False
|
|
229
|
+
assert bin_vlv.get_close_fbk() == False
|
|
230
|
+
elif set_command in ["set_close_op", "set_close_aut"]:
|
|
231
|
+
if command:
|
|
232
|
+
assert bin_vlv["Ctrl"] == expected_ctrl
|
|
233
|
+
assert bin_vlv.get_open_fbk() == False
|
|
234
|
+
assert bin_vlv.get_close_fbk() == expected_fbk
|
|
235
|
+
else:
|
|
236
|
+
assert bin_vlv["Ctrl"] == False
|
|
237
|
+
assert bin_vlv.get_open_fbk() == False
|
|
238
|
+
assert bin_vlv.get_close_fbk() == False
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
@pytest.mark.parametrize(
|
|
242
|
+
"op_mode, src_mode, set_command, expected_ctrl, expected_fbk", test_scenario
|
|
243
|
+
)
|
|
244
|
+
def test_open_close_interlock_en_false(
|
|
245
|
+
op_mode, src_mode, set_command, expected_ctrl, expected_fbk
|
|
246
|
+
):
|
|
247
|
+
for command in [True, False]:
|
|
248
|
+
bin_vlv = init_bin_vlv(
|
|
249
|
+
init_op_mode=op_mode, init_src_mode=src_mode, intl_en=False
|
|
250
|
+
)
|
|
251
|
+
bin_vlv.set_interlock(True)
|
|
252
|
+
eval(f"bin_vlv.{set_command}({command})")
|
|
253
|
+
print(
|
|
254
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected_ctrl: {expected_ctrl}, "
|
|
255
|
+
f"expected_fbk: {expected_fbk}"
|
|
256
|
+
)
|
|
257
|
+
|
|
258
|
+
assert bin_vlv["Interlock"] == True
|
|
259
|
+
assert bin_vlv["SafePosAct"] == False
|
|
260
|
+
if set_command in ["set_open_op", "set_open_aut"]:
|
|
261
|
+
if command:
|
|
262
|
+
assert bin_vlv["Ctrl"] == expected_ctrl
|
|
263
|
+
assert bin_vlv.get_open_fbk() == expected_fbk
|
|
264
|
+
assert bin_vlv.get_close_fbk() == False
|
|
265
|
+
else:
|
|
266
|
+
assert bin_vlv["Ctrl"] == False
|
|
267
|
+
assert bin_vlv.get_open_fbk() == False
|
|
268
|
+
assert bin_vlv.get_close_fbk() == False
|
|
269
|
+
elif set_command in ["set_close_op", "set_close_aut"]:
|
|
270
|
+
if command:
|
|
271
|
+
assert bin_vlv["Ctrl"] == expected_ctrl
|
|
272
|
+
assert bin_vlv.get_open_fbk() == False
|
|
273
|
+
assert bin_vlv.get_close_fbk() == expected_fbk
|
|
274
|
+
else:
|
|
275
|
+
assert bin_vlv["Ctrl"] == False
|
|
276
|
+
assert bin_vlv.get_open_fbk() == False
|
|
277
|
+
assert bin_vlv.get_close_fbk() == False
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
@pytest.mark.parametrize(
|
|
281
|
+
"op_mode, src_mode, set_command, expected_ctrl, expected_fbk", test_scenario
|
|
282
|
+
)
|
|
283
|
+
def test_open_close_protect_en_true(
|
|
284
|
+
op_mode, src_mode, set_command, expected_ctrl, expected_fbk
|
|
285
|
+
):
|
|
286
|
+
for command in [True, False]:
|
|
287
|
+
bin_vlv = init_bin_vlv(
|
|
288
|
+
init_op_mode=op_mode, init_src_mode=src_mode, prot_en=True
|
|
289
|
+
)
|
|
290
|
+
bin_vlv.set_protect(False)
|
|
291
|
+
eval(f"bin_vlv.{set_command}({command})")
|
|
292
|
+
print(f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected: False")
|
|
293
|
+
|
|
294
|
+
assert bin_vlv["Protect"] == False
|
|
295
|
+
assert bin_vlv["SafePosAct"] == True
|
|
296
|
+
assert bin_vlv["Ctrl"] == False
|
|
297
|
+
assert bin_vlv.get_open_fbk() == False
|
|
298
|
+
assert bin_vlv.get_close_fbk() == True
|
|
299
|
+
|
|
300
|
+
for command in [True, False]:
|
|
301
|
+
bin_vlv = init_bin_vlv(
|
|
302
|
+
init_op_mode=op_mode, init_src_mode=src_mode, prot_en=True
|
|
303
|
+
)
|
|
304
|
+
bin_vlv.set_protect(True)
|
|
305
|
+
eval(f"bin_vlv.{set_command}({command})")
|
|
306
|
+
print(
|
|
307
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected_ctrl: {expected_ctrl}, "
|
|
308
|
+
f"expected_fbk: {expected_fbk}"
|
|
309
|
+
)
|
|
310
|
+
|
|
311
|
+
assert bin_vlv["Protect"] == True
|
|
312
|
+
assert bin_vlv["SafePosAct"] == False
|
|
313
|
+
if set_command in ["set_open_op", "set_open_aut"]:
|
|
314
|
+
if command:
|
|
315
|
+
assert bin_vlv["Ctrl"] == expected_ctrl
|
|
316
|
+
assert bin_vlv.get_open_fbk() == expected_fbk
|
|
317
|
+
assert bin_vlv.get_close_fbk() == False
|
|
318
|
+
else:
|
|
319
|
+
assert bin_vlv["Ctrl"] == False
|
|
320
|
+
assert bin_vlv.get_open_fbk() == False
|
|
321
|
+
assert bin_vlv.get_close_fbk() == False
|
|
322
|
+
elif set_command in ["set_close_op", "set_close_aut"]:
|
|
323
|
+
if command:
|
|
324
|
+
assert bin_vlv["Ctrl"] == expected_ctrl
|
|
325
|
+
assert bin_vlv.get_open_fbk() == False
|
|
326
|
+
assert bin_vlv.get_close_fbk() == expected_fbk
|
|
327
|
+
else:
|
|
328
|
+
assert bin_vlv["Ctrl"] == False
|
|
329
|
+
assert bin_vlv.get_open_fbk() == False
|
|
330
|
+
assert bin_vlv.get_close_fbk() == False
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
@pytest.mark.parametrize(
|
|
334
|
+
"op_mode, src_mode, set_command, expected_ctrl, expected_fbk", test_scenario
|
|
335
|
+
)
|
|
336
|
+
def test_open_close_protect_en_false(
|
|
337
|
+
op_mode, src_mode, set_command, expected_ctrl, expected_fbk
|
|
338
|
+
):
|
|
339
|
+
for command in [True, False]:
|
|
340
|
+
bin_vlv = init_bin_vlv(
|
|
341
|
+
init_op_mode=op_mode, init_src_mode=src_mode, prot_en=False
|
|
342
|
+
)
|
|
343
|
+
bin_vlv.set_protect(True)
|
|
344
|
+
eval(f"bin_vlv.{set_command}({command})")
|
|
345
|
+
print(
|
|
346
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected_ctrl: {expected_ctrl}, "
|
|
347
|
+
f"expected_fbk: {expected_fbk}"
|
|
348
|
+
)
|
|
349
|
+
|
|
350
|
+
assert bin_vlv["Protect"] == True
|
|
351
|
+
assert bin_vlv["SafePosAct"] == False
|
|
352
|
+
if set_command in ["set_open_op", "set_open_aut"]:
|
|
353
|
+
if command:
|
|
354
|
+
assert bin_vlv["Ctrl"] == expected_ctrl
|
|
355
|
+
assert bin_vlv.get_open_fbk() == expected_fbk
|
|
356
|
+
assert bin_vlv.get_close_fbk() == False
|
|
357
|
+
else:
|
|
358
|
+
assert bin_vlv["Ctrl"] == False
|
|
359
|
+
assert bin_vlv.get_open_fbk() == False
|
|
360
|
+
assert bin_vlv.get_close_fbk() == False
|
|
361
|
+
elif set_command in ["set_close_op", "set_close_aut"]:
|
|
362
|
+
if command:
|
|
363
|
+
assert bin_vlv["Ctrl"] == expected_ctrl
|
|
364
|
+
assert bin_vlv.get_open_fbk() == False
|
|
365
|
+
assert bin_vlv.get_close_fbk() == expected_fbk
|
|
366
|
+
else:
|
|
367
|
+
assert bin_vlv["Ctrl"] == False
|
|
368
|
+
assert bin_vlv.get_open_fbk() == False
|
|
369
|
+
assert bin_vlv.get_close_fbk() == False
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
test_scenario_reset = [
|
|
373
|
+
("off", "int", "set_reset_op", False),
|
|
374
|
+
("off", "man", "set_reset_op", False),
|
|
375
|
+
("op", "int", "set_reset_op", True),
|
|
376
|
+
("op", "man", "set_reset_op", True),
|
|
377
|
+
("aut", "int", "set_reset_op", False),
|
|
378
|
+
("aut", "man", "set_reset_op", False),
|
|
379
|
+
("off", "int", "set_reset_aut", False),
|
|
380
|
+
("off", "man", "set_reset_aut", False),
|
|
381
|
+
("op", "int", "set_reset_aut", False),
|
|
382
|
+
("op", "man", "set_reset_aut", False),
|
|
383
|
+
("aut", "int", "set_reset_aut", True),
|
|
384
|
+
("aut", "man", "set_reset_aut", True),
|
|
385
|
+
]
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
@pytest.mark.parametrize("op_mode, src_mode, set_command, result", test_scenario_reset)
|
|
389
|
+
def test_reset(op_mode, src_mode, set_command, result):
|
|
390
|
+
for command in [True, False]:
|
|
391
|
+
bin_vlv = init_bin_vlv(
|
|
392
|
+
init_op_mode=op_mode, init_src_mode=src_mode, prot_en=True
|
|
393
|
+
)
|
|
394
|
+
|
|
395
|
+
bin_vlv.set_protect(False)
|
|
396
|
+
assert bin_vlv["Protect"] == False
|
|
397
|
+
assert bin_vlv["SafePosAct"] == True
|
|
398
|
+
assert bin_vlv.get_open_fbk() == False
|
|
399
|
+
assert bin_vlv.get_close_fbk() == True
|
|
400
|
+
|
|
401
|
+
eval(f"bin_vlv.{set_command}({command})")
|
|
402
|
+
print(f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected: {result}")
|
|
403
|
+
|
|
404
|
+
if command:
|
|
405
|
+
assert bin_vlv["Protect"] == result
|
|
406
|
+
assert bin_vlv["SafePosAct"] != result
|
|
407
|
+
assert bin_vlv.get_close_fbk() != result
|
|
408
|
+
|
|
409
|
+
else:
|
|
410
|
+
assert bin_vlv["Protect"] == False
|
|
411
|
+
assert bin_vlv["SafePosAct"] == True
|
|
412
|
+
assert bin_vlv.get_close_fbk() == True
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
test_scenario_safe_pos_en = [
|
|
416
|
+
("op", "int", "set_open_op", 1, True),
|
|
417
|
+
("op", "man", "set_open_op", 1, True),
|
|
418
|
+
("aut", "int", "set_open_aut", 1, False),
|
|
419
|
+
("aut", "man", "set_open_aut", 1, False),
|
|
420
|
+
("op", "int", "set_close_op", 0, True),
|
|
421
|
+
("op", "man", "set_close_op", 0, True),
|
|
422
|
+
("aut", "int", "set_close_aut", 0, False),
|
|
423
|
+
("aut", "man", "set_close_aut", 0, False),
|
|
424
|
+
]
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
@pytest.mark.parametrize(
|
|
428
|
+
"op_mode, src_mode, set_command, safe_pos, safe_pos_en", test_scenario_safe_pos_en
|
|
429
|
+
)
|
|
430
|
+
def test_safe_pos_en_interlock(op_mode, src_mode, set_command, safe_pos, safe_pos_en):
|
|
431
|
+
bin_vlv = init_bin_vlv(
|
|
432
|
+
init_op_mode=op_mode,
|
|
433
|
+
init_src_mode=src_mode,
|
|
434
|
+
safe_pos=safe_pos,
|
|
435
|
+
safe_pos_en=safe_pos_en,
|
|
436
|
+
intl_en=True,
|
|
437
|
+
)
|
|
438
|
+
bin_vlv.set_interlock(True) # interlock is inactive
|
|
439
|
+
eval(f"bin_vlv.{set_command}(True)")
|
|
440
|
+
bin_vlv.set_interlock(False) # active interlock after setting a position
|
|
441
|
+
print(
|
|
442
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, True, safe_pos: {safe_pos}, "
|
|
443
|
+
f"safe_pos_en: {safe_pos_en}"
|
|
444
|
+
)
|
|
445
|
+
|
|
446
|
+
# if safe_pos_en is true, state should be to set to safety position (open or close) after interlock is
|
|
447
|
+
# activated
|
|
448
|
+
if set_command in ["set_open_op", "set_open_aut"]:
|
|
449
|
+
if safe_pos_en:
|
|
450
|
+
if safe_pos == 1:
|
|
451
|
+
assert bin_vlv["Ctrl"] == True
|
|
452
|
+
assert bin_vlv.get_open_fbk() == True
|
|
453
|
+
assert bin_vlv.get_close_fbk() == False
|
|
454
|
+
elif safe_pos == 0:
|
|
455
|
+
assert bin_vlv["Ctrl"] == False
|
|
456
|
+
assert bin_vlv.get_open_fbk() == False
|
|
457
|
+
assert bin_vlv.get_close_fbk() == False
|
|
458
|
+
|
|
459
|
+
# if safe_pos_en is false, current valve state is the last active state
|
|
460
|
+
else:
|
|
461
|
+
assert bin_vlv["Ctrl"] == True
|
|
462
|
+
assert bin_vlv.get_open_fbk() == True
|
|
463
|
+
assert bin_vlv.get_close_fbk() == False
|
|
464
|
+
|
|
465
|
+
if set_command in ["set_close_op", "set_close_aut"]:
|
|
466
|
+
if safe_pos_en:
|
|
467
|
+
if safe_pos == 1:
|
|
468
|
+
assert bin_vlv["Ctrl"] == True
|
|
469
|
+
assert bin_vlv.get_open_fbk() == True
|
|
470
|
+
assert bin_vlv.get_close_fbk() == False
|
|
471
|
+
elif safe_pos == 0:
|
|
472
|
+
assert bin_vlv["Ctrl"] == False
|
|
473
|
+
assert bin_vlv.get_open_fbk() == False
|
|
474
|
+
assert bin_vlv.get_close_fbk() == True
|
|
475
|
+
|
|
476
|
+
# if safe_pos_en is false, current valve state is the last active state
|
|
477
|
+
else:
|
|
478
|
+
assert bin_vlv["Ctrl"] == False
|
|
479
|
+
assert bin_vlv.get_open_fbk() == False
|
|
480
|
+
assert bin_vlv.get_close_fbk() == True
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
@pytest.mark.parametrize(
|
|
484
|
+
"op_mode, src_mode, set_command, safe_pos, safe_pos_en", test_scenario_safe_pos_en
|
|
485
|
+
)
|
|
486
|
+
def test_safe_pos_en_protect(op_mode, src_mode, set_command, safe_pos, safe_pos_en):
|
|
487
|
+
bin_vlv = init_bin_vlv(
|
|
488
|
+
init_op_mode=op_mode,
|
|
489
|
+
init_src_mode=src_mode,
|
|
490
|
+
safe_pos=safe_pos,
|
|
491
|
+
safe_pos_en=safe_pos_en,
|
|
492
|
+
prot_en=True,
|
|
493
|
+
)
|
|
494
|
+
bin_vlv.set_protect(True) # protect is inactive
|
|
495
|
+
eval(f"bin_vlv.{set_command}(True)")
|
|
496
|
+
bin_vlv.set_protect(False) # active protect after setting a position
|
|
497
|
+
print(
|
|
498
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, True, safe_pos: {safe_pos}, "
|
|
499
|
+
f"safe_pos_en: {safe_pos_en}"
|
|
500
|
+
)
|
|
501
|
+
|
|
502
|
+
# if safe_pos_en is true, state should be to set to safety position (open or close) after protection is
|
|
503
|
+
# activated
|
|
504
|
+
if set_command in ["set_open_op", "set_open_aut"]:
|
|
505
|
+
if safe_pos_en:
|
|
506
|
+
if safe_pos == 1:
|
|
507
|
+
assert bin_vlv["Ctrl"] == True
|
|
508
|
+
assert bin_vlv.get_open_fbk() == True
|
|
509
|
+
assert bin_vlv.get_close_fbk() == False
|
|
510
|
+
elif safe_pos == 0:
|
|
511
|
+
assert bin_vlv["Ctrl"] == False
|
|
512
|
+
assert bin_vlv.get_open_fbk() == False
|
|
513
|
+
assert bin_vlv.get_close_fbk() == False
|
|
514
|
+
|
|
515
|
+
# if safe_pos_en is false, current valve state is the last active state
|
|
516
|
+
else:
|
|
517
|
+
assert bin_vlv["Ctrl"] == True
|
|
518
|
+
assert bin_vlv.get_open_fbk() == True
|
|
519
|
+
assert bin_vlv.get_close_fbk() == False
|
|
520
|
+
|
|
521
|
+
if set_command in ["set_close_op", "set_close_aut"]:
|
|
522
|
+
if safe_pos_en:
|
|
523
|
+
if safe_pos == 1:
|
|
524
|
+
assert bin_vlv["Ctrl"] == True
|
|
525
|
+
assert bin_vlv.get_open_fbk() == True
|
|
526
|
+
assert bin_vlv.get_close_fbk() == False
|
|
527
|
+
elif safe_pos == 0:
|
|
528
|
+
assert bin_vlv["Ctrl"] == False
|
|
529
|
+
assert bin_vlv.get_open_fbk() == False
|
|
530
|
+
assert bin_vlv.get_close_fbk() == True
|
|
531
|
+
|
|
532
|
+
# if safe_pos_en is false, current valve state is the last active state
|
|
533
|
+
else:
|
|
534
|
+
assert bin_vlv["Ctrl"] == False
|
|
535
|
+
assert bin_vlv.get_open_fbk() == False
|
|
536
|
+
assert bin_vlv.get_close_fbk() == True
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
@pytest.mark.parametrize(
|
|
540
|
+
"op_mode, src_mode, set_command, safe_pos, safe_pos_en", test_scenario_safe_pos_en
|
|
541
|
+
)
|
|
542
|
+
def test_safe_pos_en_permit(op_mode, src_mode, set_command, safe_pos, safe_pos_en):
|
|
543
|
+
bin_vlv = init_bin_vlv(
|
|
544
|
+
init_op_mode=op_mode,
|
|
545
|
+
init_src_mode=src_mode,
|
|
546
|
+
safe_pos=safe_pos,
|
|
547
|
+
safe_pos_en=safe_pos_en,
|
|
548
|
+
perm_en=True,
|
|
549
|
+
)
|
|
550
|
+
bin_vlv.set_permit(True) # permit is inactive
|
|
551
|
+
eval(f"bin_vlv.{set_command}(True)")
|
|
552
|
+
bin_vlv.set_permit(False) # active permit after setting a position
|
|
553
|
+
print(
|
|
554
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, True, safe_pos: {safe_pos}, "
|
|
555
|
+
f"safe_pos_en: {safe_pos_en}"
|
|
556
|
+
)
|
|
557
|
+
|
|
558
|
+
if set_command in ["set_open_op", "set_open_aut"]:
|
|
559
|
+
assert bin_vlv["Ctrl"] == True
|
|
560
|
+
assert bin_vlv.get_open_fbk() == True
|
|
561
|
+
assert bin_vlv.get_close_fbk() == False
|
|
562
|
+
|
|
563
|
+
if set_command in ["set_close_op", "set_close_aut"]:
|
|
564
|
+
assert bin_vlv["Ctrl"] == False
|
|
565
|
+
assert bin_vlv.get_open_fbk() == False
|
|
566
|
+
assert bin_vlv.get_close_fbk() == True
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
def test_open_fbk():
|
|
570
|
+
bin_vlv = init_bin_vlv(open_fbk_calc=False, close_fbk_calc=False)
|
|
571
|
+
assert bin_vlv.get_open_fbk() == False
|
|
572
|
+
bin_vlv.set_open_fbk(True)
|
|
573
|
+
assert bin_vlv.get_open_fbk() == True
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
def test_close_fbk():
|
|
577
|
+
bin_vlv = init_bin_vlv(open_fbk_calc=False, close_fbk_calc=False)
|
|
578
|
+
assert bin_vlv.get_close_fbk() == False
|
|
579
|
+
bin_vlv.set_close_fbk(True)
|
|
580
|
+
assert bin_vlv.get_close_fbk() == True
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
if __name__ == "__main__":
|
|
584
|
+
# This allows running the tests directly if needed
|
|
585
|
+
pytest.main([__file__, "-v"])
|