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