Add option for supplying custom step function name
Note that this only applies to the runnable in the generated yaml file. Change-Id: I11eea48b41801d3a0dfc479b6cc489108659bb55
This commit is contained in:
parent
7888ebe2b7
commit
fc03669666
powertrain_build
test_data/zone_controller/test_composition_yaml
tests/zone_controller
@ -256,6 +256,7 @@ class BuildProjConfig:
|
||||
'compositionEnding': 'yml',
|
||||
'compositionArxml': file_config.get("compositionArxml", None),
|
||||
'customYamlInitFunctionName': file_config.get("customYamlInitFunctionName", None),
|
||||
'customYamlStepFunctionName': file_config.get("customYamlStepFunctionName", None),
|
||||
'generateExternalImplementationType': file_config.get("generateExternalImplementationType", True),
|
||||
'softwareComponentName': file_config.get("softwareComponentName", a2lname),
|
||||
'softwareComponentTemplate': file_config.get('softwareComponentTemplate', None),
|
||||
|
@ -359,26 +359,38 @@ class CompositionYaml(ProblemLogger):
|
||||
swc_name = self.build_cfg.get_composition_config("softwareComponentName")
|
||||
autosar_prefix = "AR_"
|
||||
swc_prefix = self.build_cfg.get_scheduler_prefix()
|
||||
custom_step_function = self.build_cfg.get_composition_config("customYamlStepFunctionName")
|
||||
custom_init_function = self.build_cfg.get_composition_config("customYamlInitFunctionName")
|
||||
standard_init_function = autosar_prefix + swc_prefix + "VcExtINI"
|
||||
init_function = custom_init_function if custom_init_function is not None else standard_init_function
|
||||
call_dict = self._get_runnable_calls_info()
|
||||
runnables = self.build_cfg.get_units_raster_cfg()["SampleTimes"]
|
||||
calibration_variables = list(self.cal_class_info["autosar"]["class_info"].keys())
|
||||
swc_content = {init_function: {"type": "INIT", "accesses": calibration_variables}}
|
||||
|
||||
if self.build_cfg.get_code_generation_config(item="generateCalibrationInterfaceFiles"):
|
||||
cal_step_function = autosar_prefix + ZCC.calibration_function_step_template.format(swc_name=swc_name)
|
||||
swc_content.update(
|
||||
{
|
||||
cal_step_function: {
|
||||
"type": "PERIODIC",
|
||||
"period": 0.1,
|
||||
"accesses": calibration_variables,
|
||||
},
|
||||
}
|
||||
swc_content[cal_step_function] = {
|
||||
"type": "PERIODIC",
|
||||
"period": 0.1,
|
||||
"accesses": calibration_variables,
|
||||
}
|
||||
|
||||
if len(runnables) == 1 and custom_step_function is not None:
|
||||
swc_content[custom_step_function] = {
|
||||
"type": "PERIODIC",
|
||||
"period": list(runnables.values())[0],
|
||||
"accesses": calibration_variables,
|
||||
}
|
||||
if call_dict:
|
||||
swc_content[custom_step_function]["calls"] = call_dict
|
||||
return swc_content
|
||||
|
||||
if custom_step_function is not None:
|
||||
self.warning(
|
||||
"Custom step function specified, but multiple runnables defined. Ignoring custom step function."
|
||||
)
|
||||
|
||||
call_dict = self._get_runnable_calls_info()
|
||||
runnables = self.build_cfg.get_units_raster_cfg()["SampleTimes"]
|
||||
for runnable, period in runnables.items():
|
||||
key = autosar_prefix + swc_prefix + runnable
|
||||
swc_content[key] = {
|
||||
|
@ -35,6 +35,36 @@ expected_result = {
|
||||
"ExternalFiles": composition_yaml_setup.base_configuration
|
||||
}
|
||||
|
||||
expected_custom_names_result = {
|
||||
"SoftwareComponents": {
|
||||
"testName_SC": {
|
||||
"type": "SWC",
|
||||
"template": "ARTCSC",
|
||||
"swcbase": "QM",
|
||||
"runnables": {
|
||||
"dummy_init": {
|
||||
"type": "INIT",
|
||||
"accesses": composition_yaml_setup.base_accesses
|
||||
},
|
||||
"dummy_step": {
|
||||
"period": 10,
|
||||
"type": "PERIODIC",
|
||||
"accesses": composition_yaml_setup.base_accesses
|
||||
},
|
||||
},
|
||||
"diagnostics": {},
|
||||
"static": composition_yaml_setup.base_static,
|
||||
"shared": composition_yaml_setup.base_shared,
|
||||
"ports": {
|
||||
"GlobSignNme": {"direction": "IN", "interface": "PIGlobSignNme"}
|
||||
},
|
||||
}
|
||||
},
|
||||
"DataTypes": composition_yaml_setup.base_data_types,
|
||||
"PortInterfaces": composition_yaml_setup.base_port_interfaces,
|
||||
"ExternalFiles": composition_yaml_setup.base_configuration
|
||||
}
|
||||
|
||||
expected_cal_result = {
|
||||
"SoftwareComponents": {
|
||||
"testName_SC": {
|
||||
|
@ -28,11 +28,12 @@ SRC_DIR = Path(__file__).parent
|
||||
|
||||
|
||||
class BuildProjConfigMock(BuildProjConfig):
|
||||
"""Class mocking BuildProjConfig"""
|
||||
"""Class mocking BuildProjConfig."""
|
||||
name = ""
|
||||
|
||||
|
||||
def mocked_get_composition_config(key):
|
||||
def mock_get_composition_config_default(key):
|
||||
"""Function to mock BuildProjConfig.get_composition_config."""
|
||||
return {
|
||||
"compositionArxml": "some_arxml.arxml",
|
||||
"compositionName": "compositionName",
|
||||
@ -41,6 +42,25 @@ def mocked_get_composition_config(key):
|
||||
"softwareComponentTemplate": "ARTCSC",
|
||||
"softwareComponentBase": "QM",
|
||||
"customYamlInitFunctionName": None,
|
||||
"customYamlStepFunctionName": None,
|
||||
"generateExternalImplementationType": True,
|
||||
'includeStatic': True,
|
||||
'includeShared': True,
|
||||
'includeDiagnostics': True,
|
||||
}[key]
|
||||
|
||||
|
||||
def mock_get_composition_config_custom_names(key):
|
||||
"""Function to mock BuildProjConfig.get_composition_config."""
|
||||
return {
|
||||
"compositionArxml": "some_arxml.arxml",
|
||||
"compositionName": "compositionName",
|
||||
'compositionEnding': 'yml',
|
||||
"softwareComponentName": "testName_SC",
|
||||
"softwareComponentTemplate": "ARTCSC",
|
||||
"softwareComponentBase": "QM",
|
||||
"customYamlInitFunctionName": "dummy_init",
|
||||
"customYamlStepFunctionName": "dummy_step",
|
||||
"generateExternalImplementationType": True,
|
||||
'includeStatic': True,
|
||||
'includeShared': True,
|
||||
@ -54,7 +74,7 @@ class TestCompositionYaml(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Set-up common data structures for all tests in the test case."""
|
||||
self.build_cfg = MagicMock(spec_set=BuildProjConfigMock)
|
||||
self.build_cfg.get_composition_config.side_effect = mocked_get_composition_config
|
||||
self.build_cfg.get_composition_config.side_effect = mock_get_composition_config_default
|
||||
self.build_cfg.name = "XVC"
|
||||
self.build_cfg.get_scheduler_prefix = MagicMock(return_value="prefix_")
|
||||
self.build_cfg.get_src_code_dst_dir = MagicMock(
|
||||
@ -111,6 +131,15 @@ class TestCompositionYaml(unittest.TestCase):
|
||||
result = self.composition_yaml.gather_yaml_info()
|
||||
self.assertDictEqual(composition_yaml.expected_result, result)
|
||||
|
||||
def test_composition_yaml_with_custom_names(self):
|
||||
"""Checking that the dict is generated correctly with custom names."""
|
||||
self.build_cfg.get_composition_config.side_effect = mock_get_composition_config_custom_names
|
||||
self.composition_yaml = CompositionYaml(
|
||||
self.build_cfg, self.zc_spec, self.unit_cfg, self.zc_core, self.zc_dids, {}
|
||||
)
|
||||
result = self.composition_yaml.gather_yaml_info()
|
||||
self.assertDictEqual(composition_yaml.expected_custom_names_result, result)
|
||||
|
||||
def test_composition_yaml_with_calibration(self):
|
||||
"""Checking that the dict is generated correctly including calibration data,
|
||||
setting generateCalibrationInterfaceFiles to true (sort of)."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user