PreBuild and PostBuild Variance
The variance access API is the entry point for convenient access to variant AUTOSAR model content. It provides means to filter variant model content and access variant specific data.
The DaVinci Configurator supports two types of variance:
- PostBuild variance (Post-build selectable)
- PreBuild variance
Investigate Project Variance
The projects variance can be analyzed using the variance keyword. These methods can be called then:
- The method
getCurrentlyActiveView()returns the currently active model view. -
The method
variantView(String)returns theIPostBuildPredefinedVariantViewwith the given name. This may be a PreBuild of PostBuild view.
scriptTask("TaskName", DV_PROJECT){
code{
// Activates the DoorLeftFront variant
variance.variantView("DoorLeftFront").activeWith{
// Now all MDF model accesses are executed in the variant "DoorLeftFront"
}
}
}
scriptTask("TaskName", DV_PROJECT){
code{
def activeView1 = variance.currentlyActiveView
assert activeView1 instanceof IPostBuildInvariantValuesView
// ... or with a closure
variance {
def activeView2 = currentlyActiveView
assert activeView1 == activeView2
assert activeView1 == postBuildInvariantValuesView
// Get number of variants
int num = allPostBuildVariantViews.size()
assert num == 4
}
}
}
Investigate Project Variance - PostBuild
-
The method
hasPostBuildVariance()returnstrueif the active project contains post-build variants. -
The method
getPostBuildInvariantValuesView()returns the PostBuild invariant values view. This view contains objects which are not variant (Object or parent have no VariationPoint) or the values in all variants are equal. -
The method
getPostBuildInvariantEcucDefView()returns the PostBuild invariant Ecuc definition view. This view contains the same objects as the invariant values view but excludes all objects which, by (EcuC / BSWMD) definition, support variance. Using this view you can avoid dealing with objects which are accidentally equal by value (in your test configurations) but potentially can be different because they support variance. -
The method
getAllPostBuildVariantViews()returns the model views of all PostBuild predefined variants defined in the evaluated variant set. It never returnsnull. If the project contains no PostBuild variants, the result will be an empty list.The order of variant views returned is deterministic. It is the natural order of the names of the variants defined in the evaluated variant set.
-
The method
getAllPostBuildVariantViewsOrInvariant()returns the same as the methodgetAllPostBuildVariantViews()if the project contains PostBuild variants. If the project contains no PostBuld variants (seehasPostBuildVariance()) the method returns a list containing only theIPostBuildInvariantValuesView.This helps to create code working with both variant and non-variant projects.
Variant Model Objects
The following model object extensions provide convenient means to investigate model object variance in detail.
The method
IModelView.activeWith(Supplier)executes code under visibility of the specified model view.-
The method
MIObject.isModelInvariant()returnstrueif the object and all its parents has no variation point conditions. If this istrue, this model object instance is visible in all variant view. The method
MIObject.isVisible()returnstrueif the object is visible in the current model view.The method
MIObject.isVisibleInModelView(IModelView)returnstrueif the object is visible in the specified model view.The method
MIObject.asViewedModelObject()returns a newIViewedModelObjectinstance using the currently active view.-
The method
For details about the sibling semantic see VariantSiblings.MIObject.getPostBuildVariantSiblings()returns MDF object instances representing the same object but in all variants. -
The method
getPostBuildVariantSiblingsWithoutMyself(MIObject)returns the same collection asgetPostBuildVariantSiblings(MIObject)but without the specified object.
// IPostBuildPredefinedVariantView viewDoorLeftFront = ...
// MIParameterValue variantParameter = ...
viewDoorLeftFront.activeWith {
assert variance.currentlyActiveView == viewDoorLeftFront
// The parameter instance is not visible in all variants ...
assert !variantParameter.isModelInvariant()
// ... but all variants have a sibling with the same value
assert variantParameter.isPostBuildValueInvariant()
}
Variant Model Objects - PostBuild
-
The method
MIObject.isPostBuildValueInvariant()returnstrueif the object has the same value in all PostBuild variants.See
IPostBuildInvariantValuesViewfor more details to the concept.Attention: This must also return true for elements in other variants as the first PostBuild Predefined Variant, when the element is invariant! This is not the same result as
For details about invariant views see InvariantModelViews.IPostBuildInvariantValuesViewisVisible()method returns. -
The method
MIObject.isPostBuildEcucDefInvariant()returnstrueif the object is invariant according to its EcuC definition.See
IPostBuildInvariantEcucDefViewfor more details to the concept.Attention: This must also return true for elements in other variants as the first PostBuild Predefined Variant, when the element is invariant! This is not the same result as
IPostBuildInvariantEcucDefViewisVisible()method returns. The method
MIObject.isNeverPostBuildVisible()returnstrue, if the object is invisible in all variant view.-
The method
MIObject.getVisiblePostBuildVariantViews(MIObject)returns all variant views the specified object is visible in. -
The method
MIObject.getVisiblePostBuildVariantViews(MIObject)returns all variant views the specified object is visible in.