Update towards breaking yaml generator changes

Change-Id: I456b9f1bc4545600af78908886968c9b7c313309
This commit is contained in:
Henrik Wahlqvist 2025-01-16 09:18:47 +01:00
parent 55f9545791
commit 76390d71f7
11 changed files with 115 additions and 32 deletions

@ -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

@ -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),

@ -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"]

@ -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",

@ -151,7 +151,8 @@ expected_result = {
"testName_SC": {
"type": "SWC",
"template": "ARTCSC",
"swcbase": "QM",
"asil": "QM",
"secure": False,
"runnables": {
"AR_prefix_VcExtINI": {
"type": "INIT",

@ -10,7 +10,8 @@ expected_result = {
"testName_SC": {
"type": "SWC",
"template": "ARTCSC",
"swcbase": "QM",
"asil": "QM",
"secure": False,
"runnables": {
"AR_prefix_VcExtINI": {
"type": "INIT",

@ -10,7 +10,8 @@ expected_result = {
"testName_SC": {
"type": "SWC",
"template": "ARTCSC",
"swcbase": "QM",
"asil": "QM",
"secure": False,
"runnables": {
"AR_prefix_VcExtINI": {
"type": "INIT",

@ -42,7 +42,8 @@ expected_result = {
"testName_SC": {
"type": "SWC",
"template": "ARTCSC",
"swcbase": "QM",
"asil": "QM",
"secure": False,
"runnables": {
"AR_prefix_VcExtINI": {
"type": "INIT",

@ -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,

@ -114,7 +114,8 @@ expected_result = {
"testName_SC": {
"type": "SWC",
"template": "ARTCSC",
"swcbase": "QM",
"asil": "QM",
"secure": False,
"runnables": {
"AR_prefix_VcExtINI": {
"type": "INIT",

@ -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,