Diagnostics Domain
The diagnostics domain API is specifically designed to support diagnostics related use cases.
It is available from the com.vector.cfg.automation.scripting.base.IAutomationContext.IDomainApi IDomainApi in the form of the IDiagnosticsApi interface.
getDiagnostics allows accessing the IDiagnosticsApi like a property.
scriptTask('taskName') {
code {
// IDiagnosticsApi is available as "diagnostics" property
def diagnostics = domain.diagnostics
}
}
diagnostics(Transformer) allows accessing the IDiagnosticsApi in a scope-like way.
scriptTask('taskName') {
code {
domain.diagnostics {
// IDiagnosticsApi is available here
}
}
}
The following use cases are supported:
Dem Events
The API provides access and creation of IDemEvents in the configuration. See chapter IDemEvent for more
details.
DemEvents
An
IDemEvent instance represents a diagnostic event and and provides usecase centric functionalities to
modify and query diagnostic events.
Creating Dem Events
createDemEvent(Action) is used to create diagnostic events of different kinds.
The method can be configured to create different types of DTCs/Events:
-
UDS Event: This is the default type of event, when only an 'eventName' and a 'dtc' number is specified. A new DemEventParameter container with the given shortname and a new DemDTCClass with the given DemUdsDTC is created.
Create a new UDS DTC with eventscriptTask('taskName') { code { transaction { domain.diagnostics { def udsEvent = createDemEvent { eventName = "NewUdsEvent" dtc = 0x30 } }}}} -
OBD II Event: If OBD II is enabled for the loaded configuration, and a 'obd2Dtc' is specified instead of a 'dtc', the method will create an OBD II relevant event. The difference is, that it will set the parameter DemObdDTC instead of DemUdsDTC. It is also possible to specify 'dtc' as well as 'obd2dtc', which will result in both DTC parameters are set.
Enable OBD II and create a new OBD related DTC with eventscriptTask('taskName') { code { transaction { domain.diagnostics { // OBD must be enabled and legislation must be OBD2 // Enable OBD2 obd2Enabled = true def obd2Event = createDemEvent { eventName = 'NewOBD2Event' obd2Dtc = 0x40 } def obd2CombinedEvent = createDemEvent { eventName = 'UDS_OBD2_Combined_Event' dtc = 0x31 obd2Dtc = 0x41 } }}}} -
WWH-OBD Event: If WWH-OBD is enabled for the loaded configuration, and a 'wwhObdDtcClass' with a value other than 'NO_CLASS' is specified, the method will create a WWH-OBD relevant event. Note that WWH-OBD relevant events usually du reference the so called MIL indicator, thus this reference will be set by default in the newly created DemEventParameter.
Enable WWH-OBD and create a new OBD related DTC with eventscriptTask('taskName') { code { transaction { domain.diagnostics { // OBD must be enabled, and legislation must be WWH-OBD // The parameter '/Dem/DemGeneral/DemMILIndicatorRef' must be set wwhObdEnabled = true def wwhObdEvent = createDemEvent { eventName = 'WWHOBD_Event' dtc = 0x50 // wwhObdClass != NO_CLASS indicates WWH-OBD event wwhObdDtcClass = CLASS_A } }}}} -
J1939 Event: The last type of event is a J1939 related event, which can be created when J1939 is licensed and available for the loaded configuration. This is done in a similar way as for UDS events, but additionally specifying 'spn', 'fmi' values as well as the name of the referenced 'nodeAddress'.
Open a project, enable J1939 and create a new J1939 DTC with eventscriptTask('taskName') { code { def nodeAddressContainer = mdfModel(AsrPath.create("/ActiveEcuC/Dem/DemConfigSet/DemJ1939NodeAddress", MIContainer)) transaction { domain.diagnostics { // J1939 Event creation // J1939 must be enabled and License must be available. j1939Enabled = true def j1939Event = createDemEvent { eventName 'J1939_Event' dtc 0x30 spn 90 fmi 13 nodeAddress nodeAddressContainer } }}}}
Important Note:
For every DTC numbers apply the rule, that if there are already DemDTCClasses with the given number, they will be used. In such a case, no new DemDTCClass container is created.