@@ -202,16 +202,16 @@ oms::Component* oms::ComponentFMUCS::NewComponent(const oms::ComRef& cref, oms::
202202 for (auto const & v : component->allVariables )
203203 {
204204 if (v.isInput ())
205- component->inputs .push_back (v);
205+ component->inputs .push_back (v. getIndex () );
206206 else if (v.isOutput ())
207207 {
208- component->outputs .push_back (v);
208+ component->outputs .push_back (v. getIndex () );
209209 component->outputsGraph .addNode (Connector (oms_causality_output, v.getType (), v.getCref (), component->getFullCref ()));
210210 }
211211 else if (v.isParameter ())
212- component->parameters .push_back (v);
212+ component->parameters .push_back (v. getIndex () );
213213 else if (v.isCalculatedParameter ())
214- component->calculatedParameters .push_back (v);
214+ component->calculatedParameters .push_back (v. getIndex () );
215215
216216 if (v.isInitialUnknown ())
217217 component->initialUnknownsGraph .addNode (Connector (v.getCausality (), v.getType (), v.getCref (), component->getFullCref ()));
@@ -223,18 +223,18 @@ oms::Component* oms::ComponentFMUCS::NewComponent(const oms::ComRef& cref, oms::
223223 while (component->connectors .size () > 0 && NULL == component->connectors .back ())
224224 component->connectors .pop_back ();
225225
226- int i = 1 ;
226+ int j = 1 ;
227227 int size = 1 + component->inputs .size ();
228- for (const auto & v : component->inputs )
229- component->connectors .push_back (new Connector (oms_causality_input, v .getType (), v .getCref (), component->getFullCref (), i ++/(double )size));
230- i = 1 ;
228+ for (const auto & i : component->inputs )
229+ component->connectors .push_back (new Connector (oms_causality_input, component-> allVariables [i] .getType (), component-> allVariables [i] .getCref (), component->getFullCref (), j ++/(double )size));
230+ j = 1 ;
231231 size = 1 + component->outputs .size ();
232- for (const auto & v : component->outputs )
233- component->connectors .push_back (new Connector (oms_causality_output, v .getType (), v .getCref (), component->getFullCref (), i ++/(double )size));
234- for (const auto & v : component->parameters )
235- component->connectors .push_back (new Connector (oms_causality_parameter, v .getType (), v .getCref (), component->getFullCref ()));
236- for (const auto & v : component->calculatedParameters )
237- component->connectors .push_back (new Connector (oms_causality_calculatedParameter, v .getType (), v .getCref (), component->getFullCref ()));
232+ for (const auto & i : component->outputs )
233+ component->connectors .push_back (new Connector (oms_causality_output, component-> allVariables [i] .getType (), component-> allVariables [i] .getCref (), component->getFullCref (), j ++/(double )size));
234+ for (const auto & i : component->parameters )
235+ component->connectors .push_back (new Connector (oms_causality_parameter, component-> allVariables [i] .getType (), component-> allVariables [i] .getCref (), component->getFullCref ()));
236+ for (const auto & i : component->calculatedParameters )
237+ component->connectors .push_back (new Connector (oms_causality_calculatedParameter, component-> allVariables [i] .getType (), component-> allVariables [i] .getCref (), component->getFullCref ()));
238238 component->connectors .push_back (NULL );
239239 component->element .setConnectors (&component->connectors [0 ]);
240240
@@ -440,8 +440,8 @@ oms_status_enu_t oms::ComponentFMUCS::initializeDependencyGraph_initialUnknowns(
440440 for (int i=0 ; i < N; i++)
441441 {
442442 logDebug (std::string (getCref ()) + " : " + getPath () + " initial unknown " + std::string (initialUnknownsGraph.getNodes ()[i]) + " depends on all inputs" );
443- for (int j= 0 ; j < inputs. size (); j++ )
444- initialUnknownsGraph.addEdge (inputs [j].makeConnector (this ->getFullCref ()), initialUnknownsGraph.getNodes ()[i]);
443+ for (const auto & j : inputs)
444+ initialUnknownsGraph.addEdge (allVariables [j].makeConnector (this ->getFullCref ()), initialUnknownsGraph.getNodes ()[i]);
445445 }
446446 return oms_status_ok;
447447 }
@@ -484,8 +484,8 @@ oms_status_enu_t oms::ComponentFMUCS::initializeDependencyGraph_initialUnknowns(
484484 else if ((startIndex[i] + 1 == startIndex[i+1 ]) && (dependency[startIndex[i]] == 0 ))
485485 {
486486 logDebug (std::string (getCref ()) + " : " + getPath () + " initial unknown " + std::string (initialUnknownsGraph.getNodes ()[i]) + " depends on all inputs" );
487- for (int j = 0 ; j < inputs. size (); j++ )
488- initialUnknownsGraph.addEdge (inputs [j].makeConnector (this ->getFullCref ()), initialUnknownsGraph.getNodes ()[i]);
487+ for (const auto & j : inputs)
488+ initialUnknownsGraph.addEdge (allVariables [j].makeConnector (this ->getFullCref ()), initialUnknownsGraph.getNodes ()[i]);
489489 }
490490 else
491491 {
@@ -524,29 +524,30 @@ oms_status_enu_t oms::ComponentFMUCS::initializeDependencyGraph_outputs()
524524 return oms_status_ok;
525525 }
526526
527- for (int i = 0 ; i < outputs.size (); i++)
527+ for (int i= 0 ; i < outputs.size (); i++)
528528 {
529+ Variable& output = allVariables[outputs[i]];
529530 if (startIndex[i] == startIndex[i + 1 ])
530531 {
531- logDebug (std::string (getCref ()) + " : " + getPath () + " output " + std::string (outputs[i] ) + " has no dependencies" );
532+ logDebug (std::string (getCref ()) + " : " + getPath () + " output " + std::string (output ) + " has no dependencies" );
532533 }
533534 else if ((startIndex[i] + 1 == startIndex[i + 1 ]) && (dependency[startIndex[i]] == 0 ))
534535 {
535- logDebug (std::string (getCref ()) + " : " + getPath () + " output " + std::string (outputs[i] ) + " depends on all" );
536- for (int j = 0 ; j < inputs. size (); j++ )
537- outputsGraph.addEdge (inputs [j].makeConnector (this ->getFullCref ()), outputs[i] .makeConnector (this ->getFullCref ()));
536+ logDebug (std::string (getCref ()) + " : " + getPath () + " output " + std::string (output ) + " depends on all" );
537+ for (const auto & j : inputs)
538+ outputsGraph.addEdge (allVariables [j].makeConnector (this ->getFullCref ()), output .makeConnector (this ->getFullCref ()));
538539 }
539540 else
540541 {
541542 for (size_t j = startIndex[i]; j < startIndex[i + 1 ]; j++)
542543 {
543544 if (dependency[j] < 1 || dependency[j] > allVariables.size ())
544545 {
545- logWarning (" Output " + std::string (outputs[i] ) + " has bad dependency on variable with index " + std::to_string (dependency[j]) + " which couldn't be resolved" );
546+ logWarning (" Output " + std::string (output ) + " has bad dependency on variable with index " + std::to_string (dependency[j]) + " which couldn't be resolved" );
546547 return logError (std::string (getCref ()) + " : erroneous dependencies detected in modelDescription.xml" );
547548 }
548- logDebug (std::string (getCref ()) + " : " + getPath () + " output " + std::string (outputs[i] ) + " depends on " + std::string (allVariables[dependency[j] - 1 ]));
549- outputsGraph.addEdge (allVariables[dependency[j] - 1 ].makeConnector (this ->getFullCref ()), outputs[i] .makeConnector (this ->getFullCref ()));
549+ logDebug (std::string (getCref ()) + " : " + getPath () + " output " + std::string (output ) + " depends on " + std::string (allVariables[dependency[j] - 1 ]));
550+ outputsGraph.addEdge (allVariables[dependency[j] - 1 ].makeConnector (this ->getFullCref ()), output .makeConnector (this ->getFullCref ()));
550551 }
551552 }
552553 }
0 commit comments