Picking one ECUC module through instance a new EcucData with the ECUC module name. Picking one ECUC module is start of future ECUC element picking.
/* Pick Can module */
var can = new EcucData(instanceManager, bswmdManager, "Can");
After picking a module, the further element element can be picked by [] operation.
- Further element name.
- Filter function to filter result.
[] operation can be chained to continous picking level after level.
Member, the result of [] is a list.
/* Pick controller from CanConfigSet of Can module.
Controller name shall not end with "_001" and "_002" */
var controllers = can["CanConfigSet"]["CanController", x => !(x.AsrPathShort.EndsWith("_001") || x.AsrPathShort.EndsWith("_002"))];
The value is stored in element and can be got by property "Value". Since [] operation return a list of EcucData, the value of first EcucData can be got through property "FirstValue". List of EcucData also has "Value" property return a list of value for each element.
/* Pick CanIf module */
var canIf = new EcucData(instanceManager, bswmdManager, "CanIf");
/* Pick CanIfRxPduCfgs which CanIfRxPduUserRxIndicationUL element is not "CAN_NM" */
var canIdTypeContainers = canIf["CanIfInitCfg"]["CanIfRxPduCfg", x => x["CanIfRxPduUserRxIndicationUL"].FirstValue != "CAN_NM"]["CanIfRxPduCanIdType"];
/* Pick all Id Types */
var canIdTypes = canIdTypeContainers.Value;
Since value is stored as string, property "ValueAsInt" is used to pick integer result;
/* Pick all filters in CanFilterMask */
var filters = controllers["CanFilterMask"];
/* Pick CanFilterCodeValue as integer */
var codeValues = filters["CanFilterCodeValue"].ValueAsInt;
/* Pick CanFilterMaskValue as integer */
var maskValues = filters["CanFilterMaskValue"].ValueAsInt;
AddContainer and AddContainerWithRequiredField of EcucData are used to add sub container with specified name.
AddContainer will add a empty subcontainer with no sub container and value. AddContainerWithRequiredFiel will add a subcontainer with required sub container and value.
- Container name
- Container instance name
/* Pick CanHardwareObject from CanController from CanConfigSet */
var controller = data["CanConfigSet"]["CanController", x => !(x.Value.EndsWith("_001") || x.Value.EndsWith("_002"))].First;
var hardwareObject = data["CanConfigSet"]["CanHardwareObject", x => x.Value.EndsWith("Rx")].First;
/* Add container CanFilterMask to CanController */
var filter = controller.AddContainerWithRequiredField("CanFilterMask", $"CanFilterMaskRx_0x{id:X3}");
Method UpdateValidStatus of EcucData is used to set EcucData validatation result. The validation result will implict transfer to upper element.
- Status of validation to set. True for valid and false for invalid.
- Hit message of validation.
/* Set Can module to invalid whit hint "Filter missing" */
can.UpdateValidStatus(false, "Filter missing");
/* Set Can module back to valid */
can.UpdateValidStatus(true);
Method UpdateValidSolve of EcucData is used to set EcucData validatation soultion.
- Hit message of solution.
- Function of solution.
- Parameter transfer to function.
/* Add soultion to Can module */
can.UpdateValidSolve($"Add missing filter 0x{frame.ID:X3}", FixCanFilter, frame.ID);
/* Fix Can filter solution */
private void FixCanFilter(EcucData data, object? idSuggest)
{
if (idSuggest is uint id)
{
/* Pick CanHardwareObject from CanController from CanConfigSet */
var controller = data["CanConfigSet"]["CanController", x => !(x.Value.EndsWith("_001") || x.Value.EndsWith("_002"))].First;
var hardwareObject = data["CanConfigSet"]["CanHardwareObject", x => x.Value.EndsWith("Rx")].First;
/* Add container CanFilterMask to CanController */
var filter = controller.AddContainerWithRequiredField("CanFilterMask", $"CanFilterMaskRx_0x{id:X3}");
/* Update CanFilterMask value */
filter["CanFilterMaskValue"].FirstValueAsInt = 0x7FF;
filter["CanFilterCodeValue"].FirstValueAsInt = id;
filter["IsLocked"].FirstValue = "false";
/* Add reference CanFilterMaskRef to CanFilterMask */
hardwareObject.AddRef("CanFilterMaskRef", filter.AsrPath);
}
}