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.
- find_declaration(predicate_fn) GlobalDeclaration | None #
Find a declaration for which predicate_fn returns True.
- Parameters:
- predicate_fn
function
Function taking one S.GlobalDeclaration as argument and returning True when some property holds, else False.
- predicate_fn
- 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.
- 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:
- name
str
Module name.
- 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 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 modules: Generator[Module, None, None]#
Loaded module (module body or interface) as a generator.
- property parser: SwanParser#
Swan parser.
- property sensors: Generator[SensorDecl, None, None]#
Return a generator on sensor declarations.