Communication Domain
CAN Communication API
The communication domain API is specifically designed to support communication related use cases.
It is available from the com.vector.cfg.automation.scripting.base.IAutomationContext.IDomainApi IDomainApi in the form of the ICommunicationApi interface.
getCommunication() allows accessing the ICommunicationApi like a property.
scriptTask('taskName') {
code {
// ICommunicationApi is available as "communication" property
def communication = domain.communication
}
}
communication(Transformer) allows accessing the ICommunicationApi in a scope-like way.
scriptTask('taskName') {
code {
domain.communication {
// ICommunicationApi is available inside this Closure
}
}
}
The following use cases are supported:
Accessing Can Controllers
getCanControllers() returns a list of all ICanControllers in the configuration ICanController.
Accessing Can Pdus
getCanPdus() returns a list of all ICanPdus in the configuration. Can Pdus of a certain Can Controller can also be accessed via
ICanController.getCanPdus(). ICanPdu
CanControllers
An
ICanController instance represents a CanController MIContainer providing support for use
cases exceeding those supported by the model API.
scriptTask('OptimizeAcceptanceFilters') {
code {
transaction {
domain.communication {
// open acceptance filters of all CanControllers
canControllers*.openAcceptanceFilters()
// open acceptance filters of first CanController
canControllers.first.openAcceptanceFilters()
canControllers[0].openAcceptanceFilters() // same as above
// open acceptance filters of second CanController
// (if there is a second CanController)
canControllers[1]?.openAcceptanceFilters()
// open acceptance filters of a dedicated CanController
canControllers.filter { it.getMdfObject().getName().contains 'CH0' }.single.openAcceptanceFilters()
// accessing a dedicated CanController
def ch0 = canControllers.filter { it.getMdfObject().getName().contains 'CH0' }.single
// assert: ch0's first CanFilterMask value is XXXXXXXXXXX
assert 'XXXXXXXXXXX' == ch0.canFilterMasks[0].filter
// set CanFilterMask value to 01111111111
ch0.canFilterMasks[0].filter = '01111111111'
assert '01111111111' == ch0.canFilterMasks[0].filter
// automatic acceptance filter optimization
ch0.optimizeFilters { fullCan = true }
}
}
scriptLogger.info('Successfully optimized Can acceptance filters.')
}
}
Opening Acceptance Filters
openAcceptanceFilters() opens all of this ICanController's acceptance filters.
Optimizing Acceptance Filters
optimizeFilters(Action) optimizes this ICanController's acceptance filter mask configurations. The given
Closure is delegated to the IOptimizeAcceptanceFiltersApi interface for parameterizing the optimization.
Using
setFullCan(boolean) it can be specified whether the optimization
shall take full can objects into account or not.
Creating new CanFilterMasks
createCanFilterMask() creates a new ICanFilterMask for this ICanController.
CanFilterMasks
An
ICanFilterMask instance represents a CanFilterMask MIContainer providing support for use
cases exceeding those supported by the model API.
For example code see ICanController. The following use cases are supported:
Filter Types
ECanAcceptanceFilterType lists the possible values for an ICanFilterMask's filter type.
++++++
+++STANDARD results in a standard Can acceptance filter value with length 11.+++
++++++
EXTENDED results in an extended Can acceptance filter value with length 29.
MIXED
results in a mixed Can acceptance filter value with length 29.
+ === Accessing a CanFilterMask's Filter Type +
getFilterType() returns this ICanFilterMask's filter type.
+ === Specifying a CanFilterMask's Filter Type + Using
setFilterType(ECanAcceptanceFilterType) this ICanFilterMask's filter type can be specified.
+ === Accessing a CanFilterMask's Filter Value +
getFilter() returns this ICanFilterMask's filter value. A CanFilterMask's filter value is a String
containing the characters '0', '1' and 'X' (don't care). For determining if a given Can ID passes the filter it is matched bit for bit against the String's
characters. The character at index 0 is matched against the most significant bit. The character at index length() - 1 is matched against the least significant
bit. The length of the String corresponds to the CanFilterMask's filter type.
+ === Specifying a CanFilterMask's Filter Value + Using
setFilter(String) this ICanFilterMask's filter value can be specified.
+ === Accessing a CanFilterMask's MIContainer +
getMdfObject() returns the MIContainer represented by this ICanFilterMask.
+
== CanPdus
+
++++++
+++AnICanPdu represents a Pdu of the CanIf module.+++
+++
+++-
++++++
disableFullCan()disables the FullCAN feature for thisICanPdu. In other words the corresponding FullCAN hardware object will be deleted and the references redirected to a suitable BasicCAN hardware object.
To enable the FullCAN feature please use
enableFullCan(). -
++++++
enableFullCan()enables the FullCAN feature for thisICanPdu. In other words a corresponding FullCAN hardware object will be created and the references of the relevant objects redirected to it from the previously referenced BasicCAN hardware object.
To disable the FullCAN feature please use
disableFullCan(). If the FullCAN feature is already enabled can be checked usingisFullCanEnabled(). This might be useful to avoid multiple hardware objects for the same PDU, when usingenableFullCan()more than once on the same PDU. -
++++++
setFullCanLocked(boolean)switches whether the filter optimization algorithm is allowed to change the configured CAN handle type (BasicCAN/FullCAN) or not.If locked the selected CAN handle type (FullCAN/BasicCAN) of the corresponding Rx-PDU is NOT touched and NOT changed by the filter optimization algorithm.
Tx
ICanPdus are ignored by this method, since the lock is only available for RxICanPdus. -
++++++
isFullCanEnabled()determines whether the configured CAN handle type is FullCAN or BasicCAN .The CAN handle type can be changed between FullCAN and BasicCAN using
enableFullCan()anddisableFullCan()methods. -
++++++
isFullCanLocked()determines whether the CAN handle type is locked for the filter optimization algorithm.
Note: Only RxICanPdus can be locked, so returns always false for TxICanPdus.
+++
+++Accessing a CanController’s CanPdus
getCanPdus() returns all of this ICanController's ICanPdus.
+++
+++Accessing a CanPdu’s MIContainer
getMdfObject() returns the MIContainer represented by this ICanPdu.
import com.vector.cfg.model.asr.view.IModelViewExecutionContext
scriptTask("enableFullCAN", DV_PROJECT){
code {
transaction {
domain.communication {
variance {
getAllPostBuildVariantViewsOrInvariant().each {
if (it.getName().equals("Left")) {
final IModelViewExecutionContext context = it.executeWithThisView()
context.withCloseable {
canPdus.filter {
it.getMdfObject().getName().equals("RxFullCanDisabled1_0a94227e_Rx")
}*.enableFullCan()
}
}
}
}
}
}
}
}
import com.vector.cfg.model.asr.view.IModelViewExecutionContext
scriptTask("disableFullCAN", DV_PROJECT){
code {
transaction {
domain.communication {
variance {
getAllPostBuildVariantViewsOrInvariant().each {
if (it.getName().equals("Left")) {
final IModelViewExecutionContext context = it.executeWithThisView()
context.withCloseable {
canControllers.filter {
it.getMdfObject().getName().equals("Controller_MyEcu_1_2514e902")
}*.canPdus
.flatten()
*.disableFullCan()
}
}
}
}
}
}
}
}