Adding lsb, offset to curves and maps
If this is not wanted, add scaleMapsAndCurves: false to composition config in project config (default true). Change-Id: Iaca39b9371be07e81c0ace2ba63c9ea0c57d4a8f
This commit is contained in:
parent
6b5b321881
commit
f6b42534e3
@ -352,7 +352,8 @@ when building with conan.
|
||||
"includeShared": false,
|
||||
"includeDiagnostics": true,
|
||||
"includeNvm": true,
|
||||
"nvmPortPattern": "PS_LVCSC_SwcNv_{NvName}"
|
||||
"nvmPortPattern": "PS_LVCSC_SwcNv_{NvName}",
|
||||
"scaleMapsAndCurves": false
|
||||
}
|
||||
}
|
||||
```
|
||||
@ -431,6 +432,11 @@ Default is True.
|
||||
|
||||
Port naming format string for NVM ports.
|
||||
|
||||
#### scaleMapsAndCurves
|
||||
|
||||
Include slope and bias to MAP and CURVE data types or not.
|
||||
Default is True.
|
||||
|
||||
### MemoryMapConfig
|
||||
|
||||
This configuration is required when [generateInterfaceHeaders](#generateinterfaceheaders) is set to true.
|
||||
|
@ -269,6 +269,7 @@ class BuildProjConfig:
|
||||
'includeDiagnostics': file_config.get('includeDiagnostics', True),
|
||||
'includeNvm': file_config.get('includeNvm', True),
|
||||
'nvmPortPattern': file_config.get('nvmPortPattern', None),
|
||||
'scaleMapsAndCurves': file_config.get('scaleMapsAndCurves', True),
|
||||
}
|
||||
composition_name = file_config.get("compositionName", None)
|
||||
if composition_name is not None:
|
||||
|
@ -100,26 +100,6 @@ class CompositionYaml(ProblemLogger):
|
||||
}
|
||||
return base_data_types
|
||||
|
||||
def check_unsupported_fields(self, signal_name, signal_data):
|
||||
"""Warn about signal data containing unsupported field values.
|
||||
|
||||
Unsupported fields will not be propagated to the ARXML.
|
||||
If any signal contains non-default data, PyBuild should fail.
|
||||
|
||||
Args:
|
||||
signal_name (string): Name of signal to process.
|
||||
signal_data (dict): signal data.
|
||||
"""
|
||||
unsupported_fields = {"lsb": 1, "offset": 0}
|
||||
for field, default_value in unsupported_fields.items():
|
||||
if signal_data[field] != "-" and signal_data[field] != default_value:
|
||||
self.warning(
|
||||
"Unsupported configuration: %s -> %s, for signal %s.",
|
||||
field,
|
||||
signal_data[field],
|
||||
signal_name,
|
||||
)
|
||||
|
||||
def generate_yaml(self):
|
||||
"""Generates a yaml from project/model information."""
|
||||
composition_name = self.build_cfg.get_composition_config("compositionName")
|
||||
@ -577,7 +557,6 @@ class CompositionYaml(ProblemLogger):
|
||||
else:
|
||||
self.critical("Signal %s has no class defined.", signal_name)
|
||||
continue
|
||||
self.check_unsupported_fields(signal_name, info)
|
||||
return calibration_variables, measurable_variables
|
||||
|
||||
def _get_class_info(self, variable_dict):
|
||||
@ -692,6 +671,9 @@ class CompositionYaml(ProblemLogger):
|
||||
"label": "Val",
|
||||
},
|
||||
}
|
||||
if self.build_cfg.get_composition_config("scaleMapsAndCurves") and "int" in info["type"].lower():
|
||||
new_data_type_data["slope"] = info["lsb"]
|
||||
new_data_type_data["bias"] = info["offset"]
|
||||
elif signal_name.startswith("m"):
|
||||
new_data_type_data = {
|
||||
"type": "COM_AXIS",
|
||||
@ -724,6 +706,9 @@ class CompositionYaml(ProblemLogger):
|
||||
"label": "Val",
|
||||
},
|
||||
}
|
||||
if self.build_cfg.get_composition_config("scaleMapsAndCurves") and "int" in info["type"].lower():
|
||||
new_data_type_data["slope"] = info["lsb"]
|
||||
new_data_type_data["bias"] = info["offset"]
|
||||
elif info["width"][0] == 1:
|
||||
new_data_type_name = f"dt_{signal_name}_{info['width'][1]}"
|
||||
new_data_type_data = {
|
||||
|
@ -214,6 +214,8 @@ base_data_types = {
|
||||
"axis-index": 1,
|
||||
"size": 10,
|
||||
"limits": {"lower": 0, "upper": 255},
|
||||
"slope": 1.0,
|
||||
"bias": 0.0,
|
||||
"swrecordlayout": {
|
||||
"name": "Distr_mVcGpaDemo_X_DummyTwo_r",
|
||||
"type": "INDEX_INCR",
|
||||
@ -226,6 +228,8 @@ base_data_types = {
|
||||
"axis-index": 2,
|
||||
"size": 25,
|
||||
"limits": {"lower": 0, "upper": 255},
|
||||
"slope": 1.0,
|
||||
"bias": 0.0,
|
||||
"swrecordlayout": {
|
||||
"name": "Distr_mVcGpaDemo_X_DummyTwo_c",
|
||||
"type": "INDEX_INCR",
|
||||
@ -238,6 +242,8 @@ base_data_types = {
|
||||
"x-axis": "dt_mVcGpaDemo_X_DummyTwo_r",
|
||||
"y-axis": "dt_mVcGpaDemo_X_DummyTwo_c",
|
||||
"limits": {"lower": 5, "upper": 10},
|
||||
"slope": 1.0,
|
||||
"bias": 0.0,
|
||||
"swrecordlayout": {
|
||||
"name": "Map_mVcGpaDemo_X_DummyTwo",
|
||||
"type": "COLUMN_DIR",
|
||||
|
@ -313,6 +313,8 @@ expected_result = {
|
||||
"axis-index": 1,
|
||||
"size": 10,
|
||||
"limits": {"lower": 0, "upper": 255},
|
||||
"slope": 1.0,
|
||||
"bias": 0.0,
|
||||
"swrecordlayout": {
|
||||
"name": "Distr_mVcGpaDemo_X_DummyTwo_r",
|
||||
"type": "INDEX_INCR",
|
||||
@ -325,6 +327,8 @@ expected_result = {
|
||||
"axis-index": 2,
|
||||
"size": 25,
|
||||
"limits": {"lower": 0, "upper": 255},
|
||||
"slope": 1.0,
|
||||
"bias": 0.0,
|
||||
"swrecordlayout": {
|
||||
"name": "Distr_mVcGpaDemo_X_DummyTwo_c",
|
||||
"type": "INDEX_INCR",
|
||||
@ -337,6 +341,8 @@ expected_result = {
|
||||
"x-axis": "dt_mVcGpaDemo_X_DummyTwo_r",
|
||||
"y-axis": "dt_mVcGpaDemo_X_DummyTwo_c",
|
||||
"limits": {"lower": 5, "upper": 10},
|
||||
"slope": 1.0,
|
||||
"bias": 0.0,
|
||||
"swrecordlayout": {
|
||||
"name": "Map_mVcGpaDemo_X_NotSameAsAxisTwo",
|
||||
"type": "COLUMN_DIR",
|
||||
|
@ -50,6 +50,7 @@ def mock_get_composition_config_default(key):
|
||||
'includeShared': True,
|
||||
'includeDiagnostics': True,
|
||||
'includeNvm': True,
|
||||
'scaleMapsAndCurves': True,
|
||||
}[key]
|
||||
|
||||
|
||||
@ -70,6 +71,7 @@ def mock_get_composition_config_custom_names(key):
|
||||
'includeShared': True,
|
||||
'includeDiagnostics': True,
|
||||
'includeNvm': True,
|
||||
'scaleMapsAndCurves': True,
|
||||
}[key]
|
||||
|
||||
|
||||
@ -117,23 +119,6 @@ class TestCompositionYaml(unittest.TestCase):
|
||||
self.build_cfg, self.zc_spec, self.unit_cfg, self.zc_core, self.zc_dids, self.nvm_def, {}, {}
|
||||
)
|
||||
|
||||
def test_check_unsupported_fields(self):
|
||||
"""Test CompositionYaml.check_unsupported_fields."""
|
||||
self.composition_yaml.warning = MagicMock()
|
||||
test_data = {
|
||||
"name": "sVcGpaDemo_D_BrkCtrlr",
|
||||
"type": "UInt8",
|
||||
"class": "CVC_DISP",
|
||||
"lsb": 1,
|
||||
"offset": "-",
|
||||
"width": 1,
|
||||
}
|
||||
self.composition_yaml.check_unsupported_fields("dummy", test_data)
|
||||
self.composition_yaml.warning.assert_not_called()
|
||||
test_data["lsb"] = 10
|
||||
self.composition_yaml.check_unsupported_fields("dummy", test_data)
|
||||
self.composition_yaml.warning.assert_called_once()
|
||||
|
||||
def test_composition_yaml(self):
|
||||
"""Checking that the dict is generated correctly"""
|
||||
result = self.composition_yaml.gather_yaml_info()
|
||||
|
Loading…
x
Reference in New Issue
Block a user