171{
172
173 auto elementList = m_ctrlContainer->GetControlElementsList();
174 for (auto& element : elementList) {
175 element->SetSolved(false);
176 }
177 auto connectionLineList = m_ctrlContainer->GetConnectionLineList();
178 for (auto& cLine : connectionLineList) {
179 cLine->SetSolved(false);
180 }
181
182
184
185
186 auto constantList = m_ctrlContainer->GetConstantList();
187 for (auto it = constantList.begin(), itEnd = constantList.end(); it != itEnd; ++it) {
190 constant->SetSolved();
192 child->SetValue(constant->GetValue());
193 child->SetSolved();
194 FillAllConnectedChildren(child);
195 }
196 }
197
198
199 auto mathExprList = m_ctrlContainer->GetMathExprList();
200 for (auto it = mathExprList.begin(), itEnd = mathExprList.end(); it != itEnd; ++it) {
202 if (mathExpr->GetVariables().size() == 0) {
203 m_inputToSolve[0] = 0.0;
204 m_inputToSolve[1] = m_currentTime;
205 m_inputToSolve[2] = m_switchStatus;
206 mathExpr->Solve(m_inputToSolve, m_timeStep);
207 mathExpr->SetSolved();
209 child->SetValue(mathExpr->GetOutput());
210 child->SetSolved();
211 FillAllConnectedChildren(child);
212 }
213 }
214
215
216 auto ioList = m_ctrlContainer->GetIOControlList();
217 for (auto it = ioList.begin(), itEnd = ioList.end(); it != itEnd; ++it) {
220 io->SetSolved();
223 bool inputType = true;
224 io->SetSolved();
225 switch (io->GetValue()) {
226 case IOControl::IN_TERMINAL_VOLTAGE: {
227 child->SetValue(m_terminalVoltage);
228 } break;
229 case IOControl::IN_VELOCITY: {
230 child->SetValue(m_velocity);
231 } break;
232 case IOControl::IN_ACTIVE_POWER: {
233 child->SetValue(m_activePower);
234 } break;
235 case IOControl::IN_REACTIVE_POWER: {
236 child->SetValue(m_reactivePower);
237 } break;
238 case IOControl::IN_INITIAL_TERMINAL_VOLTAGE: {
239 child->SetValue(m_initTerminalVoltage);
240 } break;
241 case IOControl::IN_INITIAL_MEC_POWER: {
242 child->SetValue(m_initMecPower);
243 } break;
244 case IOControl::IN_INITIAL_VELOCITY: {
245 child->SetValue(m_initVelocity);
246 } break;
247 case IOControl::IN_DELTA_VELOCITY: {
248 child->SetValue(m_deltaVelocity);
249 } break;
250 case IOControl::IN_DELTA_ACTIVE_POWER: {
251 child->SetValue(m_deltaPe);
252 } break;
253 case IOControl::IN_TEST: {
254 child->SetValue(io->GetTestValue());
255 } break;
256 default: {
257 inputType = false;
258 io->SetSolved(false);
259 } break;
260 }
261 if (inputType) {
262 child->SetSolved();
263 FillAllConnectedChildren(child);
264 }
265 }
266 }
267
269 while (currentLine) {
270 currentLine = SolveNextElement(currentLine);
271 if (!m_isOK) return;
272 }
273
274 bool haveUnsolvedElement = true;
275 while (haveUnsolvedElement) {
276 haveUnsolvedElement = false;
277
278 for (auto& cLine : connectionLineList) {
279 if (cLine->IsSolved()) {
280 auto parentList = cLine->GetParentList();
281 for (auto itP = parentList.begin(), itPEnd = parentList.end(); itP != itPEnd; ++itP) {
283 if (!parent->IsSolved()) {
284 haveUnsolvedElement = true;
285
286 currentLine = cLine.get();
287 while (currentLine) {
288 currentLine = SolveNextElement(currentLine);
289 if (!m_isOK) return;
290 }
291 break;
292 }
293 }
294 }
295 if (haveUnsolvedElement) break;
296 }
297 }
298
299
300 for (auto it = ioList.begin(), itEnd = ioList.end(); it != itEnd; ++it) {
303 io->SetSolved();
305 switch (io->GetValue()) {
306 case IOControl::OUT_MEC_POWER: {
307 m_mecPower = child->GetValue();
308 m_solutions.push_back(m_mecPower);
309 } break;
310 case IOControl::OUT_FIELD_VOLTAGE: {
311 m_fieldVoltage = child->GetValue();
312 m_solutions.push_back(m_fieldVoltage);
313 } break;
314 default:
315 break;
316 }
317 }
318 }
319}
A control element that provides a constant value.
A generic math expression block that can perform math and conditional operations with the inputs.