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,246 @@
|
|
|
1
|
+
"""Test suite for ParameterElement."""
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from mtppy.part4.automation_services.base_functions.service_operation_mode import (
|
|
6
|
+
ServiceOperationMode,
|
|
7
|
+
)
|
|
8
|
+
from mtppy.part4.automation_services.base_functions.service_source_mode import (
|
|
9
|
+
ServiceSourceMode,
|
|
10
|
+
)
|
|
11
|
+
from mtppy.part4.automation_services.service_elements.parameter_elements.common_serv_param import (
|
|
12
|
+
SERVICE_PARAM_BASE_DATA_ITEMS,
|
|
13
|
+
)
|
|
14
|
+
from mtppy.part4.automation_services.service_elements.parameter_elements.parameter_element import (
|
|
15
|
+
ParameterElement,
|
|
16
|
+
)
|
|
17
|
+
from mtppy.part5.definitions.w3c_xml_data_types import W3cXmlDataTypes
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class TestParameterElement(ParameterElement):
|
|
21
|
+
CLASS_DATA_ITEMS = (
|
|
22
|
+
ParameterElement.CLASS_DATA_ITEMS
|
|
23
|
+
| SERVICE_PARAM_BASE_DATA_ITEMS(W3cXmlDataTypes.STRING)
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def create_parameter():
|
|
28
|
+
return TestParameterElement("TestParameter", "Test description")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def test_initialization():
|
|
32
|
+
parameter = create_parameter()
|
|
33
|
+
|
|
34
|
+
assert parameter.tag_name == "TestParameter"
|
|
35
|
+
assert parameter.tag_description == "Test description"
|
|
36
|
+
assert parameter.mtpObjectType.endswith("ParameterElement")
|
|
37
|
+
assert parameter[ParameterElement.APPLY_EN] is True
|
|
38
|
+
assert parameter[ParameterElement.APPLY_EXT] is False
|
|
39
|
+
assert parameter[ParameterElement.APPLY_OP] is False
|
|
40
|
+
assert parameter[ParameterElement.APPLY_INT] is False
|
|
41
|
+
assert parameter[ParameterElement.SYNC_] is False
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def test_set_apply_en_and_sync():
|
|
45
|
+
parameter = create_parameter()
|
|
46
|
+
|
|
47
|
+
parameter.set_apply_en(False)
|
|
48
|
+
parameter.set_sync(True)
|
|
49
|
+
|
|
50
|
+
assert parameter[ParameterElement.APPLY_EN] is False
|
|
51
|
+
assert parameter[ParameterElement.SYNC_] is True
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@pytest.mark.parametrize(
|
|
55
|
+
("method_name", "operation_mode", "source_mode"),
|
|
56
|
+
[
|
|
57
|
+
(
|
|
58
|
+
"apply_op",
|
|
59
|
+
ServiceOperationMode.STATE_OP_ACT,
|
|
60
|
+
None,
|
|
61
|
+
),
|
|
62
|
+
(
|
|
63
|
+
"apply_int",
|
|
64
|
+
ServiceOperationMode.STATE_AUT_ACT,
|
|
65
|
+
ServiceSourceMode.SRC_INT_ACT,
|
|
66
|
+
),
|
|
67
|
+
(
|
|
68
|
+
"apply_ext",
|
|
69
|
+
ServiceOperationMode.STATE_AUT_ACT,
|
|
70
|
+
ServiceSourceMode.SRC_EXT_ACT,
|
|
71
|
+
),
|
|
72
|
+
],
|
|
73
|
+
)
|
|
74
|
+
def test_apply_callbacks_update_when_mode_matches(
|
|
75
|
+
monkeypatch, method_name, operation_mode, source_mode
|
|
76
|
+
):
|
|
77
|
+
parameter = create_parameter()
|
|
78
|
+
update_calls = []
|
|
79
|
+
monkeypatch.setattr(parameter, "update_v_out", lambda: update_calls.append(True))
|
|
80
|
+
parameter.service_op_mode[operation_mode] = True
|
|
81
|
+
if source_mode is not None:
|
|
82
|
+
parameter.service_src_mode[source_mode] = True
|
|
83
|
+
|
|
84
|
+
getattr(parameter, method_name)(True)
|
|
85
|
+
|
|
86
|
+
assert update_calls == [True]
|
|
87
|
+
apply_item = {
|
|
88
|
+
"apply_op": ParameterElement.APPLY_OP,
|
|
89
|
+
"apply_int": ParameterElement.APPLY_INT,
|
|
90
|
+
"apply_ext": ParameterElement.APPLY_EXT,
|
|
91
|
+
}[method_name]
|
|
92
|
+
assert parameter[apply_item] is False
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
@pytest.mark.parametrize(
|
|
96
|
+
("method_name", "operation_mode", "source_mode"),
|
|
97
|
+
[
|
|
98
|
+
("apply_op", ServiceOperationMode.STATE_OP_ACT, None),
|
|
99
|
+
(
|
|
100
|
+
"apply_int",
|
|
101
|
+
ServiceOperationMode.STATE_AUT_ACT,
|
|
102
|
+
ServiceSourceMode.SRC_INT_ACT,
|
|
103
|
+
),
|
|
104
|
+
(
|
|
105
|
+
"apply_ext",
|
|
106
|
+
ServiceOperationMode.STATE_AUT_ACT,
|
|
107
|
+
ServiceSourceMode.SRC_EXT_ACT,
|
|
108
|
+
),
|
|
109
|
+
],
|
|
110
|
+
)
|
|
111
|
+
def test_apply_callbacks_reset_without_matching_request(
|
|
112
|
+
monkeypatch, method_name, operation_mode, source_mode
|
|
113
|
+
):
|
|
114
|
+
parameter = create_parameter()
|
|
115
|
+
update_calls = []
|
|
116
|
+
monkeypatch.setattr(parameter, "update_v_out", lambda: update_calls.append(True))
|
|
117
|
+
parameter.service_op_mode[operation_mode] = False
|
|
118
|
+
if source_mode is not None:
|
|
119
|
+
parameter.service_src_mode[source_mode] = False
|
|
120
|
+
|
|
121
|
+
getattr(parameter, method_name)(False)
|
|
122
|
+
|
|
123
|
+
assert update_calls == []
|
|
124
|
+
assert (
|
|
125
|
+
parameter[
|
|
126
|
+
{
|
|
127
|
+
"apply_op": ParameterElement.APPLY_OP,
|
|
128
|
+
"apply_int": ParameterElement.APPLY_INT,
|
|
129
|
+
"apply_ext": ParameterElement.APPLY_EXT,
|
|
130
|
+
}[method_name]
|
|
131
|
+
]
|
|
132
|
+
is False
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def test_update_v_req_prefers_operator_mode():
|
|
137
|
+
parameter = create_parameter()
|
|
138
|
+
parameter["VOp"] = "operator"
|
|
139
|
+
parameter["VInt"] = "internal"
|
|
140
|
+
parameter["VExt"] = "external"
|
|
141
|
+
parameter.service_op_mode[ServiceOperationMode.STATE_OP_ACT] = True
|
|
142
|
+
parameter.service_op_mode[ServiceOperationMode.STATE_AUT_ACT] = True
|
|
143
|
+
parameter.service_src_mode[ServiceSourceMode.SRC_INT_ACT] = True
|
|
144
|
+
parameter.service_src_mode[ServiceSourceMode.SRC_EXT_ACT] = True
|
|
145
|
+
|
|
146
|
+
parameter.update_v_req()
|
|
147
|
+
|
|
148
|
+
assert parameter["VReq"] == "operator"
|
|
149
|
+
assert parameter["VFbk"] == "operator"
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
@pytest.mark.parametrize(
|
|
153
|
+
("source_mode", "expected"),
|
|
154
|
+
[
|
|
155
|
+
(ServiceSourceMode.SRC_INT_ACT, "internal"),
|
|
156
|
+
(ServiceSourceMode.SRC_EXT_ACT, "external"),
|
|
157
|
+
],
|
|
158
|
+
)
|
|
159
|
+
def test_update_v_req_uses_active_automatic_source(source_mode, expected):
|
|
160
|
+
parameter = create_parameter()
|
|
161
|
+
parameter["VInt"] = "internal"
|
|
162
|
+
parameter["VExt"] = "external"
|
|
163
|
+
parameter.service_op_mode[ServiceOperationMode.STATE_AUT_ACT] = True
|
|
164
|
+
parameter.service_src_mode[source_mode] = True
|
|
165
|
+
|
|
166
|
+
parameter.update_v_req()
|
|
167
|
+
|
|
168
|
+
assert parameter["VReq"] == expected
|
|
169
|
+
assert parameter["VFbk"] == expected
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def test_update_v_out_and_get_v_out():
|
|
173
|
+
parameter = create_parameter()
|
|
174
|
+
parameter["VOp"] = "requested"
|
|
175
|
+
parameter.service_op_mode[ServiceOperationMode.STATE_OP_ACT] = True
|
|
176
|
+
|
|
177
|
+
parameter.update_v_out()
|
|
178
|
+
|
|
179
|
+
assert parameter.get_v_out() == "requested"
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def test_update_v_req_without_active_mode_only_updates_feedback():
|
|
183
|
+
parameter = create_parameter()
|
|
184
|
+
parameter["VReq"] = "unchanged"
|
|
185
|
+
|
|
186
|
+
parameter.update_v_req()
|
|
187
|
+
|
|
188
|
+
assert parameter["VReq"] == "unchanged"
|
|
189
|
+
assert parameter["VFbk"] == "unchanged"
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def test_set_v_fbk_updates_feedback_value():
|
|
193
|
+
parameter = create_parameter()
|
|
194
|
+
|
|
195
|
+
parameter.set_v_fbk("feedback")
|
|
196
|
+
|
|
197
|
+
assert parameter["VFbk"] == "feedback"
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
@pytest.mark.parametrize(
|
|
201
|
+
("method_name", "value", "apply_item"),
|
|
202
|
+
[
|
|
203
|
+
("apply_op", False, ParameterElement.APPLY_OP),
|
|
204
|
+
("apply_int", False, ParameterElement.APPLY_INT),
|
|
205
|
+
("apply_ext", False, ParameterElement.APPLY_EXT),
|
|
206
|
+
],
|
|
207
|
+
)
|
|
208
|
+
def test_apply_callbacks_reset_false_requests(method_name, value, apply_item):
|
|
209
|
+
parameter = create_parameter()
|
|
210
|
+
|
|
211
|
+
getattr(parameter, method_name)(value)
|
|
212
|
+
|
|
213
|
+
assert parameter[apply_item] is False
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
@pytest.mark.parametrize("method_name", ["set_v_op", "set_v_int", "set_v_ext"])
|
|
217
|
+
def test_set_values_ignores_invalid_values(monkeypatch, method_name):
|
|
218
|
+
parameter = create_parameter()
|
|
219
|
+
monkeypatch.setattr(parameter, "is_valid_value", lambda value: False)
|
|
220
|
+
value_item = {
|
|
221
|
+
"set_v_op": "VOp",
|
|
222
|
+
"set_v_int": "VInt",
|
|
223
|
+
"set_v_ext": "VExt",
|
|
224
|
+
}[method_name]
|
|
225
|
+
initial_values = {
|
|
226
|
+
"set_v_op": parameter["VOp"],
|
|
227
|
+
"set_v_int": parameter["VInt"],
|
|
228
|
+
"set_v_ext": parameter["VExt"],
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
getattr(parameter, method_name)("invalid")
|
|
232
|
+
|
|
233
|
+
assert parameter[value_item] == initial_values[method_name]
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
def test_set_values_and_default_validation():
|
|
237
|
+
parameter = create_parameter()
|
|
238
|
+
|
|
239
|
+
parameter.set_v_op("operator")
|
|
240
|
+
parameter.set_v_int("internal")
|
|
241
|
+
parameter.set_v_ext("external")
|
|
242
|
+
|
|
243
|
+
assert parameter["VOp"] == "operator"
|
|
244
|
+
assert parameter["VInt"] == "internal"
|
|
245
|
+
assert parameter["VExt"] == "external"
|
|
246
|
+
assert parameter.is_valid_value(object()) is True
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""Implementation of the String Service Parameter."""
|
|
2
|
+
|
|
3
|
+
__copyright__ = (
|
|
4
|
+
"Copyright (c) 2026 Dresden University of Technology, Process-to-Order Group"
|
|
5
|
+
)
|
|
6
|
+
__license__ = "MIT"
|
|
7
|
+
|
|
8
|
+
from typing import ClassVar
|
|
9
|
+
|
|
10
|
+
from mtppy.part5.definitions.w3c_xml_data_types import W3cXmlDataTypes
|
|
11
|
+
from mtppy.part4.automation_services.service_elements.parameter_elements.common_serv_param import (
|
|
12
|
+
SERVICE_PARAM_BASE_DATA_ITEMS,
|
|
13
|
+
CommonServParameter,
|
|
14
|
+
)
|
|
15
|
+
from mtppy.part4.automation_services.service_elements.parameter_elements.parameter_element import ParameterElement
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class StringServParam(ParameterElement):
|
|
19
|
+
"""String Service Parameter implementation.
|
|
20
|
+
|
|
21
|
+
This class implements string service parameters for service elements. It
|
|
22
|
+
inherits from ParameterElement and provides string-specific functionality
|
|
23
|
+
for parameter handling with appropriate data types.
|
|
24
|
+
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
CLASS_DATA_ITEMS: ClassVar = SERVICE_PARAM_BASE_DATA_ITEMS(W3cXmlDataTypes.STRING)
|
|
28
|
+
|
|
29
|
+
def __init__(self, tag_name: str, tag_description: str = "") -> None:
|
|
30
|
+
"""Initialize String Service Parameter (StringServParam).
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
tag_name: The name identifier for the parameter element
|
|
34
|
+
tag_description: A descriptive text for the parameter element
|
|
35
|
+
"""
|
|
36
|
+
super().__init__(tag_name, tag_description)
|
|
37
|
+
self.mtpObjectType = "MTPDataAssemblySUCLib/DataAssembly/ServiceElement/\
|
|
38
|
+
ParameterElement/StringServParam"
|
|
39
|
+
|
|
40
|
+
self.get_item(CommonServParameter.V_OP).init_value = ""
|
|
41
|
+
self.get_item(CommonServParameter.V_INT).init_value = ""
|
|
42
|
+
self.get_item(CommonServParameter.V_EXT).init_value = ""
|
|
43
|
+
self.get_item(CommonServParameter.V_REQ).init_value = ""
|
|
44
|
+
self.get_item(CommonServParameter.V_OUT).init_value = ""
|
|
45
|
+
self.get_item(CommonServParameter.V_FBK).init_value = ""
|
|
46
|
+
|
|
47
|
+
self.get_item(CommonServParameter.V_OP).ext_wrt_cb = self.set_v_op
|
|
48
|
+
self.get_item(CommonServParameter.V_EXT).ext_wrt_cb = self.set_v_ext
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""Test suite for StringServParam."""
|
|
2
|
+
|
|
3
|
+
from mtppy.part4.automation_services.service_elements.parameter_elements.common_serv_param import (
|
|
4
|
+
CommonServParameter as CSP,
|
|
5
|
+
)
|
|
6
|
+
from mtppy.part4.automation_services.service_elements.parameter_elements.string_serv_param import (
|
|
7
|
+
StringServParam,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def test_initialization_sets_string_values_to_empty():
|
|
12
|
+
parameter = StringServParam("RecipeName", "Recipe name")
|
|
13
|
+
|
|
14
|
+
assert parameter.tag_name == "RecipeName"
|
|
15
|
+
assert parameter.tag_description == "Recipe name"
|
|
16
|
+
assert parameter.get_item(CSP.V_OP).init_value == ""
|
|
17
|
+
assert parameter.get_item(CSP.V_INT).init_value == ""
|
|
18
|
+
assert parameter.get_item(CSP.V_EXT).init_value == ""
|
|
19
|
+
assert parameter.get_item(CSP.V_REQ).init_value == ""
|
|
20
|
+
assert parameter.get_item(CSP.V_OUT).init_value == ""
|
|
21
|
+
assert parameter.get_item(CSP.V_FBK).init_value == ""
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def test_set_v_op_accepts_string_value():
|
|
25
|
+
parameter = StringServParam("RecipeName")
|
|
26
|
+
|
|
27
|
+
parameter.set_v_op("Recipe A")
|
|
28
|
+
|
|
29
|
+
assert parameter[CSP.V_OP] == "Recipe A"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def test_set_v_ext_accepts_string_value():
|
|
33
|
+
parameter = StringServParam("RecipeName")
|
|
34
|
+
|
|
35
|
+
parameter.set_v_ext("Recipe B")
|
|
36
|
+
|
|
37
|
+
assert parameter[CSP.V_EXT] == "Recipe B"
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""View on procedure health."""
|
|
2
|
+
|
|
3
|
+
__copyright__ = (
|
|
4
|
+
"Copyright (c) 2026 Dresden University of Technology, Process-to-Order Group"
|
|
5
|
+
)
|
|
6
|
+
__license__ = "MIT"
|
|
7
|
+
|
|
8
|
+
from mtppy.utils.data_item import DataItem
|
|
9
|
+
from mtppy.part3.definitions.mtp_access import MTPAccess
|
|
10
|
+
from mtppy.part5.definitions.w3c_xml_data_types import W3cXmlDataTypes
|
|
11
|
+
from mtppy.part4.automation_services.service_elements.service_element import ServiceElement
|
|
12
|
+
from typing import ClassVar
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ProcedureHealthView(ServiceElement):
|
|
16
|
+
# DataItem constant definitions
|
|
17
|
+
COMMAND_INFO = "CommandInfo"
|
|
18
|
+
|
|
19
|
+
# Class-level data items dictionary
|
|
20
|
+
CLASS_DATA_ITEMS: ClassVar = {
|
|
21
|
+
COMMAND_INFO: DataItem(
|
|
22
|
+
COMMAND_INFO, W3cXmlDataTypes.UNSIGNED_SHORT, MTPAccess.ReadAccess, 0
|
|
23
|
+
),
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
def __init__(self, tag_name: str, tag_description: str):
|
|
27
|
+
super().__init__(tag_name, tag_description)
|
|
28
|
+
self.mtpObjectType = (
|
|
29
|
+
"MTPDataAssemblySUCLib/DataAssembly/ServiceElement/ProcedureHealthView"
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
# Initialize data items with dynamic values (using class-defined data items)
|
|
33
|
+
self[ProcedureHealthView.COMMAND_INFO] = 0
|
|
34
|
+
|
|
35
|
+
def set_command_info(self, value):
|
|
36
|
+
self[ProcedureHealthView.COMMAND_INFO] = value
|