Make it possible to manually select static and shared variables
Change-Id: I69bda8b861550003aebe3a720415ebb27c132566
This commit is contained in:
@@ -431,11 +431,15 @@ Default is False.
|
||||
Include static elements or not.
|
||||
Default is True.
|
||||
|
||||
It also possible to set to set to "manual" to only include manually provided variables.
|
||||
|
||||
#### includeShared
|
||||
|
||||
Include shared elements or not.
|
||||
Default is True.
|
||||
|
||||
It also possible to set to set to "manual" to only include manually provided variables.
|
||||
|
||||
#### includeSharedSwAddrMethod
|
||||
|
||||
Add the swAddrMethod to the output yaml file for calibration variables.
|
||||
|
@@ -586,20 +586,28 @@ class CompositionYaml(ProblemLogger):
|
||||
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"):
|
||||
if self.build_cfg.get_composition_config("includeShared") is True:
|
||||
swcs[software_component_name]["shared"] = self.cal_class_info["autosar"]["class_info"]
|
||||
for variable_name, variable_info in self.composition_spec.get("shared", {}).items():
|
||||
if variable_name in swcs[software_component_name]["shared"]:
|
||||
self.critical("Shared variable %s already defined in project.", variable_name)
|
||||
else:
|
||||
swcs[software_component_name]["shared"][variable_name] = variable_info
|
||||
if self.build_cfg.get_composition_config("includeStatic"):
|
||||
elif self.build_cfg.get_composition_config("includeShared") == "manual":
|
||||
swcs[software_component_name]["shared"] = {}
|
||||
for variable_name, variable_info in self.composition_spec.get("shared", {}).items():
|
||||
swcs[software_component_name]["shared"][variable_name] = variable_info
|
||||
if self.build_cfg.get_composition_config("includeStatic") is True:
|
||||
swcs[software_component_name]["static"] = self.meas_class_info["autosar"]["class_info"]
|
||||
for variable_name, variable_info in self.composition_spec.get("static", {}).items():
|
||||
if variable_name in swcs[software_component_name]["static"]:
|
||||
self.critical("Static variable %s already defined in project.", variable_name)
|
||||
else:
|
||||
swcs[software_component_name]["static"][variable_name] = variable_info
|
||||
elif self.build_cfg.get_composition_config("includeStatic") == "manual":
|
||||
swcs[software_component_name]["static"] = {}
|
||||
for variable_name, variable_info in self.composition_spec.get("static", {}).items():
|
||||
swcs[software_component_name]["static"][variable_name] = variable_info
|
||||
swcs[software_component_name]["ports"] = self._get_ports_info()
|
||||
if self.composition_spec.get("io") is not None:
|
||||
swcs[software_component_name]["io"] = self.composition_spec["io"]
|
||||
@@ -610,7 +618,7 @@ class CompositionYaml(ProblemLogger):
|
||||
if self.build_cfg.get_composition_config("includeNvm"):
|
||||
swcs[software_component_name]["nv-needs"] = nvm_info
|
||||
nvm_data_types = nvm_data_types_tmp
|
||||
if self.build_cfg.get_composition_config("includeStatic"):
|
||||
if self.build_cfg.get_composition_config("includeStatic") is True:
|
||||
swcs[software_component_name]["static"].update(static_variables)
|
||||
else:
|
||||
nvm_data_types = {}
|
||||
|
@@ -50,6 +50,64 @@ expected_result = {
|
||||
"ExternalFiles": composition_yaml_setup.base_configuration
|
||||
}
|
||||
|
||||
expected_manual_static_shared_result = {
|
||||
"SoftwareComponents": {
|
||||
"testName_SC": {
|
||||
"type": "SWC",
|
||||
"template": "ARTCSC",
|
||||
"asil": "QM",
|
||||
"secure": False,
|
||||
"runnables": {
|
||||
"AR_prefix_VcExtINI": {
|
||||
"type": "INIT",
|
||||
"accesses": composition_yaml_setup.base_accesses
|
||||
},
|
||||
"AR_prefix_testRunnable": {
|
||||
"period": 10,
|
||||
"type": "PERIODIC",
|
||||
"accesses": composition_yaml_setup.base_accesses,
|
||||
"reads": composition_yaml_setup.base_reads
|
||||
},
|
||||
},
|
||||
"diagnostics": {},
|
||||
"nv-needs": {},
|
||||
"static": {
|
||||
"sVcManual_D_Measurable": {
|
||||
"access": "READ-ONLY",
|
||||
"type": "UInt8",
|
||||
"init": 0
|
||||
}
|
||||
},
|
||||
"shared": {
|
||||
"sVcManual_D_Calibratable": {
|
||||
"access": "READ-WRITE",
|
||||
"type": "Float32",
|
||||
"init": 0.0,
|
||||
"longname": "A calibratable variable for testing purposes"
|
||||
}
|
||||
},
|
||||
"io": {
|
||||
"DUMMY1": {
|
||||
"DUMMY1": {
|
||||
"dataElement": "DUMMY1",
|
||||
"runnable": ["DummyRunnable"]
|
||||
},
|
||||
"PPortPrototype_IoHwAb_GetDUMMY1": {
|
||||
"operation": "Op_IoHwAb_GetDUMMY1",
|
||||
"runnable": ["DummyRunnable"],
|
||||
"timeout": 0,
|
||||
"calltype": "sync"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ports": composition_yaml_setup.base_ports
|
||||
}
|
||||
},
|
||||
"DataTypes": composition_yaml_setup.base_data_types,
|
||||
"PortInterfaces": composition_yaml_setup.base_port_interfaces,
|
||||
"ExternalFiles": composition_yaml_setup.base_configuration
|
||||
}
|
||||
|
||||
expected_extra_runnable_keys_result = {
|
||||
"SoftwareComponents": {
|
||||
"testName_SC": {
|
||||
|
@@ -100,6 +100,29 @@ def mock_get_composition_config_default(key):
|
||||
}[key]
|
||||
|
||||
|
||||
def mock_get_composition_config_manual_static_shared(key):
|
||||
"""Function to mock BuildProjConfig.get_composition_config."""
|
||||
return {
|
||||
"compositionArxml": "some_arxml.arxml",
|
||||
"compositionName": "compositionName",
|
||||
"compositionEnding": "yml",
|
||||
"softwareComponentName": "testName_SC",
|
||||
"softwareComponentTemplate": "ARTCSC",
|
||||
"asil": "QM",
|
||||
"secure": False,
|
||||
"customYamlInitFunctionName": None,
|
||||
"customYamlStepFunctionName": None,
|
||||
"generateExternalImplementationType": True,
|
||||
"includeStatic": "manual",
|
||||
"includeShared": "manual",
|
||||
"includeSharedSwAddrMethod": False,
|
||||
"includeDiagnostics": True,
|
||||
"includeNvm": True,
|
||||
"useCamelCaseForNvmVariables": False,
|
||||
"scaleMapsAndCurves": True,
|
||||
}[key]
|
||||
|
||||
|
||||
def mock_get_composition_config_custom_names(key):
|
||||
"""Function to mock BuildProjConfig.get_composition_config."""
|
||||
return {
|
||||
@@ -213,6 +236,15 @@ class TestCompositionYaml(unittest.TestCase):
|
||||
result = self.composition_yaml.gather_yaml_info()
|
||||
self.assertDictEqual(composition_yaml.expected_result, result)
|
||||
|
||||
def test_composition_yaml_manual_static_shared(self):
|
||||
"""Checking that the dict is generated correctly with manual static and shared."""
|
||||
self.build_cfg.get_composition_config.side_effect = mock_get_composition_config_manual_static_shared
|
||||
self.composition_yaml = CompositionYaml(
|
||||
self.build_cfg, self.signal_interfaces, self.unit_cfg, self.zc_core, self.zc_dids, self.nvm_def, {}, {}
|
||||
)
|
||||
result = self.composition_yaml.gather_yaml_info()
|
||||
self.assertDictEqual(composition_yaml.expected_manual_static_shared_result, result)
|
||||
|
||||
def test_composition_yaml_extra_runnable_keys(self):
|
||||
"""Checking that the dict is generated correctly with extra runnable keys."""
|
||||
self.signal_interfaces.composition_spec["mode_switch_points"] = ["DummyPort"]
|
||||
|
Reference in New Issue
Block a user