FMU export#
This section contains the classes related to Scade One FMU export.
The FMU export supports the FMI 2.0 version for Model-Exchange and Co-Simulation.
The principle is to build a FMU package from a given Scade One operator. This operator has to be a root operator of a code generation job, and this job must have been executed before FMU export.
For more information about the FMI standard, consult FMU/FMI.
from ansys.scadeone.core import ScadeOne
from ansys.scadeone.core.svc.fmu import FMU_2_Export
with ScadeOne('<install_dir>') as app:
project = app.load_project('project.sproj')
fmu = FMU_2_Export(project, 'CodeGen')
fmu.generate('ME', 'project_ME')
fmu.build(True)
Limitations
Imported Types
The FMU export is not possible if imported types are used for any of the inputs or outputs of the selected operator, or sensors in the scope of the export.
Supported Platforms
This version only supports gcc compiler on 64-bits Windows platforms.
FMU export command line#
The FMU export can also be performed using the pyscadeone command line, by selecting the fmu command.
The command performs the complete export, by running FMU_2_Export.generate()
and FMU_2_Export.build() methods of the FMU_2_Export class.
All expected arguments can be passed through this command. Complete list is given by –help.
pyscadeone fmu --help
usage: pyscadeone fmu [-h] -inst INSTALL_DIR [-op OPER_NAME]
[-max MAX_VARIABLES] [-k KIND] [-o OUTDIR] [-p PERIOD]
[-ws] [-args key value]
project job_name
positional arguments:
project Scade One project
job_name Generated Code job name
optional arguments:
-h, --help Show this help message and exit
-inst INSTALL_DIR, --install_dir INSTALL_DIR
Scade One installation directory
-op OPER_NAME, --oper_name OPER_NAME
Root operator name
-max MAX_VARIABLES, --max_variables MAX_VARIABLES
Maximum number on FMI variables (flattened sensors,
inputs and outputs) supported by the export (1000 by
default).
-k KIND, --kind KIND FMI kind: ‘ME’ for Model Exchange (default), ‘CS’ for
Co-Simulation
-o OUTDIR, --outdir OUTDIR
Directory where the FMU is built (by default,
'FMU_Export_<kind>_<job_name>')
-p PERIOD, --period PERIOD
Execution period in seconds
-ws, --with_sources Keep the sources in the FMU package
-args key value, --build_arguments key value
Build arguments. Use one -args argument per key. Supported keys are:
arch: compiler architecture,
user_sources: list (comma separated) of user source files or directories (code, includes),
cc_opts: list (comma separated) of extra compiler options,
link_opts: list (comma separated) of extra link (dll creation) options,
swan_config_begin: data to insert at the beginning of swan_config.h,
swan_config_end: data to insert at the end of swan_config.h.
FMU export documentation#
This section gives the API for the FMU export.
Note that the FMU export relies on the Generated code API.
- class ansys.scadeone.core.svc.fmu.FMU_2_Export(prj: Project, job_name: str, oper_name: str = '', max_variables: int = 1000)#
Bases:
FMU_ExportFMU 2.0 export main class.
- Parameters:
- prj
Project The Scade One project.
- job_name
str The name of the code generation job for the operator to be exported as an FMU.
- oper_name
str,optional Optional operator name (by default it is the root operator of the job, if provided it has to be a root operator for the job).
- max_variables
int,optional Maximum number on FMI variables (flattened sensors, inputs and outputs) supported by the export (1000 by default).
- prj
- generate(kind: str, outdir: str | PathLike, period: float = 0.02) None#
Generate the FMI 2.0 XML and C file according to SCADE generated code.
- Parameters:
- kind
str The FMI kind (‘ME’ for Model Exchange, ‘CS’ for Co-Simulation).
- outdir
Union[str,os.PathLike] The output directory where the files are generated.
- period
float,optional The execution period in seconds (default is 0.02).
- kind
- build(with_sources: bool = False, args: dict | None = None) None#
Build the FMU package from generated files.
The .FMU is built in the outdir directory provided when code was generated (see method
generate), and its name is the name of the selected operator.- Parameters:
- with_sourcesbool,
optional True to keep the sources in the FMU package.
- args
Optional[dict],optional Build arguments, provided as a dictionary (default is None): - user_sources: list of user source files or directories (code, includes) - cc_opts: list of extra compiler options - link_opts: list of extra link options - swan_config_begin: data to insert at the beginning of
swan_config.h- swan_config_end: data to insert at the end ofswan_config.h
- with_sourcesbool,
- property oper: ModelOperator#
Return the ModelOperator object.
- property sensors: List[ModelSensor]#
Return the ModelSensor objects.
- codegen#
Associated
GeneratedCodeobject.