Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add new FMI config flag to filter modelDescription vars (#880)
- Loading branch information
Showing
11 changed files
with
302 additions
and
39 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
97 changes: 97 additions & 0 deletions
97
testsuite/openmodelica/fmi/ModelExchange/2.0/fmi_attributes_11.mos
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,97 @@ | ||
// name: fmi_attributes_11.mos | ||
// keywords: FMI 2.0 export | ||
// status: correct | ||
// teardown_command: rm -rf fmi_attributes_11.fmu fmi_attributes_11.log fmi_attributes_11.xml fmi_attributes_11_tmp.xml fmi_attributes_11.fmutmp/ | ||
|
||
loadString(" | ||
model fmi_attributes_11 | ||
input Real u; | ||
Real x; | ||
output Real y; | ||
Real a, b; | ||
parameter Real z=30; | ||
initial equation | ||
x = 0.0; | ||
equation | ||
a = 2.0*u; | ||
b = 0.5*a; | ||
der(x) = b+z; | ||
y = x; | ||
end fmi_attributes_11; | ||
"); getErrorString(); | ||
|
||
setCommandLineOptions("--fmiFilter=blackBox"); getErrorString(); | ||
translateModelFMU(fmi_attributes_11); getErrorString(); | ||
|
||
// unzip to console, quiet, extra quiet | ||
system("unzip -cqq fmi_attributes_11.fmu modelDescription.xml > fmi_attributes_11_tmp.xml"); getErrorString(); | ||
system("sed -n \"/<ModelVariables>/,/<\\/ModelVariables>/p\" fmi_attributes_11_tmp.xml > fmi_attributes_11.xml"); getErrorString(); | ||
readFile("fmi_attributes_11.xml"); getErrorString(); | ||
|
||
system("sed -n \"/<ModelStructure>/,/<\\/ModelStructure>/p\" fmi_attributes_11_tmp.xml > fmi_attributes_11.xml"); getErrorString(); | ||
readFile("fmi_attributes_11.xml"); getErrorString(); | ||
|
||
|
||
// Result: | ||
// true | ||
// "" | ||
// true | ||
// "" | ||
// "fmi_attributes_11.fmu" | ||
// "" | ||
// 0 | ||
// "" | ||
// 0 | ||
// "" | ||
// " <ModelVariables> | ||
// <!-- Index of variable = \"1\" --> | ||
// <ScalarVariable | ||
// name=\"_D_concealed1\" | ||
// valueReference=\"0\" | ||
// > | ||
// <Real/> | ||
// </ScalarVariable> | ||
// <!-- Index of variable = \"2\" --> | ||
// <ScalarVariable | ||
// name=\"_D_concealed2\" | ||
// valueReference=\"1\" | ||
// > | ||
// <Real derivative=\"1\"/> | ||
// </ScalarVariable> | ||
// <!-- Index of variable = \"3\" --> | ||
// <ScalarVariable | ||
// name=\"u\" | ||
// valueReference=\"4\" | ||
// causality=\"input\" | ||
// > | ||
// <Real start=\"0.0\"/> | ||
// </ScalarVariable> | ||
// <!-- Index of variable = \"4\" --> | ||
// <ScalarVariable | ||
// name=\"y\" | ||
// valueReference=\"5\" | ||
// causality=\"output\" | ||
// > | ||
// <Real/> | ||
// </ScalarVariable> | ||
// </ModelVariables> | ||
// " | ||
// "" | ||
// 0 | ||
// "" | ||
// " <ModelStructure> | ||
// <Outputs> | ||
// <Unknown index=\"4\" dependencies=\"1\" dependenciesKind=\"dependent\" /> | ||
// </Outputs> | ||
// <Derivatives> | ||
// <Unknown index=\"2\" dependencies=\"3\" dependenciesKind=\"dependent\" /> | ||
// </Derivatives> | ||
// <InitialUnknowns> | ||
// <Unknown index=\"1\" dependencies=\"\" dependenciesKind=\"\" /> | ||
// <Unknown index=\"2\" dependencies=\"3\" dependenciesKind=\"dependent\" /> | ||
// <Unknown index=\"4\" dependencies=\"\" dependenciesKind=\"\" /> | ||
// </InitialUnknowns> | ||
// </ModelStructure> | ||
// " | ||
// "" | ||
// endResult |
124 changes: 124 additions & 0 deletions
124
testsuite/openmodelica/fmi/ModelExchange/2.0/fmi_attributes_12.mos
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,124 @@ | ||
// name: fmi_attributes_12.mos | ||
// keywords: FMI 2.0 export | ||
// status: correct | ||
// teardown_command: rm -rf fmi_attributes_12.fmu fmi_attributes_12.log fmi_attributes_12.xml fmi_attributes_12_tmp.xml fmi_attributes_12.fmutmp/ | ||
|
||
loadString(" | ||
model fmi_attributes_12 | ||
input Real u; | ||
Real x; | ||
output Real y; | ||
Real a, b; | ||
parameter Real z=30; | ||
protected | ||
Real m, n; | ||
initial equation | ||
x = 0.0; | ||
equation | ||
a = 2.0*u; | ||
b = 0.5*a; | ||
der(x) = b+z; | ||
y = x; | ||
m = z; | ||
n = a; | ||
end fmi_attributes_12; | ||
"); getErrorString(); | ||
|
||
setCommandLineOptions("--fmiFilter=protected"); getErrorString(); | ||
translateModelFMU(fmi_attributes_12); getErrorString(); | ||
|
||
// unzip to console, quiet, extra quiet | ||
system("unzip -cqq fmi_attributes_12.fmu modelDescription.xml > fmi_attributes_12_tmp.xml"); getErrorString(); | ||
system("sed -n \"/<ModelVariables>/,/<\\/ModelVariables>/p\" fmi_attributes_12_tmp.xml > fmi_attributes_12.xml"); getErrorString(); | ||
readFile("fmi_attributes_12.xml"); getErrorString(); | ||
|
||
system("sed -n \"/<ModelStructure>/,/<\\/ModelStructure>/p\" fmi_attributes_12_tmp.xml > fmi_attributes_12.xml"); getErrorString(); | ||
readFile("fmi_attributes_12.xml"); getErrorString(); | ||
|
||
|
||
// Result: | ||
// true | ||
// "" | ||
// true | ||
// "" | ||
// "fmi_attributes_12.fmu" | ||
// "" | ||
// 0 | ||
// "" | ||
// 0 | ||
// "" | ||
// " <ModelVariables> | ||
// <!-- Index of variable = \"1\" --> | ||
// <ScalarVariable | ||
// name=\"x\" | ||
// valueReference=\"0\" | ||
// > | ||
// <Real/> | ||
// </ScalarVariable> | ||
// <!-- Index of variable = \"2\" --> | ||
// <ScalarVariable | ||
// name=\"der(x)\" | ||
// valueReference=\"1\" | ||
// > | ||
// <Real derivative=\"1\"/> | ||
// </ScalarVariable> | ||
// <!-- Index of variable = \"3\" --> | ||
// <ScalarVariable | ||
// name=\"a\" | ||
// valueReference=\"2\" | ||
// > | ||
// <Real/> | ||
// </ScalarVariable> | ||
// <!-- Index of variable = \"4\" --> | ||
// <ScalarVariable | ||
// name=\"b\" | ||
// valueReference=\"3\" | ||
// > | ||
// <Real/> | ||
// </ScalarVariable> | ||
// <!-- Index of variable = \"5\" --> | ||
// <ScalarVariable | ||
// name=\"u\" | ||
// valueReference=\"4\" | ||
// causality=\"input\" | ||
// > | ||
// <Real start=\"0.0\"/> | ||
// </ScalarVariable> | ||
// <!-- Index of variable = \"6\" --> | ||
// <ScalarVariable | ||
// name=\"y\" | ||
// valueReference=\"5\" | ||
// causality=\"output\" | ||
// > | ||
// <Real/> | ||
// </ScalarVariable> | ||
// <!-- Index of variable = \"7\" --> | ||
// <ScalarVariable | ||
// name=\"z\" | ||
// valueReference=\"7\" | ||
// variability=\"fixed\" | ||
// causality=\"parameter\" | ||
// > | ||
// <Real start=\"30.0\"/> | ||
// </ScalarVariable> | ||
// </ModelVariables> | ||
// " | ||
// "" | ||
// 0 | ||
// "" | ||
// " <ModelStructure> | ||
// <Outputs> | ||
// <Unknown index=\"6\" dependencies=\"1\" dependenciesKind=\"dependent\" /> | ||
// </Outputs> | ||
// <Derivatives> | ||
// <Unknown index=\"2\" dependencies=\"5\" dependenciesKind=\"dependent\" /> | ||
// </Derivatives> | ||
// <InitialUnknowns> | ||
// <Unknown index=\"1\" dependencies=\"\" dependenciesKind=\"\" /> | ||
// <Unknown index=\"2\" dependencies=\"5 7\" dependenciesKind=\"dependent dependent\" /> | ||
// <Unknown index=\"6\" dependencies=\"\" dependenciesKind=\"\" /> | ||
// </InitialUnknowns> | ||
// </ModelStructure> | ||
// " | ||
// "" | ||
// endResult |