﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
4448	ExternData library is not working in OpenModelica	musa_me4@…	Adrian Pop	"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."	defect	accepted	high	Future	Code Generation	v1.12.0		ExternData	Adam Dershowitz
