#include "DataStreamPort.hxx"
#include "ElementaryNode.hxx"
#include "ComponentInstance.hxx"
+#include "ForEachLoop.hxx"
#include <iostream>
#include <set>
return ret;
}
+
+//! Get the progress weight for all elementary nodes
+/*!
+ * Only elementary nodes have weight. If a node is in a for each loop, his weight is modified by the size of the loop
+ *
+ */
+list<pair<int,int> > ComposedNode::getProgressWeight()
+{
+ list<pair<int,int> > ret;
+ list<Node *> setOfNode=edGetDirectDescendants();
+ int elemDone, elemTotal;
+ for(list<Node *>::const_iterator iter=setOfNode.begin();iter!=setOfNode.end();iter++)
+ {
+ if ( dynamic_cast<ForEachLoop*> (*iter) )
+ {
+ elemDone=((ForEachLoop*)(*iter))->getCurrentIndex();
+ elemTotal=((ForEachLoop*)(*iter))->getNbOfElementsToBeProcessed();
+ list<pair<int,int> > myCurrentSet=((ComposedNode*)(*iter))->getProgressWeight();
+ myCurrentSet.pop_front();
+ myCurrentSet.pop_back();
+ for(list<pair<int,int> >::iterator iter=myCurrentSet.begin();iter!=myCurrentSet.end();iter++)
+ {
+ (*iter).first=(*iter).second*elemDone;
+ (*iter).second*=elemTotal;
+ }
+ ret.insert(ret.end(),myCurrentSet.begin(),myCurrentSet.end());
+ }
+ else if ( dynamic_cast<ComposedNode*> (*iter) )
+ {
+ list<pair<int,int> > myCurrentSet=((ComposedNode*)(*iter))->getProgressWeight();
+ ret.insert(ret.end(),myCurrentSet.begin(),myCurrentSet.end());
+ }
+ else
+ {
+ if ((*iter)->getState() == YACS::DONE)
+ ret.push_back(pair<int,int>(1,1));
+ else
+ ret.push_back(pair<int,int>(0,1));
+ }
+ }
+ return ret;
+}
+
//! Get the input port name
/*!
* get the input port name used by the current node, recursively built with children names.
std::list<ElementaryNode *> getRecursiveConstituents() const;
std::list<Node *> getAllRecursiveNodes();
virtual std::list<Node *> getAllRecursiveConstituents(); // first implementation
+ std::list<std::pair<int,int> > getProgressWeight();
std::string getInPortName(const InPort *) const throw (Exception);
std::string getOutPortName(const OutPort *) const throw (Exception);
//
return progress;
}
+int Proc::getGlobalProgressPercent()
+{
+ list<pair <int,int> > weightList = getProgressWeight();
+ int weightDone = 0;
+ int weightTotal = 0;
+ int progressPercent = 0;
+ for(list<pair <int,int> >::const_iterator iter=weightList.begin();iter!=weightList.end();iter++)
+ {
+ weightDone += (*iter).first;
+ weightTotal += (*iter).second;
+ }
+ if (weightTotal > 0)
+ progressPercent = int(float(weightDone) / float(weightTotal) * 100);
+ return progressPercent;
+}
+
std::string Proc::getXMLState(int numId)
{
if(YACS::ENGINE::Node::idMap.count(numId) == 0)
YACS::StatesForNode getNodeState(int numId);
std::string getNodeProgress(int numId);
+ int getGlobalProgressPercent();
std::string getInPortValue(int nodeNumId, std::string portName);
std::string setInPortValue(std::string nodeName, std::string portName, std::string value);
std::string getOutPortValue(int nodeNumId, std::string portName);