Skip to content

Commit 2bf8021

Browse files
committed
- The System.readPtolemy* functions now exist in SimulationResults.mo (and System.mo no longer depends on Values.mo).
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@4520 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent a7f27af commit 2bf8021

File tree

6 files changed

+102
-210
lines changed

6 files changed

+102
-210
lines changed

Compiler/CevalScript.mo

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ protected import UnitAbsyn;
9090
protected import UnitParserExt;
9191
protected import UnitAbsynBuilder;
9292
protected import Inline;
93+
protected import SimulationResults;
9394

9495
public function cevalInteractiveFunctions
9596
"function cevalInteractiveFunctions
@@ -710,7 +711,7 @@ algorithm
710711
pwd = System.pwd();
711712
pd = System.pathDelimiter();
712713
filename_1 = Util.stringAppendList({pwd,pd,filename});
713-
value = System.readPtolemyplotDataset(filename_1, vars_1, size);
714+
value = SimulationResults.readPtolemyplotDataset(filename_1, vars_1, size);
714715
then
715716
(cache,value,st);
716717

@@ -739,7 +740,7 @@ algorithm
739740
pwd = System.pwd();
740741
pd = System.pathDelimiter();
741742
filename_1 = Util.stringAppendList({pwd,pd,filename});
742-
value = System.readPtolemyplotDatasetSize(filename_1);
743+
value = SimulationResults.readPtolemyplotDatasetSize(filename_1);
743744
then
744745
(cache,value,st);
745746

@@ -776,7 +777,7 @@ algorithm
776777

777778
(cache,Values.RECORD(orderd={Values.STRING(filename)}),_) = Ceval.ceval(cache,env,
778779
Exp.CREF(Exp.CREF_IDENT("currentSimulationResult",Exp.OTHER(),{}),Exp.OTHER()), true, SOME(st), NONE, msg);
779-
value = System.readPtolemyplotDataset(filename, vars_2, 0);
780+
value = SimulationResults.readPtolemyplotDataset(filename, vars_2, 0);
780781
pwd = System.pwd();
781782
cit = winCitation();
782783

@@ -808,7 +809,7 @@ algorithm
808809
vars_2 = Util.listUnionElt("time", vars_1);
809810
(cache,Values.RECORD(orderd={Values.STRING(filename)}),_) = Ceval.ceval(cache,env,
810811
Exp.CREF(Exp.CREF_IDENT("currentSimulationResult",Exp.OTHER(),{}),Exp.OTHER()), true, SOME(st), NONE, msg);
811-
failure(_ = System.readPtolemyplotDataset(filename, vars_2, 0));
812+
failure(_ = SimulationResults.readPtolemyplotDataset(filename, vars_2, 0));
812813
then
813814
(cache,Values.STRING("Error reading the simulation result."),st);
814815

@@ -875,10 +876,10 @@ algorithm
875876
// vars_2 =
876877

877878

878-
// value = System.readPtolemyplotDataset(filename2, vars_2, 0);
879+
// value = SimulationResults.readPtolemyplotDataset(filename2, vars_2, 0);
879880

880881

881-
// failure(_ = System.readPtolemyplotDataset(filename2, vars_2, 0));
882+
// failure(_ = SimulationResults.readPtolemyplotDataset(filename2, vars_2, 0));
882883

883884
then
884885
(cache,Values.STRING("Error reading the simulation result."),st);
@@ -920,7 +921,7 @@ algorithm
920921
// vars_2 =
921922

922923

923-
value = System.readPtolemyplotDataset(filename2, vars_2, 0);
924+
value = SimulationResults.readPtolemyplotDataset(filename2, vars_2, 0);
924925

925926
res = Values.sendPtolemyplotDataset(value, vars_2, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, Exp.printExpStr(xRange), Exp.printExpStr(yRange));
926927

@@ -953,7 +954,7 @@ algorithm
953954
failure(_ = System.getVariableNames(filename));
954955
// vars_2 = Util.stringSplitAtChar(str, " ");
955956

956-
// failure(_ = System.readPtolemyplotDataset(filename, vars_2, 0));
957+
// failure(_ = SimulationResults.readPtolemyplotDataset(filename, vars_2, 0));
957958

958959
then
959960
(cache,Values.STRING("Error reading the simulation result."),st);
@@ -982,7 +983,7 @@ algorithm
982983
Exp.CREF(Exp.CREF_IDENT("currentSimulationResult",Exp.OTHER(),{}),Exp.OTHER()), true, SOME(st), NONE, msg);
983984
str = System.getVariableNames(filename);
984985
vars_2 = Util.stringSplitAtChar(str, " ");
985-
value = System.readPtolemyplotDataset(filename, vars_2, 0);
986+
value = SimulationResults.readPtolemyplotDataset(filename, vars_2, 0);
986987

987988
res = Values.sendPtolemyplotDataset(value, vars_2, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, Exp.printExpStr(xRange), Exp.printExpStr(yRange));
988989

@@ -1018,7 +1019,7 @@ algorithm
10181019
filename = Absyn.pathString(className);
10191020
filename = Util.stringAppendList({filename, "_res.plt"});
10201021

1021-
value = System.readPtolemyplotDataset(filename, vars_2, 0);
1022+
value = SimulationResults.readPtolemyplotDataset(filename, vars_2, 0);
10221023

10231024
res = Values.sendPtolemyplotDataset(value, vars_2, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, Exp.printExpStr(xRange), Exp.printExpStr(yRange));
10241025

@@ -1052,7 +1053,7 @@ algorithm
10521053
filename = Absyn.pathString(className);
10531054
filename = Util.stringAppendList({filename, "_res.plt"});
10541055

1055-
failure(_ = System.readPtolemyplotDataset(filename, vars_2, 0));
1056+
failure(_ = SimulationResults.readPtolemyplotDataset(filename, vars_2, 0));
10561057

10571058
then
10581059
(cache,Values.STRING("Error reading the simulation result."),st);
@@ -1080,7 +1081,7 @@ algorithm
10801081
vars_2 = Util.listUnionElt("time", vars_1);
10811082
(cache,Values.RECORD(orderd={Values.STRING(filename)}),_) = Ceval.ceval(cache,env,
10821083
Exp.CREF(Exp.CREF_IDENT("currentSimulationResult",Exp.OTHER(),{}),Exp.OTHER()), true, SOME(st), NONE, msg);
1083-
value = System.readPtolemyplotDataset(filename, vars_2, 0);
1084+
value = SimulationResults.readPtolemyplotDataset(filename, vars_2, 0);
10841085
res = Values.sendPtolemyplotDataset(value, vars_2, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, Exp.printExpStr(xRange), Exp.printExpStr(yRange));
10851086

10861087
then
@@ -1110,7 +1111,7 @@ algorithm
11101111
vars_2 = Util.listUnionElt("time", vars_1);
11111112
(cache,Values.RECORD(orderd={Values.STRING(filename)}),_) = Ceval.ceval(cache,env,
11121113
Exp.CREF(Exp.CREF_IDENT("currentSimulationResult",Exp.OTHER(),{}),Exp.OTHER()), true, SOME(st), NONE, msg);
1113-
failure(_ = System.readPtolemyplotDataset(filename, vars_2, 0));
1114+
failure(_ = SimulationResults.readPtolemyplotDataset(filename, vars_2, 0));
11141115
then
11151116
(cache,Values.STRING("Error reading the simulation result."),st);
11161117

@@ -1197,11 +1198,11 @@ algorithm
11971198
filename = Util.stringAppendList({filename, "_res.plt"});
11981199
//print("filename: ");
11991200
//print(filename);
1200-
vars = System.readPtolemyplotVariables(filename, visvar_str);
1201+
vars = SimulationResults.readPtolemyplotVariables(filename, visvar_str);
12011202
vars_2 = Util.listUnionElt("time", vars);
12021203
//print(Util.stringAppendList(vars_2));
12031204
//print(Util.stringDelimitList(vars_2, ", "));
1204-
value = System.readPtolemyplotDataset(filename, vars_2, 0);
1205+
value = SimulationResults.readPtolemyplotDataset(filename, vars_2, 0);
12051206
res = Values.sendPtolemyplotDataset2(value, vars_2, visvar_str, "Plot by OpenModelica");
12061207

12071208
then
@@ -1230,9 +1231,9 @@ algorithm
12301231
//vars_2 = Util.listUnionElt("time", vars_1);
12311232
filename = Absyn.pathString(className);
12321233
filename = Util.stringAppendList({filename, "_res.plt"});
1233-
vars = System.readPtolemyplotVariables(filename);
1234+
vars = SimulationResults.readPtolemyplotVariables(filename);
12341235
1235-
failure(_ = System.readPtolemyplotDataset(filename, vars, 0));
1236+
failure(_ = SimulationResults.readPtolemyplotDataset(filename, vars, 0));
12361237
12371238
then
12381239
(cache,Values.STRING("Error reading the simulation result."),st);*/
@@ -1263,7 +1264,7 @@ algorithm
12631264
(cache,Values.RECORD(orderd={Values.STRING(filename)}),_) = Ceval.ceval(cache,env,
12641265
Exp.CREF(Exp.CREF_IDENT("currentSimulationResult",Exp.OTHER(),{}),Exp.OTHER()), true, SOME(st), NONE, msg);
12651266
print("tjo\n");
1266-
value = System.readPtolemyplotDataset(filename, vars_2, 0);
1267+
value = SimulationResults.readPtolemyplotDataset(filename, vars_2, 0);
12671268
print("value = " +& Values.valString(value));
12681269
res = Values.sendPtolemyplotDataset(value, vars_2, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, title, title);
12691270

@@ -1293,7 +1294,7 @@ algorithm
12931294
vars_2 = Util.listUnionElt("time", vars_1);
12941295
(cache,Values.RECORD(orderd={Values.STRING(filename)}),_) = Ceval.ceval(cache,env,
12951296
Exp.CREF(Exp.CREF_IDENT("currentSimulationResult",Exp.OTHER(),{}),Exp.OTHER()), true, SOME(st), NONE, msg);
1296-
failure(_ = System.readPtolemyplotDataset(filename, vars_2, 0));
1297+
failure(_ = SimulationResults.readPtolemyplotDataset(filename, vars_2, 0));
12971298
then
12981299
(cache,Values.STRING("Error reading the simulation result."),st);
12991300

@@ -1371,8 +1372,8 @@ algorithm
13711372
(cache,Values.RECORD(orderd={Values.STRING(filename)}),_) = Ceval.ceval(cache,env,
13721373
Exp.CREF(Exp.CREF_IDENT("currentSimulationResult",Exp.OTHER(),{}),Exp.OTHER()), true, SOME(st), NONE, msg);
13731374
1374-
Values.ARRAY({Values.ARRAY(varValues)}) = System.readPtolemyplotDataset(filename, vars_1, 0);
1375-
Values.ARRAY({Values.ARRAY(timeValues)}) = System.readPtolemyplotDataset(filename, {"time"}, 0);
1375+
Values.ARRAY({Values.ARRAY(varValues)}) = SimulationResults.readPtolemyplotDataset(filename, vars_1, 0);
1376+
Values.ARRAY({Values.ARRAY(timeValues)}) = SimulationResults.readPtolemyplotDataset(filename, {"time"}, 0);
13761377
13771378
13781379
tV = Values.valueReals(timeValues);
@@ -1408,8 +1409,8 @@ algorithm
14081409
(cache,Values.RECORD(orderd={Values.STRING(filename)}),_) = Ceval.ceval(cache,env,
14091410
Exp.CREF(Exp.CREF_IDENT("currentSimulationResult",Exp.OTHER(),{}),Exp.OTHER()), true, SOME(st), NONE, msg);
14101411
1411-
Values.ARRAY({Values.ARRAY(varValues)}) = System.readPtolemyplotDataset(filename, vars_1, 0);
1412-
Values.ARRAY({Values.ARRAY(timeValues)}) = System.readPtolemyplotDataset(filename, {"time"}, 0);
1412+
Values.ARRAY({Values.ARRAY(varValues)}) = SimulationResults.readPtolemyplotDataset(filename, vars_1, 0);
1413+
Values.ARRAY({Values.ARRAY(timeValues)}) = SimulationResults.readPtolemyplotDataset(filename, {"time"}, 0);
14131414
14141415
14151416
tV = Values.valueReals(timeValues);
@@ -1522,7 +1523,7 @@ algorithm
15221523
(length > 1) = true;
15231524
(cache,Values.RECORD(orderd={Values.STRING(filename)}),_) = Ceval.ceval(cache,env,
15241525
Exp.CREF(Exp.CREF_IDENT("currentSimulationResult",Exp.OTHER(),{}),Exp.OTHER()), true, SOME(st), NONE, msg);
1525-
value = System.readPtolemyplotDataset(filename, vars_1, 0);
1526+
value = SimulationResults.readPtolemyplotDataset(filename, vars_1, 0);
15261527
pwd = System.pwd();
15271528
cit = winCitation();
15281529
omhome = Settings.getInstallationDirectoryPath();
@@ -1565,7 +1566,7 @@ algorithm
15651566
vars_1 = Util.listMap(vars, Exp.printExpStr) "Catch error reading simulation file." ;
15661567
(cache,Values.RECORD(orderd={Values.STRING(filename)}),_) = Ceval.ceval(cache,env,
15671568
Exp.CREF(Exp.CREF_IDENT("currentSimulationResult",Exp.OTHER(),{}),Exp.OTHER()), true, SOME(st), NONE, msg) "Util.list_union_elt(\"time\",vars\') => vars\'\' &" ;
1568-
failure(_ = System.readPtolemyplotDataset(filename, vars_1, 0));
1569+
failure(_ = SimulationResults.readPtolemyplotDataset(filename, vars_1, 0));
15691570
then
15701571
(cache,Values.STRING("Error reading the simulation result."),st);
15711572

@@ -1621,7 +1622,7 @@ algorithm
16211622
filename = Absyn.pathString(className);
16221623
filename = Util.stringAppendList({filename, "_res.plt"});
16231624

1624-
value = System.readPtolemyplotDataset(filename, vars_1, 0);
1625+
value = SimulationResults.readPtolemyplotDataset(filename, vars_1, 0);
16251626
pwd = System.pwd();
16261627
cit = winCitation();
16271628
omhome = Settings.getInstallationDirectoryPath();
@@ -1659,7 +1660,7 @@ algorithm
16591660
(length > 1) = true;
16601661
(cache,Values.RECORD(orderd={Values.STRING(filename)}),_) = Ceval.ceval(cache,env,
16611662
Exp.CREF(Exp.CREF_IDENT("currentSimulationResult",Exp.OTHER(),{}),Exp.OTHER()), true, SOME(st), NONE, msg);
1662-
value = System.readPtolemyplotDataset(filename, vars_1, 0);
1663+
value = SimulationResults.readPtolemyplotDataset(filename, vars_1, 0);
16631664
res = Values.sendPtolemyplotDataset(value, vars_1, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, Exp.printExpStr(xRange), Exp.printExpStr(yRange));
16641665

16651666
then
@@ -1709,7 +1710,7 @@ algorithm
17091710
vars_1 = Util.listMap(vars, Exp.printExpStr) "Catch error reading simulation file." ;
17101711
(cache,Values.RECORD(orderd={Values.STRING(filename)}),_) = Ceval.ceval(cache,env,
17111712
Exp.CREF(Exp.CREF_IDENT("currentSimulationResult",Exp.OTHER(),{}),Exp.OTHER()), true, SOME(st), NONE, msg) "Util.list_union_elt(\"time\",vars\') => vars\'\' &" ;
1712-
failure(_ = System.readPtolemyplotDataset(filename, vars_1, 0));
1713+
failure(_ = SimulationResults.readPtolemyplotDataset(filename, vars_1, 0));
17131714
then
17141715
(cache,Values.STRING("Error reading the simulation result."),st);
17151716

@@ -2194,8 +2195,8 @@ algorithm
21942195
(cache,Values.RECORD(orderd={Values.STRING(filename)}),_) = Ceval.ceval(cache,env,
21952196
Exp.CREF(Exp.CREF_IDENT("currentSimulationResult",Exp.OTHER(),{}),Exp.OTHER()), true, SOME(st), NONE, Ceval.NO_MSG());
21962197

2197-
Values.ARRAY({Values.ARRAY(varValues)}) = System.readPtolemyplotDataset(filename, {varName}, 0);
2198-
Values.ARRAY({Values.ARRAY(timeValues)}) = System.readPtolemyplotDataset(filename, {"time"}, 0);
2198+
Values.ARRAY({Values.ARRAY(varValues)}) = SimulationResults.readPtolemyplotDataset(filename, {varName}, 0);
2199+
Values.ARRAY({Values.ARRAY(timeValues)}) = SimulationResults.readPtolemyplotDataset(filename, {"time"}, 0);
21992200

22002201
tV = Values.valueReals(timeValues);
22012202
vV = Values.valueReals(varValues);

Compiler/Makefile.common

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ RTOBJ = $(srcdir)/runtime/systemimpl.o $(srcdir)/runtime/dynload.o \
2424
$(srcdir)/runtime/daeext.o $(CORBAOBJ) \
2525
$(srcdir)/modpar/libmodpar.a $(srcdir)/runtime/settingsimpl.o \
2626
$(srcdir)/runtime/optmanager.o $(srcdir)/runtime/unitparser.o \
27-
$(srcdir)/runtime/unitparserext.o
27+
$(srcdir)/runtime/unitparserext.o $(srcdir)/runtime/SimulationResults.o
2828

2929
# The MO sources
3030
SRCMO= Absyn.mo \
@@ -90,7 +90,8 @@ SRCMO= Absyn.mo \
9090

9191
# These are externally defined MO modules
9292
ALLMO = $(SRCMO) DAEEXT.mo DynLoad.mo Print.mo RTOpts.mo System.mo Parser.mo \
93-
TaskGraphExt.mo Corba.mo Socket.mo ErrorExt.mo Settings.mo OptManager.mo UnitParserExt.mo
93+
TaskGraphExt.mo Corba.mo Socket.mo ErrorExt.mo Settings.mo \
94+
OptManager.mo UnitParserExt.mo SimulationResults.mo
9495

9596
SRCC= $(SRCMO:.mo=.c)
9697
SRCH= $(SRCMO:.mo=.h)

Compiler/SimulationResults.mo

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* This file is part of OpenModelica.
3+
*
4+
* Copyright (c) 1998-2008, Linköpings University,
5+
* Department of Computer and Information Science,
6+
* SE-58183 Linköping, Sweden.
7+
*
8+
* All rights reserved.
9+
*
10+
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THIS OSMC PUBLIC
11+
* LICENSE (OSMC-PL). ANY USE, REPRODUCTION OR DISTRIBUTION OF
12+
* THIS PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THE OSMC
13+
* PUBLIC LICENSE.
14+
*
15+
* The OpenModelica software and the Open Source Modelica
16+
* Consortium (OSMC) Public License (OSMC-PL) are obtained
17+
* from Linköpings University, either from the above address,
18+
* from the URL: http://www.ida.liu.se/projects/OpenModelica
19+
* and in the OpenModelica distribution.
20+
*
21+
* This program is distributed WITHOUT ANY WARRANTY; without
22+
* even the implied warranty of MERCHANTABILITY or FITNESS
23+
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
24+
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS
25+
* OF OSMC-PL.
26+
*
27+
* See the full OSMC Public License conditions for more details.
28+
*
29+
*/
30+
31+
package SimulationResults
32+
" file: SimulationResults.mo
33+
package: SimulationResults
34+
description: Read simulation results into the Values.Value structure.
35+
36+
RCS: $Id: System.mo 4473 2009-11-09 16:21:24Z sjoelund.se $
37+
38+
"
39+
40+
public import Values;
41+
42+
public function readPtolemyplotVariables
43+
input String inString;
44+
input String inVisVars;
45+
output list<String> outStringLst;
46+
47+
external "C" ;
48+
end readPtolemyplotVariables;
49+
50+
public function readPtolemyplotDataset
51+
input String inString;
52+
input list<String> inStringLst;
53+
input Integer inInteger;
54+
output Values.Value outValue;
55+
56+
external "C" ;
57+
end readPtolemyplotDataset;
58+
59+
public function readPtolemyplotDatasetSize
60+
input String inString;
61+
output Values.Value outValue;
62+
63+
external "C" ;
64+
end readPtolemyplotDatasetSize;
65+
66+
end SimulationResults;
67+

Compiler/System.mo

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ package System
3838
This module contain a set of system calls, for e.g. compiling and
3939
executing stuff, reading and writing files and so on."
4040

41-
public import Values;
42-
4341
public function removeFirstAndLastChar
4442
input String inString;
4543
output String outString;
@@ -251,14 +249,6 @@ public function sendData2
251249
external "C" ;
252250
end sendData2;
253251

254-
public function readPtolemyplotVariables
255-
input String inString;
256-
input String inVisVars;
257-
output list<String> outStringLst;
258-
259-
external "C" ;
260-
end readPtolemyplotVariables;
261-
262252
public function writeFile
263253
input String inString1;
264254
input String inString2;
@@ -273,29 +263,13 @@ public function readFile
273263
external "C" ;
274264
end readFile;
275265

276-
public function readPtolemyplotDataset
277-
input String inString;
278-
input list<String> inStringLst;
279-
input Integer inInteger;
280-
output Values.Value outValue;
281-
282-
external "C" ;
283-
end readPtolemyplotDataset;
284-
285266
public function getVariableNames
286267
input String modelname;
287268
output String variables;
288269

289270
external "C";
290271
end getVariableNames;
291272

292-
public function readPtolemyplotDatasetSize
293-
input String inString;
294-
output Values.Value outValue;
295-
296-
external "C" ;
297-
end readPtolemyplotDatasetSize;
298-
299273
public function systemCall
300274
input String inString;
301275
output Integer outInteger;

Compiler/runtime/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ CC = gcc
3232
IDL = @IDLCMD@
3333
CFLAGS += -O3 -I$(RMLINCLUDE) -I$(top_builddir)/c_runtime -I$(top_builddir)/c_runtime/superlu/include -I$(srcdir) -I. $(CORBAINCL) -I../ -Ilpsolve
3434
CXXFLAGS = $(CFLAGS)
35-
SRC = rtopts.c socketimpl.c printimpl.c systemimpl.c settingsimpl.c dynload.c
35+
SRC = rtopts.c socketimpl.c printimpl.c systemimpl.c settingsimpl.c dynload.c SimulationResults.c
3636

3737
CPPSRC = unitparser.cpp unitparserext.cpp ptolemyio.cpp daeext.cpp ErrorMessage.cpp errorext.cpp optmanager.cpp $(CORBASRC)
3838
OBJ = $(SRC:.c=.o) $(CPPSRC:.cpp=.o) $(CPPSRC:.cc=.o)

0 commit comments

Comments
 (0)