Bitwise, boolean, arithmetic, relational, sequential#
Arithmetic, logical, bitwise, and relational expressions are represented by unary expressions (ex: not X), binary expressions (ex: 1 + 2), or n-ary expressions.
Unary and binary expressions are implemented with the UnaryExpr and BinaryExpr classes
with the appropriate operator as an enumeration value.
N-ary expressions correspond to specific operator NAryOperator
with the appropriate operator as an enumeration value.
Operator |
Operation |
Class and operator as enum value |
|---|---|---|
lnot |
bitwise not |
|
land |
bitwise and |
|
lor |
bitwise or |
|
lxor |
bitwise xor |
|
lsl |
logical shift left |
|
lsr |
logical shift right |
|
Operator |
Operation |
Class and operator as enum value |
|---|---|---|
not |
logical not |
|
and |
logical and |
|
or |
logical or |
|
xor |
logical xor |
|
Operator |
Operation |
Class and operator as enum value |
|---|---|---|
- |
minus / subtraction |
|
+ |
plus / addition |
|
* |
multiplication |
|
/ |
division |
|
mod |
modulo |
|
(:>) |
cast operation |
|
Operator |
Operation |
Class and operator as enum value |
|---|---|---|
= |
equal |
|
<> |
different |
|
< |
less than |
|
<= |
less than or equal to |
|
> |
greater than |
|
>= |
greater than or equal to |
|
Unary expressions#
A unary expression is composed of a unary operator and an expression.
Unary operators are defined with the UnaryExpr enumeration.
- class ansys.scadeone.core.swan.UnaryExpr(operator: UnaryOp, expr: Expression)#
Bases:
ExpressionExpression with unary operators :py:class`ansys.scadeone.core.swan.expressions.UnaryOp`.
- 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:
strPath within the owner and name of the Swan construct.
- Raises:
ScadeOneExceptionIf the method is not implemented for the current SwanItem type.
- 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.
- property at: Identifier | None#
Memory constrained location.
- 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 model: IModel#
Return model containing the Swan item.
- property module: ModuleBase | None#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBodyandModuleInterfaceor None if the object is itself a module.
- property operator: UnaryOp#
Unary operator.
Binary expressions#
A binary expression is composed of a binary operator and two expressions.
Binary operators are defined with the BinaryExpr enumeration.
- class ansys.scadeone.core.swan.BinaryExpr(operator: BinaryOp, left: Expression, right: Expression)#
Bases:
ExpressionExpression with binary operators :py:class`ansys.scadeone.swan.expressions.BinaryOp`.
- 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:
strPath within the owner and name of the Swan construct.
- Raises:
ScadeOneExceptionIf the method is not implemented for the current SwanItem type.
- 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.
- property at: Identifier | None#
Memory constrained location.
- 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 left: Expression#
Left expression.
- property model: IModel#
Return model containing the Swan item.
- property module: ModuleBase | None#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBodyandModuleInterfaceor None if the object is itself a module.
- property operator: BinaryOp#
Binary operator.
- property right: Expression#
Right expression.
Cast operators#
A cast operator ( :> ) is a specific binary expression as it takes an expression and a type.
- class ansys.scadeone.core.swan.NumericCast(expr: Expression, type: TypeExpression)#
Bases:
ExpressionCast expression: ( expr :> type_expr).
- 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:
strPath within the owner and name of the Swan construct.
- Raises:
ScadeOneExceptionIf the method is not implemented for the current SwanItem type.
- 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.
- property at: Identifier | None#
Memory constrained location.
- 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 model: IModel#
Return model containing the Swan item.
- property module: ModuleBase | None#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBodyandModuleInterfaceor None if the object is itself a module.
- property type: TypeExpression#
Type expression.
N-ary expressions#
N-ary operators are a special case of operator calls. The n-ary operations are given by the following enumeration.
- class ansys.scadeone.core.swan.NAryOperator(operator: NaryOp)#
Bases:
OperatorExpressionN-ary operators: ‘+’ | ‘*’ | ‘@’ | and | or | xor | land | lor | lxor.
- 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:
strPath within the owner and name of the Swan construct.
- Raises:
ScadeOneExceptionIf the method is not implemented for the current SwanItem type.
- 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.
- 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
ModuleBodyandModuleInterfaceor None if the object is itself a module.
- property operator: NaryOp#
N-ary operator.
Sequential expressions#
- class ansys.scadeone.core.swan.PreExpr(expr: Expression)#
Bases:
UnaryExprUnit delay expression: pre(expr).
This is a unary expression with the operator
ansys.scadeone.swan.expressions.UnaryOp.Pre.- 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:
strPath within the owner and name of the Swan construct.
- Raises:
ScadeOneExceptionIf the method is not implemented for the current SwanItem type.
- 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.
- property at: Identifier | None#
Memory constrained location.
- 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 model: IModel#
Return model containing the Swan item.
- property module: ModuleBase | None#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBodyandModuleInterfaceor None if the object is itself a module.
- property operator: UnaryOp#
Unary operator.
- class ansys.scadeone.core.swan.PreWithInitialValueExpr(left: Expression, right: Expression)#
Bases:
BinaryExprUnit delay with initial value expression: expr pre expr).
This is a binary expression with the operator
ansys.scadeone.swan.expressions.BinaryOp.Pre.- 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:
strPath within the owner and name of the Swan construct.
- Raises:
ScadeOneExceptionIf the method is not implemented for the current SwanItem type.
- 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.
- property at: Identifier | None#
Memory constrained location.
- property expr: Expression#
Delayed expression.
- property initial: Expression#
Initial value 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 left: Expression#
Left expression.
- property model: IModel#
Return model containing the Swan item.
- property module: ModuleBase | None#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBodyandModuleInterfaceor None if the object is itself a module.
- property operator: BinaryOp#
Binary operator.
- property right: Expression#
Right expression.
- class ansys.scadeone.core.swan.InitialValueExpr(left: Expression, right: Expression)#
Bases:
BinaryExprInitial value expression: (expr -> expr).
This is a binary expression with the operator
ansys.scadeone.swan.expressions.BinaryOp.Arrow.- 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:
strPath within the owner and name of the Swan construct.
- Raises:
ScadeOneExceptionIf the method is not implemented for the current SwanItem type.
- 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.
- property at: Identifier | None#
Memory constrained location.
- property expr: Expression#
Delayed expression.
- property initial: Expression#
Initial value 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 left: Expression#
Left expression.
- property model: IModel#
Return model containing the Swan item.
- property module: ModuleBase | None#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBodyandModuleInterfaceor None if the object is itself a module.
- property operator: BinaryOp#
Binary operator.
- property right: Expression#
Right expression.