Group#

Groups can be declared using the group declaration.

Groups are used either as a list of group items or as adaptation of an expression may for groups.

../../_images/group.svg

Group class diagram#

Group construction#

Group constructor is : ( group ). A group is itself a list of group items.

class ansys.scadeone.core.swan.GroupConstructor(group: Group)#

Bases: Expression

A group expression: group_expr ::= (*group).

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.Group(items: List[GroupItem])#

Bases: SwanItem

Group item as a list of GroupItem.

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 items: List[GroupItem]#

Group items.

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.GroupItem(expr: Expression, label: Identifier | None = None)#

Bases: SwanItem

Item of a group expression: group_item ::= [[ label : ]] expr.

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 expr: Expression#

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 label: Identifier | None#

Group item label.

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.

Group projection and renaming#

A group projection accesses to fields in a group and returns a group of the matching fields, using renaming.

The syntax is: expr .( group_renaming ) where .( group_renaming ) is a group adaptation, also used for Connection in diagrams.

class ansys.scadeone.core.swan.GroupProjection(expr: Expression, adaptation: GroupAdaptation)#

Bases: Expression

Group projection: group_expr ::= expr group_adaptation.

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#

Expression group adaptation.

property expr: Expression#

Adapted 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 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.GroupAdaptation(renamings: List[GroupRenaming])#

Bases: SwanItem

Group adaptation: group_adaptation ::= . ( group_renamings ).

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.

property renamings: List[GroupRenaming]#

Renaming list of group adaptation.

class ansys.scadeone.core.swan.GroupRenaming(source: Identifier | Literal, renaming: Identifier | None = None, is_shortcut: bool | None = False)#

Bases: SwanItem

Group renaming: (( Id | Integer)) [: [Id]].

  • Renaming source index as Id or Integer, either a name or a position. For example: a or 2.

  • Optional renaming target index:

    • No index

    • Renaming as : Id, for example: a : b, 2 : b

    • Shortcut, example a : means a : a

Parameters:
source: common.Identifier | LiteralExpr

Source index.

renaming: common.Identifier (optional)

Renaming as an Identifier.

is_shortcut: bool (optional)

Renaming is a shortcut of the form ID.

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

True when access by name.

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

True when renaming is a shortcut.

property is_valid: bool#

True when renaming is a shortcut with no renaming, or a renaming with no shortcut.

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 renaming: Identifier | None#

Renaming in new group. None if no renaming.

property source: Identifier | Literal#

Source selection in group.

class ansys.scadeone.core.swan.ProtectedGroupRenaming(data: str, markup: str | None = 'syntax')#

Bases: GroupRenaming, ProtectedItem

Specific class when a renaming is protected for syntax error.

Source is an adaptation such as: .( {syntax%renaming%syntax} ).

get_full_path() str#

Full path of Swan construct.

has_markup(markup: str) bool#

Check if protected data has the specified markup.

Parameters:
markupstr

String markup.

Returns:
result: bool

True when instance markup is same as parameter.

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

Protected data between markups.

Returns:
str

Protected data.

property is_by_name: bool#

True when access by name.

property is_protected#

Tell if item is syntactically protected and provided as a string.

property is_shortcut: bool#

True when renaming is a shortcut.

property is_valid: bool#

True when renaming is a shortcut with no renaming, or a renaming with no shortcut.

property markup: str#

Protection markup.

Returns:
str

Markup string.

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 renaming: Identifier | None#

Renaming in new group. None if no renaming.

property source: None#

Source selection in group.