ghorwin / FMICodeGenerator

A Code Generator that creates native C/C++ code to build Functional Mock-Up Units (FMU) with support for FMI version 2.0 (rollback)
BSD 3-Clause "New" or "Revised" License
51 stars 25 forks source link

How to use VS2022 to compile the code #42

Closed richman2024 closed 2 years ago

richman2024 commented 2 years ago

Hi,

I compiled the code use VS2022 to the fmu file, and loaded it into openmodelica. But I got below issue. [test_model: 0:0-0:0]: [Expected test0901_me_FMU to be a class, but found component instead.](omeditmessagesbrowser:///test_model?lineNumber=0) Is that only support VS2015? Or how could I do just using VS2022 if possible?

ghorwin commented 2 years ago

Hi, this has nothing to do with the compilation of the DLL, but rather how you integrate the FMU into OpenModelica. Please ask in the OM forum for help!

richman2024 commented 2 years ago

Hi, this has nothing to do with the compilation of the DLL, but rather how you integrate the FMU into OpenModelica. Please ask in the OM forum for help!

I compiled a FMU 2 months ago used VS2015, and there still isn't any issues when integrate it into OpenModelica.

ghorwin commented 2 years ago

Ok, well, I'll check this then. However, I don't have VC 2022 installed yet, so I need to setup a VM first and test it there... will take some time.

PS: Which OpenModelica-Version are you using? Also, do you copy the needed VC2022 runtime libraries together with the FMU dll? This might be the case. Also, please download MasterSim and test the FMU there - if it runs there, the issue is with OpenModelica.

Can you provide me with the FMU source code for testing?

richman2024 commented 2 years ago

Ok, well, I'll check this then. However, I don't have VC 2022 installed yet, so I need to setup a VM first and test it there... will take some time.

PS: Which OpenModelica-Version are you using? Also, do you copy the needed VC2022 runtime libraries together with the FMU dll? This might be the case. Also, please download MasterSim and test the FMU there - if it runs there, the issue is with OpenModelica.

Can you provide me with the FMU source code for testing?

Thank you for your support! OpenModelica-Version: 1.20.0-dev-64bit How can I copy VC2022 runtime libraries together with the FMU dll? I just follow the guide to generate the FMU. Below is my csource code, 1 input x and 8 output(ya, yb, ... , yh)

    double x = m_realVar[FMI_INPUT_x];

    double ya, yb, yc, yd, ye, yf, yg, yh;
    ya = 0.000295 * x + 0.000815;
    yb = 0.000602 * x + 0.00166;
    yc = 0.000893 * x + 0.00246;
    yd = 0.001174 * x + 0.00322;
    ye = 0.001465 * x + 0.00404;
    yf = 0.001757 * x + 0.00486;
    yg = 0.002051 * x + 0.00569;
    yh = 0.002347 * x + 0.00649;

    m_realVar[FMI_OUTPUT_ya] = ya;
    m_realVar[FMI_OUTPUT_yb] = yb;
    m_realVar[FMI_OUTPUT_yc] = yc;
    m_realVar[FMI_OUTPUT_yd] = yd;
    m_realVar[FMI_OUTPUT_ye] = ye;
    m_realVar[FMI_OUTPUT_yf] = yf;
    m_realVar[FMI_OUTPUT_yg] = yg;
    m_realVar[FMI_OUTPUT_yh] = yh;

    m_externalInputVarsModified = false;

Also, I'll test the FMU in MasterSim later.

richman2024 commented 1 year ago

Hi,

Seems it doesn't work. Do you have any idea to solve it? I got below error whatever the function is. Expected XXX_FMU to be a class, but found component instead.](omeditmessagesbrowser:///test?lineNumber=0)

ghorwin commented 1 year ago

Hi, this is all OpenModelica-Related (and also linked to your installation). I'm using OpenModelica on Linux and here the FMU works ok. Sorry, but I cannot help you with that.

Suggestions:

richman2024 commented 1 year ago

Hi, this is all OpenModelica-Related (and also linked to your installation). I'm using OpenModelica on Linux and here the FMU works ok. Sorry, but I cannot help you with that.

Suggestions:

  • use a different Modelica-Environment (SimX, Dymola, Test-Versions should be enough) and see, if the problem persists
  • please ask in the OpenModelica-Forum about the error message you receive

Thank you for your support!

Done for this issue, and it's not about your program.