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:

../../../_images/activate_if.svg

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_activation
if_activation ::= if expr then ifte_branch
{{ elsif expr then ifte_branch }}
else ifte_branch
ifte_branch ::= data_def | if_activation
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 if_activation: IfActivation#

Activation branch of activate.

property is_equation: bool#

True when the object is an equation.

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

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property name: Luid | None#

Return name or None if no name.

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

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

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

class ansys.scadeone.core.swan.IfteBranch#

Bases: SwanItem

Base class for IfteDataDef and IfteIfActivation classes.

ifte_branch ::= data_def
| if_activation
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 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.

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

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

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

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

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_activation
match_activation ::= when expr match
{{ | pattern_with_capture : data_def }}+
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 branches: List[ActivateWhenBranch]#

Activate when branches.

property condition: Expression#

Activate when condition.

property is_equation: bool#

True when the object is an equation.

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 there is at least one branch.

property lhs: EquationLHS | None#

Left-hand side of the equation, may be None.

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 name: Luid | None#

Return name or None if no name.

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

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 data_def: Equation | Scope#

Branch data definition.

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: 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 pattern: Pattern#

Branch pattern.