Activations#
This section describes the activate if and activate when constructs.
Activate if#
The activate if operator uses a tree of conditional expressions. The classes to represent the operator are organized as follows:
Activate If class diagram#
The ActivateIf
references the IfActivation
which in turns stores
all the if condition elsif condition else branches. Branches are in the order if, then elsif and else.
The class IfActivationBranch
stores an if, or elsif or else branch with
its condition (but for else branch) and its associated computation (data_def) or another
decision tree.
- class ansys.scadeone.core.swan.ActivateIf(if_activation: IfActivation, lhs: EquationLHS | None = None, name: Luid | None = None, is_equation: bool = False)#
Bases:
DefByCase
Activate if operator definition:
select_activation ::= activate [[ LUID ]] if_activationif_activation ::= if expr then ifte_branch{{ elsif expr then ifte_branch }}else ifte_branchifte_branch ::= data_def | if_activation- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- property if_activation: IfActivation#
Activation branch of activate.
- 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 lhs: EquationLHS | None#
Left-hand side of the equation, may be None.
- property module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
- class ansys.scadeone.core.swan.IfActivation(branches: List[IfActivationBranch])#
Bases:
SwanItem
List of if_activation branches as a list of
IfActivationBranch
.if_activation ::= if expr then ifte_branch{{ elsif expr then ifte_branch }}else ifte_branch- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- property branches: List[IfActivationBranch]#
Return branches of if_activation. There must be at least two branches, the if and the else branches.
- 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#
Activation branches must be at least if and else, and elsif has a condition.
- property module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
- class ansys.scadeone.core.swan.IfActivationBranch(condition: Expression | None, branch: IfteBranch)#
Bases:
SwanItem
Stores a branch of an if_activation.
A branch is:
if expr then ifte_branch, or
elsif expr then ifte_branch, or
else ifte_branch
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- property branch: IfteBranch#
Branch activation branch.
- property condition: Expression | None#
Branch condition, None for else branch.
- 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.
- class ansys.scadeone.core.swan.IfteBranch#
Bases:
SwanItem
Base class for
IfteDataDef
andIfteIfActivation
classes.ifte_branch ::= data_def| if_activation- 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.
- class ansys.scadeone.core.swan.IfteDataDef(data_def: Equation | Scope)#
Bases:
IfteBranch
ifte_branch of an activate if as a data definition. See
ActivateIf
.ifte_branch ::= data_def
- 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.
- class ansys.scadeone.core.swan.IfteIfActivation(if_activation: IfActivation)#
Bases:
IfteBranch
ifte_branch of an activate if as an if_activation. See
ActivateIf
.ifte_branch ::= if_activation
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- property if_activation: IfActivation#
If activation.
- 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.
Activate when#
- class ansys.scadeone.core.swan.ActivateWhen(condition: Expression, branches: List[ActivateWhenBranch], lhs: EquationLHS | None = None, name: str | None = None, is_equation: bool = False)#
Bases:
DefByCase
Activate when operator definition.
There must be at least one branch. This can be checked with the is_valid() method.
select_activation ::= activate [[ LUID ]] match_activationmatch_activation ::= when expr match{{ | pattern_with_capture : data_def }}+- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- property branches: List[ActivateWhenBranch]#
Activate when branches.
- property condition: Expression#
Activate when condition.
- 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 lhs: EquationLHS | None#
Left-hand side of the equation, may be None.
- property module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
- class ansys.scadeone.core.swan.ActivateWhenBranch(pattern: Pattern, data_def: Equation | Scope)#
Bases:
SwanItem
Stores a branch of a match_activation.
A branch is: | pattern_with_capture : data_def
- 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.