Model#

A Model object gives access to the model items defined in the Swan sources of a project. The unique Model instance of a project is the object returned by the ansys.scadeone.core.project.Project.model property of a project instance.

from ansys.scadeone.core import ScadeOne
with ScadeOne() as app:
    project = app.load_project('project.sproj')
    model = project.model

Model documentation#

class ansys.scadeone.core.model.Model#

Bases: object

Model handling class. A model contains module and interface declarations.

Loading of Swan sources is lazy.

configure(project: IProject)#

Configure model with project as owner. The configuration associate the project and the model and prepare internal data to store module bodies and interfaces.

It is called by ansys.scadeone.core.project.Project.model.

filter_declarations(filter_fn) Generator[GlobalDeclaration, None, None]#

Return declarations matched by a filter.

Parameters:
filter_fnfunction

A function of one argument of type S.GlobalDeclaration, returning True or False.

Yields:
Generator[S.GlobalDeclaration, None, None]

Generator on matching declarations.

find_declaration(predicate_fn) GlobalDeclaration | None#

Find a declaration for which predicate_fn returns True.

Parameters:
predicate_fnfunction

Function taking one S.GlobalDeclaration as argument and returning True when some property holds, else False.

Returns:
Union[S.GlobalDeclaration, None]

Found declaration or None.

get_module_body(name: str) ModuleBody | None#

Return module body of name ‘name’

get_module_from_pathid(pathid: str, module: Module) Module | None#

Return the Module instance for a given pathid. A path is of the form [ID ::]+ ID, where the last ID is the object name, and the “ID::ID…::” is the module path.

If the pathid has no path part (reduced to ID), return module.

Parameters:
pathidstr

object full path

moduleModule

Context module where the search occurs.

Returns:
Union[S.Module, None]

Module of the object, or None if not module found

get_module_interface(name: str) ModuleInterface | None#

Return module interface of name ‘name’

load_all_modules()#

Load systematically all modules.

load_module(name: str)#

Load module by name

Parameters:
namestr

Module name.

Returns:
Module

Swan Module, either a ModuleBody or a ModuleInterface.

property all_modules_loaded: True#

Return True when all Swan modules have been loaded.

property constants: Generator[ConstDecl, None, None]#

Return a generator on constant declarations.

property declarations: Generator[GlobalDeclaration, None, None]#

Declarations found in all modules/interfaces as a generator.

The Swan code of a module/interface is loaded if not yet loaded.

property groups: Generator[GroupDecl, None, None]#

Return a generator on group declarations.

property modules: Generator[Module, None, None]#

Loaded module (module body or interface) as a generator.

property operators: Generator[Operator, None, None]#

Return a generator on operator declarations.

property parser: SwanParser#

Swan parser.

property project: IProject#

Model project, as a Project object.

property sensors: Generator[SensorDecl, None, None]#

Return a generator on sensor declarations.

property signatures: Generator[Signature, None, None]#

Return a generator on operator signature declarations.

property types: Generator[TypeDecl, None, None]#

Return a generator on type declarations.