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 DataSource with 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: Equation

Class 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:
str

Path within the owner and name of the Swan construct.

Raises:
ScadeOneException

If 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.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem], None]

Items to set owner.

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 ModuleBody and ModuleInterface or None if the object is itself a module.

property owner: SwanItem | IModel | None#

Owner of current Swan construct.

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: DiagramObject

Class 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:
str

Path within the owner and name of the Swan construct.

Raises:
ScadeOneException

If 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.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem], None]

Items to set owner.

property is_protected: bool#

True when sensor is syntactically incorrect and protected.

property locals: List[DiagramObject]#

Local objects of object.

property luid: Luid | None#

Luid of object, or None if no Luid.

property lunum: Lunum | None#

Lunum of object, or None if no Lunum.

property model: IModel#

Return model containing the Swan item.

property module: ModuleBase | None#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface or None if the object is itself a module.

property owner: SwanItem | IModel | None#

Owner of current Swan construct.

property pragmas: List[Pragma]#

List of pragmas.

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.