Salome HOME
new method returning calculation progress
authorLauffenburger Thomas <thomas.lauffenburger@edf.fr>
Tue, 18 Aug 2015 07:54:42 +0000 (09:54 +0200)
committerLauffenburger Thomas <thomas.lauffenburger@edf.fr>
Tue, 18 Aug 2015 09:00:46 +0000 (11:00 +0200)
tmp commit

src/engine/ComposedNode.cxx
src/engine/ComposedNode.hxx
src/engine/Proc.cxx
src/engine/Proc.hxx

index 39fa5bef897a073f92d1940cbc14747a97944498..418f18ea836a9e46f3e8238039a8928a35a12b29 100644 (file)
@@ -28,6 +28,7 @@
 #include "DataStreamPort.hxx"
 #include "ElementaryNode.hxx"
 #include "ComponentInstance.hxx"
+#include "ForEachLoop.hxx"
 
 #include <iostream>
 #include <set>
@@ -1131,6 +1132,49 @@ list<Node *> ComposedNode::getAllRecursiveNodes()
   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.
index d3663c368f8f01113de3d8ea8f3bfc8798463203..84e4d5555520c32a56ac5c9a78ec29095ffe5260 100644 (file)
@@ -80,6 +80,7 @@ namespace YACS
       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);
       //
index 5f83fe162dc967e630e282360b65bc76ef8bdfff..4cb7429557d682721059287de61881aa0e0fe619 100644 (file)
@@ -230,6 +230,22 @@ std::string Proc::getNodeProgress(int numId)
   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)
index e4b8329a3a7ce7f525e9340e621ca1df7b13ff23..a09b026c9c4eb6c201b601562c3bc277db5f0118 100644 (file)
@@ -67,6 +67,7 @@ namespace YACS
 
       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);