forked from OpenModelica/OMLibraries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MSL.3.2.2.mos
149 lines (141 loc) · 6.16 KB
/
MSL.3.2.2.mos
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
setModelicaPath("");
tmpScript:="Modelica.3.2.2.tmp.mos";
if 0<>system("patch -l -d build/ -f -p1 < 'Modelica 3.2.2.manual.patch'") or
0<>system("patch -l -d build/ -f -p1 < 'ModelicaServices 3.2.2.manual.patch'") then
exit(1);
end if;
for pack in {"Modelica","ModelicaServices"} loop
suffix := if pack=="Complex" then ".mo" else "/package.mo";
if not loadFile("build/"+pack+" 3.2.2"+suffix) then
print("Failed to load "+pack+" 3.2.2\n");
print(getErrorString());
exit(1);
end if;
end for;
getErrorString();
getSourceFile(Modelica);
getSourceFile(ModelicaServices);
echo(false);
tablesFile:=getSourceFile(Modelica.Blocks.Tables);fileStrTables:=readFile(tablesFile);print(tablesFile);
echo(true);
// Patch the damned tableAvailable hack
for str in {
"Modelica.Blocks.Tables.CombiTable1D.getTableValue",
"Modelica.Blocks.Tables.CombiTable1D.getDerTableValue",
"Modelica.Blocks.Tables.CombiTable1D.getTableValueNoDer",
"Modelica.Blocks.Tables.CombiTable1Ds.getTableValue",
"Modelica.Blocks.Tables.CombiTable1Ds.getDerTableValue",
"Modelica.Blocks.Tables.CombiTable1Ds.getTableValueNoDer",
"Modelica.Blocks.Tables.CombiTable2D.getTableValue",
"Modelica.Blocks.Tables.CombiTable2D.getDerTableValue",
"Modelica.Blocks.Tables.CombiTable2D.getTableValueNoDer"
} loop
cmd := "updateComponent(tableAvailable, Real, "+str+", annotate=__OpenModelica_UnusedVariable(true));\n";
writeFile(tmpScript, cmd);
print("Running "+cmd);
res := runScript(tmpScript);
if "true\n"<>res then
print("Failed to run script: " + cmd + "\n");
print("Got result: "+res);
exit(1);
end if;
listing := listFile(Modelica.Blocks.Tables);
fileStrTables := diffModelicaFileListings(fileStrTables, listing, OpenModelica.Scripting.DiffFormat.plain);
err := getErrorString();
if "" <> err then
print(err);
exit(1);
end if;
print(str+" success\n");
end for;
writeFile(tablesFile, fileStrTables);getErrorString();
getErrorString();
// Patch the damned tableAvailable hack
tablesFile:=getSourceFile(Modelica.Blocks.Sources);fileStrTables:=readFile(tablesFile); // print(tablesFile);
for str in {
"Modelica.Blocks.Sources.CombiTimeTable.getNextTimeEvent"
} loop
cmd := "updateComponent(tableAvailable, Real, "+str+", annotate=__OpenModelica_UnusedVariable(true));\n";
writeFile(tmpScript, cmd);
print("Running "+cmd);
res := runScript(tmpScript);
if "true\n"<>res then
print("Failed to run script: " + cmd + "\n");
print("Got result: "+res);
exit(1);
end if;
listing := listFile(Modelica.Blocks.Sources);
fileStrTables := diffModelicaFileListings(fileStrTables, listing, OpenModelica.Scripting.DiffFormat.plain);
err := getErrorString();
if "" <> err then
print(err);
exit(1);
end if;
print(str+" success\n");
end for;
writeFile(tablesFile, fileStrTables);getErrorString();
getErrorString();
echo(false);
fundamentalWaveFile := getSourceFile(Modelica.Magnetic.QuasiStatic.FundamentalWave);
fileStrFundamentalWave := readFile(fundamentalWaveFile);
addClassAnnotation(Modelica.Magnetic.QuasiStatic.FundamentalWave.Examples.BasicMachines.InductionMachines.IMC_YD, __OpenModelica_simulationFlags(nls = "newton"));
addClassAnnotation(Modelica.Magnetic.QuasiStatic.FundamentalWave.Examples.BasicMachines.InductionMachines.IMC_Transformer, __OpenModelica_simulationFlags(nls = "newton"));
listing := listFile(Modelica.Magnetic.QuasiStatic.FundamentalWave);
fileStrFundamentalWave := diffModelicaFileListings(fileStrFundamentalWave, listing, OpenModelica.Scripting.DiffFormat.plain);
writeFile(fundamentalWaveFile, fileStrFundamentalWave);getErrorString();
echo(false);mathFile:=getSourceFile(Modelica.Math);mathFileStr:=readFile(mathFile);echo(true);
getErrorString();
/*
if not addClassAnnotation(Modelica.Math.tempInterpol1, $annotation(derivative(zeroDerivative=table,zeroDerivative=icol)=tempInterpol1_der)) then
print("tempInterpol1 annotation failed\n");
exit(1);
end if;
mathFileStr := diffModelicaFileListings(mathFileStr, listFile(Modelica.Math), OpenModelica.Scripting.DiffFormat.plain);
err := getErrorString();
if "" <> err then
print(err);
exit(1);
end if;
if not addClassAnnotation(Modelica.Math.tempInterpol2, $annotation(derivative(zeroDerivative=table,zeroDerivative=icol)=tempInterpol2_der)) then
print("tempInterpol1 annotation failed\n");
exit(1);
end if;
mathFileStr := diffModelicaFileListings(mathFileStr, listFile(Modelica.Math), OpenModelica.Scripting.DiffFormat.plain);
err := getErrorString();
if "" <> err then
print(err);
exit(1);
end if;
writeFile("new.Math.mo", mathFileStr);getErrorString();
*/
echo(false);
servicesFile:=getSourceFile(ModelicaServices);
print(servicesFile);
servicesFileStr:=readFile(servicesFile);
setClassComment(ModelicaServices, "ModelicaServices (OpenModelica implementation) - Models and functions used in the Modelica Standard Library requiring a tool specific implementation");
servicesFileStr := diffModelicaFileListings(servicesFileStr, listFile(ModelicaServices), OpenModelica.Scripting.DiffFormat.plain);
setComponentModifierValue(ModelicaServices, target, $Code(="OpenModelica"));
servicesFileStr := diffModelicaFileListings(servicesFileStr, listFile(ModelicaServices), OpenModelica.Scripting.DiffFormat.plain);
setComponentModifierValue(ModelicaServices.Machine, Integer_inf, $Code(=OpenModelica.Internal.Architecture.integerMax()));
servicesFileStr := diffModelicaFileListings(servicesFileStr, listFile(ModelicaServices), OpenModelica.Scripting.DiffFormat.plain);
addClassAnnotation(ModelicaServices.ExternalReferences.loadResource, annotate=__OpenModelica_EarlyInline(true));
servicesFileStr := diffModelicaFileListings(servicesFileStr, listFile(ModelicaServices), OpenModelica.Scripting.DiffFormat.plain);
err := getErrorString();
if err<>"" then
print(err);
exit(1);
end if;
echo(true);
writeFile(servicesFile, servicesFileStr);
if 0<>system("jq '.repos[] | select(.dest == \"MSL\") | .multitarget[] | select(.options.gitbranch == \"maint/3.2.2\") | .rev' repos.json > " + tmpScript) then
exit(1);
end if;
if 0<>system("cd git/Modelica && git checkout " + readFile(tmpScript)) then
exit(1);
end if;
if
0<>system("make 'Modelica 3.2.2.patch'") or
0<>system("make 'ModelicaServices 3.2.2.patch'")
then
exit(1);
end if;