GenerateCode - MapleSim Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


BRConnector

  

GenerateCode

  

generate B&R custom FMU

 

Calling Sequence

Parameters

Returns

Options

Description

Calling Sequence

GenerateCode(system, options)

Parameters

system

-

module ; MapleSim model (connection module created using MapleSim[LinkModel])

options

-

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

Returns

• 

list(string) : a list containing the path and name of the generated Functional Mock-Up Unit (FMU).

Options

FMI Version and Environment

• 

fmiVersion : string; "FMI2.0"

  

Specifies that "FMI2.0" version of the FMI standard should be generated.

• 

fmiType : string; "CS"

  

Specifies the format of the FMU export, which is set to "CS" for Co-Simulation.

Export and Compiler Settings

• 

fname : string

  

Specifies the name of the generated FMU and C file. The default value is "FMUModel".

• 

fmiDistType : string; one of "SourceCode" or "DLL"

  

Specifies if the generated sources should be compiled into a dynamically linked library (DLL).

  

If set to "SourceCode", the FMU will contain source code only. This setting will generate sources with 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. The default value is "SourceCode".

• 

outputdir : string

  

Specifies the output directory for the generated file(s). The default is the home directory (kernelopts('homedir')).

• 

removetmpdir : true or false

  

Specifies whether the generated temporary directory should be removed. The temporary directory is generated in directory specified with the outputdir option 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 packaged into a file with a .fmu file extension. The default value is true.

• 

auxout : list

  

Specifies a list of expressions that will be generated into a separate C-code procedure.

• 

resources : list(list)

  

Specifies a list of additional resource files and where they should be placed in the FMU. Each sublist is a tuple of a string defining directory location within the FMU dir1 and a string containing the path to the resource file file1.  The subdirectory dir1 will be created under the resources folder of the .fmu and the resource file file1 will be copied into that directory.

Inputs, Outputs, and Parameters

• 

inputs : list of functions

  

Specifies the names of the system's input variables. By default, the inputs will be determined directly from the MapleSim model. For the top-level model, inputs will be an empty list.

• 

outputs : list of functions

  

Specifies the names of the system's output variables. By default, the outputs will be determined directly from the MapleSim model. For the top-level model, outputs will be a list of top-level probes.

• 

params : list of equations name = value

  

Specifies the values of the system's parameters for parameters to be exported in the FMU. By default, the parameters will be determined directly from the MapleSim model. Only those parameters defined at the specified (sub)system level are exported.

• 

longparnames : true or false

  

Specifies whether parameter names will be fully-qualified (long parameter names) in the FMU. The default value is false.

Constraint Handling

• 

coniter : non-negative integer

  

Specifies the maximum number of constraint projection iterations. The default value is 20.

• 

contol : positive

  

Specifies the constraint projection error tolerance. The default value is 1e-7.

• 

evtproj : true or false

  

Specifies whether constraint projection should be applied during event iterations. The default value is true.

Event Handling

• 

evtiter : positive integer

  

Specifies the maximum number of event iterations. The default value is 10.

• 

evthyst : non-negative

  

Specifies the width of the event hysteresis band. The default value is 1e-10.

Run-time Error Reporting

• 

rtetrack : true or false

  

Specifies whether run-time error reporting should be used. The default value is false.

Co-Simulation Settings

• 

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

  

Specifies which fixed step solver should be generated as the embedded solver for Co-Simulation. The default value is "Euler".

• 

stepsize : positive

  

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

• 

tunableparams : set(posint)

  

Specifies the indices of the system's tunable parameters. A tunable parameter in an FMU (supported only in FMI 2.0 Co-Simulation) is a parameter whose value can be changed during simulation if supported by the simulation environment. The default value is an empty set.

Baumgarte Constraint Stabilization

• 

baumgarte : list of numeric values

  

Specifies the Baumgarte parameters using a list of the form [Alpha, Beta], where Alpha sets the derivative gain and Beta sets the proportional gain for Baumgarte constraint stabilization. If baumgarte is set to an empty list, Baumgarte constraint stabilization is not applied. The default value is an empty list.

Optional Model Information

• 

optmodelinfo: record or string "default"

  

Specifies a record containing optional model information to be included in the XML modelDescription file.

  

The following fields apply:

– 

author : Name and organization of the model author (for example, "Maplesoft http://www.maplesoft.com/").

– 

descript : Brief description of the model (for example, "Model of battery").

– 

modelver : Version of FMU (for example, "4.1.5").

– 

copyright : Intellectual property copyright (for example "(C) MyCompany 2015").

– 

license : Intellectual property licensing (for example, "Proprietary", "Public Domain", or "BSD License").

  

The default value is the string "default", which means that all optional information will be an empty strings in the XML modelDescription file.

Additional Settings

• 

forceoverwrite : true or false

  

Specifies whether the FMU archive should be overwritten without prompting the user. The default value is false, meaning the user will be asked to confirm if the original files should be overwritten.

• 

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`. The default value is false.

Description

• 

The GenerateCode command generates a B&R custom FMU (Functional Mock-Up Unit) from a MapleSim system.

• 

An FMU is a zip archive with an .fmu file extension. It contains the binaries, resources, documentation, and sources folders, and the XML modelDescription file, according to the FMI specification. The resources contains visualization data files under the BR sub-directory.

• 

The FMU is generated in the home directory or in the path specified by the outputdir option.

  

For more details, see Export and Compiler Settings in the Options section of this topic.

See Also

BRConnector

FMU Distribution Notice

MapleSim