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,732 @@
|
|
|
1
|
+
"""Test Suite for AnaVlv."""
|
|
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.utils.logging import logger
|
|
11
|
+
from mtppy.part3.data_assembly_set.active_elements.valves.ana_vlv import AnaVlv
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def init_ana_vlv(
|
|
15
|
+
init_op_mode="off",
|
|
16
|
+
init_src_mode="int",
|
|
17
|
+
open_fbk_calc=True,
|
|
18
|
+
close_fbk_calc=True,
|
|
19
|
+
pos_fbk_calc=True,
|
|
20
|
+
safe_pos=0,
|
|
21
|
+
safe_pos_en=True,
|
|
22
|
+
perm_en=False,
|
|
23
|
+
intl_en=False,
|
|
24
|
+
prot_en=False,
|
|
25
|
+
):
|
|
26
|
+
ana_vlv = AnaVlv(
|
|
27
|
+
"tag",
|
|
28
|
+
tag_description="",
|
|
29
|
+
pos_min=2,
|
|
30
|
+
pos_max=10,
|
|
31
|
+
pos_scl_min=0,
|
|
32
|
+
pos_scl_max=10,
|
|
33
|
+
pos_unit=0,
|
|
34
|
+
open_fbk_calc=open_fbk_calc,
|
|
35
|
+
close_fbk_calc=close_fbk_calc,
|
|
36
|
+
pos_fbk_calc=pos_fbk_calc,
|
|
37
|
+
safe_pos=safe_pos,
|
|
38
|
+
safe_pos_en=safe_pos_en,
|
|
39
|
+
perm_en=perm_en,
|
|
40
|
+
intl_en=intl_en,
|
|
41
|
+
prot_en=prot_en,
|
|
42
|
+
)
|
|
43
|
+
data_object_set_modes(ana_vlv, init_op_mode, init_src_mode)
|
|
44
|
+
return ana_vlv
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
test_scenario = [
|
|
48
|
+
("off", "int", "set_open_op", False),
|
|
49
|
+
("off", "man", "set_open_op", False),
|
|
50
|
+
("op", "int", "set_open_op", True),
|
|
51
|
+
("op", "man", "set_open_op", True),
|
|
52
|
+
("aut", "int", "set_open_op", False),
|
|
53
|
+
("aut", "man", "set_open_op", False),
|
|
54
|
+
("off", "int", "set_open_aut", False),
|
|
55
|
+
("off", "man", "set_open_aut", False),
|
|
56
|
+
("op", "int", "set_open_aut", False),
|
|
57
|
+
("op", "man", "set_open_aut", False),
|
|
58
|
+
("aut", "int", "set_open_aut", True),
|
|
59
|
+
("aut", "man", "set_open_aut", True),
|
|
60
|
+
("off", "int", "set_close_op", False),
|
|
61
|
+
("off", "man", "set_close_op", False),
|
|
62
|
+
("op", "int", "set_close_op", True),
|
|
63
|
+
("op", "man", "set_close_op", True),
|
|
64
|
+
("aut", "int", "set_close_op", False),
|
|
65
|
+
("aut", "man", "set_close_op", False),
|
|
66
|
+
("off", "int", "set_close_aut", False),
|
|
67
|
+
("off", "man", "set_close_aut", False),
|
|
68
|
+
("op", "int", "set_close_aut", False),
|
|
69
|
+
("op", "man", "set_close_aut", False),
|
|
70
|
+
("aut", "int", "set_close_aut", True),
|
|
71
|
+
("aut", "man", "set_close_aut", True),
|
|
72
|
+
]
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@pytest.mark.parametrize(
|
|
76
|
+
"op_mode, src_mode, set_command, expected_result", test_scenario
|
|
77
|
+
)
|
|
78
|
+
def test_open_close(op_mode, src_mode, set_command, expected_result):
|
|
79
|
+
for command in [True, False]:
|
|
80
|
+
ana_vlv = init_ana_vlv(init_op_mode=op_mode, init_src_mode=src_mode)
|
|
81
|
+
eval(f"ana_vlv.{set_command}({command})")
|
|
82
|
+
print(
|
|
83
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected: {expected_result}"
|
|
84
|
+
)
|
|
85
|
+
if set_command in ["set_open_op", "set_open_aut"]:
|
|
86
|
+
if command:
|
|
87
|
+
assert ana_vlv["OpenAct"] == expected_result
|
|
88
|
+
assert ana_vlv.get_open_fbk() == expected_result
|
|
89
|
+
assert ana_vlv["CloseAct"] == False
|
|
90
|
+
assert ana_vlv.get_close_fbk() == False
|
|
91
|
+
else:
|
|
92
|
+
assert ana_vlv["OpenAct"] == False
|
|
93
|
+
assert ana_vlv.get_open_fbk() == False
|
|
94
|
+
assert ana_vlv["CloseAct"] == False
|
|
95
|
+
assert ana_vlv.get_close_fbk() == False
|
|
96
|
+
elif set_command in ["set_close_op", "set_close_aut"]:
|
|
97
|
+
if command:
|
|
98
|
+
assert ana_vlv["OpenAct"] == False
|
|
99
|
+
assert ana_vlv.get_open_fbk() == False
|
|
100
|
+
assert ana_vlv["CloseAct"] == expected_result
|
|
101
|
+
assert ana_vlv.get_close_fbk() == expected_result
|
|
102
|
+
else:
|
|
103
|
+
assert ana_vlv["OpenAct"] == False
|
|
104
|
+
assert ana_vlv.get_open_fbk() == False
|
|
105
|
+
assert ana_vlv["CloseAct"] == False
|
|
106
|
+
assert ana_vlv.get_close_fbk() == False
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
@pytest.mark.parametrize(
|
|
110
|
+
"op_mode, src_mode, set_command, expected_result", test_scenario
|
|
111
|
+
)
|
|
112
|
+
def test_open_close_permit_en_true(op_mode, src_mode, set_command, expected_result):
|
|
113
|
+
for command in [True, False]:
|
|
114
|
+
ana_vlv = init_ana_vlv(
|
|
115
|
+
init_op_mode=op_mode, init_src_mode=src_mode, perm_en=True
|
|
116
|
+
)
|
|
117
|
+
ana_vlv.set_permit(False)
|
|
118
|
+
eval(f"ana_vlv.{set_command}({command})")
|
|
119
|
+
print(f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected: False")
|
|
120
|
+
assert ana_vlv["SafePosAct"] == False
|
|
121
|
+
assert ana_vlv["Permit"] == False
|
|
122
|
+
assert ana_vlv["OpenAct"] == False
|
|
123
|
+
assert ana_vlv["CloseAct"] == False
|
|
124
|
+
assert ana_vlv.get_open_fbk() == False
|
|
125
|
+
assert ana_vlv.get_close_fbk() == False
|
|
126
|
+
|
|
127
|
+
for command in [True, False]:
|
|
128
|
+
ana_vlv = init_ana_vlv(
|
|
129
|
+
init_op_mode=op_mode, init_src_mode=src_mode, perm_en=True
|
|
130
|
+
)
|
|
131
|
+
ana_vlv.set_permit(True)
|
|
132
|
+
eval(f"ana_vlv.{set_command}({command})")
|
|
133
|
+
print(
|
|
134
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected: {expected_result}"
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
assert ana_vlv["Permit"] == True
|
|
138
|
+
assert ana_vlv["SafePosAct"] == False
|
|
139
|
+
if set_command in ["set_open_op", "set_open_aut"]:
|
|
140
|
+
if command:
|
|
141
|
+
assert ana_vlv["OpenAct"] == expected_result
|
|
142
|
+
assert ana_vlv.get_open_fbk() == expected_result
|
|
143
|
+
assert ana_vlv["CloseAct"] == False
|
|
144
|
+
assert ana_vlv.get_close_fbk() == False
|
|
145
|
+
else:
|
|
146
|
+
assert ana_vlv["OpenAct"] == False
|
|
147
|
+
assert ana_vlv.get_open_fbk() == False
|
|
148
|
+
assert ana_vlv["CloseAct"] == False
|
|
149
|
+
assert ana_vlv.get_close_fbk() == False
|
|
150
|
+
elif set_command in ["set_close_op", "set_close_aut"]:
|
|
151
|
+
if command:
|
|
152
|
+
assert ana_vlv["OpenAct"] == False
|
|
153
|
+
assert ana_vlv.get_open_fbk() == False
|
|
154
|
+
assert ana_vlv["CloseAct"] == expected_result
|
|
155
|
+
assert ana_vlv.get_close_fbk() == expected_result
|
|
156
|
+
else:
|
|
157
|
+
assert ana_vlv["OpenAct"] == False
|
|
158
|
+
assert ana_vlv.get_open_fbk() == False
|
|
159
|
+
assert ana_vlv["CloseAct"] == False
|
|
160
|
+
assert ana_vlv.get_close_fbk() == False
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
@pytest.mark.parametrize(
|
|
164
|
+
"op_mode, src_mode, set_command, expected_result", test_scenario
|
|
165
|
+
)
|
|
166
|
+
def test_open_close_permit_en_false(op_mode, src_mode, set_command, expected_result):
|
|
167
|
+
for command in [True, False]:
|
|
168
|
+
ana_vlv = init_ana_vlv(
|
|
169
|
+
init_op_mode=op_mode, init_src_mode=src_mode, perm_en=False
|
|
170
|
+
)
|
|
171
|
+
ana_vlv.set_permit(True)
|
|
172
|
+
eval(f"ana_vlv.{set_command}({command})")
|
|
173
|
+
print(
|
|
174
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected: {expected_result}"
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
assert ana_vlv["Permit"] == True
|
|
178
|
+
assert ana_vlv["SafePosAct"] == False
|
|
179
|
+
if set_command in ["set_open_op", "set_open_aut"]:
|
|
180
|
+
if command:
|
|
181
|
+
assert ana_vlv["OpenAct"] == expected_result
|
|
182
|
+
assert ana_vlv.get_open_fbk() == expected_result
|
|
183
|
+
assert ana_vlv["CloseAct"] == False
|
|
184
|
+
assert ana_vlv.get_close_fbk() == False
|
|
185
|
+
else:
|
|
186
|
+
assert ana_vlv["OpenAct"] == False
|
|
187
|
+
assert ana_vlv.get_open_fbk() == False
|
|
188
|
+
assert ana_vlv["CloseAct"] == False
|
|
189
|
+
assert ana_vlv.get_close_fbk() == False
|
|
190
|
+
elif set_command in ["set_close_op", "set_close_aut"]:
|
|
191
|
+
if command:
|
|
192
|
+
assert ana_vlv["OpenAct"] == False
|
|
193
|
+
assert ana_vlv.get_open_fbk() == False
|
|
194
|
+
assert ana_vlv["CloseAct"] == expected_result
|
|
195
|
+
assert ana_vlv.get_close_fbk() == expected_result
|
|
196
|
+
else:
|
|
197
|
+
assert ana_vlv["OpenAct"] == False
|
|
198
|
+
assert ana_vlv.get_open_fbk() == False
|
|
199
|
+
assert ana_vlv["CloseAct"] == False
|
|
200
|
+
assert ana_vlv.get_close_fbk() == False
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
@pytest.mark.parametrize(
|
|
204
|
+
"op_mode, src_mode, set_command, expected_result", test_scenario
|
|
205
|
+
)
|
|
206
|
+
def test_open_close_interlock_en_true(op_mode, src_mode, set_command, expected_result):
|
|
207
|
+
for command in [True, False]:
|
|
208
|
+
ana_vlv = init_ana_vlv(
|
|
209
|
+
init_op_mode=op_mode, init_src_mode=src_mode, intl_en=True
|
|
210
|
+
)
|
|
211
|
+
ana_vlv.set_interlock(False)
|
|
212
|
+
eval(f"ana_vlv.{set_command}({command})")
|
|
213
|
+
print(f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected: False")
|
|
214
|
+
|
|
215
|
+
assert ana_vlv["Interlock"] == False
|
|
216
|
+
assert ana_vlv["SafePosAct"] == True
|
|
217
|
+
assert ana_vlv["OpenAct"] == False
|
|
218
|
+
assert ana_vlv["CloseAct"] == True
|
|
219
|
+
assert ana_vlv.get_open_fbk() == False
|
|
220
|
+
assert ana_vlv.get_close_fbk() == True
|
|
221
|
+
|
|
222
|
+
for command in [True, False]:
|
|
223
|
+
ana_vlv = init_ana_vlv(
|
|
224
|
+
init_op_mode=op_mode, init_src_mode=src_mode, intl_en=True
|
|
225
|
+
)
|
|
226
|
+
ana_vlv.set_interlock(True)
|
|
227
|
+
eval(f"ana_vlv.{set_command}({command})")
|
|
228
|
+
|
|
229
|
+
assert ana_vlv["Interlock"] == True
|
|
230
|
+
assert ana_vlv["SafePosAct"] == False
|
|
231
|
+
if set_command in ["set_open_op", "set_open_aut"]:
|
|
232
|
+
if command:
|
|
233
|
+
assert ana_vlv["OpenAct"] == expected_result
|
|
234
|
+
assert ana_vlv.get_open_fbk() == expected_result
|
|
235
|
+
assert ana_vlv["CloseAct"] == False
|
|
236
|
+
assert ana_vlv.get_close_fbk() == False
|
|
237
|
+
else:
|
|
238
|
+
assert ana_vlv["OpenAct"] == False
|
|
239
|
+
assert ana_vlv.get_open_fbk() == False
|
|
240
|
+
assert ana_vlv["CloseAct"] == False
|
|
241
|
+
assert ana_vlv.get_close_fbk() == False
|
|
242
|
+
elif set_command in ["set_close_op", "set_close_aut"]:
|
|
243
|
+
if command:
|
|
244
|
+
assert ana_vlv["OpenAct"] == False
|
|
245
|
+
assert ana_vlv.get_open_fbk() == False
|
|
246
|
+
assert ana_vlv["CloseAct"] == expected_result
|
|
247
|
+
assert ana_vlv.get_close_fbk() == expected_result
|
|
248
|
+
else:
|
|
249
|
+
assert ana_vlv["OpenAct"] == False
|
|
250
|
+
assert ana_vlv.get_open_fbk() == False
|
|
251
|
+
assert ana_vlv["CloseAct"] == False
|
|
252
|
+
assert ana_vlv.get_close_fbk() == False
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
@pytest.mark.parametrize(
|
|
256
|
+
"op_mode, src_mode, set_command, expected_result", test_scenario
|
|
257
|
+
)
|
|
258
|
+
def test_open_close_interlock_en_false(op_mode, src_mode, set_command, expected_result):
|
|
259
|
+
for command in [True, False]:
|
|
260
|
+
ana_vlv = init_ana_vlv(
|
|
261
|
+
init_op_mode=op_mode, init_src_mode=src_mode, intl_en=False
|
|
262
|
+
)
|
|
263
|
+
ana_vlv.set_interlock(True)
|
|
264
|
+
eval(f"ana_vlv.{set_command}({command})")
|
|
265
|
+
print(
|
|
266
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected: {expected_result}"
|
|
267
|
+
)
|
|
268
|
+
|
|
269
|
+
assert ana_vlv["Interlock"] == True
|
|
270
|
+
assert ana_vlv["SafePosAct"] == False
|
|
271
|
+
if set_command in ["set_open_op", "set_open_aut"]:
|
|
272
|
+
if command:
|
|
273
|
+
assert ana_vlv["OpenAct"] == expected_result
|
|
274
|
+
assert ana_vlv.get_open_fbk() == expected_result
|
|
275
|
+
assert ana_vlv["CloseAct"] == False
|
|
276
|
+
assert ana_vlv.get_close_fbk() == False
|
|
277
|
+
else:
|
|
278
|
+
assert ana_vlv["OpenAct"] == False
|
|
279
|
+
assert ana_vlv.get_open_fbk() == False
|
|
280
|
+
assert ana_vlv["CloseAct"] == False
|
|
281
|
+
assert ana_vlv.get_close_fbk() == False
|
|
282
|
+
elif set_command in ["set_close_op", "set_close_aut"]:
|
|
283
|
+
if command:
|
|
284
|
+
assert ana_vlv["OpenAct"] == False
|
|
285
|
+
assert ana_vlv.get_open_fbk() == False
|
|
286
|
+
assert ana_vlv["CloseAct"] == expected_result
|
|
287
|
+
assert ana_vlv.get_close_fbk() == expected_result
|
|
288
|
+
else:
|
|
289
|
+
assert ana_vlv["OpenAct"] == False
|
|
290
|
+
assert ana_vlv.get_open_fbk() == False
|
|
291
|
+
assert ana_vlv["CloseAct"] == False
|
|
292
|
+
assert ana_vlv.get_close_fbk() == False
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
@pytest.mark.parametrize(
|
|
296
|
+
"op_mode, src_mode, set_command, expected_result", test_scenario
|
|
297
|
+
)
|
|
298
|
+
def test_open_close_protect_en_true(op_mode, src_mode, set_command, expected_result):
|
|
299
|
+
for command in [True, False]:
|
|
300
|
+
ana_vlv = init_ana_vlv(
|
|
301
|
+
init_op_mode=op_mode, init_src_mode=src_mode, prot_en=True
|
|
302
|
+
)
|
|
303
|
+
ana_vlv.set_protect(False)
|
|
304
|
+
eval(f"ana_vlv.{set_command}({command})")
|
|
305
|
+
print(f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected: False")
|
|
306
|
+
|
|
307
|
+
assert ana_vlv["Protect"] == False
|
|
308
|
+
assert ana_vlv["SafePosAct"] == True
|
|
309
|
+
assert ana_vlv["OpenAct"] == False
|
|
310
|
+
assert ana_vlv["CloseAct"] == True
|
|
311
|
+
|
|
312
|
+
for command in [True, False]:
|
|
313
|
+
ana_vlv = init_ana_vlv(
|
|
314
|
+
init_op_mode=op_mode, init_src_mode=src_mode, prot_en=True
|
|
315
|
+
)
|
|
316
|
+
ana_vlv.set_protect(True)
|
|
317
|
+
assert ana_vlv["Protect"] == True
|
|
318
|
+
assert ana_vlv["SafePosAct"] == False
|
|
319
|
+
assert ana_vlv["OpenAct"] == False # state after calling reset
|
|
320
|
+
assert ana_vlv["CloseAct"] == False # state after calling reset
|
|
321
|
+
|
|
322
|
+
eval(f"ana_vlv.{set_command}({command})")
|
|
323
|
+
print(
|
|
324
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, expected: {expected_result}"
|
|
325
|
+
)
|
|
326
|
+
|
|
327
|
+
if set_command in ["set_open_op", "set_open_aut"]:
|
|
328
|
+
if command:
|
|
329
|
+
assert ana_vlv["OpenAct"] == expected_result
|
|
330
|
+
assert ana_vlv.get_open_fbk() == expected_result
|
|
331
|
+
assert ana_vlv["CloseAct"] == False
|
|
332
|
+
assert ana_vlv.get_close_fbk() == False
|
|
333
|
+
else:
|
|
334
|
+
assert ana_vlv["OpenAct"] == False
|
|
335
|
+
assert ana_vlv.get_open_fbk() == False
|
|
336
|
+
assert ana_vlv["CloseAct"] == False
|
|
337
|
+
assert ana_vlv.get_close_fbk() == False
|
|
338
|
+
elif set_command in ["set_rev_op", "set_rev_aut"]:
|
|
339
|
+
if command:
|
|
340
|
+
assert ana_vlv["OpenAct"] == False
|
|
341
|
+
assert ana_vlv.get_open_fbk() == False
|
|
342
|
+
assert ana_vlv["CloseAct"] == expected_result
|
|
343
|
+
assert ana_vlv.get_close_fbk() == expected_result
|
|
344
|
+
else:
|
|
345
|
+
assert ana_vlv["OpenAct"] == False
|
|
346
|
+
assert ana_vlv.get_open_fbk() == False
|
|
347
|
+
assert ana_vlv["CloseAct"] == False
|
|
348
|
+
assert ana_vlv.get_close_fbk() == False
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
@pytest.mark.parametrize(
|
|
352
|
+
"op_mode, src_mode, set_command, expected_result", test_scenario
|
|
353
|
+
)
|
|
354
|
+
def test_open_close_protect_en_false(op_mode, src_mode, set_command, expected_result):
|
|
355
|
+
for command in [True, False]:
|
|
356
|
+
ana_vlv = init_ana_vlv(
|
|
357
|
+
init_op_mode=op_mode, init_src_mode=src_mode, prot_en=False
|
|
358
|
+
)
|
|
359
|
+
ana_vlv.set_protect(True)
|
|
360
|
+
|
|
361
|
+
assert ana_vlv["Protect"] == True
|
|
362
|
+
assert ana_vlv["SafePosAct"] == False
|
|
363
|
+
assert ana_vlv["OpenAct"] == False # state after calling reset
|
|
364
|
+
assert ana_vlv["CloseAct"] == False # state after calling reset
|
|
365
|
+
|
|
366
|
+
eval(f"ana_vlv.{set_command}({command})")
|
|
367
|
+
|
|
368
|
+
if set_command in ["set_open_op", "set_open_aut"]:
|
|
369
|
+
if command:
|
|
370
|
+
assert ana_vlv["OpenAct"] == expected_result
|
|
371
|
+
assert ana_vlv["CloseAct"] == False
|
|
372
|
+
else:
|
|
373
|
+
assert ana_vlv["OpenAct"] == False
|
|
374
|
+
assert ana_vlv["CloseAct"] == False
|
|
375
|
+
elif set_command in ["set_close_op", "set_close_aut"]:
|
|
376
|
+
if command:
|
|
377
|
+
assert ana_vlv["OpenAct"] == False
|
|
378
|
+
assert ana_vlv["CloseAct"] == expected_result
|
|
379
|
+
else:
|
|
380
|
+
assert ana_vlv["OpenAct"] == False
|
|
381
|
+
assert ana_vlv["CloseAct"] == False
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
test_scenario_reset = [
|
|
385
|
+
("off", "int", "set_reset_op", False),
|
|
386
|
+
("off", "man", "set_reset_op", False),
|
|
387
|
+
("op", "int", "set_reset_op", True),
|
|
388
|
+
("op", "man", "set_reset_op", True),
|
|
389
|
+
("aut", "int", "set_reset_op", False),
|
|
390
|
+
("aut", "man", "set_reset_op", False),
|
|
391
|
+
("off", "int", "set_reset_aut", False),
|
|
392
|
+
("off", "man", "set_reset_aut", False),
|
|
393
|
+
("op", "int", "set_reset_aut", False),
|
|
394
|
+
("op", "man", "set_reset_aut", False),
|
|
395
|
+
("aut", "int", "set_reset_aut", True),
|
|
396
|
+
("aut", "man", "set_reset_aut", True),
|
|
397
|
+
]
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
@pytest.mark.parametrize("op_mode, src_mode, set_command, result", test_scenario_reset)
|
|
401
|
+
def test_reset(op_mode, src_mode, set_command, result):
|
|
402
|
+
for command in [True, False]:
|
|
403
|
+
ana_vlv = init_ana_vlv(
|
|
404
|
+
init_op_mode=op_mode, init_src_mode=src_mode, prot_en=True
|
|
405
|
+
)
|
|
406
|
+
|
|
407
|
+
# active protect lock
|
|
408
|
+
ana_vlv.set_protect(False)
|
|
409
|
+
assert ana_vlv["Protect"] == False
|
|
410
|
+
assert ana_vlv["SafePosAct"] == True
|
|
411
|
+
assert ana_vlv["OpenAct"] == False
|
|
412
|
+
assert ana_vlv["CloseAct"] == True
|
|
413
|
+
|
|
414
|
+
# call reset
|
|
415
|
+
eval(f"ana_vlv.{set_command}({command})")
|
|
416
|
+
|
|
417
|
+
if command:
|
|
418
|
+
assert ana_vlv["Protect"] == result
|
|
419
|
+
assert ana_vlv["SafePosAct"] != result
|
|
420
|
+
assert ana_vlv["OpenAct"] == False
|
|
421
|
+
assert ana_vlv["CloseAct"] != result
|
|
422
|
+
else:
|
|
423
|
+
assert ana_vlv["Protect"] == False
|
|
424
|
+
assert ana_vlv["SafePosAct"] == True
|
|
425
|
+
assert ana_vlv["OpenAct"] == False
|
|
426
|
+
assert ana_vlv["CloseAct"] == True
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
test_scenario_pos = [
|
|
430
|
+
("off", "int", "set_pos_int", True),
|
|
431
|
+
("off", "man", "set_pos_int", False),
|
|
432
|
+
("op", "int", "set_pos_int", True),
|
|
433
|
+
("op", "man", "set_pos_int", False),
|
|
434
|
+
("aut", "int", "set_pos_int", True),
|
|
435
|
+
("aut", "man", "set_pos_int", False),
|
|
436
|
+
("off", "int", "set_pos_man", False),
|
|
437
|
+
("off", "man", "set_pos_man", True),
|
|
438
|
+
("op", "int", "set_pos_man", False),
|
|
439
|
+
("op", "man", "set_pos_man", True),
|
|
440
|
+
("aut", "int", "set_pos_man", False),
|
|
441
|
+
("aut", "man", "set_pos_man", True),
|
|
442
|
+
]
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
@pytest.mark.parametrize(
|
|
446
|
+
"op_mode, src_mode, set_command, changes_expected", test_scenario_pos
|
|
447
|
+
)
|
|
448
|
+
def test_pos_open(op_mode, src_mode, set_command, changes_expected):
|
|
449
|
+
for command in [-2, 2, 5, 10, 100]:
|
|
450
|
+
ana_vlv = init_ana_vlv(
|
|
451
|
+
init_op_mode=op_mode, init_src_mode=src_mode, pos_fbk_calc=True
|
|
452
|
+
)
|
|
453
|
+
pos = ana_vlv.get_pos()
|
|
454
|
+
pos_fbk = ana_vlv.get_pos_fbk()
|
|
455
|
+
|
|
456
|
+
if op_mode == "op":
|
|
457
|
+
ana_vlv.set_open_op(True)
|
|
458
|
+
elif op_mode == "aut":
|
|
459
|
+
ana_vlv.set_open_aut(True)
|
|
460
|
+
elif op_mode == "off":
|
|
461
|
+
pass
|
|
462
|
+
|
|
463
|
+
eval(f"ana_vlv.{set_command}({command})")
|
|
464
|
+
|
|
465
|
+
if changes_expected:
|
|
466
|
+
if 2 <= command <= 10:
|
|
467
|
+
assert ana_vlv.get_pos() == command
|
|
468
|
+
assert ana_vlv.get_pos_fbk() == command
|
|
469
|
+
else:
|
|
470
|
+
assert ana_vlv.get_pos() == 2
|
|
471
|
+
assert ana_vlv.get_pos_fbk() == 2
|
|
472
|
+
else:
|
|
473
|
+
assert ana_vlv.get_pos() == pos
|
|
474
|
+
assert ana_vlv.get_pos_fbk() == pos_fbk
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
@pytest.mark.parametrize(
|
|
478
|
+
"op_mode, src_mode, set_command, changes_expected", test_scenario_pos
|
|
479
|
+
)
|
|
480
|
+
def test_pos_close(op_mode, src_mode, set_command, changes_expected):
|
|
481
|
+
for value in [-2, 2, 5, 10, 100]:
|
|
482
|
+
logger.info(
|
|
483
|
+
f"op={op_mode},src={src_mode},cmd={set_command}({value}),change={changes_expected}"
|
|
484
|
+
)
|
|
485
|
+
ana_vlv = init_ana_vlv(
|
|
486
|
+
init_op_mode=op_mode, init_src_mode=src_mode, pos_fbk_calc=True
|
|
487
|
+
)
|
|
488
|
+
|
|
489
|
+
if op_mode == "op":
|
|
490
|
+
ana_vlv.set_close_op(True)
|
|
491
|
+
elif op_mode == "aut":
|
|
492
|
+
ana_vlv.set_close_aut(True)
|
|
493
|
+
elif op_mode == "off":
|
|
494
|
+
pass
|
|
495
|
+
|
|
496
|
+
eval(f"ana_vlv.{set_command}({value})")
|
|
497
|
+
|
|
498
|
+
if (
|
|
499
|
+
changes_expected
|
|
500
|
+
and op_mode == "off"
|
|
501
|
+
and ana_vlv[AnaVlv.POS_SCL_MIN] <= value <= ana_vlv[AnaVlv.POS_SCL_MAX]
|
|
502
|
+
):
|
|
503
|
+
assert ana_vlv.get_pos() == value
|
|
504
|
+
assert ana_vlv.get_pos() == value
|
|
505
|
+
else:
|
|
506
|
+
assert ana_vlv.get_pos() == 2
|
|
507
|
+
assert ana_vlv.get_pos_fbk() == 2
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
test_scenario_safe_pos_en = [
|
|
511
|
+
("op", "int", "set_pos_int", 1, True),
|
|
512
|
+
("aut", "int", "set_pos_int", 1, True),
|
|
513
|
+
("op", "man", "set_pos_man", 1, True),
|
|
514
|
+
("aut", "man", "set_pos_man", 1, True),
|
|
515
|
+
("op", "int", "set_pos_int", 1, False),
|
|
516
|
+
("aut", "int", "set_pos_int", 1, False),
|
|
517
|
+
("op", "man", "set_pos_man", 1, False),
|
|
518
|
+
("aut", "man", "set_pos_man", 1, False),
|
|
519
|
+
("op", "int", "set_pos_int", 0, True),
|
|
520
|
+
("aut", "int", "set_pos_int", 0, True),
|
|
521
|
+
("op", "man", "set_pos_man", 0, True),
|
|
522
|
+
("aut", "man", "set_pos_man", 0, True),
|
|
523
|
+
("op", "int", "set_pos_int", 0, False),
|
|
524
|
+
("aut", "int", "set_pos_int", 0, False),
|
|
525
|
+
("op", "man", "set_pos_man", 0, False),
|
|
526
|
+
("aut", "man", "set_pos_man", 0, False),
|
|
527
|
+
]
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
@pytest.mark.parametrize(
|
|
531
|
+
"op_mode, src_mode, set_command, safe_pos, safe_pos_en", test_scenario_safe_pos_en
|
|
532
|
+
)
|
|
533
|
+
def test_safe_pos_en_true_interlock(
|
|
534
|
+
op_mode, src_mode, set_command, safe_pos, safe_pos_en
|
|
535
|
+
):
|
|
536
|
+
for command in [5, 7]:
|
|
537
|
+
ana_vlv = init_ana_vlv(
|
|
538
|
+
init_op_mode=op_mode,
|
|
539
|
+
init_src_mode=src_mode,
|
|
540
|
+
pos_fbk_calc=True,
|
|
541
|
+
safe_pos=safe_pos,
|
|
542
|
+
safe_pos_en=safe_pos_en,
|
|
543
|
+
intl_en=True,
|
|
544
|
+
)
|
|
545
|
+
ana_vlv.set_interlock(True) # interlock is inactive
|
|
546
|
+
if op_mode == "op": # open valve
|
|
547
|
+
ana_vlv.set_open_op(True)
|
|
548
|
+
elif op_mode == "aut":
|
|
549
|
+
ana_vlv.set_open_aut(True)
|
|
550
|
+
eval(f"ana_vlv.{set_command}({command})") # set legal position
|
|
551
|
+
ana_vlv.set_interlock(False) # active interlock after setting a position
|
|
552
|
+
print(
|
|
553
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, {command}, safe_pos: {safe_pos}, "
|
|
554
|
+
f"safe_pos_en: {safe_pos_en}"
|
|
555
|
+
)
|
|
556
|
+
|
|
557
|
+
# if safe_pos_en is true, valve should be to set to safety position (max or min) after interlock is
|
|
558
|
+
# activated
|
|
559
|
+
if safe_pos_en:
|
|
560
|
+
if safe_pos == 1:
|
|
561
|
+
assert ana_vlv.get_pos() == 10
|
|
562
|
+
assert ana_vlv.get_pos_fbk() == 10
|
|
563
|
+
elif safe_pos == 0:
|
|
564
|
+
assert ana_vlv.get_pos() == 2
|
|
565
|
+
assert ana_vlv.get_pos_fbk() == 2
|
|
566
|
+
|
|
567
|
+
# if safe_pos_en is false, current valve position should be hold after interlock is activated
|
|
568
|
+
else:
|
|
569
|
+
assert ana_vlv.get_pos() == command
|
|
570
|
+
assert ana_vlv.get_pos_fbk() == command
|
|
571
|
+
|
|
572
|
+
# try to set new value (6) for position, after interlock is activated again, the position should not be
|
|
573
|
+
# changed
|
|
574
|
+
eval(f"ana_vlv.{set_command}(6)") # set legal position
|
|
575
|
+
print(
|
|
576
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, 6, safe_pos: {safe_pos}, "
|
|
577
|
+
f"safe_pos_en: {safe_pos_en}, safe_pos_act: True"
|
|
578
|
+
)
|
|
579
|
+
if safe_pos_en:
|
|
580
|
+
if safe_pos == 1:
|
|
581
|
+
assert ana_vlv.get_pos() == 10
|
|
582
|
+
assert ana_vlv.get_pos_fbk() == 10
|
|
583
|
+
elif safe_pos == 0:
|
|
584
|
+
assert ana_vlv.get_pos() == 2
|
|
585
|
+
assert ana_vlv.get_pos_fbk() == 2
|
|
586
|
+
|
|
587
|
+
else:
|
|
588
|
+
assert ana_vlv.get_pos() == command
|
|
589
|
+
assert ana_vlv.get_pos_fbk() == command
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
@pytest.mark.parametrize(
|
|
593
|
+
"op_mode, src_mode, set_command, safe_pos, safe_pos_en", test_scenario_safe_pos_en
|
|
594
|
+
)
|
|
595
|
+
def test_safe_pos_en_true_protect(
|
|
596
|
+
op_mode, src_mode, set_command, safe_pos, safe_pos_en
|
|
597
|
+
):
|
|
598
|
+
for command in [5, 7]:
|
|
599
|
+
ana_vlv = init_ana_vlv(
|
|
600
|
+
init_op_mode=op_mode,
|
|
601
|
+
init_src_mode=src_mode,
|
|
602
|
+
pos_fbk_calc=True,
|
|
603
|
+
safe_pos=safe_pos,
|
|
604
|
+
safe_pos_en=safe_pos_en,
|
|
605
|
+
prot_en=True,
|
|
606
|
+
)
|
|
607
|
+
ana_vlv.set_protect(True) # protect lock is inactive
|
|
608
|
+
if op_mode == "op": # open valve
|
|
609
|
+
ana_vlv.set_open_op(True)
|
|
610
|
+
elif op_mode == "aut":
|
|
611
|
+
ana_vlv.set_open_aut(True)
|
|
612
|
+
eval(f"ana_vlv.{set_command}({command})") # set legal position
|
|
613
|
+
ana_vlv.set_protect(False) # active protect lock after setting a position
|
|
614
|
+
print(
|
|
615
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, {command}, safe_pos: {safe_pos}, "
|
|
616
|
+
f"safe_pos_en: {safe_pos_en}"
|
|
617
|
+
)
|
|
618
|
+
|
|
619
|
+
# if safe_pos_en is true, valve should be to set to safety position (max or min) after protect lock is
|
|
620
|
+
# activated
|
|
621
|
+
if safe_pos_en:
|
|
622
|
+
if safe_pos == 1:
|
|
623
|
+
assert ana_vlv.get_pos() == 10
|
|
624
|
+
assert ana_vlv.get_pos_fbk() == 10
|
|
625
|
+
elif safe_pos == 0:
|
|
626
|
+
assert ana_vlv.get_pos() == 2
|
|
627
|
+
assert ana_vlv.get_pos_fbk() == 2
|
|
628
|
+
|
|
629
|
+
# if safe_pos_en is false, current valve position should be hold after protect lock is activated
|
|
630
|
+
else:
|
|
631
|
+
assert ana_vlv.get_pos() == command
|
|
632
|
+
assert ana_vlv.get_pos_fbk() == command
|
|
633
|
+
|
|
634
|
+
# try to set new value (6) for position, after protect lock is activated again, the position should not be
|
|
635
|
+
# changed
|
|
636
|
+
eval(f"ana_vlv.{set_command}(6)") # set legal position
|
|
637
|
+
print(
|
|
638
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, 6, safe_pos: {safe_pos}, "
|
|
639
|
+
f"safe_pos_en: {safe_pos_en}, safe_pos_act: True"
|
|
640
|
+
)
|
|
641
|
+
if safe_pos_en:
|
|
642
|
+
if safe_pos == 1:
|
|
643
|
+
assert ana_vlv.get_pos() == 10
|
|
644
|
+
assert ana_vlv.get_pos_fbk() == 10
|
|
645
|
+
elif safe_pos == 0:
|
|
646
|
+
assert ana_vlv.get_pos() == 2
|
|
647
|
+
assert ana_vlv.get_pos_fbk() == 2
|
|
648
|
+
|
|
649
|
+
else:
|
|
650
|
+
assert ana_vlv.get_pos() == command
|
|
651
|
+
assert ana_vlv.get_pos_fbk() == command
|
|
652
|
+
|
|
653
|
+
|
|
654
|
+
@pytest.mark.parametrize(
|
|
655
|
+
"op_mode, src_mode, set_command, safe_pos, safe_pos_en", test_scenario_safe_pos_en
|
|
656
|
+
)
|
|
657
|
+
def test_safe_pos_en_true_permit(op_mode, src_mode, set_command, safe_pos, safe_pos_en):
|
|
658
|
+
for command in [5, 7]:
|
|
659
|
+
ana_vlv = init_ana_vlv(
|
|
660
|
+
init_op_mode=op_mode,
|
|
661
|
+
init_src_mode=src_mode,
|
|
662
|
+
pos_fbk_calc=True,
|
|
663
|
+
safe_pos=safe_pos,
|
|
664
|
+
safe_pos_en=safe_pos_en,
|
|
665
|
+
perm_en=True,
|
|
666
|
+
)
|
|
667
|
+
ana_vlv.set_permit(True) # permit lock is inactive
|
|
668
|
+
if op_mode == "op": # open valve
|
|
669
|
+
ana_vlv.set_open_op(True)
|
|
670
|
+
elif op_mode == "aut":
|
|
671
|
+
ana_vlv.set_open_aut(True)
|
|
672
|
+
eval(f"ana_vlv.{set_command}({command})") # set legal position
|
|
673
|
+
ana_vlv.set_permit(False) # active permit lock after setting a position
|
|
674
|
+
print(
|
|
675
|
+
f"Scenario: mode {op_mode} {src_mode}, {set_command}, {command}, safe_pos: {safe_pos}, "
|
|
676
|
+
f"safe_pos_en: {safe_pos_en}"
|
|
677
|
+
)
|
|
678
|
+
|
|
679
|
+
# activated DataAssembly in the locked state (permit mode) is not set to the safe position
|
|
680
|
+
assert ana_vlv.get_pos() == command
|
|
681
|
+
assert ana_vlv.get_pos_fbk() == command
|
|
682
|
+
|
|
683
|
+
# try to set new position after permit is activated, position should not be changed
|
|
684
|
+
eval(f"ana_vlv.{set_command}(6)")
|
|
685
|
+
assert ana_vlv.get_pos() == command
|
|
686
|
+
assert ana_vlv.get_pos_fbk() == command
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
@pytest.mark.parametrize("pos", [-2, 2, 5, 10, 100])
|
|
690
|
+
def test_pos_rbk(pos):
|
|
691
|
+
ana_vlv = init_ana_vlv()
|
|
692
|
+
ana_vlv.set_pos_rbk(pos)
|
|
693
|
+
|
|
694
|
+
if 2 <= pos <= 10:
|
|
695
|
+
assert ana_vlv.get_pos_rbk() == pos
|
|
696
|
+
elif pos < 2:
|
|
697
|
+
assert ana_vlv.get_pos_rbk() == 2
|
|
698
|
+
elif pos > 10:
|
|
699
|
+
assert ana_vlv.get_pos_rbk() == 10
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
@pytest.mark.parametrize("pos", [-2, 2, 5, 10, 100])
|
|
703
|
+
def test_pos_fbk(pos):
|
|
704
|
+
for fbk_calc in [False, True]:
|
|
705
|
+
ana_vlv = init_ana_vlv(pos_fbk_calc=fbk_calc)
|
|
706
|
+
ana_vlv.set_pos_fbk(pos)
|
|
707
|
+
if not fbk_calc:
|
|
708
|
+
if 2 <= pos <= 10:
|
|
709
|
+
assert ana_vlv.get_pos_fbk() == pos
|
|
710
|
+
elif pos < 2:
|
|
711
|
+
assert ana_vlv.get_pos_fbk() == 2
|
|
712
|
+
elif pos > 10:
|
|
713
|
+
assert ana_vlv.get_pos_fbk() == 10
|
|
714
|
+
|
|
715
|
+
|
|
716
|
+
def test_open_fbk():
|
|
717
|
+
ana_vlv = init_ana_vlv(open_fbk_calc=False, close_fbk_calc=False)
|
|
718
|
+
assert ana_vlv.get_open_fbk() == False
|
|
719
|
+
ana_vlv.set_open_fbk(True)
|
|
720
|
+
assert ana_vlv.get_open_fbk() == True
|
|
721
|
+
|
|
722
|
+
|
|
723
|
+
def test_close_fbk():
|
|
724
|
+
ana_vlv = init_ana_vlv(open_fbk_calc=False, close_fbk_calc=False)
|
|
725
|
+
assert ana_vlv.get_close_fbk() == False
|
|
726
|
+
ana_vlv.set_close_fbk(True)
|
|
727
|
+
assert ana_vlv.get_close_fbk() == True
|
|
728
|
+
|
|
729
|
+
|
|
730
|
+
if __name__ == "__main__":
|
|
731
|
+
# This allows running the tests directly if needed
|
|
732
|
+
pytest.main([__file__, "-v"])
|