1 | package Test
|
---|
2 | extends Modelica.Icons.Package;
|
---|
3 | function __OpenModelica_getReal "Get scalar Real value from XML file"
|
---|
4 | extends Modelica.Icons.Function;
|
---|
5 | input String fileName="" "File where external data is stored";
|
---|
6 | input String varName "Key";
|
---|
7 | output Real y "Real value";
|
---|
8 | protected
|
---|
9 | ExternData.Types.ExternXMLFile xml = ExternData.Types.ExternXMLFile(fileName) "External XML file object";
|
---|
10 | algorithm
|
---|
11 | y := ExternData.Functions.XML.getReal(xml=xml, varName=varName);
|
---|
12 | annotation(Inline=false);
|
---|
13 | end __OpenModelica_getReal;
|
---|
14 |
|
---|
15 | model XMLTest "XML file read test"
|
---|
16 | extends Modelica.Icons.Example;
|
---|
17 | parameter String fileName = Modelica.Utilities.Files.loadResource("C:\OpenModelica1.12.0-dev-64bit\lib\omlibrary\ExternData 2.2.0\Resources\Examples\test.xml");
|
---|
18 | Real test = __OpenModelica_getReal(fileName, "set1.gain.k");
|
---|
19 | annotation(experiment(StopTime=1));
|
---|
20 | end XMLTest;
|
---|
21 |
|
---|
22 | annotation(uses(ExternData(version="2.2.0"), Modelica(version="3.2.2")));
|
---|
23 | end Test;
|
---|