|
3 | 3 | # UniFMU - Universal Functional Mock-Up Units |
4 | 4 |
|
5 | 5 | The [_Functional Mock-Up Interface_](https://fmi-standard.org/) _(FMI)_ defines an exchange format that allows models, referred to as _Functional Mock-Up Unit (FMU)_, to be shared between tools supporting the standard. |
| 6 | +In general, an FMU must be implemented in a programming language that can produce binaries that can be called from C, such as C itself or C++. |
| 7 | +While this allows efficient execution of a simulation, it is a significant limitation when prototyping models. |
6 | 8 |
|
7 | | -Traditionally, an FMU must be implemented in a programming language that is compatible with C's binary interface such as C itself or C++. |
| 9 | +UniFMU is a command line tool that facilitates the implementation of FMUs in other popular languages that would otherwise not be able to produce C-compatible binaries. |
| 10 | +It does this by providing a precompiled binary that is C-compatible, which then dispatches calls to the implementation of the model in the target language. |
8 | 11 |
|
9 | | -UniFMU is a command line tool that facilitates the implementation of FMUs in languages in several languages, such as: |
| 12 | +| Specification Version | FMU Types | Languages | |
| 13 | +| --------------------- | ------------ | ---------- | |
| 14 | +| FMI3 | | | |
| 15 | +| FMI2 | cosimulation | Python, C# | |
| 16 | +| FMI1 | | | |
10 | 17 |
|
11 | | -- Python |
12 | | -- C# |
| 18 | +Examples of generated FMUs can be found in the [unifmu_examples](https://github.com/INTO-CPS-Association/unifmu_examples) repo. |
13 | 19 |
|
14 | | -This is made possible by providing a generic binary that dispatches calls to the users implementation using _remote procedure call_ _(RPC)_. |
| 20 | +## Getting the tool |
15 | 21 |
|
16 | | -## Installing the tool |
17 | | - |
18 | | -The current and revious versions of the tool can be downloaded from the releases tab of the repository. |
19 | | - |
20 | | -For convenience the tool can be copied to a directory that is in the systems path such as `/usr/bin/` for most Linux distributions. |
| 22 | +The tool can be downloaded from [releases](https://github.com/INTO-CPS-Association/unifmu/releases) tab of the repository. |
| 23 | +It is a single executable that bundles all assets used during FMU generation as part of the binary. |
21 | 24 |
|
22 | 25 | ## How to use the command line interface? |
23 | 26 |
|
24 | 27 | To display the synopsis use the `--help` flag. |
25 | 28 |
|
26 | 29 | ``` |
27 | | -UniFMU 0.0.4 |
| 30 | +UniFMU 0.0.6 |
28 | 31 | Implement 'Functional Mock-up units' (FMUs) in various source languages. |
29 | 32 |
|
30 | 33 | USAGE: |
@@ -93,74 +96,6 @@ Like the file structure, the workflow for modifying FMUs varies depending on the |
93 | 96 | Depending on the language a `README.md` is placed in the root of the generated FMU, which serves as documentation for the particular language. |
94 | 97 | For reference the `README.md` copied into Python FMUs looks like [README.md](tool/unifmu/resources/backends/python/README.md). |
95 | 98 |
|
96 | | -## Building and Testing |
97 | | - |
98 | | -Build the cross compilation image from the dockerfile stored in `docker-build` folder: |
99 | | - |
100 | | -``` |
101 | | -docker build -t unifmu-build docker-build |
102 | | -``` |
103 | | - |
104 | | -**Note: This process may take a long time 10-30 minutes, but must only be done once.** |
105 | | - |
106 | | -Start a container with the name `builder` from the cross-compilation image `unifmu-build`: |
107 | | - |
108 | | -```bash |
109 | | -docker run --name builder -it -v $(pwd):/workdir unifmu-build # bash |
110 | | -``` |
111 | | - |
112 | | -```powershell |
113 | | -$pwd = (pwd).Path |
114 | | -docker run --name builder -it -v ${pwd}:/workdir unifmu-build # powershell |
115 | | -``` |
116 | | - |
117 | | -**Note: On windows you may have to enable the use of shared folders through the dockers interface, otherwise the container fails to start.** |
118 | | - |
119 | | -To build the code invoke the script `docker-build/build_all.sh` in the `workdir` of the container: |
120 | | - |
121 | | -``` bash |
122 | | -bash ./docker-build/build_all.sh |
123 | | -``` |
124 | | - |
125 | | -This generates and copies all relevant build artifacts into the `assets/auto_generated` directory: |
126 | | - |
127 | | -``` |
128 | | -📦auto_generated |
129 | | - ┣ 📜.gitkeep |
130 | | - ┣ 📜unifmu.dll |
131 | | - ┣ 📜unifmu.dylib |
132 | | - ┣ 📜unifmu.so |
133 | | - ┣ 📜UnifmuFmi2.cs |
134 | | - ┗ 📜unifmu_fmi2_pb2.py |
135 | | -``` |
136 | | - |
137 | | -**Note: On windows Git may be configured to replace LF line-endings with CRLF, which are not compatible with bash.** |
138 | | - |
139 | | -Following this the cli is compiled for each platform, including the assets that were just compiled. |
140 | | -The final standalone executables can be found in the target folder, under the host tripple: |
141 | | - |
142 | | -- linux: unifmu-x86_64-unknown-linux-gnu-0.0.4.zip |
143 | | -- windows: unifmu-x86_64-pc-windows-gnu-0.0.4.zip |
144 | | -- macOS: unifmu-x86_64-apple-darwin-0.0.4.zip |
145 | | - |
146 | | -## Environment Variables |
147 | | - |
148 | | -In addition to the systems environment variables, UniFMU defines the following variables in the process created during instantiation of a slave. |
149 | | -These can be accessed during execution by the model implementation or the backend. |
150 | | - |
151 | | -| Variable | Description | Example | |
152 | | -| ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | |
153 | | -| UNIFMU_GUID | The global unique identifier, passed as an argument to fmi2Instantiate | 77236337-210e-4e9c-8f2c-c1a0677db21b | |
154 | | -| UNIFMU_INSTANCE_NAME | Name of the slave instance, passed as an argument to fmi2Instantiate | left_wheel_motor | |
155 | | -| UNIFMU_VISIBLE | Flag used to indicating if the instance should run in visible mode, passed as an argument to fmi2Instantiate | {true, false} | |
156 | | -| UNIFMU_LOGGING_ON | Flag used to indicating if the instance should run with logging, passed as an argument to fmi2Instantiate | {true, false} | |
157 | | -| UNIFMU_FMU_TYPE | Flag used to indicating if the instance is running in co-sim or model exchange mode, passed as an argument to fmi2Instantiate | {fmi2ModelExchange, fmi2CoSimulation} | |
158 | | -| UNIFMU_DISPATCHER_ENDPOINT | Endpoint bound by the zmq socket of the binary | tcp://127.0.0.1/5000 | |
159 | | -| UNIFMU_DISPATCHER_ENDPOINT_PORT | Port component of UNIFMU_DISPATCHER_ENDPOINT | 5000 | |
160 | | -| UNIFMU_REFS_TO_ATTRS | Mapping from value references to variable names encoded as a JSON dictionary\*. | {"0": "my_input", "1" : "my_output"} | |
161 | | - |
162 | | -\* This variable is only defined if the modelDescription.xml is present in the parent directory of the resources folder passed to fmi2Instantiate. |
163 | | - |
164 | 99 | ## Citing the tool |
165 | 100 |
|
166 | 101 | When citing the tool, please cite the following paper: |
|
0 commit comments