ntnu-ihb / fmi4cpp Goto Github PK
View Code? Open in Web Editor NEWFMI 2.0 implementation written in modern C++.
License: MIT License
FMI 2.0 implementation written in modern C++.
License: MIT License
Program will always crash if a prior run crashed without deleting the temporal folder.
If the folder is manually deleted from the temp directory (fmi4cpp generated folders are prefixed with fmi4cpp_), things will start working again.
I don't understand why this is happening as folders are generated per FMU and should not affect independent program runs..
Logging is clumsy and should be improved.
Today it's like this:
#if FMI4CPP_DEBUG_LOGGING_ENABLED
cout << "Hello world!'" << endl;
#endif
FMI4CPP_DEBUG_LOGGING_ENABLED
can be misspelled and the message is only printed in debug mode and cannot be turned off. A logging framework provided more control should probably be used.
There are probably some best practices in the C++ that should be followed?
Allow path to FMUs to be specified using an URL.
Should be an optional feature.
Blocks NTNU-IHB/FMU-proxy#66
boost::optional should be more performant and should be more self-explanatory
Long ago, boost/optional was replaced with (c++17) optional (in public headers) in order to not publicly have boost as a project dependency. This was before boost-odeint was added. With that module enabled, boost must be present in public headers anyway, so we might just use boost optional.
This might fix #61
Just FYI, FMI 3.0 will be supported in the future.
Some refactoring is underway to accommodate this, but the actual FMI 3.0 support will not come before it's officially released.
Hi,
I noticed the library requires cxx17, what is that you actually require ? (I did not spot anything fancy in the code).
Hi @markaren,
thanks for the great work on the library!
I had a small question, as I was not able to find this info in the README. At the moment the library provides support for importing FMUs, but I was wondering if you have planned/are interested in providing facilities/support for implementing FMU in C++, in a sense providing support for "FMI export".
It would be great if you could provide C headers also, to access the library FMI4cpp. I would like to call this library from the D Programming Language. D can easily access libraries which has a C headers (and to a specific degree also C++ headers, but here I failed).
e.g.
boost/1.69
instead of
boost/1.66.0@conan/stable
in conanfile.txt
see also https://conan.io/center/
I thought a valueReference
was a unique identifier to scalarVariable (or a list of scalarVariable
that are aliases
). But it seems you can have the same valueReference
for a integer/real/boolean/string/enumeration
.
That means the getByValueReference
function is wrong, as it will return the first occurence.
Functions pointers can be cached for a execution speedup
It's not really an bug from fmi4cpp.
But under visual studio I get syntax error at line 104 of fmi2/xml/typed_scalar_variable.hpp when I try to include fmi4cpp.hpp in my project.
The problem is caused by the minwindef.h that define min and max macros, which break the bounded_scalar_variable::min().
One of the solution is to include fmi4cpp.hpp earlier or define NOMINMAX as suggest here
Though I put a message here in case it help others like me that were not familiar with this windows macro.
I'm not sure this feature is even used, and I cannot vouch for it's validity.
I Believe this feature is best implemented by users themselves.
To be clear, the ME API will persist, but fmi4cpp
will not provide a way to wrap ME models as CS ones.
It's not worth the maintenance effort. Use conan
or apt
Thanks for your generous replying!
Log messages are currently not formatted as intended by the FMI standard.
The current approach is to reload the shared library if canBeInstantiatedOnlyOncePerProcess=true
, otherwise re-use it. E.g for fmi2CoSimulationFmu
:
unique_ptr<fmi2CoSimulationSlave> fmi2CoSimulationFmu::newInstance(const bool visible, const bool loggingOn) {
shared_ptr<fmi2CoSimulationLibrary> lib = nullptr;
string modelIdentifier = modelDescription_->modelIdentifier();
if (modelDescription_->canBeInstantiatedOnlyOncePerProcess()) {
lib = make_shared<fmi2CoSimulationLibrary>(modelIdentifier, resource_);
} else {
if (lib_ == nullptr) {
lib_ = make_shared<fmi2CoSimulationLibrary>(modelIdentifier, resource_);
}
lib = lib_;
}
fmi2Component c = lib->instantiate(modelIdentifier, fmi2CoSimulation, guid(),
resource_->getResourcePath(), visible, loggingOn);
return make_unique<fmi2CoSimulationSlave>(c, lib, modelDescription_);
}
Apparently this approach is flawed and won't work.
It's better to pass
-DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake
through the command line.
This is also the recommendation from vcpkg
vcpkg port is currently at v0.5.3.
Feel free to bump this issue if you are eager for me to push an update.
Thank you for providing this package.
Some error messages (Cf later in the post) during compilation after the command :
conan create . FMI4cpp/testing while I am in the /Documents/FMI/FMI4cpp-conan$ directory.
My current system is the following :
Linux 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 GNU/Linux
I also add to manually install cmake to this version as the Debian distro doesn't provide it.
cmake version 3.14.2
Could you be so kind as to providing some advices for me to solve this issue?
Thank you for your help.
.....
Here is one of the error messages ....
/ModelDescription.hpp:29:20: fatal error: optional: No such file or directory
#include
....
Following is a detailed description of the error message ending with the previous lines.
[ 31%] Building CXX object src/CMakeFiles/fmi4cpp.dir/fmi4cpp/fmi2/import/fmi2Fmu.cpp.o
[ 36%] Building CXX object src/CMakeFiles/fmi4cpp.dir/fmi4cpp/fmi2/import/fmi2CoSimulationLibrary.cpp.o
[ 42%] Building CXX object src/CMakeFiles/fmi4cpp.dir/fmi4cpp/fmi2/import/fmi2Library.cpp.o
In file included from /home/frederic/.conan/data/FMI4cpp/0.6.1/FMI4cpp/testing/build/2ddc3fb6da02007e31c4d4885b23776a2dab579a/FMI4cpp/src/../include/fmi4cpp/fmi2/fmi2.hpp:29:0,
from /home/frederic/.conan/data/FMI4cpp/0.6.1/FMI4cpp/testing/build/2ddc3fb6da02007e31c4d4885b23776a2dab579a/FMI4cpp/src/../include/fmi4cpp/fmi4cpp.hpp:28,
from /home/frederic/.conan/data/FMI4cpp/0.6.1/FMI4cpp/testing/build/2ddc3fb6da02007e31c4d4885b23776a2dab579a/FMI4cpp/src/../include/fmi4cpp/common/driver/fmu_driver.hpp:31,
from /home/frederic/.conan/data/FMI4cpp/0.6.1/FMI4cpp/testing/build/2ddc3fb6da02007e31c4d4885b23776a2dab579a/FMI4cpp/src/fmi4cpp/common/driver/fmu_driver.cpp:29:
/home/frederic/.conan/data/FMI4cpp/0.6.1/FMI4cpp/testing/build/2ddc3fb6da02007e31c4d4885b23776a2dab579a/FMI4cpp/src/../include/fmi4cpp/fmi2/xml/ModelDescription.hpp:29:20: fatal error: optional: No such file or directory
#include
^
In order to keep this repository slimmer for easier maintenance, I've decided to remove the driver application. I have not used i myself and don't know others that have either.
Hi,
You dont run any integration tests ? Do you know Travis, Appveyor and such ?
Allow ME models to be wrapped as CS models. Requires solvers. Sundials are available through vcpkg. But I have to check that linux is supported. If not I should add the support to the port file myself.
Hello,
When doing make install
, the following error is thrown :
CMake Error at cmake_install.cmake:68 (file): file INSTALL cannot find "/root/FMI4cpp/cmake/FindCURL_.cmake".
Best,
Benjamin
It's not worth the maintenance effort
While FmuSlave::init(start, stop) is easy to use, bu it introduces some issues:
Solution: Let the user call the three functions (setupExperiment, enterInitializationMode and exitInitializationMode
) that init calls internally manually.
No idea why. No changes since last successful CI run.
Hi,
I would very much like to hear from you, the person reading this.
Why are you interested in this project, have you tried it?
What is unclear, what can be improved?
Note that it is also possible to chat on gitter!
in fmu::fmu, unzip is called, and it finds the appropriate files. However, those in the subdirectories (e.g. binaries/win64) are not written to the uncompressed temp location. I see logic in unzipper
if (sb.size == 0) {
fs::create_directories(newFile);
} else {
that is meant to catch the directories and create them, but it never executed. Is there a specific compression method needed so that libzip finds the directories first? I used normal windows compressed folder creation and 7zip without success.
Create a simple cmd application for running FMUs and print data to csv. Will be used to generate the crosscheck-results requested in #25
When compiling with Visual Studio 2019 errors occur in typed_scalar_variable.hpp since the min and max member functions of bounded_scalar_variable.
This can be solved by undefining the old min and max macros via:
#ifdef max
#undef max
#endif
#ifdef min
#undef min
#endif
I'm trying to write a little program that needs to load an example FMU generated from Simulink (a multiplier). It works using PyFMI but not in FMI4cpp, and specifically it's throwing an exception when trying to create a new instance.
fmi4cpp::fmi2::fmu multiplier("multiplier.fmu");
auto cs_fmu = multiplier.as_cs_fmu();
auto cs_md = multiplier.get_model_description();
auto step_size = cs_md->default_experiment->stepSize;
auto stop_time = cs_md->default_experiment->stopTime;
auto int1 = cs_md->get_variable_by_name("int1").as_real();
auto int2 = cs_md->get_variable_by_name("int2").as_real();
auto outv = cs_md->get_variable_by_name("out").as_real();
auto slave = cs_fmu->new_instance(); // exception
The exception is:
Unable to load dynamic library '/tmp/fmi4cpp_multiplier_23920508/binaries/linux64/multiplier.so'! /tmp/fmi4cpp_multiplier_23920508/binaries/linux64/multiplier.so: cannot open shared object file: No such file or directory
terminate called after throwing an instance of 'std::runtime_error'
what(): Unable to load dynamic library '/tmp/fmi4cpp_multiplier_23920508/binaries/linux64/multiplier.so'! /tmp/fmi4cpp_multiplier_23920508/binaries/linux64/multiplier.so: cannot open shared object file: No such file or directory
Am I missing something or it's a bug?
Speed up conan run by cache .conan folder
Generate cross-check results and upload them to https://github.com/modelica/fmi-cross-check
Don't know if there is something we can do about that?
Guess it's time to release 0.8.0.
0.8.0 is not backwards compatible with 0.7.0 and removes some features.
Master branch has been based on 0.8.0 for a long long time.
Help appreciated..
Add vcpkg port. Should be straight forward, but I want to wait a little while to allow the API to settle.
Hello,
Is it possible to add a cmake option to create a dynamic (shared) library instead of a static one ?
Best,
Benjamin
When using the current master of omc
to generate an FMU, the file <model>_info.json
is put directly into the resources
folder inside the FMU. However, FMI4cpp looks for it in the folder "resources" + getOs() + "/" + getLibExt()
, which for me is resources/linux64/.so
and thus cannot find the file.
Is this a bug? When I remove adding getOs()
and getLibExt()
everything works as expected.
For using the library in a external projects, it is convenient to add an install
target using the CMake's install
command to install library files, header files and CMake exported targets and configuration files (see https://cmake.org/cmake/help/v3.12/manual/cmake-packages.7.html and https://github.com/robotology/how-to-export-cpp-library).
Do you plan to add those? I would be happy to help on this, if you need any support.
Should read() and write() on typed_scalar_variable be marked as const? Unless they are it seems problematic to make the example code work because as_integer() as_real() and friends return a const type. This makes templating with this type require the use of std::remove_const and an intermediate copy of the underlying description object.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.