Opened 7 years ago
Last modified 7 years ago
#4448 accepted defect
ExternData library is not working in OpenModelica
Reported by: | Owned by: | Adrian Pop | |
---|---|---|---|
Priority: | high | Milestone: | Future |
Component: | Code Generation | Version: | v1.12.0 |
Keywords: | ExternData | Cc: | Adam Dershowitz |
Description
The ExternData library works in Dymola and SimulationX, unfortunately, it is currently not working in OpenModelica. The library developed mentioned this in the documentation and suggest a quick fix (https://github.com/tbeu/ExternData). However, the fix does not work in OpenModelica. (please check this discussion board https://github.com/tbeu/ExternData/issues/9#issuecomment-308656184). By using a stand-alone function as suggested by the library developer-
package Test
extends Modelica.Icons.Package;
function OpenModelica_getReal "Get scalar Real value from XML file"
extends Modelica.Icons.Function;
input String fileName="" "File where external data is stored";
input String varName "Key";
output Real y "Real value";
protected
ExternData.Types.ExternXMLFile xml = ExternData.Types.ExternXMLFile(fileName) "External XML file object";
algorithm
y := ExternData.Functions.XML.getReal(xml=xml, varName=varName);
annotation(Inline=false);
end OpenModelica_getReal;
model XMLTest "XML file read test"
extends Modelica.Icons.Example;
parameter String fileName = Modelica.Utilities.Files.loadResource("modelica://ExternData/Resources/Examples/test.xml");
Real test = OpenModelica_getReal(fileName, "set1.gain.k");
annotation(experiment(StopTime=1));
end XMLTest;
annotation(uses(ExternData(version="2.2.0"), Modelica(version="3.2.2")));
end Test;
XML test compiles without any error but when I try to run it gives following errors.
[1] 10:44:56 Translation Notification
[ExternData: 512:7-520:18]: Created directory C:\Users\mrn04\AppData\Local\Temp\/omc_compile_ED_XMLFile_422688
[2] 10:44:56 Translation Notification
[ExternData: 512:7-520:18]: cp -a "C:/OpenModelica1.12.0-dev-64bit/lib/omlibrary/ExternData 2.2.0/Resources"/* "C:\Users\mrn04\AppData\Local\Temp\/omc_compile_ED_XMLFile_422688"
[3] 10:44:56 Translation Notification
[ExternData: 512:7-520:18]: Changed directory to C:/Users/mrn04/AppData/Local/Temp/omc_compile_ED_XMLFile_422688/BuildProjects/autotools
[4] 10:44:56 Scripting Error
Error opening file: log: No such file or directory.
[5] 10:44:56 Translation Error
[C:/dev/OpenModelica64bit/OMCompiler/Compiler/SimCode/SimCodeFunctionUtil.mo: 742:9-742:129]: Internal error function elaborateFunction failed for function:
function ExternData.Functions.XML.getReal"Inline never" "Get scalar Real value from XML file"
input String varName "Key";
output Real y "Real value";
input ExternalObject ExternData.Types.ExternXMLFile xml "External XML file object"; external "C" y = ED_getDoubleFromXML(xml, varName);
end ExternData.Functions.XML.getReal;
[6] 10:44:56 Translation Error
[C:/dev/OpenModelica64bit/OMCompiler/Compiler/SimCode/SimCodeUtil.mo: 603:5-603:83]: Internal error Creation of Modelica functions failed.
Any kind of help on this issue will be very helpful. Thanks.
Attachments (1)
Change History (7)
by , 7 years ago
comment:1 by , 7 years ago
Cc: | added |
---|
comment:2 by , 7 years ago
Component: | OMEdit → Code Generation |
---|---|
Owner: | changed from | to
comment:3 by , 7 years ago
Owner: | changed from | to
---|---|
Status: | new → accepted |
comment:4 by , 7 years ago
Yes, the library compiled for OpenModelica. As far my understanding, the ExternData library is included in OM system library. One just need to add it to library browser.
comment:6 by , 7 years ago
There are no mingw binaries in the ExternData lib. That's why omc tries to build it from source. This fails. I made a pull request inlcuding the mingw binaries to ExternData. This should fix the issue reported here, but it is still necessary to apply the workaround by tbeu as omc will refuse to allow externalObjects as record members.
This seems to depend on some external C code library. Is that library compiled for OpenModelica?
I guess one would need to compile that using OMDev and maybe add some Library and Include directives to external functions.