FMIConnector - MapleSim Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : MapleSim Toolboxes : MapleSim FMI Connector : FMIConnector Package : FMIConnector/GenerateCode

FMIConnector

  

GenerateCode

  

generate FMI C code

 

Calling Sequence

Parameters

Returns

Options

Description

Examples

Calling Sequence

GenerateCode(system, options)

Parameters

system

-

`module` ; Msim model

options

-

(optional) equation(s) of the form name = value

Returns

• 

list : a list of settings used for FMU generation

Options

• 

fname : string

  

Specifies the filename of the generated C file. Default is "FMUModel".

• 

outputdir : string

  

Specifies the output directory for generated files. Default is "kernelopts('homedir')".

• 

removetmpdir : true or false

  

Specifies whether the generated temporary directory should be removed. The temporary directory is generated in "outputdir" location and its name is a combination of the string "fmiTmp" and a randomly generated number. This directory temporarily stores the contents of an FMU before they are packed into a file with ".fmu" extension. Default is true.

• 

architecture : one of the following: "32", "64"

  

Specifies the architecture of the target binary.

• 

pathVC : string

  

Specifies the path to the Visual C++ installation directory if generating on Windows platform.  This option is ignored if platform is not Windows.  The first location that is checked for this compiler is "C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC".  If it is not found there then the default is set to "C:/Program Files/Microsoft Visual Studio 10.0/VC".

• 

initial : set of equations

  

Specifies the initial conditions for all system's states, algebraic variables, and inputs.

• 

inputs : list of functions

  

Specifies system's input variables.

• 

outputs : list of functions

  

Specifies system's output variables.

• 

params : list of equations

  

Specifies values of system's parameters.

• 

nosubs : true or false

  

Specifies whether the parameters are entered as the original model names or the substituted names.  The original model names are in the long form, for example, `Main.MyModel.Parameter1` and the short names are uniquely shortened versions of the long names, for example `Parameter1`.  Default is false.

• 

optimize : one of the following: false, "subexpronly", "fast", true

  

Specifies the level of code optimization.  Setting of false results in no optimization being performed, "subexpronly" optimizes only simple expressions, "fast" performs subexpression and some additional fast optimizations, and true results in full optimization.  Default is "subexpronly".

• 

coniter : non-negative integer

  

Specifies constraint iteration count.  Default is 20.

• 

contol : positive

  

Specifies constraint tolerance.  Default is 1e-7.

• 

evtiter : positive integer

  

Specifies maximum number of event iterations.  Default is 10.

• 

evtproj : true or false

  

Specifies use projection in events.  Default is true.

• 

evthyst : non-negative

  

Specifies width of event hysteresis band.  Default is 1e-10.

• 

removesrc : true or false

  

Specifies whether the generated source directory and its contents should be removed. Default is false.

• 

fmiVersion : one of the following: "FMI1.0", "FMI2.0"

  

Specifies which version of the FMI standard will be generated.  Default is "FMI2.0".

• 

fmiDistType : one of "DLL" or "SourceCode"

  

Specifies if the generated sources should be compiled into a dynamically linked library. If set to "SourceCode" then the FMU will contain source code only. This setting will generate sources with FMI_FUNCTION_PREFIX (or FMI2_FUNCTION_PREFIX) defined as the name of the FMU followed by an underscore character.  This name will be prepended to all the FMI functions.  If such prefix is not desired then the source code must be compiled with the "-DDISABLE_PREFIX" flag, which will disable this setting. Default is "DLL".

• 

fmiType : one of "CS" or "ME"

  

Specifies the format of the FMU export, either "ME" for ModelExchange or "CS" for Co-Simulation.  Default is "ME".

Options for Co-Simulation only

• 

solver : one of the following: "Euler", "ImplicitEuler", "RK2", "RK3", "RK4"

  

Specifies which fixed step solver should be generated.  Default is "Euler".

• 

stepsize : positive

  

Specifies the Co-Simulation step size.  This value must be specified by the user.

Description

• 

The GenerateCode command generates FMI C code from a MapleSim system.

• 

The output is a sequence of the following FMU generation settings, in order:

1. 

String containing the path to the XML modelDescription file

2. 

String containing the path to the C file

3. 

If FMI version is "FMI1.0", then a string specifying location of MsimModel.c file containing Maple specific functions. (Otherwise it is the same as the C file location string.)

4. 

String containing the name of the temporary directory into which the above files are generated

5. 

FMU architecture ("32" or "64" bit)

6. 

String containing the path to the Microsoft Visual Studio compiler (empty string for UNIX-based platforms)

7. 

Boolean flag specifying if temporary directory was removed

8. 

Boolean flag specifying if the sources directory was removed

9. 

String containing the FMI version

10. 

String containing the FMU format (ModelExchange or CoSimulation)

Examples

Linking to a MapleSim model located in the following .msim file:

filecatkernelopts'toolboxdir'=MapleSim,/data/examples/RLCcircuit.msim:

AMapleSim:-LinkModelfilename=file:

FMIConnector:-GenerateCodeA

/tmp/fmiTmpjxmpSBIs/modelDescription.xml,/tmp/fmiTmpjxmpSBIs/sources/_UNASSIGNED.c,/tmp/fmiTmpjxmpSBIs/sources/_UNASSIGNED.c,/tmp/fmiTmpjxmpSBIs,64,,true,false,FMI2.0,DLL

(1)

See Also

FMIConnector

FMIConnector[CreateArchive]

MapleSim

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam