Diagrams#
A Diagram
object stores the representation of a diagram.
It contains the various blocks (see figure) and connections using
Wire
instances.
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.
- static set_owner(owner: Self, children: Self | Iterable[Self])#
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 module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- 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.
- static set_owner(owner: Self, children: Self | Iterable[Self])#
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 module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
- 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
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- 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 module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
- 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.
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- property is_protected#
True when definition is syntactically incorrect and protected.
- property lhs: EquationLHS | ProtectedItem#
Returned defined flows.
- property module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
- 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.
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- 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 module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
- 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
- static set_owner(owner: Self, children: Self | Iterable[Self])#
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 module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property operation: GroupOperation#
Group operation.
- property owner: Self#
Owner of current Swan construct.
- 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.
- static set_owner(owner: Self, children: Self | Iterable[Self])#
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 module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
- 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.
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- property adaptation: GroupAdaptation | None#
Returns the adaptation of the port of the connection.
- 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 module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
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.- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- 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 module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
- 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.- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- 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 module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
- 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.- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- 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 module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
- 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
- static set_owner(owner: Self, children: Self | Iterable[Self])#
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 module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
- 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