Sensor handling#
Sensors can be defined within a Test module. There are three ways to define the value of a sensor:
using a _sensor sensor_name block in a diagram,
using a sensor_name := expr equation in a let scope section,
or providing a
DataSourcewith the sensor values.
To add a _sensor sensor_name block to a Test module, use the DiagramCreator.add_set_sensor() method,
and connect its input to the appropriate expression in the diagram.
Sensors found in a data source are automatically connected to their corresponding sensors. There is no need to create explicit connections in the diagram.
To add an equation, one must create the equation and add it to a let scope section.
SetSensorEquation class#
- class ansys.scadeone.core.swan.SetSensorEquation(sensor: PathIdentifier, value: Expression)#
Bases:
EquationClass representing a set sensor equation in the harness.
- get_full_path() str#
Full path of the Swan construct.
This method is implemented by derived classes that correspond to a declaration at the module level (such as sensor, type, group, const, operator), or a module itself.
- Returns:
strPath within the owner and name of the Swan construct.
- Raises:
ScadeOneExceptionIf the method is not implemented for the current SwanItem type.
- static set_owner(owner: SwanItem | IModel | None, children: SwanItem | Iterable[SwanItem] | None) None#
Helper to set owner as the owner of each item in the Iterable items.
- property is_protected: bool#
Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).
- property model: IModel#
Return model containing the Swan item.
- property module: ModuleBase | None#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBodyandModuleInterfaceor None if the object is itself a module.
- property sensor: PathIdentifier#
Sensor identifier.
- property value: Expression#
Value to set.
SetSensorBlock class#
- class ansys.scadeone.core.swan.SetSensorBlock(sensor: PathIdentifier | ProtectedItem, lunum: Lunum | None = None, luid: Luid | None = None, locals: List[DiagramObject] | None = None, pragmas: List[Pragma] | None = None)#
Bases:
DiagramObjectClass representing a set sensor block in the harness.
- get_full_path() str#
Full path of the Swan construct.
This method is implemented by derived classes that correspond to a declaration at the module level (such as sensor, type, group, const, operator), or a module itself.
- Returns:
strPath within the owner and name of the Swan construct.
- Raises:
ScadeOneExceptionIf the method is not implemented for the current SwanItem type.
- static set_owner(owner: SwanItem | IModel | None, children: SwanItem | Iterable[SwanItem] | None) None#
Helper to set owner as the owner of each item in the Iterable items.
- property locals: List[DiagramObject]#
Local objects of object.
- property model: IModel#
Return model containing the Swan item.
- property module: ModuleBase | None#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBodyandModuleInterfaceor None if the object is itself a module.
- property sensor: PathIdentifier | ProtectedItem#
Sensor identifier.
- property sources: List[tuple[DiagramObject, GroupAdaptation, List[GroupAdaptation] | None]]#
Return a list of all diagram objects that are sources of current diagram object. A list item is a tuple of source object and the source and target adaptations used for connection if any.
- property targets: List[tuple[DiagramObject, GroupAdaptation, GroupAdaptation]]#
Return a list of all diagram objects that are targets of current diagram object. A list item is a tuple of target object and the source and target adaptations used for connection if any.