Global declarations#

This section describes the classes that represent the global declarations of a Swan program: const, type, sensor and group constructs.

Note

In Swan, a global declaration can contain several declarations. One can have for instance: const C1: int32; C2: int32; or const C1: int32; const C2: int32;. The Swan editor produces the second form, but having a list of declarations is correct.

class ansys.scadeone.core.swan.Declaration(id: Identifier)#

Bases: SwanItem

Base class for declarations.

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 id: Identifier#

Language item identifier.

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

Bases: ModuleItem

Abstract class for global declarations:

  • type declaration list

  • constant declaration list

  • sensor declaration list

  • group declarations

  • user operator declaration (without body, in interface)

  • user operator definition (with body)

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.

Types#

class ansys.scadeone.core.swan.TypeDeclarations(types: List[TypeDecl])#

Bases: GlobalDeclaration

Type declarations: type {{ type_decl ; }}.

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 types: List[TypeDecl]#

Declared types.

See also Type declarations for details on type definitions.

Constants#

class ansys.scadeone.core.swan.ConstDecl(id: Identifier, type: TypeExpression | None, value: Expression | None = None)#

Bases: Declaration

Constant declaration, with an id, a type, and an optional expression.

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 id: Identifier#

Language item identifier.

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 type: TypeExpression | None#

Type of constant.

property value: Expression | None#

Constant optional value. None if undefined.

class ansys.scadeone.core.swan.ConstDeclarations(constants: List[ConstDecl])#

Bases: GlobalDeclaration

Constant declarations: constant {{ constant_decl ; }}.

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 constants: List[ConstDecl]#

Declared constants.

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.

Sensors#

class ansys.scadeone.core.swan.SensorDecl(id: Identifier, type: TypeExpression)#

Bases: Declaration

Sensor declaration with an id and a type.

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 id: Identifier#

Language item identifier.

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 type: TypeExpression#

Sensor type.

class ansys.scadeone.core.swan.SensorDeclarations(sensors: List[SensorDecl])#

Bases: GlobalDeclaration

Sensor declarations: sensor {{ sensor_decl ; }}.

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 sensors: List[SensorDecl]#

Declared sensors.

Groups#

A GroupDecl object defines a group declaration, with a name and a GroupTypeExpression for the type.

A GroupTypeExpression can be:

../../../_images/group_type_expr.svg
class ansys.scadeone.core.swan.GroupDecl(id: Identifier, type: GroupTypeExpression)#

Bases: Declaration

Group declaration with an id and a type.

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 id: Identifier#

Language item identifier.

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 type: GroupTypeExpression#

Group type expression.

class ansys.scadeone.core.swan.GroupTypeExpression#

Bases: SwanItem

Base class for group type expressions.

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.TypeGroupTypeExpression(type: TypeExpression)#

Bases: GroupTypeExpression

Group type expression: group_type_expr ::= type_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 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 type#

Type expression of group item

class ansys.scadeone.core.swan.NamedGroupTypeExpression(label: Identifier, type: GroupTypeExpression)#

Bases: GroupTypeExpression

A named group type expression, used in GroupTypeExpressionList as id : group_type_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 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#

Label of named group item.

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 type#

Type of named group item.

class ansys.scadeone.core.swan.GroupTypeExpressionList(positional: List[GroupTypeExpression], named: List[NamedGroupTypeExpression])#

Bases: GroupTypeExpression

Group list made of positional items followed by named items. Each item is a group type expression.

group_type_expr ::= ( group_type_expr {{ , group_type_expr }}
{{ , id : group_type_expr }} )
| ( id : group_type_expr {{ , id : group_type_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 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: Generator[GroupTypeExpression, None, None]#

Returns all 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 named: Generator[NamedGroupTypeExpression, None, None]#

Return named group items

property owner: Self#

Owner of current Swan construct.

property positional: Generator[GroupTypeExpression, None, None]#

Return positional group items

class ansys.scadeone.core.swan.GroupDeclarations(groups: List[GroupDecl])#

Bases: GlobalDeclaration

Group declarations: group {{ group_decl ; }}.

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 groups: List[GroupDecl]#

Declared groups.

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.

Protected declarations#

class ansys.scadeone.core.swan.ProtectedDecl(markup: str, data: str)#

Bases: ProtectedItem, GlobalDeclaration

Protected declaration.

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

Protected const declaration.

property is_group: bool#

Protected group declaration.

property is_protected#

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

property is_sensor: bool#

Protected sensor declaration.

property is_type: bool#

Protected type declaration.

property is_user_operator: bool#

Protected operator declaration.

Note: operator declaration within {text% … %text} is parsed.

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.