Operators#
Operator are declared with the OperatorDeclaration class and defined with the OperatorDefinition class.
Fig. 6 Operator class diagram#
Operator declaration#
Declares an operator, giving its interface only. In a module interface, an operator declaration can be the declaration of an operator which body definition is given in the module body, or it can declare a public imported operator. In a module body, an operator declaration is the declaration of a private imported operator if the module has an interface, otherwise it is the declaration of a public imported operator.
The class SizeParameter defines size parameters that can be used for array sizes.
The class TypeConstraint defines constraints that can be applied to generic types.
- class ansys.scadeone.core.swan.OperatorDeclaration(id: Identifier, is_inlined: bool, is_node: bool, inputs: List[Variable], outputs: List[Variable], size_parameters: List[SizeParameter] | None = None, type_constraints: List[TypeConstraint] | None = None, specialization: PathIdentifier | None = None, pragmas: List[Pragma] | None = None)#
Bases:
OperatorDeclarationDefinitionBase,OperatorDeclarationCreatorOperator declaration definition.
Used in module body or interface.
- 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 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 is_text: bool#
True when operator is given from {text%…%text} markup, or an interface is given from {text%…%text} markup (body) or {signature%…%signature} markup (interface).
- 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 size_parameters: List[SizeParameter]#
Return size parameters as a list.
- property specialization: PathIdentifier | None#
Return specialization path_id or None.
- property type_constraints: List[TypeConstraint]#
Return type constraints as a list.
Size parameters#
- class ansys.scadeone.core.swan.SizeParameter(id: Identifier, pragmas: List[Pragma] | None = None)#
Bases:
DeclarationSize parameter declaration, used in operator declarations and definitions.
- 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 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: 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.
Type constraints#
- class ansys.scadeone.core.swan.TypeConstraint(type_vars: List[VariableTypeExpression] | str, kind: NumericKind)#
Bases:
SwanItemType constraint for operator. A constraint is:
where_decl ::= where typevar {{ , typevar }} numeric_kind
The typevar list can be protected and represented with string.
- 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 kind: NumericKind#
Constraint numeric kind.
- 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_vars: List[VariableTypeExpression] | str#
Return type variable names of constraints.
- Returns:
Union[List[VariableTypeExpression],str]Returns the list of type names, if not protected, or the constraint names as a string.
Operator definition#
Defines an operator with a body in a module body. See Operator body for content of the body.
The operator definition has the same interface as the corresponding operator declaration in the module interface, if any,
see OperatorDeclaration, SizeParameter and TypeConstraint.
- class ansys.scadeone.core.swan.OperatorDefinition(id: Identifier, is_inlined: bool, is_node: bool, inputs: List[Variable], outputs: List[Variable], body: Scope | Equation | Callable | None = None, size_parameters: List[SizeParameter] | None = None, type_constraints: List[TypeConstraint] | None = None, specialization: PathIdentifier | None = None, pragmas: List[Pragma] | None = None)#
Bases:
OperatorDeclarationDefinitionBase,OperatorCreatorOperator definition, with a body.
Used in module body. The body may be empty.
- 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 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 is_text: bool#
True when operator is given from {text%…%text} markup, or an interface is given from {text%…%text} markup (body) or {signature%…%signature} markup (interface).
- 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 size_parameters: List[SizeParameter]#
Return size parameters as a list.
- property specialization: PathIdentifier | None#
Return specialization path_id or None.
- property type_constraints: List[TypeConstraint]#
Return type constraints as a list.