Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

OpenModelica and FMU example

OpenModelica and FMU example

Hi!
I am trying a simple example with Modelica and FMUs but I cannot get it to work. Here is the example I am trying to run:
I have the following two models:

TestFMU1.mo

Code:


model TestFMU1
  parameter Real p = 1.0;
  connector TestOutputConnector
    output Real value;
  end TestOutputConnector;
  TestOutputConnector c;
equation
  c.value = p;
end TestFMU1;

TestFMU2.mo

Code:


model TestFMU2
  Real result;
  connector TestInputConnector
    input Real value;
  end TestInputConnector;
  TestInputConnector c;
equation
  result = c.value;
end TestFMU2;

In OpenModelica shell I export these models to FMU with

Code:


>> loadFile("TestFMU1.mo")
>> translateModelFMU(TestFMU1)

... and this went fine. But when trying the same for TestFMU2

.. I get the following error(s):

Code:


>> translateModelFMU(TestFMU2)
Error: Fel vid bygge av simulator. Loggfil: gcc -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -O -falign-functions -msse2 -mfpmath=sse -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -I. -c -o TestFMU2_FMU.o TestFMU2_FMU.c
gcc -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -O -falign-functions -msse2 -mfpmath=sse -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -I. -c -o TestFMU2.o TestFMU2.c
gcc -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -O -falign-functions -msse2 -mfpmath=sse -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -I. -c -o TestFMU2_functions.o TestFMU2_functions.c
In file included from TestFMU2_FMU.c:59:
C:/CE_installed_programs/OpenModelica//include/omc/c/fmu_model_interface.c: In function 'TestFMU2_fmiEventUpdate':
C:/CE_installed_programs/OpenModelica//include/omc/c/fmu_model_interface.c:627: warning: passing argument 2 of 'infoStreamPrint' makes integer from pointer without a cast
C:/CE_installed_programs/OpenModelica//include/omc/c/util/omc_error.h:142: note: expected 'int' but argument is of type 'char *'
C:/CE_installed_programs/OpenModelica//include/omc/c/fmu_model_interface.c:627: warning: passing argument 3 of 'infoStreamPrint' makes pointer from integer without a cast
C:/CE_installed_programs/OpenModelica//include/omc/c/util/omc_error.h:142: note: expected 'const char *' but argument is of type 'long int'
gcc -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -O -falign-functions -msse2 -mfpmath=sse -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -I. -c -o TestFMU2_records.o TestFMU2_records.c
gcc -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -O -falign-functions -msse2 -mfpmath=sse -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -I. -c -o TestFMU2_01exo.o TestFMU2_01exo.c
gcc -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -O -falign-functions -msse2 -mfpmath=sse -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -I. -c -o TestFMU2_02nls.o TestFMU2_02nls.c
gcc -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -O -falign-functions -msse2 -mfpmath=sse -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -I. -c -o TestFMU2_03lsy.o TestFMU2_03lsy.c
gcc -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -O -falign-functions -msse2 -mfpmath=sse -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -I. -c -o TestFMU2_04set.o TestFMU2_04set.c
gcc -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -O -falign-functions -msse2 -mfpmath=sse -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -I. -c -o TestFMU2_05evt.o TestFMU2_05evt.c
gcc -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -O -falign-functions -msse2 -mfpmath=sse -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -I. -c -o TestFMU2_06inz.o TestFMU2_06inz.c
gcc -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -O -falign-functions -msse2 -mfpmath=sse -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -I. -c -o TestFMU2_07dly.o TestFMU2_07dly.c
gcc -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -O -falign-functions -msse2 -mfpmath=sse -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -I. -c -o TestFMU2_08bnd.o TestFMU2_08bnd.c
gcc -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -O -falign-functions -msse2 -mfpmath=sse -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -I. -c -o TestFMU2_09alg.o TestFMU2_09alg.c
gcc -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -O -falign-functions -msse2 -mfpmath=sse -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -I. -c -o TestFMU2_10asr.o TestFMU2_10asr.c
gcc -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -O -falign-functions -msse2 -mfpmath=sse -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -I. -c -o TestFMU2_11mix.o TestFMU2_11mix.c
gcc -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -O -falign-functions -msse2 -mfpmath=sse -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -I. -c -o TestFMU2_12jac.o TestFMU2_12jac.c
gcc -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -O -falign-functions -msse2 -mfpmath=sse -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -I. -c -o TestFMU2_13opt.o TestFMU2_13opt.c
gcc -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -O -falign-functions -msse2 -mfpmath=sse -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -I. -c -o TestFMU2_14lnz.o TestFMU2_14lnz.c
g++ -shared -I. -o TestFMU2.dll TestFMU2_FMU.o TestFMU2.o TestFMU2_functions.o TestFMU2_records.o TestFMU2_01exo.o TestFMU2_02nls.o TestFMU2_03lsy.o TestFMU2_04set.o TestFMU2_05evt.o TestFMU2_06inz.o TestFMU2_07dly.o TestFMU2_08bnd.o TestFMU2_09alg.o TestFMU2_10asr.o TestFMU2_11mix.o TestFMU2_12jac.o TestFMU2_13opt.o TestFMU2_14lnz.o -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -I. -I"C:/CE_installed_programs/OpenModelica//include/omc/c" -O -falign-functions -msse2 -mfpmath=sse -L"C:/CE_installed_programs/OpenModelica//lib/omc" -Wl,-rpath,'C:/CE_installed_programs/OpenModelica//lib/omc' -lSimulationRuntimeC -linteractive -lregex -lexpat -lgc -lpthread -fopenmp -loleaut32 -lSimulationRuntimeC -lgc -lexpat -lregex -static-libgcc -luuid -loleaut32 -lole32 -lws2_32 -lsundials_kinsol -lsundials_nvecserial -lipopt -lcoinmumps -lcoinmetis -lpthread -lm -lgfortranbegin -lgfortran -lmingw32 -lgcc_eh -lmoldname -lmingwex -lmsvcrt -luser32 -lkernel32 -ladvapi32 -lshell32 -llapack-mingw -ltmglib-mingw -lblas-mingw -lf2c -linteractive -lwsock32 -llis -lstdc++ -Wl,-Bstatic -lf2c -Wl,-Bdynamic -llis -Wl,--kill-at
g++: TestFMU2_FMU.o: No such file or directory
g++: TestFMU2.o: No such file or directory
g++: TestFMU2_records.o: No such file or directory
mingw32-make: *** [TestFMU2.dll] Error 1

What I am doing wrong?

Re: OpenModelica and FMU example

I have some suggestions.

Don't you think that the connector must be defined outside your model :

Code:


connector TestOutputConnector
  output Real value;
end TestOutputConnector;
model TestFMU1
  parameter Real p = 1.0;
  TestOutputConnector c;
equation
  c.value = p;
end TestFMU1;

The name of your model is TestFMU2 and you want to build oa model called TestFMU1.

There are 0 guests and 0 other users also viewing this topic
You are here: