- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » How to Export a FMU as C# ( Csharp ) ?
How to Export a FMU as C# ( Csharp ) ?
How to Export a FMU as C# ( Csharp ) ?
Hi,
iam new in this community and want to learn to work with modelica. My first project idea was to connect a robot model with my Robot in Solidworks, to simulate the Robot while turning in my motion study in Solidworks.
Therefor i need to export the Modelica-Model in C#. I saw its possible to export as C-Code, but when i change the target language i get this error:
------------------------------------------------------------------------------------------------------
[27] 13:18:18 Übersetzung Fehler
Interner Fehler Unknown FMU template target: CSharp
[28] 13:18:18 Übersetzung Fehler
Interner Fehler SimCode: The model testrob could not be translated to FMU
------------------------------------------------------------------------------------------------------
What setting do i need to export the FMU as CSharp?
The next question is, how can i work with the exported model-Code. I saw the Exporter exports a "main.c" file, but i didnt got how i can start the model and get any output?!
Does any one of you exported a Model and used it in a code? Maybe i start a 2. thread but i first need the Csharp files to test it with my Solidworks-Addin.
Best regards,
Simon Fritz
Re: How to Export a FMU as C# ( Csharp ) ?
FMI is a binary format specifying C linkage. So all FMUs regardless of language used will import in the way (unless you use source-code FMUs which we do not do for C#; we also do not do FMI export using C#). My guess is that you just need an FMI master written in C# and load the FMU from that at run-time.
- sjoelund.se
- 1700 Posts
Re: How to Export a FMU as C# ( Csharp ) ?
thx for your quick reply!
Could you help me get started by coding a FMI master? I started working with modelica this week so i have no clue how to do this Or do you know a good tutorial how to code a FMI master?
Thx!
Simon
Re: How to Export a FMU as C# ( Csharp ) ?
Go to fmi-standard.org and read the documentation very carefully. That + Google weird errors importing dll's should tell you everything you need to know.
- sjoelund.se
- 1700 Posts
Re: How to Export a FMU as C# ( Csharp ) ?
- sjoelund.se
- 1700 Posts
Re: How to Export a FMU as C# ( Csharp ) ?
I found a easier solution for my problem. I use the ".exe" file to simulate. I just have the problem that i didnt found a way to read the results from the ".mat" file with C#.
I found this library but its only for Matlab 5 Files... and it doesnt work for the modelica results (Matlab 4)
http://www.mathworks.com/matlabcentral/ … or-net-2-0
Does anyone has a idea to read the result files without matlab in C#?
Re: How to Export a FMU as C# ( Csharp ) ?
The mat4 format is very simple, the reader is quite short: https://github.com/OpenModelica/OMCompi … _matlab4.c
- sjoelund.se
- 1700 Posts
Re: How to Export a FMU as C# ( Csharp ) ?
Efficiency reasons. Reading mat-files is easier than parsing csv, I promise. But yes, you can change output format to csv. Just specify -r outfile.csv when calling the simulation executable or choose csv from OMEdit or call https://openmodelica.org/doc/OpenModeli … ionresults to convert from mat to csv.
- sjoelund.se
- 1700 Posts
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » How to Export a FMU as C# ( Csharp ) ?