Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Lars Ivar Hatledal
    @markaren
    Hi! Any questions you have about FMI4cpp can be asked here!
    KAITO-FBX
    @KAITO-FBX
    Hi Thank you for your answer on github. I have one question : " I see in your repo that you provide an example with OpenModelica ... is it version 1.11.0 ? and have you tried to load the 1.13.2 ?
    Lars Ivar Hatledal
    @markaren
    The test uses v1.11.0. But I only load the XML. I know I had big issues with OM fmus using FMI4j
    I have not tried 1.13.2 FMUs. I get my fmus from the XC repo: https://github.com/modelica/fmi-cross-check
    But it seems they have removed all OM FMUs (except arm)
    KAITO-FBX
    @KAITO-FBX
    I am asking because I have had some issues on my side with a lisp cffi connection tool I built that seems to work with 1.12.0 version (me-fmu) of OM [with simulation running :-) ] but now completely fails with the last version of OM. Please give me time to understand your package (I am not good at all in C++ lol) and I will return to you ... hopefully. :-) Thank you very much.
    fresh-ji
    @fresh-ji
    Hello, i want to ask that how can i use fmi4cpp in VS2013?
    is there any solution? thanks!
    Lars Ivar Hatledal
    @markaren
    Hi @fresh-ji . Did my answer to your GitHub issue make it any clearer?
    Matteo Iervasi
    @JackHack96
    Hello! I'm trying to convert a Python script I made with PyFMI into C++ with FMI4cpp.
    The program is this one (https://gitlab.com/JackHack96/fmu2opcua/-/blob/master/src/FmuSimulation.py).
    The actual problem is that in Python with just one line of code I can pass a list made of <value_reference, actual_value> and write the values to the respective ports (line 40 of the Python script).
    What would be the quickest way to replicate this in C++ with FMI4cpp?
    I was looking at std::variant, I tought that I could make an std::unordered_map<fmi2ValueReference, std::variant> with all the possibile variable types, but I'm not entirely sure this is the correct approach (I still have to learn a lot about C++ though I've been studying it for 1 year now)
    Lars Ivar Hatledal
    @markaren
    Just keep it simple? Do a get/set for each scalar type.
    the map approach would not work as a single fmi2ValueReference could represent each type in the variant (eg. valueref of 1 is valid for both int/real/boolean/string)
    at the same time.
    Matteo Iervasi
    @JackHack96
    void FMU::set_inputs(const std::unordered_map<fmi2ValueReference, std::any> &inputs) {
      std::unique_lock<std::mutex> lock(input_mutex);
      for (const auto &i : inputs) {
        if (i.second.type() == typeid(fmi2String)) {
          if (!fmu_instance->write_string(i.first, std::any_cast<fmi2String>(i.second))) {
            std::cerr << "Error! step() returned with status: " << to_string(fmu_instance->last_status()) << std::endl;
            break;
          }
        } else if (i.second.type() == typeid(fmi2Boolean)) {
          if (!fmu_instance->write_boolean(i.first, std::any_cast<fmi2Boolean>(i.second))) {
            std::cerr << "Error! step() returned with status: " << to_string(fmu_instance->last_status()) << std::endl;
            break;
          }
        } else if (i.second.type() == typeid(fmi2Integer)) {
          if (!fmu_instance->write_integer(i.first, std::any_cast<fmi2Integer>(i.second))) {
            std::cerr << "Error! step() returned with status: " << to_string(fmu_instance->last_status()) << std::endl;
            break;
          }
        } else if (i.second.type() == typeid(fmi2Real)) {
          if (!fmu_instance->write_real(i.first, std::any_cast<fmi2Real>(i.second))) {
            std::cerr << "Error! step() returned with status: " << to_string(fmu_instance->last_status()) << std::endl;
            break;
          }
        }
      }
    }
    I actually went another route. I mean, what I wanted to achieve was the ability to set port values with a map (eg. set port 1 to true, set port 2 to 2.5 and so on)
    So I discovered another C++17 things called std::any which seems to fit
    In theory, this way I can create a map of <ID,value> without having to do write_real/write_boolean and so on for each one of the ports
    Kuhnovic
    @Kuhnovic
    Hi! I'm currently using FMI4cpp 0.8.0 on linux (gcc 6.3), and I'm getting a bunch of "undefined reference to `vtable for fmi4cpp::fmi2::fmu'" errors. After some google/stackoverflow reading, it seems that the issue is the lack of virtual constructors for the classes. MSVC has no issue with this. Is this something that is known/intentional? I just want to check before I create any issue :)
    Lars Ivar Hatledal
    @markaren
    Not intentional, but it compiles on gcc7 and I'm not sure supporting gcc6 is something I'd care to do. If it fails on say MSCV 2019, it would be something I'd want to fix. I currently only test on MSCV 2017.
    Kuhnovic
    @Kuhnovic
    No issuee with MSVC 2019 as far as I can tell. But not having the destructors virtual is a more fundamental issue, as it could lead to memory leaks since it would lead to only the base class members being destroyed. Regardless of compiler version.
    Lars Ivar Hatledal
    @markaren
    been a while since I looked at the code.. you are saying I should add virtual (default) deconstructors to the abstract classes?
    Kuhnovic
    @Kuhnovic
    Yes I think that's a good idea, it's good code practice in general :)
    Kuhnovic
    @Kuhnovic
    Hey Lars, we are in a situation where we need the raw DLL handle in order to implement a callback for an FMU, something that is currently not supported by the standard. We have patched fmi4cpp locally to make this work. Is this something you would be interested in to have in the official fmi4cpp? I can imagine other cases where this might be necessary, for example licensing checks.
    Lars Ivar Hatledal
    @markaren
    Thanks for the input. Currently I have no plans working on it myself, but if the change is non-intrusive you could make a PR and I'll consider it
    Kuhnovic
    @Kuhnovic
    Thanks for the quick reply, the PR is published NTNU-IHB/FMI4cpp#116