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.
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- 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 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.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)
- 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.
Types#
- class ansys.scadeone.core.swan.TypeDeclarations(types: List[TypeDecl])#
Bases:
GlobalDeclaration
Type declarations: type {{ type_decl ; }}.
- 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.
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.
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- 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 module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- 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 ; }}.
- 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.
Sensors#
- class ansys.scadeone.core.swan.SensorDecl(id: Identifier, type: TypeExpression)#
Bases:
Declaration
Sensor declaration with an id and a type.
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- 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 module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- 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 ; }}.
- 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 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:
a type expression, represented by a
TypeGroupTypeExpressionGroupType
instanceor a list of
GroupTypeExpression
items, decomposed into two lists:a positional list of
GroupTypeExpression
itemsfollowed by a list of named
GroupTypeExpression
items, represented withNamedGroupTypeExpression
instances.
- class ansys.scadeone.core.swan.GroupDecl(id: Identifier, type: GroupTypeExpression)#
Bases:
Declaration
Group declaration with an id and a type.
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- 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 module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- 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.
- 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.TypeGroupTypeExpression(type: TypeExpression)#
Bases:
GroupTypeExpression
Group type expression: group_type_expr ::= type_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 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 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.
- 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 label#
Label of named group item.
- property module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- 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 }} )- 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 items: Generator[GroupTypeExpression, None, None]#
Returns all items
- property module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- 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 ; }}.
- 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.
Protected declarations#
- class ansys.scadeone.core.swan.ProtectedDecl(markup: str, data: str)#
Bases:
ProtectedItem
,GlobalDeclaration
Protected declaration.
- 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#
Tell if item is syntactically protected and provided as a string.
- property is_user_operator: bool#
Protected operator declaration.
Note: operator declaration within {text% … %text} is parsed.
- property module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.