Model-based Bus Port API¶
BusToModelPathResolver¶
- class BusToModelPathResolver¶
This class describes the interface of a BusToModelPathResolver.
In order for ecu.test to recognize a class as a
BusToModelPathResolver, the class must meet the requirements of this interface. In addition, theMODULE_TYPEmust be set toBUS_TO_MODEL_PATH_RESOLVER.import ... MODULE_TYPE = 'BUS_TO_MODEL_PATH_RESOLVER' class MyBusToModelPathResolver: def __init__(self, properties: dict[str, str | bool]) -> None: ...- __init__(properties)¶
- Parameters:
- properties : dict[str, str | bool]¶
Dictionary with the properties from the test bench configuration for this BusToModelPathResolver and the configured values. The possible properties are defined by the return value of the
GetProperties()method.
- classmethod GetName()¶
Provides the name of the BusToModelPathResolver. This name is displayed as the implementation type of a bus port for tools that support this type of port.
- Returns:
Name of the port
- Return type:
str
- classmethod GetProperties()¶
Optional (does not have to be implemented)
Properties of the custom BusToModelPathResolver. These properties can be configured in the test bench configuration. The configured properties are passed to the custom BusToModelPathResolver constructor when the configuration is started. Available property types are STRING, BOOL and CHOICE. Properties may be sorted into groups to improve visual separation in the test bench configuration.
Example:
@classmethod def GetProperties(cls) -> dict[str, dict]: return { 'Group 1': { 'Option 1': { 'Description': 'This is Option 1', 'Type': 'STRING', 'Default': 'default value', }, 'Option 2': { 'Description': 'This is Option 2', 'Type': 'BOOL', 'Default': True, }, 'Option 3': { 'Description': 'This is Option 3', 'Type': 'CHOICE', 'Choices': ['c1', 'c2', 'c3'], 'Default': 'c2', }, } }The above example will generate the following properties:
- Returns:
Dictionary with properties of the custom BusToModelPathResolver.
- Return type:
dict[str, dict]
- GetSettings()¶
Optional (does not have to be implemented)
Can be used to overwrite the default values of certain settings. If a setting is not overwritten, its default value is used.
- Returns:
Dictionary with new settings
- Return type:
- GetConstants()¶
Optional (does not have to be implemented)
Can be used to overwrite the default values of certain constants. If a constant is not overwritten, its default value is used.
- Returns:
Dictionary with new constant values
- Return type:
- GetTxPath(busEntity)¶
Returns the model path for manipulation when a Write, Stimulate or Reset test step is executed on a bus signal. The setpoint value will be written to that model path. Such a model path is called Tx or transmission path in this context because it typically denotes a variable that is transmitted by the model as part of a restbus simulation.
For some models it is necessary to activate the manipulation by changing another model value. The path for that can be specified within the implemetation of
GetTxSwitchPath().
- GetRxPath(busEntity)¶
Returns the model path with the current value when a Read test step is executed on a bus signal. Such a model path is called Rx or receive path because it typically denotes a variable that is received by the model.
- GetTxSwitchPath(busEntity)¶
Optional (does not have to be implemented)
Returns the model path for manipulation activation when a Write, Stimulate or Reset test step is executed on a bus signal.
Such model paths are called switch or control, as they switch the source for the associated bus signal from the model to a constant or vice versa.
The value that will be written to that model path depends on the test step. Depending on the signal being an alive, CRC or standard signal the value is one of the following:
physical input, set for Write/Stimulate
Constants.ActivateSignalManipulationConstants.ActivateCrcSignalManipulationConstants.ActivateAliveSignalManipulation
simulation or calculation by the model, set for Reset:
Constants.DeactivateSignalManipulationConstants.DeactivateCrcSignalManipulationConstants.DeactivateAliveSignalManipulation
Illustration of a switch:
- GetPduEnablePath(busEntity)¶
Returns the model path for enabling or disabling a PDU.
The value that will be written to that model path depends on the action:
Constants.EnablePdu: PDU is being enabledConstants.DisablePdu: PDU is being disabled
- GetPduEnableSwitchPath(busEntity)¶
Returns the model path for the activation of the corresponding signal that enables or disables a PDU, see GetPduEnablePath.
The value that will be written to that model path depends on the action:
Constants.ActivateSignalManipulation: activates the corresponding signalConstants.DeactivateSignalManipulation: deactivates the corresponding signal
- GetFeatureSwitchPath(busEntity)¶
Optional (does not have to be implemented)
Returns the model path for enabling or disabling a feature switch.
The value that will be written to that model path depends on the action:
Constants.OverwritePermanentlyFeatureSwitchValue: feature switch is being enabledConstants.NoneFeatureSwitchValue: feature switch is being disabled
- GetFeatureSwitchSwitchPath(busEntity)¶
Optional (does not have to be implemented)
Returns the model path for the activation of the corresponding signal that enables or disables a feature switch, see GetFeatureSwitchPath.
The value that will be written to that model path depends on the action:
Constants.ActivateSignalManipulation: activates the corresponding signalConstants.DeactivateSignalManipulation: deactivates the corresponding signal
- GetPduTimingPath(busEntity)¶
Optional (does not have to be implemented)
Returns the model path used to control the PDU timing in a Change Timing test step.
- GetPduTimingSwitchPath(busEntity)¶
Optional (does not have to be implemented)
Returns the model path for the activation of the corresponding signal that controls the PDU timing, see GetPduTimingPath.
The value that will be written to that model path depends on the action:
Constants.ActivateSignalManipulation: activates the corresponding signalConstants.DeactivateSignalManipulation: deactivates the corresponding signal
Settings¶
- class Settings¶
Bases:
TypedDictPossible settings.
All settings are optional. This means that they do not have to be set explicitly. Each setting has a default value. If the setting is not set, the default value is used.
- TxSwitchBehavior : NotRequired[Literal['BeforeConst', 'AfterConst']]¶
Determines the behavior, whether the switch is written before or after the constant.
Default:
AfterConst
- RestoreBehaviour : NotRequired[Literal['Default', 'SwitchModel']]¶
Determines the behavior when performing a reset.
DefaultBoth switch and const value are reset to their initial values.SwitchModelThe switch will always be reset to “use the calculated value”. The const value is not changed.
Default:
Default
- AlterPduTimingSupport : NotRequired[bool]¶
Indicates whether the BusToModelPathResolver implementation and the associated model port supports setting the PDU timing.
Activating this setting means that the
BusToModelPathResolver.GetPduTimingPath()method must be implemented.Default:
False
- PduCycleTimeFactor : NotRequired[float]¶
Factor by which the cycle time is multiplied. ecu.test writes the cycle time in milliseconds. This factor can be used to change the unit of the cycle time.
If, for example, the value should be written in seconds instead of milliseconds, the factor 0.001 can be used:
1000ms * 0.001 = 1.0s
Default:
1.0
- FeatureSwitchSupport : NotRequired[bool]¶
Indicates whether the BusToModelPathResolver implementation and the associated model port supports FeatureSwitches. FeatureSwitches are a feature of dSPACE BusManager.
Activating this setting means that the
BusToModelPathResolver.GetFeatureSwitchPath()method must be implemented.Default:
False
Constants¶
- class Constants¶
Bases:
TypedDictPossible constants.
All constants are optional. This means that they do not have to be set explicitly. Each constant has a default value. If the constant is not set, the default value is used.
- DeactivateCrcSignalManipulation : NotRequired[int]¶
This value is written to the switch in order to set the switch back to simulation as the source for the CRC signal.
Default:
0
- ActivateCrcSignalManipulation : NotRequired[int]¶
This value is written to the switch in order to set the switch to a constant value as the source for the CRC signal.
Default:
1
- DeactivateAliveSignalManipulation : NotRequired[int]¶
This value is written to the switch in order to set the switch back to simulation as the source for the alive signal.
Default:
0
- ActivateAliveSignalManipulation : NotRequired[int]¶
This value is written to the switch in order to set the switch to a constant value as the source for the alive signal.
Default:
1
- DeactivateSignalManipulation : NotRequired[int]¶
This value is written to the switch in order to set the switch back to simulation as the source for the signal.
Default:
0
- ActivateSignalManipulation : NotRequired[int]¶
This value is written to the switch in order to set the switch to a constant value as the source for the signal.
Default:
1
- NoneFeatureSwitchValue : NotRequired[int]¶
This value is written to the FeatureSwitch in order to set it to None.
Default:
0
- OverwritePermanentlyFeatureSwitchValue : NotRequired[int]¶
This value is written to the FeatureSwitch in order to permanently enable it.
Default:
1
- DisablePdu : NotRequired[int]¶
This value is written to the PDU enable path in order to deactivate PDUs.
Default:
0
- EnablePdu : NotRequired[int]¶
This value is written to the PDU enable path in order to enable PDUs.
Default:
1