Ticket #6325: SizingExampleXML3.mo

File SizingExampleXML3.mo, 1.2 KB (added by Dietmar Winkler, 4 years ago)
Line 
1model SizingExampleXML3
2 constant String hString = "multiTank.tankHeights" "XML element name";
3 constant String fName = "/tmp/multiTank1.xml" "XML file name";
4 final parameter Integer n = readArraySize1D(hString, fName) "Array size";
5 parameter Real heightVector[n] = readRealArray1D(hString, fName, n) "Array parameter";
6 function readArraySize1D "Read array size"
7 input String hString "XML element name";
8 input String fName "XML file name";
9 output Integer n "Array size";
10 protected
11 ExternData.Types.ExternXMLFile extObj = ExternData.Types.ExternXMLFile(fName, verboseRead=true) "External XML file object";
12 algorithm
13 n := ExternData.Functions.XML.getArraySize1D(hString, extObj);
14 end readArraySize1D;
15 function readRealArray1D "Read array"
16 input String hString "XML element name";
17 input String fName "XML file name";
18 input Integer n "Array size";
19 output Real arr[n] "Array";
20 protected
21 ExternData.Types.ExternXMLFile extObj = ExternData.Types.ExternXMLFile(fName, verboseRead=true) "External XML file object";
22 algorithm
23 arr := ExternData.Functions.XML.getRealArray1D(hString, n, extObj);
24 end readRealArray1D;
25 annotation(uses(ExternData(version="2.5.0")));
26end SizingExampleXML3;