- Index
- » Users
- » SulivanK
- » Profile
Posts
Posts
Hi,
We work about extended standard of FMI. I use OpenModelica to execute simulation architectures with several FMUs. Some problems exist but its can be avoided and globally, we are satisfied. We would like use this platform with extended FMI standard but attributes and elements of the xml-file are checked and OM print error. Is it possible to desactivate these checkings or all errors ? Theorically, the ModelDescription is defined in xml_parser.h/c so if we add new elements, that should work with extended version in OM if we keep the original elements and attributes.
Thank you,
Sincerely,
Sulivan Küttler
OM version : OpenModelica 1.9.1 (r22929) (RML version)
Thank you for your help. The c code works now with the a-file. Here my mo-file :
within ;
package Interpolate
model Test
extends Modelica.Icons.Example;
MyTable table1 = MyTable("tab.txt", "table1");
Real y;
equation
der(y) = interpolateMyTable(table1, 300 * (time + 1), "S_adm_f");
annotation(experiment(StartTime = 0.0, StopTime = 1.0, Tolerance = 0.000001));
end Test;
class MyTable
extends ExternalObject;
function constructor
input String fileName;
input String tableName;
output MyTable table;
external "C" table = initMyTable(fileName, tableName, Modelica.Utilities.Files.loadResource("modelica://Interpolate/donnees/")) annotation( LibraryDirectory = "modelica://Interpolate/Clibraries", Library = "Document");
end constructor;
function destructor
input MyTable table;
external "C" closeMyTable(table) annotation( LibraryDirectory = "modelica://Interpolate/Clibraries", Library = "Document");
end destructor;
annotation(Documentation(info = "<HTML>
<p>
Subclass of the predefined class ExternalObject allowing to access to external data structures such as tables which are keeped between calls and passed to an external c-function for interpolation purposes.
<p>
This class has only two external c-functions named constructor and destructor which are called once before (resp. after) the first (resp. last) use of the obejct it refers to.
<p>
The tables which are to be interpolated are stored in only one structure containing :
</P>
<UL>
<LI><P >keywords naming the tables,
</P>
<LI><P >for each table, an integer defining the lengths of the table,
</P>
<LI><P >the data are given under the form of a two-dimensional table the entries of are respectively a crank angle and a value. The interpolation is carried out between two consecutive angles</P>
</UL>
</HTML>
"));
end MyTable;
function interpolateMyTable
extends Modelica.Icons.Function;
input MyTable table;
input Real u;
input String Nom_table;
output Real y;
external "C" y = interpolateMyTable(table, u, Nom_table) annotation( LibraryDirectory = "modelica://Interpolate/Clibraries", Library = "Document");
annotation(Documentation(info = "<HTML>
<p> Interpolate entries of the table \"Nom-table\" sorted in the previously defined structure of name \"table\" with the help of the external c-function \" double interpolateMyTable(void* object, double u, const char* nom_tab) \"
</HTML>"));
end interpolateMyTable;
annotation(Documentation(info = "<HTML>
<p>
Package of functions allowing linear interpolation of data such as : flow rate coefficients according to the valve lifting laws and the flow direction. These data depend on the cranck angle (between 0 and 720 degres), are stored in a .txt file and arise from external simulations or testing results
<p><b>Release Notes:</b></p>
<ul>
<li><i> </i> </li>
</ul>
</HTML>
"));
end Interpolate;
The a-file has been created with OMShell with this command :
system("gcc -c -a libDocument.a Document.o")
But the a-file is automatically stored in the MinGW ? And the ld.exe linker find the file ?
I read on "https://modelica.org/documents/ModelicaSpec32Revision2.pdf" that for Windows (a-file and so-file for linux), I need to create dll library for dynamic libraries (page 153). How is it possible with OMShell or other tools (I won't use visual studio) ? The a-file or so-file works on windows ?
I would just use c code with dynamic location for the libraries or includes in order to have a portable OpenModelica file (or application) with dynamic c function extension. Is there a easy way to do this ?
For information, I use Windows 7
Thank you.
I c-file is Document.c and I created "libDocument.a" with OMShell (system("gcc -c -o libDocument.a Document.c") which return 0 so it is ok.
However by replacing LibraryDirectory= localPatho, ... by LibraryDirectory="modelica://Document/Clibraries/" , Library="Document", ... that doesn't work. I have to store the a-file in a particular directory ?
Here my mo-file :
within ;
package Interpolate
constant String [:,2] glibraries := OpenModelica.Scripting.getLoadedLibraries();
constant String localPath = Modelica.Utilities.Strings.replace(glibraries[2,2],"\\","/");
constant String localPathh = "#include \"" + Modelica.Utilities.Strings.replace(glibraries[2,2],"\\","/") + "/Clibraries/Interpolate.h\"";
model Test
extends Modelica.Icons.Example;
MyTable table1 = MyTable("tab.txt", "table1");
Real y;
equation
der(y) = interpolateMyTable(table1, 300 * (time + 1), "S_adm_f");
annotation(experiment(StartTime = 0.0, StopTime = 1.0, Tolerance = 0.000001));
end Test;
class MyTable
extends ExternalObject;
function constructor
input String fileName;
input String tableName;
output MyTable table;
external "C" table = initMyTable(fileName, tableName, localPath + "/donnees/") annotation( LibraryDirectory="modelica://Document/Clibraries/" , Library="Document", IncludeDirectory = localPathh);
end constructor;
function destructor
input MyTable table;
external "C" closeMyTable(table) annotation( LibraryDirectory="modelica://Document/Clibraries/", Library="Document" , IncludeDirectory = localPathh);
end destructor;
annotation(Documentation(info = "<HTML>
<p>
Subclass of the predefined class ExternalObject allowing to access to external data structures such as tables which are keeped between calls and passed to an external c-function for interpolation purposes.
<p>
This class has only two external c-functions named constructor and destructor which are called once before (resp. after) the first (resp. last) use of the obejct it refers to.
<p>
The tables which are to be interpolated are stored in only one structure containing :
</P>
<UL>
<LI><P >keywords naming the tables,
</P>
<LI><P >for each table, an integer defining the lengths of the table,
</P>
<LI><P >the data are given under the form of a two-dimensional table the entries of are respectively a crank angle and a value. The interpolation is carried out between two consecutive angles</P>
</UL>
</HTML>
"));
end MyTable;
function interpolateMyTable
extends Modelica.Icons.Function;
input MyTable table;
input Real u;
input String Nom_table;
output Real y;
external "C" y = interpolateMyTable(table, u, Nom_table) annotation( LibraryDirectory="modelica://Document/Clibraries/" , Library="Document", IncludeDirectory = localPathh);
annotation(Documentation(info = "<HTML>
<p> Interpolate entries of the table \"Nom-table\" sorted in the previously defined structure of name \"table\" with the help of the external c-function \" double interpolateMyTable(void* object, double u, const char* nom_tab) \"
</HTML>"));
end interpolateMyTable;
annotation(Documentation(info = "<HTML>
<p>
Package of functions allowing linear interpolation of data such as : flow rate coefficients according to the valve lifting laws and the flow direction. These data depend on the cranck angle (between 0 and 720 degres), are stored in a .txt file and arise from external simulations or testing results
<p><b>Release Notes:</b></p>
<ul>
<li><i> </i> </li>
</ul>
</HTML>
"));
end Interpolate;
The compilation results are here :
"C:\OpenModelica1.9.1Beta2\\MinGW\bin\mingw32-make.exe" -j4 -f Interpolate.Test.makefile
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test.o Interpolate.Test.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_functions.o Interpolate.Test_functions.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_records.o Interpolate.Test_records.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_01exo.o Interpolate.Test_01exo.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_02nls.o Interpolate.Test_02nls.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_03lsy.o Interpolate.Test_03lsy.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_04set.o Interpolate.Test_04set.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_05evt.o Interpolate.Test_05evt.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_06inz.o Interpolate.Test_06inz.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_07dly.o Interpolate.Test_07dly.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_08bnd.o Interpolate.Test_08bnd.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_09alg.o Interpolate.Test_09alg.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_10asr.o Interpolate.Test_10asr.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_11mix.o Interpolate.Test_11mix.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_12jac.o Interpolate.Test_12jac.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_13opt.o Interpolate.Test_13opt.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_14lnz.o Interpolate.Test_14lnz.c
gcc -I. -o Interpolate.Test.exe Interpolate.Test.o Interpolate.Test_functions.o Interpolate.Test_records.o Interpolate.Test_01exo.o Interpolate.Test_02nls.o Interpolate.Test_03lsy.o Interpolate.Test_04set.o Interpolate.Test_05evt.o Interpolate.Test_06inz.o Interpolate.Test_07dly.o Interpolate.Test_08bnd.o Interpolate.Test_09alg.o Interpolate.Test_10asr.o Interpolate.Test_11mix.o Interpolate.Test_12jac.o Interpolate.Test_13opt.o Interpolate.Test_14lnz.o -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -lDocument -falign-functions -msse2 -mfpmath=sse -L"C:/OpenModelica1.9.1Beta2//lib/omc" -L"C:/OpenModelica1.9.1Beta2//lib" -Wl,--stack,0x2000000,-rpath,"C:/OpenModelica1.9.1Beta2//lib/omc" -Wl,-rpath,"C:/OpenModelica1.9.1Beta2//lib" -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++
c:/openmodelica1.9.1beta2/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: cannot find -lDocument
collect2: ld returned 1 exit status
mingw32-make: *** [omc_main_target] Error 1
Compilation process exited with code 2
It's better because I can see -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -lDocument but I have another problem.
Ps : I need to get the local path (get with constant String [:,2] glibraries := OpenModelica.Scripting.getLoadedLibraries() in order to send this path to the c function which read the file "tab.txt". This part works and the c function read the good path.
The C function are checked directly and the path for reading matrix in file is ok. It's the same for the includes. Only the Libraries doesn't work when a string variable is in annotation, it's localPatho.
This code modelica works because I wrote directly the path of the o-file :
within ;
package Interpolate
constant String [:,2] glibraries := OpenModelica.Scripting.getLoadedLibraries();
constant String localPath = Modelica.Utilities.Strings.replace(glibraries[2,2],"\\","/");
constant String localPatho = Modelica.Utilities.Strings.replace(glibraries[2,2],"\\","/") + "/Clibraries/Document.o";
constant String localPathh = "#include \"" + Modelica.Utilities.Strings.replace(glibraries[2,2],"\\","/") + "/Clibraries/Interpolate.h\"";
model Test
extends Modelica.Icons.Example;
MyTable table1 = MyTable("tab.txt", "table1");
Real y;
equation
der(y) = interpolateMyTable(table1, 300 * (time + 1), "S_adm_f");
annotation(experiment(StartTime = 0.0, StopTime = 1.0, Tolerance = 0.000001));
end Test;
class MyTable
extends ExternalObject;
function constructor
input String fileName;
input String tableName;
output MyTable table;
external "C" table = initMyTable(fileName, tableName, localPath + "/donnees/") annotation(LibraryDirectory = localPatho , IncludeDirectory = localPathh);
end constructor;
function destructor
input MyTable table;
external "C" closeMyTable(table) annotation(Library = "C:/OpenModelica1.9.1Beta2/tmp/Test_interp/Clibraries/Document.o" , IncludeDirectory = localPathh);
end destructor;
annotation(Documentation(info = "<HTML>
<p>
Subclass of the predefined class ExternalObject allowing to access to external data structures such as tables which are keeped between calls and passed to an external c-function for interpolation purposes.
<p>
This class has only two external c-functions named constructor and destructor which are called once before (resp. after) the first (resp. last) use of the obejct it refers to.
<p>
The tables which are to be interpolated are stored in only one structure containing :
</P>
<UL>
<LI><P >keywords naming the tables,
</P>
<LI><P >for each table, an integer defining the lengths of the table,
</P>
<LI><P >the data are given under the form of a two-dimensional table the entries of are respectively a crank angle and a value. The interpolation is carried out between two consecutive angles</P>
</UL>
</HTML>
"));
end MyTable;
function interpolateMyTable
extends Modelica.Icons.Function;
input MyTable table;
input Real u;
input String Nom_table;
output Real y;
external "C" y = interpolateMyTable(table, u, Nom_table) annotation(LibraryDirectory = localPatho , IncludeDirectory = localPathh);
annotation(Documentation(info = "<HTML>
<p> Interpolate entries of the table \"Nom-table\" sorted in the previously defined structure of name \"table\" with the help of the external c-function \" double interpolateMyTable(void* object, double u, const char* nom_tab) \"
</HTML>"));
end interpolateMyTable;
annotation(Documentation(info = "<HTML>
<p>
Package of functions allowing linear interpolation of data such as : flow rate coefficients according to the valve lifting laws and the flow direction. These data depend on the cranck angle (between 0 and 720 degres), are stored in a .txt file and arise from external simulations or testing results
<p><b>Release Notes:</b></p>
<ul>
<li><i> </i> </li>
</ul>
</HTML>
"));
end Interpolate;
We can find the -o file named Document.o in the compilation results :
"C:\OpenModelica1.9.1Beta2\\MinGW\bin\mingw32-make.exe" -j4 -f Interpolate.Test.makefile
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test.o Interpolate.Test.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_functions.o Interpolate.Test_functions.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_records.o Interpolate.Test_records.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_01exo.o Interpolate.Test_01exo.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_02nls.o Interpolate.Test_02nls.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_03lsy.o Interpolate.Test_03lsy.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_04set.o Interpolate.Test_04set.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_05evt.o Interpolate.Test_05evt.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_06inz.o Interpolate.Test_06inz.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_07dly.o Interpolate.Test_07dly.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_08bnd.o Interpolate.Test_08bnd.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_09alg.o Interpolate.Test_09alg.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_10asr.o Interpolate.Test_10asr.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_11mix.o Interpolate.Test_11mix.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_12jac.o Interpolate.Test_12jac.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_13opt.o Interpolate.Test_13opt.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_14lnz.o Interpolate.Test_14lnz.c
gcc -I. -o Interpolate.Test.exe Interpolate.Test.o Interpolate.Test_functions.o Interpolate.Test_records.o Interpolate.Test_01exo.o Interpolate.Test_02nls.o Interpolate.Test_03lsy.o Interpolate.Test_04set.o Interpolate.Test_05evt.o Interpolate.Test_06inz.o Interpolate.Test_07dly.o Interpolate.Test_08bnd.o Interpolate.Test_09alg.o Interpolate.Test_10asr.o Interpolate.Test_11mix.o Interpolate.Test_12jac.o Interpolate.Test_13opt.o Interpolate.Test_14lnz.o -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME C:/OpenModelica1.9.1Beta2/tmp/Test_interp/Clibraries/Document.o -falign-functions -msse2 -mfpmath=sse -L"C:/OpenModelica1.9.1Beta2//lib/omc" -L"C:/OpenModelica1.9.1Beta2//lib" -Wl,--stack,0x2000000,-rpath,"C:/OpenModelica1.9.1Beta2//lib/omc" -Wl,-rpath,"C:/OpenModelica1.9.1Beta2//lib" -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++
But with the localPatho variable, that doesn't work :
within ;
package Interpolate
constant String [:,2] glibraries := OpenModelica.Scripting.getLoadedLibraries();
constant String localPath = Modelica.Utilities.Strings.replace(glibraries[2,2],"\\","/");
constant String localPatho = Modelica.Utilities.Strings.replace(glibraries[2,2],"\\","/") + "/Clibraries/Document.o";
constant String localPathh = "#include \"" + Modelica.Utilities.Strings.replace(glibraries[2,2],"\\","/") + "/Clibraries/Interpolate.h\"";
model Test
extends Modelica.Icons.Example;
MyTable table1 = MyTable("tab.txt", "table1");
Real y;
equation
der(y) = interpolateMyTable(table1, 300 * (time + 1), "S_adm_f");
annotation(experiment(StartTime = 0.0, StopTime = 1.0, Tolerance = 0.000001));
end Test;
class MyTable
extends ExternalObject;
function constructor
input String fileName;
input String tableName;
output MyTable table;
external "C" table = initMyTable(fileName, tableName, localPath + "/donnees/") annotation(LibraryDirectory = localPatho , IncludeDirectory = localPathh);
end constructor;
function destructor
input MyTable table;
external "C" closeMyTable(table) annotation(LibraryDirectory = localPatho , IncludeDirectory = localPathh);
end destructor;
annotation(Documentation(info = "<HTML>
<p>
Subclass of the predefined class ExternalObject allowing to access to external data structures such as tables which are keeped between calls and passed to an external c-function for interpolation purposes.
<p>
This class has only two external c-functions named constructor and destructor which are called once before (resp. after) the first (resp. last) use of the obejct it refers to.
<p>
The tables which are to be interpolated are stored in only one structure containing :
</P>
<UL>
<LI><P >keywords naming the tables,
</P>
<LI><P >for each table, an integer defining the lengths of the table,
</P>
<LI><P >the data are given under the form of a two-dimensional table the entries of are respectively a crank angle and a value. The interpolation is carried out between two consecutive angles</P>
</UL>
</HTML>
"));
end MyTable;
function interpolateMyTable
extends Modelica.Icons.Function;
input MyTable table;
input Real u;
input String Nom_table;
output Real y;
external "C" y = interpolateMyTable(table, u, Nom_table) annotation(LibraryDirectory = localPatho , IncludeDirectory = localPathh);
annotation(Documentation(info = "<HTML>
<p> Interpolate entries of the table \"Nom-table\" sorted in the previously defined structure of name \"table\" with the help of the external c-function \" double interpolateMyTable(void* object, double u, const char* nom_tab) \"
</HTML>"));
end interpolateMyTable;
annotation(Documentation(info = "<HTML>
<p>
Package of functions allowing linear interpolation of data such as : flow rate coefficients according to the valve lifting laws and the flow direction. These data depend on the cranck angle (between 0 and 720 degres), are stored in a .txt file and arise from external simulations or testing results
<p><b>Release Notes:</b></p>
<ul>
<li><i>First version Mai 2009 M. Demoulin & C. Fourcade2</i> </li>
</ul>
</HTML>
"));
end Interpolate;
And we can not find the path for Document.o in the compilation results :
"C:\OpenModelica1.9.1Beta2\\MinGW\bin\mingw32-make.exe" -j4 -f Interpolate.Test.makefile
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test.o Interpolate.Test.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_functions.o Interpolate.Test_functions.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_records.o Interpolate.Test_records.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_01exo.o Interpolate.Test_01exo.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_02nls.o Interpolate.Test_02nls.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_03lsy.o Interpolate.Test_03lsy.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_04set.o Interpolate.Test_04set.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_05evt.o Interpolate.Test_05evt.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_06inz.o Interpolate.Test_06inz.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_07dly.o Interpolate.Test_07dly.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_08bnd.o Interpolate.Test_08bnd.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_09alg.o Interpolate.Test_09alg.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_10asr.o Interpolate.Test_10asr.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_11mix.o Interpolate.Test_11mix.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_12jac.o Interpolate.Test_12jac.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_13opt.o Interpolate.Test_13opt.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o Interpolate.Test_14lnz.o Interpolate.Test_14lnz.c
gcc -I. -o Interpolate.Test.exe Interpolate.Test.o Interpolate.Test_functions.o Interpolate.Test_records.o Interpolate.Test_01exo.o Interpolate.Test_02nls.o Interpolate.Test_03lsy.o Interpolate.Test_04set.o Interpolate.Test_05evt.o Interpolate.Test_06inz.o Interpolate.Test_07dly.o Interpolate.Test_08bnd.o Interpolate.Test_09alg.o Interpolate.Test_10asr.o Interpolate.Test_11mix.o Interpolate.Test_12jac.o Interpolate.Test_13opt.o Interpolate.Test_14lnz.o -I"C:/OpenModelica1.9.1Beta2//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -falign-functions -msse2 -mfpmath=sse -L"C:/OpenModelica1.9.1Beta2//lib/omc" -L"C:/OpenModelica1.9.1Beta2//lib" -Wl,--stack,0x2000000,-rpath,"C:/OpenModelica1.9.1Beta2//lib/omc" -Wl,-rpath,"C:/OpenModelica1.9.1Beta2//lib" -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++
Interpolate.Test_functions.o:Interpolate.Test_functions.c.text+0x13): undefined reference to `closeMyTable'
Interpolate.Test_functions.o:Interpolate.Test_functions.c.text+0x38): undefined reference to `initMyTable'
Interpolate.Test_functions.o:Interpolate.Test_functions.c.text+0x8c): undefined reference to `interpolateMyTable'
collect2: ld returned 1 exit status
mingw32-make: *** [omc_main_target] Error 1
Compilation process exited with code 2
I tried with Library = .. or LibraryDirectory = .. but it is the same issue.
Somebody could help me ?
- Index
- » Users
- » SulivanK
- » Profile