Salome HOME
Merge branch 'omu/verify_links'
authorOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Fri, 28 Aug 2015 14:20:39 +0000 (16:20 +0200)
committerOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Fri, 28 Aug 2015 14:20:39 +0000 (16:20 +0200)
src/engine/ComposedNode.cxx
src/engine/ComposedNode.hxx
src/engine/Proc.cxx
src/engine/Proc.hxx
src/runtime/TypeConversions.cxx
src/salomegui/resources/YACS_msg_fr.ts
src/yacsloader_swig/Test/testSaveLoadRun.py

index 1a4ce93caf31719887220887b1f34dbfa2a9f81d..31424ad25dfd8c0aaa9c15c82ee4877a899bb8ad 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);
index 93bac7e68b7b288f2fd5d64fb6ccea877d027bcf..9958f5473f79ff9ce4cfab0e37fe443000172b8b 100644 (file)
@@ -1306,6 +1306,17 @@ namespace YACS
                     }
                   return mystr;
                 }
+              else if ((!xmlStrcmp(cur->name, (const xmlChar *)"string")))// <- here case where pyobj value has been stored in XML. pyobj has kind==ObjRef. And the stored format is String ! EDF11027
+                {
+                  //wait a string, got a string
+                  xmlChar * s = NULL;
+                  s = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+                  if(s==0)return "";
+                  DEBTRACE( "convertToYacsString " << (const char *)s );
+                  std::string mystr=std::string((const char *)s);
+                  xmlFree(s);
+                  return mystr;
+                }
               cur = cur->next;
             }
           stringstream msg;
index a1f7bfa5bf34fc88b5d405a5a5585e8b8de02fdf..b9f7a6a7ec72a06c28185a5df12730b8adf68aa3 100644 (file)
     </message>
     <message>
         <source>New Schema</source>
-        <translation>Nouvel schéma</translation>
+        <translation>Nouveau schéma</translation>
     </message>
     <message>
         <source>Import a YACS Schema for edition</source>
index 272ce952edb31bfa5b2e90b8be3721a823dda000..ffe817d8e0c59793f8cf71107ddb13d5481bc386 100755 (executable)
@@ -1171,6 +1171,48 @@ for i in i8:
     self.assertEqual(p.getState(),pilot.DONE)
     pass
 
+  def test14(self):
+    """ Non regression EDF11027. Problem after Save/Load of a foreach node with type pyobj with input "SmplsCollection" manually set before. Correction in convertToYacsObjref from XML->Neutral. Objref can hide a string !"""
+    xmlFileName="test14.xml"
+    SALOMERuntime.RuntimeSALOME_setRuntime()
+    r=pilot.getRuntime()
+    n0=r.createProc("test23/zeRun")
+    tp=n0.createInterfaceTc("python:obj:1.0","pyobj",[])
+    tp2=n0.createSequenceTc("list[pyobj]","list[pyobj]",tp)
+    n0bis=r.createBloc("test23/main") ; n0.edAddChild(n0bis)
+    n00=r.createBloc("test23/run") ; n0bis.edAddChild(n00)
+    #
+    n000=r.createForEachLoop("test23/FE",tp) ; n00.edAddChild(n000)
+    n0000=r.createScriptNode("Salome","test23/run_internal") ; n000.edSetNode(n0000)
+    i0=n0000.edAddInputPort("i0",tp)
+    i1=n0000.edAddInputPort("i1",tp) ; i1.edInitPy(3)
+    o0=n0000.edAddOutputPort("o0",tp)
+    n0000.setScript("o0=i0+i1")
+    #
+    n00.edAddLink(n000.edGetSamplePort(),i0)
+    #
+    n000.edGetSeqOfSamplesPort().edInitPy(range(10))
+    n000.edGetNbOfBranchesPort().edInitInt(2)
+    #
+    n01=r.createScriptNode("Salome","test23/check") ; n0bis.edAddChild(n01)
+    n0bis.edAddCFLink(n00,n01)
+    i2=n01.edAddInputPort("i2",tp2)
+    o1=n01.edAddOutputPort("o1",tp2)
+    n01.setScript("o1=i2")
+    n0bis.edAddLink(o0,i2)
+    #
+    n0.saveSchema(xmlFileName)
+    #
+    l=loader.YACSLoader()
+    p=l.load(xmlFileName) # very import do not use n0 but use p instead !
+    ex=pilot.ExecutorSwig()
+    #
+    self.assertEqual(p.getState(),pilot.READY)
+    ex.RunW(p,0)
+    self.assertEqual(p.getState(),pilot.DONE)
+    self.assertEqual(p.getChildByName("test23/main.test23/check").getOutputPort("o1").getPyObj(),[3,4,5,6,7,8,9,10,11,12])
+    pass
+
   pass
 
 if __name__ == '__main__':