Variable declarations#

class ansys.scadeone.core.swan.VarSection(var_decls: List[Variable])#

Bases: ScopeSection

Implements:

var {{var_decl ;}} section.

static set_owner(owner: SwanItem | IModel | None, children: SwanItem | Iterable[SwanItem] | None) → None#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem], None]

Items to set owner.

add_pragmas(*pragmas) → None#

Add one or more pragmas to the current object.

get_full_path() → str#

Full path of the Swan construct.

This method is implemented by derived classes that correspond to a declaration at the module level (such as sensor, type, group, const, operator), or a module itself.

Returns:
str

Path within the owner and name of the Swan construct.

Raises:
ScadeOneException

If the method is not implemented for the current SwanItem type.

set_pragmas(pragmas: List[Pragma]) → None#

Sets pragmas for the scope section.

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

True when section is given from {text%…%text} markup.

property model: IModel#

Return model containing the Swan item.

property module: ModuleBase | None#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface or None if the object is itself a module.

property owner: SwanItem | IModel | None#

Owner of current Swan construct.

property pragmas: List[Pragma]#

List of pragmas.

property var_decls: List[Variable]#

Declared variables.

class ansys.scadeone.core.swan.Variable#

Bases: SwanItem

Base class for Variable and ProtectedVariable.

static set_owner(owner: SwanItem | IModel | None, children: SwanItem | Iterable[SwanItem] | None) → None#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem], None]

Items to set owner.

get_full_path() → str#

Full path of the Swan construct.

This method is implemented by derived classes that correspond to a declaration at the module level (such as sensor, type, group, const, operator), or a module itself.

Returns:
str

Path within the owner and name of the Swan construct.

Raises:
ScadeOneException

If the method is not implemented for the current SwanItem type.

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

Return model containing the Swan item.

property module: ModuleBase | None#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface or None if the object is itself a module.

property owner: SwanItem | IModel | None#

Owner of current Swan construct.

class ansys.scadeone.core.swan.VarDecl(id: Identifier, is_starred: bool = False, at: Identifier | None = None, type: GroupTypeExpression | None = None, init_type: VarInitDelay = VarInitDelay.DelayNone, causality_type: List[Identifier] | None = None, default: Expression | None = None, last: Expression | None = None, pragmas: list[Pragma] | None = None)#

Bases: Declaration, Variable

Class for variable declaration.

Parameters:
id: common.Identifier

Variable identifier.

is_starred: bool, optional

True if variable is starred. Default is False.

at: Optional[common.Identifier], optional

Memory constrained output. Name of the memory place. Note: is_output must be True. Default is None.

type: Optional[common.GroupTypeExpression], optional

Variable type. Default is None.

init_type: VarInitDelay, optional

Variable initialization delay. Default is VarInitDelay.DelayNone.

causality_type: Optional[List[common.Identifier]], optional

Variable causality_type attributes. Default is None.

default: Optional[common.Expression], optional

Variable default expression. Default is None.

last: Optional[common.Expression], optional

Variable last expression. Default is None.

pragmas: Optional[list[common.Pragma]], optional

List of pragmas. Default is None.

static set_owner(owner: SwanItem | IModel | None, children: SwanItem | Iterable[SwanItem] | None) → None#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem], None]

Items to set owner.

add_pragmas(*pragmas) → None#

Add one or more pragmas to the current object.

get_full_path() → str#

Full path of Swan construct.

property at: Identifier | None#

Memory constrained output. Name of the memory place. Note: is_output must be True.

property causality_type: List[Identifier]#

Variable causality_type attributes.

property default: Expression | None#

Variable default expression.

property has_definition: bool#

True if declaration has a definition part.

property id: Identifier#

Language item identifier.

property init_type: VarInitDelay#

Variable initialization delay.

property is_external: bool#

True if declaration has no definition.

Check if there is no alternative declaration in the module (interface or body). Warn if any, and raise an error if inconsistent.

property is_input: bool#

True when variable is an input.

property is_local: bool#

True when variable is local.

property is_output: bool#

True when variable is an output.

property is_probe: bool#

True when variable is a probe.

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

True if declaration is public.

A declaration is public if:

  • it is declared in a module interface,

  • or it is declared in a module body, but the module has no interface.

A declaration is private if it is declared in a module body, and the module has an interface, and there is no declaration with the same name in the module interface.

If declared in both a module interface and body, the declaration is considered as public, but a warning is issued.

property is_starred: bool#

True when consumption is allowed for the input variable. Note: is_input must be True.

property last: Expression | None#

Variable last expression.

property model: IModel#

Return model containing the Swan item.

property module: ModuleBase | None#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface or None if the object is itself a module.

property owner: SwanItem | IModel | None#

Owner of current Swan construct.

property pragmas: List[Pragma]#

List of pragmas.

property type: GroupTypeExpression | None#

Variable type.

class ansys.scadeone.core.swan.ProtectedVariable(data: str, pragmas: List[Pragma] | None = None)#

Bases: Variable, ProtectedItem, HasPragma

Protected variable definition as a string.

static set_owner(owner: SwanItem | IModel | None, children: SwanItem | Iterable[SwanItem] | None) → None#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem], None]

Items to set owner.

add_pragmas(*pragmas) → None#

Add one or more pragmas to the current object.

get_full_path() → str#

Full path of the Swan construct.

This method is implemented by derived classes that correspond to a declaration at the module level (such as sensor, type, group, const, operator), or a module itself.

Returns:
str

Path within the owner and name of the Swan construct.

Raises:
ScadeOneException

If the method is not implemented for the current SwanItem type.

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.

property data: str#

Protected data between markups.

Returns:
str

Protected data.

property is_protected: bool#

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

property markup: str#

Protection markup.

Returns:
str

Markup string.

property model: IModel#

Return model containing the Swan item.

property module: ModuleBase | None#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface or None if the object is itself a module.

property owner: SwanItem | IModel | None#

Owner of current Swan construct.

property pragmas: List[Pragma]#

List of pragmas.