Mode Management Domain

The mode management domain API is specifically designed to support mode management related use cases. It is available from the com.vector.cfg.automation.scripting.base.IAutomationContext.IDomainApi IDomainApi in the form of the IModeManagementApi interface.

getModeManagement() allows accessing the IModeManagementApi like a property.

Accessing IModeManagementApi as a property
scriptTask('taskName') {
  code {
    // IModeManagementApi is available as "modeManagement" property
    def modeManagement = domain.modeManagement
  }
}

modeManagement(Transformer) allows accessing the IModeManagementApi in a scope-like way.

Accessing IModeManagementApi in a scope-like way
scriptTask('taskName') {
  code {
    domain.modeManagement {
      // IModeManagementApi is available inside this Closure
    }
  }
}

BswM Auto Configuration

The IBswMAutoConfigurationApi allows for semi-automatic creation of dedicated parts of the BswM configuration. The BswM auto configuration takes an input consisting of "features" and "parameters" to be provided via the IBswMAutoConfigurationApi. Each feature may have zero, one or more sub-features and zero, one or more parameters.

The corresponding BswM configuration content is derived based on the (de)activation of features and the values assigned to the parameters.

The available features and parameters depend strongly on the project's input data and general project setup. They can be addressed by String identifiers. These identifiers are best obtained from the corresponding auto configuration assistant of the BSW management editor in the Cfg5 GUI.

ECU State Handling Auto Configuration
scriptTask('EcuStateHandlingAutoConfiguration', DV_PROJECT) {
  code {
    // In projects with post-build selectable variance switching to an
    // IPredefinedVariantView for performing auto configuration is mandatory
    variance.variantView('Left').activeWith {

      domain.modeManagement.bswMAutoConfig('Ecu State Handling') {
        activate '/ECU State Machine/Support ComM'
        set '/ECU State Machine/Self Run Request Timeout' to 0.2
        set '/ECU State Machine/Number of Run Request User' to 4
        overrides {
          if (addition || removal) {
            keepOverride
          } else if (BswMArgumentRef.DefRef.isDefinitionOf(element)
                  && feature('/ECU State Machine/Support ComM/CAN00_f26020e5').enabled
                  && parameter('/ECU State Machine/Number of PostRun Request User').value == 4) {
            discardOverride
          } else {
            keepOverride
          }
        }
      }
    }
  }
}

Executing the BswM Auto Configuration

IModeManagementApi.bswMAutoConfig(String, Transformer) delegates the given code to the IBswMAutoConfigurationApi of the given BswM auto configuration domain. Also see overload bswMAutoConfig(MIContainer, String, Transformer) for using this API in multi partition use case.

Activating BswM Auto Configuration Features

activate(String) activates the BswM auto configuration feature with the given identifier. All enabled sub-features of the specified feature are also activated. Imagine the features displayed in a tree structure (like in Cfg5 GUI) where checking a tree node automatically checks all children.

Deactivating BswM Auto Configuration Features

deactivate(String) deactivates the BswM auto configuration feature with the given identifier. All enabled sub-features of the specified feature are also deactivated. Imagine the features displayed in a tree structure (like in Cfg5 GUI) where unchecking a tree node automatically unchecks all children.

Assigning Values to BswM Auto Configuration Parameters

set(String) sets the parameter with the given identifier to the specified value. Supported value types are boolean, BigInteger, Double, String and MIReferrable (reference parameters).

Manually Adapting the BswM Auto Configuration Content

The BswM auto configuration mechanism is useful for creating large parts of the BswM configuration based on certain built-in heuristics. Where these heuristics fail to fulfill detailed project specific requirements manual adaptations to the auto-generated configuration content become necessary.

Per default manual adjustments are kept in the configuration. But subsequent BswM auto configuration runs may render previously applied adjustments obsolete or dysfunctional. Using overrides(Action) a callback can be registered to be called for each detected adaptation. The callback can decide for each adjustment if it is to remain in the configuration or if it is to be overwritten by the BswM auto configuration. For details on which information is provided to this callback please refer to the javadoc provided with IBswMAutoConfigurationOverride.

Inspecting BswM Auto Configuration Domains

The getBswMAutoConfigDomains() method of the IModeManagementApi interface provides read-access to all available BswM auto configuration domains. Available features and parameters can be inspected for various properties. See javadoc of IBswMAutoConfigurationDomain, IBswMAutoConfigurationFeature and IBswMAutoConfigurationParameter for details. Also see overload getBswMAutoConfigDomains(MIContainer) for using this API in multi partition use case.

Inspecting Auto Configuration Elements
domain.modeManagement {
  // In projects with post-build selectable variance switching to an
  // IPredefinedVariantView for inspecting auto configuration is mandatory
  variance.variantView('Left').activeWith {

    // get all BswM auto configuration domains
    bswMAutoConfigDomains.forEach {
      scriptLogger.info it.identifier
    }

    def isEnabled = bswMAutoConfigDomain 'Ecu State Handling' feature '/ECU State Machine/Support ComM' enabled
    def isActivated = bswMAutoConfigDomain 'Ecu State Handling' feature '/ECU State Machine/Support ComM' activated
    if (isEnabled && isActivated) {
      // activation state can be toggled at enabled features only
      bswMAutoConfig('Ecu State Handling') {
        deactivate '/ECU State Machine/Support ComM'
      }
    }

    bswMAutoConfigDomain('Ecu State Handling') {
      // this code is delegated to the 'Ecu State Handling'
      // auto configuration domain
      def p1 = parameter '/ECU State Machine/Self Run Request Timeout' value
      scriptLogger.info 'Self Run Request Timeout = ' + p1
      def p2 = parameter '/ECU State Machine/Number of Run Request User' value
      scriptLogger.info 'Number of Run Request User = ' + p2

      // get all root features
      rootFeatures.forEach { scriptLogger.info it.identifier }

      // get all sub-features of a feature
      feature '/ECU State Machine/Support ComM' subFeatures.forEach {
        scriptLogger.info it.identifier
      }

      // get all parameters of a feature
      feature '/ECU State Machine' parameters.forEach {
        scriptLogger.info it.identifier
      }
    }
  }
}