FMI Gateway FMU

Synposis

FMI Gateway FMU

Simulation Setup

Structure

Example Simulation

Setup

DOC: Provide description of Gateway Taskfile workflows.

Operation

The configuration and operation of the gateway is done in the stack.yaml that is to be loaded by the gateway. The stack follows the following schema with some additional, gateway specific annotations/ additions.

Stack Metadata

NameTypeRequiredDescription
metadataobjecttruenone
» namestringtrueThis field is required to be named “gateway”
» annotationobjectfalsenone
»» redis_showbooleanfalseSet to true if the redis process should be shown as terminal window
»» simbus_showbooleanfalseSet to true if the simbus process should be shown as terminal window
»» models_showbooleanfalseSet to true if the model processes should be shown as terminal windows
»» model_stackstringfalseName of the Stack.yaml containing the model descriptions. Required for session handling
--- kind: Stack metadata: name: gateway annotations: redis_show: true simbus_show: true models_show: true model_stack: stack_models_parser.yaml

Runtime

NameTypeRequiredDescription
specobjecttruenone
» runtimeobjectfalsenone
»» envobjectfalsenone
»»» REDIS_EXE_PATHstringfalsePath to the redis executable. If set, redis is handled by the gateway
»»» SIMBUS_EXE_PATHstringfalsePath to the simbus executable. Required if simbus is handled by the gateway
»»» MODELC_EXE_PATHstringfalsePath to the modelc executable. Required if models are handled by the gateway
--- kind: Stack metadata: name: gateway spec: runtime: env: REDIS_EXE_PATH: redis.exe SIMBUS_EXE_PATH: simbus.exe MODELC_EXE_PATH: modelc.exe

Simbus

If the simbus should be handled by the gateway, the simbus description must be part of the stack.yaml loaded by the gateway. For the handling additional information must be set as follows:

NameTypeRequiredDescription
specobjecttruenone
» modelsobjecttruenone
»» annotationsobjectfalsenone
»»» cliobjectfalsenone
»»»» step_sizefloat64falseSimbus step size. Default 0.0005
»»»» end_timefloat64falseSimbus end size. Default 10min (36000), do not set if gateway end time is variable
»»»» log_levelintfalseSimbus log level. Default 6 (lower equals to more information)
»»»» timeoutfloat64falseSimbus timeout. Default 60
»» runtimeobjecttruenone
»»» filesobjecttrueThis part contains a list of yaml files that are to be loaded by the simbus
--- kind: Stack metadata: name: gateway spec: models: - name: simbus model: name: simbus annotations: cli: step_size: 0.005 end_time: 0.02 log_level: 4 timeout: 600.0 runtime: files: - stack.yaml channels: - name: E2M_M2E expectedModelCount: 2 - name: com_phys expectedModelCount: 2

Gateway

The gateway description requires additional information in the stack.yaml loaded by the gateway as follows:

NameTypeRequiredDescription
specobjecttruenone
» modelsobjecttruenone
»» annotationsobjectfalsenone
»»» step_sizefloat64falseGateway step size. Default 0.0005
»»» end_timefloat64falseGateway end size. Default 10min (36000), do not set if gateway end time is variable
»»» log_levelintfalseGateway log level. Default 6 (lower equals to more information)
»»» log_locationstringfalsePath to where the log files of the models have to be saved
»»» cmd_envvarsobjectfalseThis part contains a list of environment variales that should be part of the fmi interface
»» runtimeobjectfalsenone
»»» envobjectfalsenone
»»»» GATEWAY_INIT_CMDstringfalsepath to the script/ cmd that is to be run before the simulation starts (in relation to the resource directory of the fmu)
»»»» GATEWAY_SHUTDOWN_CMDstringfalsepath to the script/ cmd that is to be run after the simulation ends (in relation to the resource directory of the fmu)
--- kind: Stack metadata: name: gateway spec: models: - name: gateway uid: 40004 model: name: Gateway annotations: step_size: 0.0050 end_time: 0.0200 log_level: 4 log_location: "./here" cmd_envvars: - envar0 - envar1 - envar2 runtime: env: # Gateway scripts. GATEWAY_INIT_CMD: "init_cmd" GATEWAY_SHUTDOWN_CMD: "shutdown_cmd" channels: - name: E2M_M2E alias: E2M_M2E selectors: channel: E2M_M2E - name: com_phys alias: com_phys selectors: channel: com_phys

Session handling of models

Models that should be handled (started & stopped) by the gateway are defined in an additional stack.yaml file that is referenced as described in this section. Additional information required is as follows:

NameTypeRequiredDescription
specobjecttruenone
» modelsobjecttruenone
»» annotationsobjectfalsenone
»»» cliobjectfalsenone
»»»» step_sizefloat64falseModel step size. Default 0.0005
»»»» end_timefloat64falseModel end size. Default 10min (36000), do not set if gateway end time is variable
»»»» log_levelintfalseModel log level. Default 6 (lower equals to more information)
»»»» timeoutfloat64falseModel timeout. Default 60
»»»» exestringfalseModel executable. This can be set in case the executable differs from the runtime modelc exe
»» runtimeobjecttruenone
»»» filesobjecttrueThis part contains a list of yaml files that are to be loaded by the model
--- kind: Stack metadata: name: stack_models spec: connection: transport: redispubsub: uri: redis://localhost:6379 timeout: 60 models: - name: Model_1 uid: 42 model: name: Model_1 annotations: cli: step_size: 0.0005 end_time: 20.0 log_level: 1 timeout: 600.0 exe: "different.exe" runtime: files: - stack.yaml - model.yaml - signalgroup.yaml channels: - name: E2M_M2E alias: signal_channel selectors: model: Model_1 channel: signal_vector

Examples

Complete examples of stack.yaml and stack_models.yaml for the gateway and its session handling.

Complete Example Stack.yaml
--- kind: Stack metadata: name: gateway annotations: redis_show: true simbus_show: true models_show: true model_stack: stack_models.yaml spec: connection: transport: redispubsub: uri: redis://localhost:6379 timeout: 60 runtime: env: REDIS_EXE_PATH: redis.exe SIMBUS_EXE_PATH: simbus.exe MODELC_EXE_PATH: modelc.exe models: - name: simbus model: name: simbus annotations: cli: step_size: 0.005 end_time: 0.02 log_level: 4 timeout: 600.0 runtime: env: SIMBUS_LOGLEVEL: 6 files: - stack.yaml channels: - name: E2M_M2E expectedModelCount: 2 - name: com_phys expectedModelCount: 2 - name: gateway uid: 40004 model: name: Gateway annotations: step_size: 0.0050 end_time: 0.0200 log_level: 4 log_location: "./here" cmd_envvars: - envar0 - envar1 - envar2 runtime: env: # Gateway scripts. GATEWAY_INIT_CMD: "init_cmd" GATEWAY_SHUTDOWN_CMD: "shutdown_cmd" channels: - name: E2M_M2E alias: E2M_M2E selectors: channel: E2M_M2E - name: com_phys alias: com_phys selectors: channel: com_phys
Complete Example Stack_models.yaml
--- kind: Stack metadata: name: stack_models spec: connection: transport: redispubsub: uri: redis://localhost:6379 timeout: 60 models: - name: Model_1 uid: 42 model: name: Model_1 annotations: cli: step_size: 0.0005 end_time: 20.0 log_level: 1 timeout: 600.0 exe: "different.exe" runtime: files: - stack.yaml - model.yaml - signalgroup.yaml channels: - name: E2M_M2E alias: signal_channel selectors: model: Model_1 channel: signal_vector - name: Model_2 uid: 45 model: name: Model_2 runtime: files: - stack.yaml - model.yaml - signalgroup.yaml channels: - name: com_phys alias: signal_channel selectors: model: Model_2 channel: signal_vector

Toolchains

The required files for the FMI gateway can be generated using a toolchain included in the FMI GO tools. This operation with generate the required modelDescription.xml, model.yaml and fmu.yaml.

NameRequiredDescription
VERSIONfalseVersion of the Gateway FMU
FMI_VERSIONfalseFMI Version of the Gateway FMU (Default 2)
STACKfalsestack.yaml file to be loaded by the gateway
SIGNAL_GROUPStrueList of yaml files to generate the required files for the Gateway FMU
OUT_DIRfalsePath to the generated files
UUIDfalseUUID of the Gateway FMU
$ task generate-fmigateway \ VERSION=0.01 \ FMI_VERSION=2 \ STACK=stack.yaml \ SIGNAL_GROUPS="extra/tools/fmi/test/testdata/fmigateway/SG1.yaml,extra/tools/fmi/test/testdata/fmigateway/SG2.yaml" \ OUT_DIR=./out \ UUID=2f9f2b62-0718-4e66-8f40-6735e03d4c08