Skip to content

Commit 6ed45ec

Browse files
authored
check for root System when exporting and importing resources/signalFilter.xml (#1337)
1 parent 8f77bab commit 6ed45ec

5 files changed

Lines changed: 71 additions & 3 deletions

File tree

src/OMSimulatorLib/Model.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,9 @@ oms_status_enu_t oms::Model::exportToSSD(Snapshot& snapshot) const
849849
oms_simulation_information.append_attribute("resultFile") = resultFilename.c_str();
850850
oms_simulation_information.append_attribute("loggingInterval") = std::to_string(loggingInterval).c_str();
851851
oms_simulation_information.append_attribute("bufferSize") = std::to_string(bufferSize).c_str();
852-
oms_simulation_information.append_attribute("signalFilter") = signalFilterFilename.c_str();
852+
// check for root system exist and export signalFilter
853+
if (system)
854+
oms_simulation_information.append_attribute("signalFilter") = signalFilterFilename.c_str();
853855

854856
return oms_status_ok;
855857
}
@@ -1576,6 +1578,10 @@ std::string oms::Model::escapeSpecialCharacters(const std::string& regex)
15761578

15771579
oms_status_enu_t oms::Model::importSignalFilter(const std::string& filename, const Snapshot& snapshot)
15781580
{
1581+
// check for system and do not import signalFilter if system == NULL
1582+
if (!system)
1583+
return oms_status_ok;
1584+
15791585
if (".*" == filename) // avoid error messages for older ssp files
15801586
{
15811587
addSignalsToResults(".*");

testsuite/api/test01.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ printStatus(status, 3)
175175
-- <ssd:Annotations>
176176
-- <ssc:Annotation type="org.openmodelica">
177177
-- <oms:Annotations>
178-
-- <oms:SimulationInformation resultFile="test01lua_res.mat" loggingInterval="0.000000" bufferSize="10" signalFilter="resources/signalFilter.xml" />
178+
-- <oms:SimulationInformation resultFile="test01lua_res.mat" loggingInterval="0.000000" bufferSize="10" />
179179
-- </oms:Annotations>
180180
-- </ssc:Annotation>
181181
-- </ssd:Annotations>

testsuite/api/test01.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def printStatus(status, expected):
175175
## <ssd:Annotations>
176176
## <ssc:Annotation type="org.openmodelica">
177177
## <oms:Annotations>
178-
## <oms:SimulationInformation resultFile="test01py_res.mat" loggingInterval="0.000000" bufferSize="10" signalFilter="resources/signalFilter.xml" />
178+
## <oms:SimulationInformation resultFile="test01py_res.mat" loggingInterval="0.000000" bufferSize="10" />
179179
## </oms:Annotations>
180180
## </ssc:Annotation>
181181
## </ssd:Annotations>

testsuite/simulation/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ activateVariant3.lua \
77
checkUnits.lua \
88
deleteConnector.lua \
99
deleteConnector1.lua \
10+
deleteRootSystem.lua \
1011
deleteReferencesAndStartValues.lua \
1112
deleteStartValues.lua \
1213
deleteStartValuesInSSV.lua \
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
-- status: correct
2+
-- teardown_command: rm -rf deleteRootSystem/
3+
-- linux: yes
4+
-- ucrt64: yes
5+
-- win: yes
6+
-- mac: yes
7+
8+
oms_setCommandLineOption("--suppressPath=true")
9+
oms_setTempDirectory("./deleteRootSystem_lua/")
10+
oms_setWorkingDirectory("./deleteRootSystem_lua/")
11+
12+
oms_newModel("model")
13+
14+
oms_addSystem("model.Root", oms_system_wc)
15+
16+
17+
oms_addSubModel("model.Root.Gain", "../../resources/Modelica.Blocks.Math.Gain.fmu")
18+
19+
oms_delete("model.Root")
20+
21+
src = oms_exportSnapshot("model")
22+
print(src)
23+
24+
oms_importSnapshot("model", src)
25+
26+
-- Result:
27+
-- <?xml version="1.0"?>
28+
-- <oms:snapshot
29+
-- xmlns:oms="https://raw.githubusercontent.com/OpenModelica/OMSimulator/master/schema/oms.xsd"
30+
-- partial="false">
31+
-- <oms:file
32+
-- name="SystemStructure.ssd">
33+
-- <ssd:SystemStructureDescription
34+
-- xmlns:ssc="http://ssp-standard.org/SSP1/SystemStructureCommon"
35+
-- xmlns:ssd="http://ssp-standard.org/SSP1/SystemStructureDescription"
36+
-- xmlns:ssv="http://ssp-standard.org/SSP1/SystemStructureParameterValues"
37+
-- xmlns:ssm="http://ssp-standard.org/SSP1/SystemStructureParameterMapping"
38+
-- xmlns:ssb="http://ssp-standard.org/SSP1/SystemStructureSignalDictionary"
39+
-- xmlns:oms="https://raw.githubusercontent.com/OpenModelica/OMSimulator/master/schema/oms.xsd"
40+
-- name="model"
41+
-- version="1.0">
42+
-- <ssd:DefaultExperiment
43+
-- startTime="0.000000"
44+
-- stopTime="1.000000">
45+
-- <ssd:Annotations>
46+
-- <ssc:Annotation
47+
-- type="org.openmodelica">
48+
-- <oms:Annotations>
49+
-- <oms:SimulationInformation
50+
-- resultFile="model_res.mat"
51+
-- loggingInterval="0.000000"
52+
-- bufferSize="10" />
53+
-- </oms:Annotations>
54+
-- </ssc:Annotation>
55+
-- </ssd:Annotations>
56+
-- </ssd:DefaultExperiment>
57+
-- </ssd:SystemStructureDescription>
58+
-- </oms:file>
59+
-- </oms:snapshot>
60+
--
61+
-- endResult

0 commit comments

Comments
 (0)