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,108 @@
|
|
|
1
|
+
"""Implementation of the AnaServ Parameters."""
|
|
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.parameter_element import (
|
|
12
|
+
ParameterElement,
|
|
13
|
+
)
|
|
14
|
+
from mtppy.part4.automation_services.service_elements.parameter_elements.common_serv_param import (
|
|
15
|
+
SERVICE_PARAM_BASE_DATA_ITEMS,
|
|
16
|
+
SERVICE_PARAM_NUMBER_DATA_ITEMS,
|
|
17
|
+
SERVICE_PARAM_SYNC_DATA_ITEMS,
|
|
18
|
+
CommonServParameter,
|
|
19
|
+
)
|
|
20
|
+
from mtppy.utils.logging import logger
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class AnaServParam(ParameterElement):
|
|
24
|
+
"""Analog Service Parameter implementation.
|
|
25
|
+
|
|
26
|
+
This class implements analog service parameters for service elements,
|
|
27
|
+
inheriting from ParameterElement. It provides configurable boundaries (VMin, VMax)
|
|
28
|
+
along with scaling parameters (VSclMin, VSclMax) for e.g. display purposes.
|
|
29
|
+
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
CLASS_DATA_ITEMS: ClassVar = (
|
|
33
|
+
SERVICE_PARAM_BASE_DATA_ITEMS(W3cXmlDataTypes.FLOAT)
|
|
34
|
+
| SERVICE_PARAM_NUMBER_DATA_ITEMS(W3cXmlDataTypes.FLOAT)
|
|
35
|
+
| SERVICE_PARAM_SYNC_DATA_ITEMS
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
v_min: float
|
|
39
|
+
v_max: float
|
|
40
|
+
v_scl_min: float
|
|
41
|
+
v_scl_max: float
|
|
42
|
+
v_unit: int
|
|
43
|
+
|
|
44
|
+
def __init__(
|
|
45
|
+
self,
|
|
46
|
+
tag_name: str,
|
|
47
|
+
tag_description: str = "",
|
|
48
|
+
*,
|
|
49
|
+
v_min: float = 0,
|
|
50
|
+
v_max: float = 100,
|
|
51
|
+
v_scl_min: float = 0,
|
|
52
|
+
v_scl_max: float = 100,
|
|
53
|
+
v_unit: int = 0,
|
|
54
|
+
) -> None:
|
|
55
|
+
"""Initialize the Analog Service Parameter (AnaServParam).
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
tag_name: The name identifier for the parameter element
|
|
59
|
+
tag_description: A descriptive text for the parameter element
|
|
60
|
+
v_min: Minimum value for the analog parameter (enforced)
|
|
61
|
+
v_max: Maximum value for the analog parameter (enforced)
|
|
62
|
+
v_scl_min: Scaled minimum value for the analog parameter (informative)
|
|
63
|
+
v_scl_max: Scaled maximum value for the analog parameter (informative)
|
|
64
|
+
v_unit: Unit identifier for the analog parameter
|
|
65
|
+
"""
|
|
66
|
+
super().__init__(tag_name, tag_description)
|
|
67
|
+
self.mtpObjectType = "MTPDataAssemblySUCLib/DataAssembly/ServiceElement/\
|
|
68
|
+
ParameterElement/AnaServParam"
|
|
69
|
+
|
|
70
|
+
self.v_min = v_min
|
|
71
|
+
self.v_max = v_max
|
|
72
|
+
self.v_scl_min = v_scl_min
|
|
73
|
+
self.v_scl_max = v_scl_max
|
|
74
|
+
self.v_unit = v_unit
|
|
75
|
+
|
|
76
|
+
# Initialize data items with dynamic values
|
|
77
|
+
self.get_item(CommonServParameter.V_OP).init_value = v_min
|
|
78
|
+
self.get_item(CommonServParameter.V_INT).init_value = v_min
|
|
79
|
+
self.get_item(CommonServParameter.V_EXT).init_value = v_min
|
|
80
|
+
self.get_item(CommonServParameter.V_REQ).init_value = v_min
|
|
81
|
+
self.get_item(CommonServParameter.V_UNIT).init_value = self.v_unit
|
|
82
|
+
self.get_item(CommonServParameter.V_SCL_MIN).init_value = self.v_scl_min
|
|
83
|
+
self.get_item(CommonServParameter.V_SCL_MAX).init_value = self.v_scl_max
|
|
84
|
+
self.get_item(CommonServParameter.V_MIN).init_value = self.v_min
|
|
85
|
+
self.get_item(CommonServParameter.V_MAX).init_value = self.v_max
|
|
86
|
+
|
|
87
|
+
self.get_item(CommonServParameter.V_OP).ext_wrt_cb = self.set_v_op
|
|
88
|
+
self.get_item(CommonServParameter.V_EXT).ext_wrt_cb = self.set_v_ext
|
|
89
|
+
|
|
90
|
+
self.get_item(CommonServParameter.V_INT).int_wrt_cb = self.set_v_int
|
|
91
|
+
|
|
92
|
+
def is_valid_value(self, value: float) -> bool:
|
|
93
|
+
"""Check if a value is within the valid range for this parameter.
|
|
94
|
+
|
|
95
|
+
Logs information about the validation process and returns whether
|
|
96
|
+
the provided value is within the defined minimum and maximum bounds.
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
value: The value to validate
|
|
100
|
+
|
|
101
|
+
Returns:
|
|
102
|
+
bool: True if the value is within range, False otherwise
|
|
103
|
+
"""
|
|
104
|
+
logger.info(f"AnaServ {value} in [{self.v_min},{self.v_max}]?")
|
|
105
|
+
if value < self.v_min or value > self.v_max:
|
|
106
|
+
logger.debug(f"{self.tag_name} invalid value, {value} (out of range)")
|
|
107
|
+
return False
|
|
108
|
+
return True
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"""Test suite for AnaServParam."""
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from mtppy.part4.automation_services.service_elements.parameter_elements.ana_serv_param import (
|
|
6
|
+
AnaServParam,
|
|
7
|
+
)
|
|
8
|
+
from mtppy.part4.automation_services.service_elements.parameter_elements.common_serv_param import (
|
|
9
|
+
CommonServParameter as CSP,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def test_initialization_sets_numeric_metadata_and_values():
|
|
14
|
+
parameter = AnaServParam(
|
|
15
|
+
"Temperature",
|
|
16
|
+
"Temperature setpoint",
|
|
17
|
+
v_min=-10.5,
|
|
18
|
+
v_max=80.5,
|
|
19
|
+
v_scl_min=0,
|
|
20
|
+
v_scl_max=100,
|
|
21
|
+
v_unit=1001,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
assert parameter.tag_name == "Temperature"
|
|
25
|
+
assert parameter.tag_description == "Temperature setpoint"
|
|
26
|
+
assert parameter.v_min == -10.5
|
|
27
|
+
assert parameter.v_max == 80.5
|
|
28
|
+
assert parameter.v_unit == 1001
|
|
29
|
+
assert parameter.get_item(CSP.V_MIN).init_value == -10.5
|
|
30
|
+
assert parameter.get_item(CSP.V_MAX).init_value == 80.5
|
|
31
|
+
assert parameter.get_item(CSP.V_UNIT).init_value == 1001
|
|
32
|
+
assert parameter.get_item(CSP.V_OP).init_value == -10.5
|
|
33
|
+
assert parameter.get_item(CSP.V_EXT).init_value == -10.5
|
|
34
|
+
assert parameter.get_item(CSP.V_INT).init_value == -10.5
|
|
35
|
+
assert parameter.get_item(CSP.V_REQ).init_value == -10.5
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@pytest.mark.parametrize("value", [-10.5, 0, 80.5])
|
|
39
|
+
def test_valid_values_include_boundaries(value):
|
|
40
|
+
parameter = AnaServParam("Temperature", v_min=-10.5, v_max=80.5)
|
|
41
|
+
|
|
42
|
+
assert parameter.is_valid_value(value) is True
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@pytest.mark.parametrize("value", [-10.6, 80.6])
|
|
46
|
+
def test_values_outside_range_are_invalid(value):
|
|
47
|
+
parameter = AnaServParam("Temperature", v_min=-10.5, v_max=80.5)
|
|
48
|
+
|
|
49
|
+
assert parameter.is_valid_value(value) is False
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def test_set_v_op_accepts_valid_value_and_rejects_invalid_value():
|
|
53
|
+
parameter = AnaServParam("Temperature", v_min=0, v_max=100)
|
|
54
|
+
|
|
55
|
+
parameter.set_v_op(42)
|
|
56
|
+
assert parameter[CSP.V_OP] == 42
|
|
57
|
+
|
|
58
|
+
parameter.set_v_op(101)
|
|
59
|
+
assert parameter[CSP.V_OP] == 42
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""Implementation of the Binary Service Parameters."""
|
|
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.utils.logging import logger
|
|
11
|
+
from mtppy.utils.data_item import DataItem
|
|
12
|
+
from mtppy.part3.definitions.mtp_access import MTPAccess
|
|
13
|
+
from mtppy.part5.definitions.w3c_xml_data_types import W3cXmlDataTypes
|
|
14
|
+
from mtppy.part4.automation_services.service_elements.parameter_elements.parameter_element import (
|
|
15
|
+
ParameterElement,
|
|
16
|
+
)
|
|
17
|
+
from mtppy.part4.automation_services.service_elements.parameter_elements.common_serv_param import (
|
|
18
|
+
CommonServParameter,
|
|
19
|
+
SERVICE_PARAM_BASE_DATA_ITEMS,
|
|
20
|
+
SERVICE_PARAM_SYNC_DATA_ITEMS,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class BinServParam(ParameterElement):
|
|
25
|
+
V_STATE_0 = "VState0"
|
|
26
|
+
V_STATE_1 = "VState1"
|
|
27
|
+
|
|
28
|
+
CLASS_DATA_ITEMS: ClassVar = (
|
|
29
|
+
SERVICE_PARAM_BASE_DATA_ITEMS(W3cXmlDataTypes.BOOLEAN)
|
|
30
|
+
| {
|
|
31
|
+
V_STATE_0: DataItem(
|
|
32
|
+
V_STATE_0,
|
|
33
|
+
W3cXmlDataTypes.STRING,
|
|
34
|
+
MTPAccess.ReadAccess,
|
|
35
|
+
init_value=None,
|
|
36
|
+
),
|
|
37
|
+
V_STATE_1: DataItem(
|
|
38
|
+
V_STATE_1,
|
|
39
|
+
W3cXmlDataTypes.STRING,
|
|
40
|
+
MTPAccess.ReadAccess,
|
|
41
|
+
init_value=None,
|
|
42
|
+
),
|
|
43
|
+
}
|
|
44
|
+
| SERVICE_PARAM_SYNC_DATA_ITEMS
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
v_state_0: str
|
|
48
|
+
v_state_1: str
|
|
49
|
+
|
|
50
|
+
def __init__(
|
|
51
|
+
self,
|
|
52
|
+
tag_name: str,
|
|
53
|
+
tag_description: str = "",
|
|
54
|
+
v_state_0: str = "false",
|
|
55
|
+
v_state_1: str = "true",
|
|
56
|
+
):
|
|
57
|
+
"""
|
|
58
|
+
Binary Service Parameter (BinServParam).
|
|
59
|
+
"""
|
|
60
|
+
super().__init__(tag_name, tag_description)
|
|
61
|
+
self.mtpObjectType = "MTPDataAssemblySUCLib/DataAssembly/ServiceElement/ParameterElement/BinServParam"
|
|
62
|
+
|
|
63
|
+
self.v_state_0 = v_state_0
|
|
64
|
+
self.v_state_1 = v_state_1
|
|
65
|
+
|
|
66
|
+
self.get_item(BinServParam.V_STATE_0).init_value = self.v_state_0
|
|
67
|
+
self.get_item(BinServParam.V_STATE_1).init_value = self.v_state_1
|
|
68
|
+
|
|
69
|
+
self.get_item(CommonServParameter.V_OP).ext_wrt_cb = self.set_v_op
|
|
70
|
+
self.get_item(CommonServParameter.V_EXT).ext_wrt_cb = self.set_v_ext
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""Test suite for BinServParam."""
|
|
2
|
+
|
|
3
|
+
from mtppy.part4.automation_services.service_elements.parameter_elements.bin_serv_param import (
|
|
4
|
+
BinServParam,
|
|
5
|
+
)
|
|
6
|
+
from mtppy.part4.automation_services.service_elements.parameter_elements.common_serv_param import (
|
|
7
|
+
CommonServParameter as CSP,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def test_initialization_sets_state_labels():
|
|
12
|
+
parameter = BinServParam(
|
|
13
|
+
"PumpEnabled",
|
|
14
|
+
"Pump enabled state",
|
|
15
|
+
v_state_0="Disabled",
|
|
16
|
+
v_state_1="Enabled",
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
assert parameter.tag_name == "PumpEnabled"
|
|
20
|
+
assert parameter.tag_description == "Pump enabled state"
|
|
21
|
+
assert parameter.v_state_0 == "Disabled"
|
|
22
|
+
assert parameter.v_state_1 == "Enabled"
|
|
23
|
+
assert parameter.get_item(BinServParam.V_STATE_0).init_value == "Disabled"
|
|
24
|
+
assert parameter.get_item(BinServParam.V_STATE_1).init_value == "Enabled"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def test_default_state_labels():
|
|
28
|
+
parameter = BinServParam("PumpEnabled")
|
|
29
|
+
|
|
30
|
+
assert parameter.get_item(BinServParam.V_STATE_0).init_value == "false"
|
|
31
|
+
assert parameter.get_item(BinServParam.V_STATE_1).init_value == "true"
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_set_v_op_updates_binary_value():
|
|
35
|
+
parameter = BinServParam("PumpEnabled")
|
|
36
|
+
|
|
37
|
+
parameter.set_v_op(True)
|
|
38
|
+
|
|
39
|
+
assert parameter[CSP.V_OP] is True
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"""Common Variables in service elements"""
|
|
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
|
+
|
|
12
|
+
|
|
13
|
+
class CommonServParameter:
|
|
14
|
+
V_OP = "VOp"
|
|
15
|
+
V_INT = "VInt"
|
|
16
|
+
V_EXT = "VExt"
|
|
17
|
+
V_REQ = "VReq"
|
|
18
|
+
V_OUT = "VOut"
|
|
19
|
+
V_FBK = "VFbk"
|
|
20
|
+
V_UNIT = "VUnit"
|
|
21
|
+
V_MIN = "VMin"
|
|
22
|
+
V_MAX = "VMax"
|
|
23
|
+
V_SCL_MIN = "VSclMin"
|
|
24
|
+
V_SCL_MAX = "VSclMax"
|
|
25
|
+
SYNC_ = "Sync"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def SERVICE_PARAM_BASE_DATA_ITEMS(datatype: W3cXmlDataTypes):
|
|
29
|
+
return {
|
|
30
|
+
CommonServParameter.V_OP: DataItem(
|
|
31
|
+
CommonServParameter.V_OP,
|
|
32
|
+
datatype,
|
|
33
|
+
MTPAccess.ReadWriteAccess,
|
|
34
|
+
init_value=0,
|
|
35
|
+
),
|
|
36
|
+
CommonServParameter.V_EXT: DataItem(
|
|
37
|
+
CommonServParameter.V_EXT,
|
|
38
|
+
datatype,
|
|
39
|
+
MTPAccess.ReadWriteAccess,
|
|
40
|
+
init_value=0,
|
|
41
|
+
),
|
|
42
|
+
CommonServParameter.V_INT: DataItem(
|
|
43
|
+
CommonServParameter.V_INT,
|
|
44
|
+
datatype,
|
|
45
|
+
MTPAccess.ReadAccess,
|
|
46
|
+
init_value=0,
|
|
47
|
+
),
|
|
48
|
+
CommonServParameter.V_REQ: DataItem(
|
|
49
|
+
CommonServParameter.V_REQ,
|
|
50
|
+
datatype,
|
|
51
|
+
MTPAccess.ReadAccess,
|
|
52
|
+
init_value=0,
|
|
53
|
+
),
|
|
54
|
+
CommonServParameter.V_OUT: DataItem(
|
|
55
|
+
CommonServParameter.V_OUT,
|
|
56
|
+
datatype,
|
|
57
|
+
MTPAccess.ReadAccess,
|
|
58
|
+
init_value=0,
|
|
59
|
+
),
|
|
60
|
+
CommonServParameter.V_FBK: DataItem(
|
|
61
|
+
CommonServParameter.V_FBK,
|
|
62
|
+
datatype,
|
|
63
|
+
MTPAccess.ReadAccess,
|
|
64
|
+
init_value=0,
|
|
65
|
+
),
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def SERVICE_PARAM_NUMBER_DATA_ITEMS(datatype: W3cXmlDataTypes):
|
|
70
|
+
return {
|
|
71
|
+
CommonServParameter.V_UNIT: DataItem(
|
|
72
|
+
CommonServParameter.V_UNIT,
|
|
73
|
+
W3cXmlDataTypes.SHORT,
|
|
74
|
+
MTPAccess.ReadAccess,
|
|
75
|
+
init_value=0,
|
|
76
|
+
),
|
|
77
|
+
CommonServParameter.V_MIN: DataItem(
|
|
78
|
+
CommonServParameter.V_MIN,
|
|
79
|
+
datatype,
|
|
80
|
+
MTPAccess.ReadAccess,
|
|
81
|
+
init_value=0,
|
|
82
|
+
),
|
|
83
|
+
CommonServParameter.V_MAX: DataItem(
|
|
84
|
+
CommonServParameter.V_MAX,
|
|
85
|
+
datatype,
|
|
86
|
+
MTPAccess.ReadAccess,
|
|
87
|
+
init_value=0,
|
|
88
|
+
),
|
|
89
|
+
CommonServParameter.V_SCL_MIN: DataItem(
|
|
90
|
+
CommonServParameter.V_SCL_MIN,
|
|
91
|
+
datatype,
|
|
92
|
+
MTPAccess.ReadAccess,
|
|
93
|
+
init_value=0,
|
|
94
|
+
),
|
|
95
|
+
CommonServParameter.V_SCL_MAX: DataItem(
|
|
96
|
+
CommonServParameter.V_SCL_MAX,
|
|
97
|
+
datatype,
|
|
98
|
+
MTPAccess.ReadAccess,
|
|
99
|
+
init_value=9,
|
|
100
|
+
),
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
SERVICE_PARAM_SYNC_DATA_ITEMS = {
|
|
105
|
+
CommonServParameter.SYNC_: DataItem(
|
|
106
|
+
CommonServParameter.SYNC_,
|
|
107
|
+
W3cXmlDataTypes.BOOLEAN,
|
|
108
|
+
MTPAccess.ReadAccess,
|
|
109
|
+
init_value=False,
|
|
110
|
+
),
|
|
111
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"""Implementation of the Integer Service Parameters."""
|
|
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.utils.logging import logger
|
|
11
|
+
from mtppy.part5.definitions.w3c_xml_data_types import W3cXmlDataTypes
|
|
12
|
+
from mtppy.part4.automation_services.service_elements.parameter_elements.parameter_element import (
|
|
13
|
+
ParameterElement,
|
|
14
|
+
)
|
|
15
|
+
from mtppy.part4.automation_services.service_elements.parameter_elements.common_serv_param import (
|
|
16
|
+
CommonServParameter,
|
|
17
|
+
SERVICE_PARAM_BASE_DATA_ITEMS,
|
|
18
|
+
SERVICE_PARAM_NUMBER_DATA_ITEMS,
|
|
19
|
+
SERVICE_PARAM_SYNC_DATA_ITEMS,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class DIntServParam(ParameterElement):
|
|
24
|
+
CLASS_DATA_ITEMS: ClassVar = (
|
|
25
|
+
SERVICE_PARAM_BASE_DATA_ITEMS(W3cXmlDataTypes.SHORT)
|
|
26
|
+
| SERVICE_PARAM_NUMBER_DATA_ITEMS(W3cXmlDataTypes.SHORT)
|
|
27
|
+
| SERVICE_PARAM_SYNC_DATA_ITEMS
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
v_min: int
|
|
31
|
+
v_max: int
|
|
32
|
+
v_scl_min: int
|
|
33
|
+
v_scl_max: int
|
|
34
|
+
v_unit: int
|
|
35
|
+
|
|
36
|
+
def __init__(
|
|
37
|
+
self,
|
|
38
|
+
tag_name: str,
|
|
39
|
+
tag_description: str = "",
|
|
40
|
+
v_op: int = 0,
|
|
41
|
+
v_min: int = 0,
|
|
42
|
+
v_max: int = 100,
|
|
43
|
+
v_scl_min: int = 0,
|
|
44
|
+
v_scl_max: int = 100,
|
|
45
|
+
v_unit: int = 0,
|
|
46
|
+
):
|
|
47
|
+
"""
|
|
48
|
+
Discrete Integer Service Parameter (DIntServParam).
|
|
49
|
+
"""
|
|
50
|
+
super().__init__(tag_name, tag_description)
|
|
51
|
+
self.mtpObjectType = "MTPDataAssemblySUCLib/DataAssembly/ServiceElement/ParameterElement/DIntServParam"
|
|
52
|
+
|
|
53
|
+
self.v_min = v_min
|
|
54
|
+
self.v_max = v_max
|
|
55
|
+
self.v_scl_min = v_scl_min
|
|
56
|
+
self.v_scl_max = v_scl_max
|
|
57
|
+
self.v_unit = v_unit
|
|
58
|
+
|
|
59
|
+
self.get_item(CommonServParameter.V_OP).init_value = v_op
|
|
60
|
+
self.get_item(CommonServParameter.V_EXT).init_value = v_op
|
|
61
|
+
self.get_item(CommonServParameter.V_UNIT).init_value = self.v_unit
|
|
62
|
+
self.get_item(CommonServParameter.V_SCL_MIN).init_value = self.v_scl_min
|
|
63
|
+
self.get_item(CommonServParameter.V_SCL_MAX).init_value = self.v_scl_max
|
|
64
|
+
self.get_item(CommonServParameter.V_MIN).init_value = self.v_min
|
|
65
|
+
self.get_item(CommonServParameter.V_MAX).init_value = self.v_max
|
|
66
|
+
|
|
67
|
+
self.get_item(CommonServParameter.V_OP).ext_wrt_cb = self.set_v_op
|
|
68
|
+
self.get_item(CommonServParameter.V_EXT).ext_wrt_cb = self.set_v_ext
|
|
69
|
+
|
|
70
|
+
def is_valid_value(self, value):
|
|
71
|
+
if value < self.v_min or value > self.v_max:
|
|
72
|
+
logger.debug(
|
|
73
|
+
f"{self.tag_name} invalid value detected {value} (out of range)"
|
|
74
|
+
)
|
|
75
|
+
return False
|
|
76
|
+
else:
|
|
77
|
+
return True
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"""Test suite for DIntServParam."""
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from mtppy.part4.automation_services.service_elements.parameter_elements.common_serv_param import (
|
|
6
|
+
CommonServParameter as CSP,
|
|
7
|
+
)
|
|
8
|
+
from mtppy.part4.automation_services.service_elements.parameter_elements.dint_serv_param import (
|
|
9
|
+
DIntServParam,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def test_initialization_sets_integer_metadata_and_values():
|
|
14
|
+
parameter = DIntServParam(
|
|
15
|
+
"BatchSize",
|
|
16
|
+
"Batch size",
|
|
17
|
+
v_op=5,
|
|
18
|
+
v_min=1,
|
|
19
|
+
v_max=20,
|
|
20
|
+
v_scl_min=0,
|
|
21
|
+
v_scl_max=20,
|
|
22
|
+
v_unit=1000,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
assert parameter.tag_name == "BatchSize"
|
|
26
|
+
assert parameter.tag_description == "Batch size"
|
|
27
|
+
assert parameter.v_min == 1
|
|
28
|
+
assert parameter.v_max == 20
|
|
29
|
+
assert parameter.v_unit == 1000
|
|
30
|
+
assert parameter.get_item(CSP.V_OP).init_value == 5
|
|
31
|
+
assert parameter.get_item(CSP.V_EXT).init_value == 5
|
|
32
|
+
assert parameter.get_item(CSP.V_UNIT).init_value == 1000
|
|
33
|
+
assert parameter.get_item(CSP.V_MIN).init_value == 1
|
|
34
|
+
assert parameter.get_item(CSP.V_MAX).init_value == 20
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@pytest.mark.parametrize("value", [1, 10, 20])
|
|
38
|
+
def test_valid_values_include_boundaries(value):
|
|
39
|
+
parameter = DIntServParam("BatchSize", v_min=1, v_max=20)
|
|
40
|
+
|
|
41
|
+
assert parameter.is_valid_value(value) is True
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@pytest.mark.parametrize("value", [0, 21])
|
|
45
|
+
def test_values_outside_range_are_invalid(value):
|
|
46
|
+
parameter = DIntServParam("BatchSize", v_min=1, v_max=20)
|
|
47
|
+
|
|
48
|
+
assert parameter.is_valid_value(value) is False
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def test_set_v_op_accepts_valid_value_and_rejects_invalid_value():
|
|
52
|
+
parameter = DIntServParam("BatchSize", v_min=1, v_max=20)
|
|
53
|
+
|
|
54
|
+
parameter.set_v_op(12)
|
|
55
|
+
assert parameter[CSP.V_OP] == 12
|
|
56
|
+
|
|
57
|
+
parameter.set_v_op(21)
|
|
58
|
+
assert parameter[CSP.V_OP] == 12
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"""Implementation of the ParameterElement."""
|
|
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.utils.logging import logger
|
|
11
|
+
from mtppy.part3.data_assembly_set.data_assembly import DataAssembly
|
|
12
|
+
from mtppy.utils.data_item import DataItem
|
|
13
|
+
from mtppy.part3.definitions.mtp_access import MTPAccess
|
|
14
|
+
from mtppy.part5.definitions.w3c_xml_data_types import W3cXmlDataTypes
|
|
15
|
+
from mtppy.part3.data_assembly_set.base_functions.oslevel import OSLevelBaseFunction
|
|
16
|
+
from mtppy.part4.automation_services.base_functions.service_operation_mode import (
|
|
17
|
+
ServiceOperationMode,
|
|
18
|
+
)
|
|
19
|
+
from mtppy.part4.automation_services.base_functions.service_source_mode import (
|
|
20
|
+
ServiceSourceMode,
|
|
21
|
+
)
|
|
22
|
+
from mtppy.part4.automation_services.service_elements.parameter_elements.common_serv_param import (
|
|
23
|
+
CommonServParameter as CSP,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class ParameterElement(DataAssembly):
|
|
28
|
+
APPLY_EN = "ApplyEn"
|
|
29
|
+
APPLY_EXT = "ApplyExt"
|
|
30
|
+
APPLY_OP = "ApplyOp"
|
|
31
|
+
APPLY_INT = "ApplyInt"
|
|
32
|
+
SYNC_ = "Sync"
|
|
33
|
+
|
|
34
|
+
CLASS_DATA_ITEMS: ClassVar = {
|
|
35
|
+
APPLY_EN: DataItem(
|
|
36
|
+
APPLY_EN,
|
|
37
|
+
W3cXmlDataTypes.BOOLEAN,
|
|
38
|
+
MTPAccess.ReadAccess,
|
|
39
|
+
init_value=True,
|
|
40
|
+
),
|
|
41
|
+
APPLY_EXT: DataItem(
|
|
42
|
+
APPLY_EXT,
|
|
43
|
+
W3cXmlDataTypes.BOOLEAN,
|
|
44
|
+
MTPAccess.ReadWriteAccess,
|
|
45
|
+
init_value=False,
|
|
46
|
+
),
|
|
47
|
+
APPLY_OP: DataItem(
|
|
48
|
+
APPLY_OP,
|
|
49
|
+
W3cXmlDataTypes.BOOLEAN,
|
|
50
|
+
MTPAccess.ReadWriteAccess,
|
|
51
|
+
init_value=False,
|
|
52
|
+
),
|
|
53
|
+
APPLY_INT: DataItem(
|
|
54
|
+
APPLY_INT,
|
|
55
|
+
W3cXmlDataTypes.BOOLEAN,
|
|
56
|
+
MTPAccess.ReadAccess,
|
|
57
|
+
init_value=False,
|
|
58
|
+
),
|
|
59
|
+
SYNC_: DataItem(
|
|
60
|
+
SYNC_,
|
|
61
|
+
W3cXmlDataTypes.BOOLEAN,
|
|
62
|
+
MTPAccess.ReadWriteAccess,
|
|
63
|
+
init_value=False,
|
|
64
|
+
),
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
os_level: OSLevelBaseFunction
|
|
68
|
+
service_op_mode: ServiceOperationMode
|
|
69
|
+
service_src_mode: ServiceSourceMode
|
|
70
|
+
|
|
71
|
+
def __init__(self, tag_name: str, tag_description: str):
|
|
72
|
+
super().__init__(tag_name, tag_description)
|
|
73
|
+
self.mtpObjectType = (
|
|
74
|
+
"MTPDataAssemblySUCLib/DataAssembly/ServiceElement/ParameterElement"
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
self.os_level = OSLevelBaseFunction()
|
|
78
|
+
self.service_op_mode = ServiceOperationMode()
|
|
79
|
+
self.service_src_mode = ServiceSourceMode()
|
|
80
|
+
|
|
81
|
+
self.get_item(ParameterElement.APPLY_EN).ext_wrt_cb = self.apply_ext
|
|
82
|
+
self.get_item(ParameterElement.APPLY_OP).ext_wrt_cb = self.apply_op
|
|
83
|
+
self.get_item(ParameterElement.SYNC_).ext_wrt_cb = self.set_sync
|
|
84
|
+
|
|
85
|
+
self.get_item(ParameterElement.APPLY_INT).int_wrt_cb = self.apply_int
|
|
86
|
+
self.get_item(ParameterElement.APPLY_EXT).int_wrt_cb = self.apply_ext
|
|
87
|
+
|
|
88
|
+
def set_apply_en(self, value: bool):
|
|
89
|
+
self[ParameterElement.APPLY_EN] = value
|
|
90
|
+
|
|
91
|
+
def set_sync(self, value: bool):
|
|
92
|
+
self[ParameterElement.SYNC_] = value
|
|
93
|
+
|
|
94
|
+
def apply_op(self, value: bool):
|
|
95
|
+
if value and self.service_op_mode[ServiceOperationMode.STATE_OP_ACT]:
|
|
96
|
+
self.update_v_out()
|
|
97
|
+
self[ParameterElement.APPLY_OP] = False
|
|
98
|
+
|
|
99
|
+
def apply_ext(self, value: bool):
|
|
100
|
+
if (
|
|
101
|
+
value
|
|
102
|
+
and self.service_op_mode[ServiceOperationMode.STATE_AUT_ACT]
|
|
103
|
+
# TBD: check SRC_EXT_ACT, was SrcExt
|
|
104
|
+
and self.service_src_mode[ServiceSourceMode.SRC_EXT_ACT]
|
|
105
|
+
):
|
|
106
|
+
self.update_v_out()
|
|
107
|
+
self[ParameterElement.APPLY_EXT] = False
|
|
108
|
+
|
|
109
|
+
def apply_int(self, value: bool):
|
|
110
|
+
if (
|
|
111
|
+
value
|
|
112
|
+
and self.service_op_mode[ServiceOperationMode.STATE_AUT_ACT]
|
|
113
|
+
# TBD: check SRC_INT_ACT, was SrcInt
|
|
114
|
+
and self.service_src_mode[ServiceSourceMode.SRC_INT_ACT]
|
|
115
|
+
):
|
|
116
|
+
self.update_v_out()
|
|
117
|
+
self[ParameterElement.APPLY_INT] = False
|
|
118
|
+
|
|
119
|
+
def update_v_req(self):
|
|
120
|
+
if self.service_op_mode[ServiceOperationMode.STATE_OP_ACT]:
|
|
121
|
+
self[CSP.V_REQ] = self[CSP.V_OP]
|
|
122
|
+
logger.info(f"VReq set to VOp={self[CSP.V_OP]}")
|
|
123
|
+
elif (
|
|
124
|
+
self.service_op_mode[ServiceOperationMode.STATE_AUT_ACT]
|
|
125
|
+
# TBD: check SRC_INT_ACT, was SrcInt
|
|
126
|
+
and self.service_src_mode[ServiceSourceMode.SRC_INT_ACT]
|
|
127
|
+
):
|
|
128
|
+
self[CSP.V_REQ] = self[CSP.V_INT]
|
|
129
|
+
logger.info(f"VReq set to VInt={self[CSP.V_INT]}")
|
|
130
|
+
elif (
|
|
131
|
+
self.service_op_mode[ServiceOperationMode.STATE_AUT_ACT]
|
|
132
|
+
# TBD: check SRC_EXT_ACT, was SrcExt
|
|
133
|
+
and self.service_src_mode[ServiceSourceMode.SRC_EXT_ACT]
|
|
134
|
+
):
|
|
135
|
+
self[CSP.V_REQ] = self[CSP.V_EXT]
|
|
136
|
+
logger.info(f"VReq set to VExt={self[CSP.V_EXT]}")
|
|
137
|
+
|
|
138
|
+
# TBD: was self[CSP.V_REQ] = self[CSP.V_EXT ?
|
|
139
|
+
self[CSP.V_FBK] = self[CSP.V_REQ]
|
|
140
|
+
|
|
141
|
+
def set_v_fbk(self, value) -> None:
|
|
142
|
+
self[CSP.V_FBK] = value
|
|
143
|
+
logger.info(f"VFbk set to {value}")
|
|
144
|
+
|
|
145
|
+
def update_v_out(self) -> None:
|
|
146
|
+
self.update_v_req()
|
|
147
|
+
value = self[CSP.V_REQ]
|
|
148
|
+
self[CSP.V_OUT] = value
|
|
149
|
+
logger.mtp(f"VOut set to {value}")
|
|
150
|
+
|
|
151
|
+
def get_v_out(self) -> None:
|
|
152
|
+
return self[CSP.V_OUT]
|
|
153
|
+
|
|
154
|
+
def set_v_op(self, value) -> None:
|
|
155
|
+
if self.is_valid_value(value):
|
|
156
|
+
self[CSP.V_OP] = value
|
|
157
|
+
logger.mtp(f"VOp set to {self[CSP.V_OP]}")
|
|
158
|
+
self.update_v_req()
|
|
159
|
+
|
|
160
|
+
def set_v_int(self, value) -> None:
|
|
161
|
+
logger.debug(f"set_v_int: args={value}")
|
|
162
|
+
if self.is_valid_value(value):
|
|
163
|
+
self[CSP.V_INT] = value
|
|
164
|
+
logger.info(f"VInt set to {self[CSP.V_INT]}")
|
|
165
|
+
self.update_v_req()
|
|
166
|
+
|
|
167
|
+
def set_v_ext(self, value) -> None:
|
|
168
|
+
if self.is_valid_value(value):
|
|
169
|
+
self[CSP.V_EXT] = value
|
|
170
|
+
logger.info(f"VExt set to {self[CSP.V_EXT]}")
|
|
171
|
+
self.update_v_req()
|
|
172
|
+
|
|
173
|
+
def is_valid_value(self, value) -> bool:
|
|
174
|
+
logger.warning(f"is_valid_value of ParameterElement called!")
|
|
175
|
+
return True
|