Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/OpenModelica/OpenModelica…
- Loading branch information
Showing
19 changed files
with
225 additions
and
659 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// name: recordTupleReturnTest | ||
// keywords: return tuple record array | ||
// status: correct | ||
// teardown_command: rm -f *RecordTupleReturn* | ||
|
||
setCommandLineOptions("+simCodeTarget=Cpp"); | ||
|
||
loadModel(Modelica); | ||
loadString(" | ||
model RecordTupleReturn | ||
record R // record with array member | ||
Real u; | ||
Real[3] a; | ||
end R; | ||
|
||
function f // return two values, one of them a record | ||
input Real u; | ||
output Real y; | ||
output R r; | ||
algorithm | ||
y := 2*u; | ||
r.u := u; | ||
r.a := {1, 2, 3}; | ||
end f; | ||
|
||
function g // process tuple return with record in a function | ||
input Real u; | ||
output Real y; | ||
output R r; | ||
protected | ||
R r2; | ||
algorithm | ||
(y, r2) := f(u); | ||
r.u := r2.u; | ||
r.a := u*r2.a; | ||
end g; | ||
|
||
model Test // process tuple return with a record in a model | ||
input Real u = 0; // prevent presolving | ||
Real y; | ||
R r; | ||
equation | ||
(y, r) = g(u + 1); | ||
end Test; | ||
end RecordTupleReturn; | ||
"); | ||
getErrorString(); | ||
|
||
simulate(RecordTupleReturn.Test); | ||
val(y, 0); | ||
val(r.a[3], 0); | ||
getErrorString(); | ||
|
||
// Result: | ||
// true | ||
// true | ||
// true | ||
// "" | ||
// record SimulationResult | ||
// resultFile = "RecordTupleReturn.Test_res.mat", | ||
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'RecordTupleReturn.Test', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''", | ||
// messages = "" | ||
// end SimulationResult; | ||
// 2.0 | ||
// 3.0 | ||
// "" | ||
// endResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,3 +36,4 @@ getErrorString(); | |
// -3.5 | ||
// 4.0 | ||
// "" | ||
// endResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.