#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);
}
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;
</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>
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__':