From 76390d71f7af7e5cd16ad0746ebc3f052f047e88 Mon Sep 17 00:00:00 2001 From: Henrik Wahlqvist <henrik.wahlqvist@volvocars.com> Date: Thu, 16 Jan 2025 09:18:47 +0100 Subject: [PATCH] Update towards breaking yaml generator changes Change-Id: I456b9f1bc4545600af78908886968c9b7c313309 --- docs/project_config.md | 74 ++++++++++++++++--- powertrain_build/build_proj_config.py | 3 +- .../zone_controller/composition_yaml.py | 29 ++++++-- .../test_composition_yaml/composition_yaml.py | 9 ++- .../composition_yaml_with_a2l_axis_data.py | 3 +- .../composition_yaml_with_calls_all_fields.py | 3 +- ...tion_yaml_with_calls_no_optional_fields.py | 3 +- .../composition_yaml_with_dids.py | 3 +- .../composition_yaml_with_dtcs.py | 11 +-- .../composition_yaml_with_nvm.py | 3 +- .../zone_controller/test_composition_yaml.py | 6 +- 11 files changed, 115 insertions(+), 32 deletions(-) diff --git a/docs/project_config.md b/docs/project_config.md index 0715b7c..77db530 100644 --- a/docs/project_config.md +++ b/docs/project_config.md @@ -335,10 +335,37 @@ Collection of config options for autosar arxml based scheduling in the project c These options affect the content of a configuration file used to complement the arxml file of the project when building with conan. +```json +{ + "CompositionConfig": { + "compositionName": "McLvcSafe", + "compositionEnding": "yaml", + "compositionArxml": "interface/McLvcSafe_GPA_17.arxml", + "customYamlInitFunctionName": "dummy_init", + "customYamlStepFunctionName": "dummy_step", + "generateExternalImplementationType": false, + "softwareComponentName":"LVCSC", + "softwareComponentTemplate": "ARTCSC", + "asil": "ASILD", + "secure": true, + "includeStatic": false, + "includeShared": false, + "includeDiagnostics": true, + "includeNvm": true, + "nvmPortPattern": "PS_LVCSC_SwcNv_{NvName}" + } +} +``` + #### compositionName Name of the composition file used by conan to complement the arxml file. -Will be .yml unless name is given with file ending. +Will be .yml unless name is given with file ending. see [compositionEnding](#compositionending). + +#### compositionEnding + +File ending of the generated yaml composition file. +Default is .yml. #### compositionArxml @@ -346,36 +373,63 @@ Name of the arxml file containing autosar packages and elements, specifying sign #### customYamlInitFunctionName -Name of Init function. Default: "AR_<scheduler_prefix>_VcExtINI" +Name of Init function. +Default is "AR_<scheduler_prefix>_VcExtINI". + +#### customYamlStepFunctionName + +Name of runnable function. +Default is "AR_<scheduler_prefix>_<runnable>". #### generateExternalImplementationType -Specifies if external implementation types should be generated or not at the build stage (conan). Default: True +Specifies if external implementation types should be generated or not at the build stage (conan). +Default is True. #### softwareComponentName Name of the software component. Needs to match the software component name in the arxml. -Default: matching "A2lConfig/name". +Default is matching "A2lConfig/name". #### softwareComponentTemplate -Name of template used by the software component. Default: None. +Name of template used by the software component. +Default is None. -#### softwareComponentBase +#### asil -Name of software component base used by the software component. Default: 'QM'. +The ASIL level used by the software component. +Default is 'QM'. + +#### secure + +Determine if the software component is secure or not. +Will determine which set of SwAddrMethods is used. +Default is False. #### includeStatic -Include static elements or not. Default: True. +Include static elements or not. +Default is True. #### includeShared -Include shared elements or not. Default: True. +Include shared elements or not. +Default is True. #### includeDiagnostics -Include diagnostics elements or not. Default: True. +Include diagnostics elements or not. +Default is True. + +#### includeNvm + +Include non-volatile memory elements or not. +Default is True. + +#### nvmPortPattern + +Port naming format string for NVM ports. ### MemoryMapConfig diff --git a/powertrain_build/build_proj_config.py b/powertrain_build/build_proj_config.py index 91973a5..82b6b49 100644 --- a/powertrain_build/build_proj_config.py +++ b/powertrain_build/build_proj_config.py @@ -262,7 +262,8 @@ class BuildProjConfig: 'generateExternalImplementationType': file_config.get("generateExternalImplementationType", True), 'softwareComponentName': file_config.get("softwareComponentName", self.get_a2l_cfg()['name']), 'softwareComponentTemplate': file_config.get('softwareComponentTemplate', None), - 'softwareComponentBase': file_config.get('softwareComponentBase', 'QM'), + 'asil': file_config.get('asil', 'QM'), + 'secure': file_config.get('secure', False), 'includeStatic': file_config.get('includeStatic', True), 'includeShared': file_config.get('includeShared', True), 'includeDiagnostics': file_config.get('includeDiagnostics', True), diff --git a/powertrain_build/zone_controller/composition_yaml.py b/powertrain_build/zone_controller/composition_yaml.py index 80c2e1e..779f246 100644 --- a/powertrain_build/zone_controller/composition_yaml.py +++ b/powertrain_build/zone_controller/composition_yaml.py @@ -5,7 +5,7 @@ import re from pathlib import Path -from ruamel.yaml import YAML +from ruamel.yaml import YAML, scalarstring from powertrain_build.problem_logger import ProblemLogger from powertrain_build.types import a2l_range @@ -307,6 +307,25 @@ class CompositionYaml(ProblemLogger): return trigger_signal + def _edit_event_dict(self, event_dict): + """Edit event dictionary to use double quoted strings on certain element values. + + The elements that need to be double quoted are JumpDown, JumpUp and EnaDEMInd. + The values are either "on" or "off", which yaml loader still interprets as boolean. + Hence the need for double quotes. + For some reason, "true" is not interpreted as boolean though. + + Args: + event_dict (dict): Dict with diagnostic event data. + Returns: + event_dict (dict): Dict with diagnostic event data, + updated with double quoted strings on certain element values.""" + for event_data in event_dict.values(): + for key, value in event_data.items(): + if key in ["JumpDown", "JumpUp", "EnaDEMInd"]: + event_data[key] = scalarstring.DoubleQuotedScalarString(value) + return event_dict + def _get_diagnostic_info(self): """Get diagnostic information from composition spec. @@ -319,7 +338,7 @@ class CompositionYaml(ProblemLogger): diagnostics = self.composition_spec.get("diagnostics", {}) dids = diagnostics.get("dids", {}) self.zc_dids.valid_dids = dids - events = diagnostics.get("events", {}) + events = self._edit_event_dict(diagnostics.get("events", {})) rids = diagnostics.get("rids", {}) if dids: diag_dict["dids"] = self.zc_dids.valid_dids @@ -500,14 +519,12 @@ class CompositionYaml(ProblemLogger): """ software_component_name = self.build_cfg.get_composition_config("softwareComponentName") software_component_template = self.build_cfg.get_composition_config("softwareComponentTemplate") - software_component_base = self.build_cfg.get_composition_config("softwareComponentBase") - swcs = {software_component_name: {}} swcs[software_component_name]["type"] = "SWC" # Other types than swc?? if software_component_template is not None: swcs[software_component_name]["template"] = software_component_template - if software_component_base is not None: - swcs[software_component_name]["swcbase"] = software_component_base + swcs[software_component_name]["asil"] = self.build_cfg.get_composition_config("asil") + swcs[software_component_name]["secure"] = self.build_cfg.get_composition_config("secure") swcs[software_component_name]["runnables"] = self._get_runnable_info() if self.build_cfg.get_composition_config("includeShared"): swcs[software_component_name]["shared"] = self.cal_class_info["autosar"]["class_info"] 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 65637d3..9cce1aa 100644 --- a/test_data/zone_controller/test_composition_yaml/composition_yaml.py +++ b/test_data/zone_controller/test_composition_yaml/composition_yaml.py @@ -10,7 +10,8 @@ expected_result = { "testName_SC": { "type": "SWC", "template": "ARTCSC", - "swcbase": "QM", + "asil": "QM", + "secure": False, "runnables": { "AR_prefix_VcExtINI": { "type": "INIT", @@ -41,7 +42,8 @@ expected_custom_names_result = { "testName_SC": { "type": "SWC", "template": "ARTCSC", - "swcbase": "QM", + "asil": "QM", + "secure": False, "runnables": { "dummy_init": { "type": "INIT", @@ -72,7 +74,8 @@ expected_cal_result = { "testName_SC": { "type": "SWC", "template": "ARTCSC", - "swcbase": "QM", + "asil": "QM", + "secure": False, "runnables": { "AR_prefix_VcExtINI": { "type": "INIT", 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 80a28d4..5154115 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 @@ -151,7 +151,8 @@ expected_result = { "testName_SC": { "type": "SWC", "template": "ARTCSC", - "swcbase": "QM", + "asil": "QM", + "secure": False, "runnables": { "AR_prefix_VcExtINI": { "type": "INIT", 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 71f0e32..cf2c0ff 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 @@ -10,7 +10,8 @@ expected_result = { "testName_SC": { "type": "SWC", "template": "ARTCSC", - "swcbase": "QM", + "asil": "QM", + "secure": False, "runnables": { "AR_prefix_VcExtINI": { "type": "INIT", 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 3cbbe1f..28b2478 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 @@ -10,7 +10,8 @@ expected_result = { "testName_SC": { "type": "SWC", "template": "ARTCSC", - "swcbase": "QM", + "asil": "QM", + "secure": False, "runnables": { "AR_prefix_VcExtINI": { "type": "INIT", 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 812428f..d18c6a4 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 @@ -42,7 +42,8 @@ expected_result = { "testName_SC": { "type": "SWC", "template": "ARTCSC", - "swcbase": "QM", + "asil": "QM", + "secure": False, "runnables": { "AR_prefix_VcExtINI": { "type": "INIT", 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 f7e7baa..bc77398 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 @@ -13,10 +13,10 @@ diagnostics = { "identifier": "34EA", "ThresholdUnconfirmed": 1, "StepDown": 0, - "JumpDown": True, + "JumpDown": "on", "JumpDownInit": 1, "StepUp": 1, - "JumpUp": True, + "JumpUp": "on", "JumpUpInit": 127, "TestFailedLimit": 0, "TestPassedLimit": 0, @@ -33,7 +33,8 @@ expected_result = { "testName_SC": { "type": "SWC", "template": "ARTCSC", - "swcbase": "QM", + "asil": "QM", + "secure": False, "runnables": { "AR_prefix_VcExtINI": { "type": "INIT", @@ -53,10 +54,10 @@ expected_result = { "identifier": "34EA", "ThresholdUnconfirmed": 1, "StepDown": 0, - "JumpDown": True, + "JumpDown": "on", "JumpDownInit": 1, "StepUp": 1, - "JumpUp": True, + "JumpUp": "on", "JumpUpInit": 127, "TestFailedLimit": 0, "TestPassedLimit": 0, 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 6456ee7..2f9b193 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 @@ -114,7 +114,8 @@ expected_result = { "testName_SC": { "type": "SWC", "template": "ARTCSC", - "swcbase": "QM", + "asil": "QM", + "secure": False, "runnables": { "AR_prefix_VcExtINI": { "type": "INIT", diff --git a/tests/zone_controller/test_composition_yaml.py b/tests/zone_controller/test_composition_yaml.py index dd1ece6..3977ebd 100644 --- a/tests/zone_controller/test_composition_yaml.py +++ b/tests/zone_controller/test_composition_yaml.py @@ -41,7 +41,8 @@ def mock_get_composition_config_default(key): 'compositionEnding': 'yml', "softwareComponentName": "testName_SC", "softwareComponentTemplate": "ARTCSC", - "softwareComponentBase": "QM", + "asil": "QM", + "secure": False, "customYamlInitFunctionName": None, "customYamlStepFunctionName": None, "generateExternalImplementationType": True, @@ -60,7 +61,8 @@ def mock_get_composition_config_custom_names(key): 'compositionEnding': 'yml', "softwareComponentName": "testName_SC", "softwareComponentTemplate": "ARTCSC", - "softwareComponentBase": "QM", + "asil": "QM", + "secure": False, "customYamlInitFunctionName": "dummy_init", "customYamlStepFunctionName": "dummy_step", "generateExternalImplementationType": True,