Comments (12)
This is currently not possible, because the Julia-C-Pipeline currently does not support variadic arguements. The only way to currently solve this, would be to redirect the variadic C function call to a DLL/LIB, replace the format placeholders inside and call a Julia-Function with the formatted string (no variadic arguments any more). As said, this would need us to ship a DLL/LIB with the library or build a DLL/LIB on the system that implements this single function.
Funny thing: In some eraly version we already tried this and it works fine, but the preferable solution would be to handle the variadic callback function with "native" Julia.
PS: The only tool I currently know that uses the variadic argument calling convention is OpenModelica, Dymoal and many others just deliver a ready to use formatted string.
So the options would be to deliver some C-library-code and (automated) compile it for the target machine and redirect the callback function (which is not a really clean solution) or wait for Julia to support variadic arguments in c-functions.
from fmi.jl.
If other tools would struggle with this I would just change it in OpenModelica. But the tools I tested (OMSimulator, FMPy) can handle it. Not sure how python does FMPy does this. Maybe Python can do this or they added a similar binary.
So the options would be to deliver some C-library-code and (automated) compile it for the target machine and redirect the callback function (which is not a really clean solution) or wait for Julia to support variadic arguments in c-functions.
The C-library would be the fastest option. Do you think you can add that library to FMI.jl until there is a pure Julia solution available?
from fmi.jl.
We still have the library and the old code, I just need to refactor it a bit. Would be nice if you could check (and maybe adapt) the DLL/LIB to compile on Linux as well as soon we are ready (we are working mainly on windows)? I think I will need about a week, because there are currently other things open, too.
from fmi.jl.
Sure, I can check it out on Linux.
I think the recommended way for C dependencies is to use BinaryBuilder.jl and Yggrasil. I never tried them myself, but instead added pre-build binaries to a Julia package. But then you have the trouble to compile the sources for all available systems.
from fmi.jl.
The more I think about it, the more I don't like the idea of checking in such a "hacky" solution. Further, we would build platform-dependent code around a library that is platform-independent, which seems not a good idea.
Because - if I understand you right - this issue isn't really urgent (there is the option to export the FMU with ready-formatted strings), I would suggest to wait for a language native fix (variadic c-functions), instead of deploying a (propably) unreliable workaround...
What do you think?
from fmi.jl.
The more I think about it, the more I don't like the idea of checking in such a "hacky" solution.
I'm not sure it is a "hacky" solution. Not everything works in Julia and you are dealing with C FMUs, so havon some C sources / binaries for FMI.jl sounds fine.
this issue isn't really urgent (there is the option to export the FMU with ready-formatted strings)
I don't know about an option for OpenModelica to have ready-formatted strings. I could add it, but the FMUs are according to the specification, so I don't think it makes that much sense to change OM FMUs.
But yes, not an urgent problem.
But how long would a language native fix be? Do you know any discussion about this? I couldn't find much about giving variadic Julia functions to a C function. Only the other way around.
from fmi.jl.
I just found an article, that this should be possible using CBindings.jl.
I will check this out ...
from fmi.jl.
This is fixed for Windows in FMI.jl 0.6.0. Until Julia supports variadic c-calls, you can use fmiInstantiate(....; externalCallbacks=true)
.
from fmi.jl.
To solve this the way it should be solved, it is needed to offer a variadic function for fmi2CallbackLogger
, that formats the message like a call to sprintf
(or printf
). In native Julia, variadic c-functions are not supported by now (as far as I know). A possible option may be using CBindings.jl but I am not familiar with ...
EDIT: Added "help wanted"-badge
from fmi.jl.
I added binaries for Linux and Mac in ThummeTo/FMIImport.jl#40.
from fmi.jl.
Much appreciated! I will merge them soon together with some other changes.
Thanks!
from fmi.jl.
Closed by FMIImport v0.11.0 (FMI.jl 0.10.0) via PR#45
from fmi.jl.
Related Issues (20)
- Simulation aborts unstable solution HOT 5
- Implement enumerations parsing HOT 1
- ME simulation for FMI3 [BETA]
- Input functions of the form (u,t) for CS FMUs HOT 7
- fmiReload and fmiLoad not thread-save HOT 9
- Warning: Using arrays or dicts to store parameters of different types can hurt performance.
- Ability to graphically visualize FMUs HOT 3
- Backport compat for SciMLBase@v2 for [email protected] HOT 5
- Solution CSV export for alias variables HOT 2
- FMI Compatibility Page for the Docs
- condition() called while not in continuous time mode HOT 1
- example inputs.ipynb doesn't run with v0.13.0 HOT 1
- DimensionMismatch for OpenModelica `Modelica.Blocks.Examples.RealNetwork1` 2.0.4 FMU
- Implement fmiGet! for fmi2Enum
- Segmentation fault after assert HOT 1
- StackOverFlowError HOT 1
- simData.success not working properly? HOT 3
- Relax compat requirements HOT 4
- Extend Compatibility information
- Request for DiffEqCallbacks v3 compat with FMI v0.10.x HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fmi.jl.