Forward expression#

A forward expression is stored as a Forward class. The class hierarchy is given in the following pictures:

../../../_images/forward.svg

Fig. 15 Forward class diagram#

class ansys.scadeone.core.swan.Forward(restart: bool | None, dimensions: List[ForwardDim], body: ForwardBody, returns: List[ForwardReturnItem], luid: Luid | None = None)#

Bases: Expression

Forward expression:

fwd_expr ::= forward [[ luid]] [[ (( restart | resume )) ]] {{ dim }}+
fwd_body returns ( returns_group )
returns_group ::= [[ returns_item {{ , returns_item }} ]]
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#

Set pragmas for the 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_restart: bool#

True if restart mode, else resume mode. Note: default mode for a forward is restart, which is indicated by the restart property being None.

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.

class ansys.scadeone.core.swan.ForwardBody(sections: List[ScopeSection], unless_expr: Expression | None = None, until_expr: Expression | None = None)#

Bases: SwanItem

forward construct:

fwd_body ::= [[ unless expr ]] scope_sections [[ until expr ]]

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.

Dimensions#

class ansys.scadeone.core.swan.ForwardDim(size: Expression | None = None, dim_id: Identifier | None = None, elems: List[ForwardCurrentElement] | None = None, protected: str | None = None)#

Bases: SwanItem

forward construct dimension:

dim ::= << size >> [[ with (( << id >> | current_elt )) {{ current_elt }} ]]

Note that:

  • there may be no with part,

  • or it is an ID followed by a possible empty list,

  • or if no ID, at least one current_element.

The is_valid() method checks for that property.

Parameters:
size: common.Expression

Dimension size.

id: common.Identifier (optional)

with ID.

elems: List[ForwardCurrentElement] (optional)

with elements part.

protected: str (optional)

Content of the dimension if it syntactically incorrect. In that case, all other parameters are 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.

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

forward dimension ID, or None.

property elems: List[ForwardCurrentElement] | None#

forward dimension elements or None.

property is_protected: bool#

True when dimension is syntactically incorrect and protected.

property is_valid: bool#

Returns True when ID is given, or list of elements is not empty.

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

Returns protected form as a string if dimension is syntactically invalid.

property size: Expression | None#

forward dimension size.

class ansys.scadeone.core.swan.ForwardCurrentElement(lhs: ForwardLHS, expr: Expression)#

Bases: SwanItem

Forward current element:

current_elt ::= current_lhs = expr ;

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

Current element 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 lhs: ForwardLHS#

Current element.

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.ForwardLHS(lhs: Identifier | ForwardLHS)#

Bases: SwanItem

forward construct:

current_lhs ::= id | [ current_lhs ]

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

True when current lhs is an ID.

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

Returns current lhs as an Identifier or a ForwardLHS.

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.

Forward returns#

The base class for return clause is ForwardReturnItem. A syntactically incorrect return clause is represented by the ProtectedForwardReturnItem class.

../../../_images/forward_return.svg

Fig. 16 Forward return#

class ansys.scadeone.core.swan.ForwardReturnItem#

Bases: SwanItem

Base class for returns_item.

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.ProtectedForwardReturnItem(data: str)#

Bases: ProtectedItem, ForwardReturnItem

forward construct: protected returns_item with {syntax% … %syntax} markup.

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.

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.

Accumulation#

Accumulation clause is represented by the ForwardAccuClause class.

class ansys.scadeone.core.swan.ForwardAccuClause(id: Identifier, last_expr: Expression)#

Bases: ForwardReturnItem

forward accumulator construct:

accu_clause ::= id : last = expr

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

Item_clause 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 last_expr: Expression#

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

Array clause#

Returned array clause is represented by the ForwardReturnArrayClause class, which references a ForwardArrayClause instance and its optional identifier.

class ansys.scadeone.core.swan.ForwardReturnArrayClause(array_clause: ForwardArrayClause, id: Identifier | None = None)#

Bases: ForwardReturnItem

forward construct:

returns_item ::= [[ id : ]] array_clause

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 array_clause: ForwardArrayClause#

Array clause.

property id: Identifier | None#

Identifier of clause, or None.

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.

Array clause is either:

class ansys.scadeone.core.swan.ForwardArrayClause#

Bases: SwanItem

Base class for forward array_clause.

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.ForwardArrayClauseExpr(expr_no_bracket: Expression, default_expr: Expression | None = None)#

Bases: ForwardArrayClause

forward construct:

array_clause ::= expr_no_bracket [[ default expr ]]

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 default_expr: Expression | None#

Default expression, or None.

property expr_no_bracket: Expression#

Expression without brackets.

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.ForwardArrayClauseElement(array_clause: ForwardArrayClause)#

Bases: ForwardArrayClause

forward construct:

array_clause ::= [ array_clause ]]

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 array_clause: ForwardArrayClause#

Array clause.

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.