From 8db817c5c39167d8ef82f1872d9b9f1e8f077fa2 Mon Sep 17 00:00:00 2001 From: Henrik Wahlqvist Date: Wed, 23 Apr 2025 18:12:25 +0200 Subject: [PATCH] Set error_handling true for e2eStatus signals Change-Id: I352c11535bd4542c4d98d3c25f0d51e882c32cc1 --- powertrain_build/interface/zone_controller.py | 28 +++++++++----- .../test_composition_yaml/composition_yaml.py | 18 +++------ .../composition_yaml_setup.py | 37 ++++++++++++++----- .../composition_yaml_with_a2l_axis_data.py | 4 +- .../composition_yaml_with_calls_all_fields.py | 29 ++++++++++++++- ...tion_yaml_with_calls_no_optional_fields.py | 29 ++++++++++++++- .../composition_yaml_with_dids.py | 4 +- .../composition_yaml_with_dtcs.py | 4 +- .../composition_yaml_with_external_io.py | 4 +- .../composition_yaml_with_nvm.py | 4 +- 10 files changed, 110 insertions(+), 51 deletions(-) diff --git a/powertrain_build/interface/zone_controller.py b/powertrain_build/interface/zone_controller.py index b955539..2f2b9b6 100644 --- a/powertrain_build/interface/zone_controller.py +++ b/powertrain_build/interface/zone_controller.py @@ -3,8 +3,10 @@ """Python module used for handling zone controller specifications""" from ruamel.yaml import YAML -from powertrain_build.lib import logger + from powertrain_build.interface.base import BaseApplication +from powertrain_build.lib import logger +from powertrain_build.lib.helper_functions import deep_dict_update LOGGER = logger.create_logger("base") @@ -152,7 +154,7 @@ class ZCAL(BaseApplication): for element_name, element_data in signal_struct.items(): self.populate_signal_translations(port_name, element_name, element_data) # Loop inside function to make sure direction is consistent - ports_info[port_name].update(self.get_port_info(port_name, direction, signal_struct)) + deep_dict_update(ports_info[port_name], self.get_port_info(port_name, direction, signal_struct)) self.composition_spec["ports"] = ports_info @staticmethod @@ -165,36 +167,42 @@ class ZCAL(BaseApplication): direction (str): Direction of the port. signal_struct (dict): Signal dict containing list of signal elements. Returns: - port_info (dict): Dict containing information if any elements - should have an update bit associated with them. + port_info (dict): Dict containing port information. """ if direction is None: raise BadYamlFormat(f'Port {port_name} is missing required property "direction".') + port_info = {} supported_directions = { "IN": "IN", "OUT": "OUT", "CLIENT": "IN", "SERVER": "OUT", } - direction = supported_directions[direction] + supported_direction = supported_directions[direction] + api_options = {} update_elements = set() for element_name, element_data in signal_struct.items(): for element in element_data: if "insignal" in element: - temp_dir = "IN" + tmp_direction = "IN" elif "outsignal" in element: - temp_dir = "OUT" + tmp_direction = "OUT" else: raise BadYamlFormat(f"in-/out-signal for element in { element_name } is missing.") - if direction != temp_dir: + if supported_direction != tmp_direction: raise BadYamlFormat(f"Signal { element_name } has both in and out elements.") if element.get("updateBit", False): update_elements.add(element_name) + if element.get("e2eStatus", False): + api_options["error_handling"] = True if update_elements: - return {"enable_update": list(update_elements)} - return {} + port_info["enable_update"] = list(update_elements) + if api_options: + port_info["api_options"] = api_options + + return port_info def populate_signal_translations(self, port_name, element_name, element_data): """Populate class translations data. diff --git a/test_data/zone_controller/test_composition_yaml/composition_yaml.py b/test_data/zone_controller/test_composition_yaml/composition_yaml.py index b26b5a7..a1e68bf 100644 --- a/test_data/zone_controller/test_composition_yaml/composition_yaml.py +++ b/test_data/zone_controller/test_composition_yaml/composition_yaml.py @@ -41,10 +41,8 @@ expected_result = { } } }, - "ports": { - "GlobSignNme": {"direction": "IN", "interface": "PIGlobSignNme"} - }, - } + "ports": composition_yaml_setup.base_ports, + }, }, "DataTypes": composition_yaml_setup.base_data_types, "PortInterfaces": composition_yaml_setup.base_port_interfaces, @@ -88,9 +86,7 @@ expected_extra_runnable_keys_result = { } } }, - "ports": { - "GlobSignNme": {"direction": "IN", "interface": "PIGlobSignNme"} - } + "ports": composition_yaml_setup.base_ports } }, "DataTypes": composition_yaml_setup.base_data_types, @@ -134,9 +130,7 @@ expected_custom_names_result = { } } }, - "ports": { - "GlobSignNme": {"direction": "IN", "interface": "PIGlobSignNme"} - }, + "ports": composition_yaml_setup.base_ports, } }, "DataTypes": composition_yaml_setup.base_data_types, @@ -189,9 +183,7 @@ expected_cal_result = { } } }, - "ports": { - "GlobSignNme": {"direction": "IN", "interface": "PIGlobSignNme"} - }, + "ports": composition_yaml_setup.base_ports, } }, "DataTypes": composition_yaml_setup.base_data_types, diff --git a/test_data/zone_controller/test_composition_yaml/composition_yaml_setup.py b/test_data/zone_controller/test_composition_yaml/composition_yaml_setup.py index be4a83d..729b902 100644 --- a/test_data/zone_controller/test_composition_yaml/composition_yaml_setup.py +++ b/test_data/zone_controller/test_composition_yaml/composition_yaml_setup.py @@ -8,6 +8,32 @@ base_configuration = { "GenerateExternalImplementationTypes": True } +base_ports = { + "PortOne": { + "direction": "IN", + "interface": "PortInterfaceOne" + }, + "PortTwo": { + "direction": "IN", + "interface": "PortInterfaceTwo", + "enable_update": ["elementOne"], + }, + "PortThree": { + "direction": "IN", + "interface": "PortInterfaceThree", + "api_options": {"dummy": "dummy"}, + }, + "PortFour": { + "direction": "IN", + "interface": "PortInterfaceFour", + "enable_update": ["elementOne", "elementTwo"], + "api_options": { + "dummy": "dummy", + "error_handling": False + }, + }, +} + base_port_interfaces = { "ExtraPortInterface": { "type": "SENDER-RECIEVER-INTERFACE", @@ -479,15 +505,8 @@ composition_spec = { } } }, - "ports": { - "GlobSignNme": {"direction": "IN", "interface": "PIGlobSignNme"} - }, - "port_interfaces": { - "ExtraPortInterface": { - "type": "SENDER-RECIEVER-INTERFACE", - "elements": "ExtraType" - } - }, + "ports": base_ports, + "port_interfaces": base_port_interfaces, "data_types": { "ExtraType": { "type": "RECORD", diff --git a/test_data/zone_controller/test_composition_yaml/composition_yaml_with_a2l_axis_data.py b/test_data/zone_controller/test_composition_yaml/composition_yaml_with_a2l_axis_data.py index d7d4cc6..96deb8f 100644 --- a/test_data/zone_controller/test_composition_yaml/composition_yaml_with_a2l_axis_data.py +++ b/test_data/zone_controller/test_composition_yaml/composition_yaml_with_a2l_axis_data.py @@ -231,9 +231,7 @@ expected_result = { } } }, - "ports": { - "GlobSignNme": {"direction": "IN", "interface": "PIGlobSignNme"} - }, + "ports": composition_yaml_setup.base_ports, } }, "DataTypes": { diff --git a/test_data/zone_controller/test_composition_yaml/composition_yaml_with_calls_all_fields.py b/test_data/zone_controller/test_composition_yaml/composition_yaml_with_calls_all_fields.py index 1d64702..4340ba3 100644 --- a/test_data/zone_controller/test_composition_yaml/composition_yaml_with_calls_all_fields.py +++ b/test_data/zone_controller/test_composition_yaml/composition_yaml_with_calls_all_fields.py @@ -48,8 +48,33 @@ expected_result = { } }, "ports": { - "GlobSignNme": {"direction": "IN", "interface": "PIGlobSignNme"}, - "CallOne": {"direction": "IN", "interface": "InterfaceOne"} + "PortOne": { + "direction": "IN", + "interface": "PortInterfaceOne" + }, + "PortTwo": { + "direction": "IN", + "interface": "PortInterfaceTwo", + "enable_update": ["elementOne"], + }, + "PortThree": { + "direction": "IN", + "interface": "PortInterfaceThree", + "api_options": {"dummy": "dummy"}, + }, + "PortFour": { + "direction": "IN", + "interface": "PortInterfaceFour", + "enable_update": ["elementOne", "elementTwo"], + "api_options": { + "dummy": "dummy", + "error_handling": False + }, + }, + "CallOne": { + "direction": "IN", + "interface": "InterfaceOne" + } } } }, diff --git a/test_data/zone_controller/test_composition_yaml/composition_yaml_with_calls_no_optional_fields.py b/test_data/zone_controller/test_composition_yaml/composition_yaml_with_calls_no_optional_fields.py index ee09cb6..7b3449f 100644 --- a/test_data/zone_controller/test_composition_yaml/composition_yaml_with_calls_no_optional_fields.py +++ b/test_data/zone_controller/test_composition_yaml/composition_yaml_with_calls_no_optional_fields.py @@ -47,8 +47,33 @@ expected_result = { } }, "ports": { - "GlobSignNme": {"direction": "IN", "interface": "PIGlobSignNme"}, - "CallOne": {"direction": "IN", "interface": "CallOne"} + "PortOne": { + "direction": "IN", + "interface": "PortInterfaceOne" + }, + "PortTwo": { + "direction": "IN", + "interface": "PortInterfaceTwo", + "enable_update": ["elementOne"], + }, + "PortThree": { + "direction": "IN", + "interface": "PortInterfaceThree", + "api_options": {"dummy": "dummy"}, + }, + "PortFour": { + "direction": "IN", + "interface": "PortInterfaceFour", + "enable_update": ["elementOne", "elementTwo"], + "api_options": { + "dummy": "dummy", + "error_handling": False + }, + }, + "CallOne": { + "direction": "IN", + "interface": "CallOne" + } } } }, diff --git a/test_data/zone_controller/test_composition_yaml/composition_yaml_with_dids.py b/test_data/zone_controller/test_composition_yaml/composition_yaml_with_dids.py index 938e028..582bef6 100644 --- a/test_data/zone_controller/test_composition_yaml/composition_yaml_with_dids.py +++ b/test_data/zone_controller/test_composition_yaml/composition_yaml_with_dids.py @@ -103,9 +103,7 @@ expected_result = { } } }, - "ports": { - "GlobSignNme": {"direction": "IN", "interface": "PIGlobSignNme"}, - } + "ports": composition_yaml_setup.base_ports, } }, "DataTypes": composition_yaml_setup.base_data_types, diff --git a/test_data/zone_controller/test_composition_yaml/composition_yaml_with_dtcs.py b/test_data/zone_controller/test_composition_yaml/composition_yaml_with_dtcs.py index e706cb5..3be38aa 100644 --- a/test_data/zone_controller/test_composition_yaml/composition_yaml_with_dtcs.py +++ b/test_data/zone_controller/test_composition_yaml/composition_yaml_with_dtcs.py @@ -85,9 +85,7 @@ expected_result = { } } }, - "ports": { - "GlobSignNme": {"direction": "IN", "interface": "PIGlobSignNme"}, - } + "ports": composition_yaml_setup.base_ports, } }, "DataTypes": composition_yaml_setup.base_data_types, diff --git a/test_data/zone_controller/test_composition_yaml/composition_yaml_with_external_io.py b/test_data/zone_controller/test_composition_yaml/composition_yaml_with_external_io.py index f58c10b..30f3e81 100644 --- a/test_data/zone_controller/test_composition_yaml/composition_yaml_with_external_io.py +++ b/test_data/zone_controller/test_composition_yaml/composition_yaml_with_external_io.py @@ -114,9 +114,7 @@ expected_result = { } } }, - "ports": { - "GlobSignNme": {"direction": "IN", "interface": "PIGlobSignNme"} - }, + "ports": composition_yaml_setup.base_ports, } }, "DataTypes": composition_yaml_setup.base_data_types, diff --git a/test_data/zone_controller/test_composition_yaml/composition_yaml_with_nvm.py b/test_data/zone_controller/test_composition_yaml/composition_yaml_with_nvm.py index 24dc29e..2a9fd04 100644 --- a/test_data/zone_controller/test_composition_yaml/composition_yaml_with_nvm.py +++ b/test_data/zone_controller/test_composition_yaml/composition_yaml_with_nvm.py @@ -160,9 +160,7 @@ expected_result = { } } }, - "ports": { - "GlobSignNme": {"direction": "IN", "interface": "PIGlobSignNme"} - }, + "ports": composition_yaml_setup.base_ports, } }, "DataTypes": {