Diagrams#

A Diagram object stores the representation of a diagram. It contains the various blocks (see figure) and connections using Wire instances.

../../../_images/diagram.svg

Diagram class diagram#

class ansys.scadeone.core.swan.Diagram(objects: List[DiagramObject])#

Bases: ScopeSection

Class for a diagram construct.

get_block_sources(obj: DiagramObject) List[tuple[DiagramObject, GroupAdaptation | None, GroupAdaptation | None]]#

Return a list of all diagram objects that are sources of current diagram.

A list item is a tuple of source object and the source and target adaptations used for connection if any.

get_block_targets(obj: DiagramObject) List[tuple[DiagramObject, GroupAdaptation | None, GroupAdaptation | None]]#

Return a list of all diagram objects that are targets of current diagram.

A list item is a tuple of source object and the source and target adaptations used for connection if any.

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

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 is_text: bool#

True when section is given from {text%…%text} markup.

property model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property objects: List[DiagramObject]#

Diagram objects.

property owner: Self#

Owner of current Swan construct.

class ansys.scadeone.core.swan.DiagramObject(lunum: Lunum | None = None, luid: Luid | None = None, locals: List[Self] | None = None, pragmas: List[Pragma] | None = None)#

Bases: SwanItem, PragmaBase

Base class for diagram objects.

object ::= ( [[ lunum ]] [[ luid ]] description [[ local_objects ]] )

Parameters:
lunum: Lunum (optional)

Object local unique number within the current operator.

luid: Luid (optional)

Object local unique identifier within the current operator.

locals: list DiagramObject

List of local objects associated with the object. If locals is None, an empty list is created.

get_full_path() str#

Full path of Swan construct.

pragma_str() str#

Return a string with all pragmas.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

to_str() str#

String representation. Must be overridden by subclasses.

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 locals: List[Self]#

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: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

property pragmas: List[Pragma]#

List of pragmas.

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.

Diagram objects#

This section describes the expr, def and block related classes.

class ansys.scadeone.core.swan.ExprBlock(expr: Expression, lunum: Lunum | None = None, luid: Luid | None = None, locals: List[Self] | None = None, pragmas: List[Pragma] | None = None)#

Bases: DiagramObject

Expression block:

  • object ::= ( [[ lunum ]] [[ luid ]] description [[ local_objects ]] )

  • description ::= expr expr

get_full_path() str#

Full path of Swan construct.

pragma_str() str#

Return a string with all pragmas.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

to_str() str#

Expr to string.

property expr: Expression#

Block expression.

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 locals: List[Self]#

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: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

property pragmas: List[Pragma]#

List of pragmas.

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.

class ansys.scadeone.core.swan.DefBlock(lhs: EquationLHS | ProtectedItem, lunum: Lunum | None = None, luid: Luid | None = None, locals: List[DiagramObject] | None = None, pragmas: List[Pragma] | None = None)#

Bases: DiagramObject

Definition block:

  • object ::= ( [[ lunum ]] [[ luid ]] description [[ local_objects ]] )

  • description ::= def lhs

  • description ::= def {syntax% text %syntax}

The is_protected property returns True when the definition is protected with a markup.

get_full_path() str#

Full path of Swan construct.

pragma_str() str#

Return a string with all pragmas.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

to_str() str#

Def to string.

property is_protected#

True when definition is syntactically incorrect and protected.

property lhs: EquationLHS | ProtectedItem#

Returned defined flows.

property locals: List[Self]#

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: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

property pragmas: List[Pragma]#

List of pragmas.

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.

class ansys.scadeone.core.swan.Block(instance: OperatorBase | OperatorExpression | ProtectedItem, lunum: Lunum | None = None, luid: Luid | None = None, locals: List[DiagramObject] | None = None, pragmas: List[Pragma] | None = None)#

Bases: DiagramObject

Generic block:

  • object ::= ( [[ lunum ]] [[ luid ]] description [[ local_objects ]] )

  • description ::= block (operator | op_expr )

  • description ::= block {syntax% text %syntax}

The is_protected property returns True when the block definition is protected with a markup.

get_full_path() str#

Full path of Swan construct.

pragma_str() str#

Return a string with all pragmas.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

to_str() str#

Block to string.

property instance: OperatorBase | OperatorExpression | ProtectedItem#

Called instance as an Operator, or an OperatorExpression or a protected string.

property is_protected#

True when called operator is defined as a string.

property locals: List[Self]#

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: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

property pragmas: List[Pragma]#

List of pragmas.

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.

Group/ungroup block (bar)#

The bar block is used to group/ungroup wires.

class ansys.scadeone.core.swan.Bar(operation: GroupOperation | None = GroupOperation.NoOp, lunum: Lunum | None = None, locals: List[DiagramObject] | None = None, pragmas: List[Pragma] | None = None)#

Bases: DiagramObject

Bar (group/ungroup constructor block):

  • object ::= ( [[ lunum ]] description [[ local_objects ]] )

  • description ::= group [[group_operation]]

  • group_operation ::= () | byname | bypos

get_full_path() str#

Full path of Swan construct.

pragma_str() str#

Return a string with all pragmas.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

to_str() str#

Group to string.

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 locals: List[Self]#

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: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property operation: GroupOperation#

Group operation.

property owner: Self#

Owner of current Swan construct.

property pragmas: List[Pragma]#

List of pragmas.

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.

class ansys.scadeone.core.swan.GroupOperation(value)#

Bases: Enum

Operation on groups.

static to_str(value: Self)#

Group Enum to string.

ByName = 2#

byname operation (keep named items)

ByPos = 3#

bypos operation (keep positional items)

NoOp = 1#

No operation on group

Normalize = 4#

Normalization operation (positional, then named items)

Wire and connections#

class ansys.scadeone.core.swan.Wire(source: Connection, targets: List[Connection], lunum: Lunum | None = None, locals: List[DiagramObject] | None = None, pragmas: List[Pragma] | None = None)#

Bases: DiagramObject

Wire definition:

  • object ::= ( [[ lunum ]] description [[ local_objects ]] )

  • description ::= wire connection => connection {{ , connection }}

A wire must have a least one target.

get_full_path() str#

Full path of Swan construct.

pragma_str() str#

Return a string with all pragmas.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

to_str() str#

Wire to string.

property has_target: bool#

Return True when wire as at least one target.

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 locals: List[Self]#

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: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

property pragmas: List[Pragma]#

List of pragmas.

property source: Connection#

Wire source.

property sources: List[tuple[DiagramObject, GroupAdaptation | None]]#

This method must not be called for a Wire

property targets: List[Connection]#

Wire targets.

class ansys.scadeone.core.swan.Connection(port: PortExpr | None = None, adaptation: GroupAdaptation | None = None)#

Bases: SwanItem

Wire connection for a source or for targets:

  • connection ::= port [[ group_adaptation ]] | ()

If both port and adaptation are None, then it corresponds to the ‘()’ form.

Connection is not valid if only adaptation is given. This is checked with the _is_valid()_ method.

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

property adaptation: GroupAdaptation | None#

Returns the adaptation of the port of the connection.

property is_connected: bool#

True when connected to some port.

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 is_valid: bool#

True when the connection either () or port [adaptation].

property model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

property port: PortExpr | None#

Returns the port of the connection.

Def-by-case blocks#

The def-by-case blocks gather the graphical version of then state machine and activate if/when constructs.

class ansys.scadeone.core.swan.StateMachineBlock(def_by_case: StateMachine, locals: List[DiagramObject] | None = None, pragmas: List[Pragma] | None = None)#

Bases: DefByCaseBlockBase

State machine block definition:

  • object ::= ( description [[ local_objects ]] )

  • description ::= [lhs :] state_machine

A StateMachineBlock is a proxy to the internal StateMachine object, therefore the methods and properties of the StateMachine object can be accessed directly.

get_full_path() str#

Full path of Swan construct.

pragma_str() str#

Return a string with all pragmas.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

to_str() str#

Section to string.

property def_by_case: DefByCase#

Def-by-case object.

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 locals: List[Self]#

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: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

property pragmas: List[Pragma]#

List of pragmas.

property sources: List[tuple[DiagramObject, GroupAdaptation | None]]#

This method must not be called for a def-by-case block.

property state_machine: StateMachine#

State machine object.

property targets: List[tuple[DiagramObject, GroupAdaptation | None]]#

This method must not be called for a def-by-case block.

class ansys.scadeone.core.swan.ActivateIfBlock(def_by_case: ActivateIf, locals: List[DiagramObject] | None = None, pragmas: List[Pragma] | None = None)#

Bases: DefByCaseBlockBase

Activate-if block definition:

  • object ::= ( description [[ local_objects ]] )

  • description ::= [lhs :] activate [[ luid ]] if_activation

A ActivateIF is a proxy to the internal ActivateIf object, therefore the methods and properties of the ActivateIf object can be accessed directly.

get_full_path() str#

Full path of Swan construct.

pragma_str() str#

Return a string with all pragmas.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

to_str() str#

Section to string.

property activate_if: ActivateIf#

Activate if object.

property def_by_case: DefByCase#

Def-by-case object.

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 locals: List[Self]#

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: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

property pragmas: List[Pragma]#

List of pragmas.

property sources: List[tuple[DiagramObject, GroupAdaptation | None]]#

This method must not be called for a def-by-case block.

property targets: List[tuple[DiagramObject, GroupAdaptation | None]]#

This method must not be called for a def-by-case block.

class ansys.scadeone.core.swan.ActivateWhenBlock(def_by_case: ActivateWhen, locals: List[DiagramObject] | None = None, pragmas: List[Pragma] | None = None)#

Bases: DefByCaseBlockBase

Activate-when block definition:

  • object ::= ( description [[ local_objects ]] )

  • description ::= [lhs :] activate [[ luid ]] when_activation

A ActivateIF is a proxy to the internal ActivateWhen object, therefore the methods and properties of the ActivateIf object can be accessed directly.

get_full_path() str#

Full path of Swan construct.

pragma_str() str#

Return a string with all pragmas.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

to_str() str#

Section to string.

property activate_when: ActivateWhen#

Activate when object.

property def_by_case: DefByCase#

Def-by-case object.

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 locals: List[Self]#

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: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

property pragmas: List[Pragma]#

List of pragmas.

property sources: List[tuple[DiagramObject, GroupAdaptation | None]]#

This method must not be called for a def-by-case block.

property targets: List[tuple[DiagramObject, GroupAdaptation | None]]#

This method must not be called for a def-by-case block.

Sections#

The SectionBlock contains a Swan section, that is to say, a let, var, diagram, assert, assume or guarantee section.

class ansys.scadeone.core.swan.SectionBlock(section: ScopeSection, locals: List[DiagramObject] | None = None, pragmas: List[Pragma] | None = None)#

Bases: DiagramObject

Section block definition:

  • object ::= ( description [[ local_objects ]] )

  • description ::= scope_section

get_full_path() str#

Full path of Swan construct.

pragma_str() str#

Return a string with all pragmas.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

to_str() str#

Section to string.

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 locals: List[Self]#

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: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

property pragmas: List[Pragma]#

List of pragmas.

property section: ScopeSection#

Section object of diagram object.

property sources: List[tuple[DiagramObject, GroupAdaptation | None]]#

This method must not be called for a SectionBlock

property targets: List[tuple[DiagramObject, GroupAdaptation | None]]#

This method must not be called for a SectionBlock