Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 295a040

Browse files
rfrankeOpenModelica-Hudson
authored andcommitted
Read all values from init.xml, ticket:4089
1 parent c58bee3 commit 295a040

File tree

1 file changed

+36
-43
lines changed

1 file changed

+36
-43
lines changed

SimulationRuntime/cpp/Core/DataExchange/XmlPropertyReader.cpp

Lines changed: 36 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,6 @@ void XmlPropertyReader::readInitialValues(IContinuous& system, shared_ptr<ISimVa
5959
if (descriptonOpt)
6060
descripton = *descriptonOpt;
6161

62-
if (_globalSettings->getEmitResults() != EMIT_ALL)
63-
{
64-
if (name.substr(0, 3) == "_D_")
65-
continue;
66-
std::string hideResultInfo = vars.second.get<std::string>("<xmlattr>.hideResult");
67-
if (hideResultInfo.compare("true") == 0)
68-
// Note: we don't need values of hidden variables because the code calculates them
69-
continue;
70-
}
71-
7262
refIdx = *refIdxOpt;
7363
std::string aliasInfo = vars.second.get<std::string>("<xmlattr>.alias");
7464
std::string variabilityInfo = vars.second.get<std::string>("<xmlattr>.variability");
@@ -77,6 +67,18 @@ void XmlPropertyReader::readInitialValues(IContinuous& system, shared_ptr<ISimVa
7767
bool isAlias = aliasInfo.compare("alias") == 0;
7868
bool isNegatedAlias = aliasInfo.compare("negatedAlias") == 0;
7969

70+
bool emitResult = true;
71+
if (_globalSettings->getEmitResults() == EMIT_NONE)
72+
emitResult = false;
73+
else if (_globalSettings->getEmitResults() != EMIT_ALL)
74+
{
75+
if (name.substr(0, 3) == "_D_")
76+
emitResult = false;
77+
std::string hideResultInfo = vars.second.get<std::string>("<xmlattr>.hideResult");
78+
if (hideResultInfo.compare("true") == 0)
79+
emitResult = false;
80+
}
81+
8082
FOREACH(ptree::value_type const& var, vars.second.get_child(""))
8183
{
8284
if (var.first == "Real")
@@ -91,10 +93,13 @@ void XmlPropertyReader::readInitialValues(IContinuous& system, shared_ptr<ISimVa
9193
}
9294
const double& realVar = sim_vars->getRealVar(refIdx);
9395
const double* realVarPtr = &realVar;
94-
if (isParameter)
95-
_realVars.addParameter(name,descripton,realVarPtr);
96-
else
97-
_realVars.addOutputVar(name,descripton,realVarPtr,isNegatedAlias);
96+
if (emitResult)
97+
{
98+
if (isParameter)
99+
_realVars.addParameter(name, descripton, realVarPtr);
100+
else
101+
_realVars.addOutputVar(name, descripton, realVarPtr, isNegatedAlias);
102+
}
98103
}
99104
else if (var.first == "Integer")
100105
{
@@ -108,10 +113,13 @@ void XmlPropertyReader::readInitialValues(IContinuous& system, shared_ptr<ISimVa
108113
}
109114
const int& intVar = sim_vars->getIntVar(refIdx);
110115
const int* intVarPtr = &intVar;
111-
if (isParameter)
112-
_intVars.addParameter(name,descripton,intVarPtr);
113-
else
114-
_intVars.addOutputVar(name,descripton,intVarPtr,isNegatedAlias);
116+
if (emitResult)
117+
{
118+
if (isParameter)
119+
_intVars.addParameter(name, descripton, intVarPtr);
120+
else
121+
_intVars.addOutputVar(name, descripton, intVarPtr, isNegatedAlias);
122+
}
115123
}
116124
else if (var.first == "Boolean")
117125
{
@@ -125,10 +133,13 @@ void XmlPropertyReader::readInitialValues(IContinuous& system, shared_ptr<ISimVa
125133
}
126134
const bool& boolVar = sim_vars->getBoolVar(refIdx);
127135
const bool* boolVarPtr = &boolVar;
128-
if (isParameter)
129-
_boolVars.addParameter(name,descripton,boolVarPtr);
130-
else
131-
_boolVars.addOutputVar(name,descripton,boolVarPtr,isNegatedAlias);
136+
if (emitResult)
137+
{
138+
if (isParameter)
139+
_boolVars.addParameter(name, descripton, boolVarPtr);
140+
else
141+
_boolVars.addOutputVar(name, descripton, boolVarPtr, isNegatedAlias);
142+
}
132143
}
133144
else if (var.first == "String")
134145
{
@@ -159,42 +170,24 @@ void XmlPropertyReader::readInitialValues(IContinuous& system, shared_ptr<ISimVa
159170

160171
const output_int_vars_t& XmlPropertyReader::getIntOutVars()
161172
{
162-
static output_int_vars_t int_none;
163173
if (_isInitialized)
164-
{
165-
if (_globalSettings->getEmitResults() == EMIT_NONE)
166-
return int_none;
167-
else
168-
return _intVars;
169-
}
174+
return _intVars;
170175
else
171176
throw ModelicaSimulationError(UTILITY, "init xml file has not been read");
172177
}
173178

174179
const output_real_vars_t& XmlPropertyReader::getRealOutVars()
175180
{
176-
static output_real_vars_t real_none;
177181
if (_isInitialized)
178-
{
179-
if (_globalSettings->getEmitResults() == EMIT_NONE)
180-
return real_none;
181-
else
182-
return _realVars;
183-
}
182+
return _realVars;
184183
else
185184
throw ModelicaSimulationError(UTILITY, "init xml file has not been read");
186185
}
187186

188187
const output_bool_vars_t& XmlPropertyReader::getBoolOutVars()
189188
{
190-
static output_bool_vars_t bool_none;
191189
if (_isInitialized)
192-
{
193-
if (_globalSettings->getEmitResults() == EMIT_NONE)
194-
return bool_none;
195-
else
196-
return _boolVars;
197-
}
190+
return _boolVars;
198191
else
199192
throw ModelicaSimulationError(UTILITY, "init xml file has not been read");
200193
}

0 commit comments

Comments
 (0)