_out << " state=\"disabled\"";
if (!nbranch->isEmpty())
_out << " nbranch=\"" << nbranch->getIntValue() << "\"";
+ _out << " weight=\"" << node->getWeight() << "\"";
if (node->edGetSamplePort())
_out << " type=\"" << node->edGetSamplePort()->edGetType()->name() << "\"";
_out << ">" << endl;
_out << " state=\"disabled\"";
if (!nbranch->isEmpty())
_out << " nbranch=\"" << nbranch->getIntValue() << "\"";
+ _out << " weight=\"" << node->getWeight() << "\"";
_out << " lib=\"" << node->getAlgLib() << "\"";
_out << " entry=\"" << node->getSymbol() << "\"";
_out << ">" << endl;
if(std::string(attr[i]) == "name")name(attr[i+1]);
if(std::string(attr[i]) == "state")this->state(attr[i+1]);
if(std::string(attr[i]) == "nbranch")nbranch(atoi(attr[i+1]));
+ if(std::string(attr[i]) == "weight")weight(atof(attr[i+1]));
if(std::string(attr[i]) == "type")datatype(attr[i+1]);
}
postAttr();
virtual void pre ()
{
_nbranch=0;
+ _weight=1;
this->looptypeParser<T>::pre();
}
virtual void name (const std::string& name)
DEBTRACE("foreach_nbranch: " << n )
_nbranch=n;
}
+ virtual void weight (const double& x)
+ {
+ DEBTRACE("foreach_weight: " << x )
+ _weight=x;
+ }
virtual void datatype (const std::string& type)
{
DEBTRACE("foreach_datatype: "<< type)
this->_cnode=theRuntime->createForEachLoop(_name,currentProc->typeMap[_datatype]);
//set number of branches
if(_nbranch > 0)this->_cnode->edGetNbOfBranchesPort()->edInit(_nbranch);
+ this->_cnode->setWeight(_weight);
this->_cnodes.push_back(this->_cnode);
currentProc->names.push_back(_fullname + '.');
}
return b;
}
int _nbranch;
+ double _weight;
std::string _fullname;
std::string _name;
std::string _datatype;
if(std::string(attr[i]) == "name")name(attr[i+1]);
if(std::string(attr[i]) == "state")this->state(attr[i+1]);
if(std::string(attr[i]) == "nbranch")nbranch(atoi(attr[i+1]));
+ if(std::string(attr[i]) == "weight")weight(atof(attr[i+1]));
if(std::string(attr[i]) == "lib")lib(attr[i+1]);
if(std::string(attr[i]) == "entry")entry(attr[i+1]);
if(std::string(attr[i]) == "kind")kind(attr[i+1]);
virtual void pre ()
{
_nbranch=0;
+ _weight=1;
this->looptypeParser<T>::pre();
}
virtual void name (const std::string& name)
DEBTRACE("optimizer_nbranch: " << n )
_nbranch=n;
}
+ virtual void weight (const double& x)
+ {
+ DEBTRACE("foreach_weight: " << x )
+ _weight=x;
+ }
virtual void kind (const std::string& name)
{
_kind=name;
this->_cnode=theRuntime->createOptimizerLoop(_name,_lib,_entry,true,_kind, currentProc);
//set number of branches
if(_nbranch > 0)this->_cnode->edGetNbOfBranchesPort()->edInit(_nbranch);
+ this->_cnode->setWeight(_weight);
this->_cnodes.push_back(this->_cnode);
currentProc->names.push_back(_fullname + '.');
}
}
int _nbranch;
+ double _weight;
std::string _fullname;
std::string _name;
std::string _entry;
self.assertEqual(q.getState(),pilot.DONE)
self.assertEqual(q.getChildByName("n2").getOutputPort("o4").getPyObj(),[0L,2L,10L,15L,20L,25L])
pass
+
+ def test23(self):
+ """ test focused on weight attribut after a dump and reload from a xml file
+ """
+ fname="test23.xml"
+ xmlStateFileName="saveState23.xml"
+ from datetime import datetime
+ p=self.r.createProc("prTest23")
+ cont=p.createContainer("gg","Salome")
+ cont.setProperty("name","localhost")
+ cont.setProperty("hostname","localhost")
+ cont.setProperty("type","multi")
+ td=p.createType("double","double")
+ ti=p.createType("int","int")
+ tsi=p.createSequenceTc("seqint","seqint",ti)
+ tsd=p.createSequenceTc("seqdbl","seqdbl",td)
+ n0=self.r.createScriptNode("","n0")
+ o0=n0.edAddOutputPort("o0",tsi)
+ n0.setScript("o0=[ elt for elt in range(6) ]")
+ p.edAddChild(n0)
+ n1=self.r.createForEachLoop("n1",ti)
+ n1.setWeight(3)
+ n10=self.r.createScriptNode("","n10")
+ n10.setExecutionMode("remote")
+ n10.setContainer(cont)
+ n1.edAddChild(n10)
+ n10.setScript("""
+import time
+time.sleep(2)
+o2=2*i1
+""")
+ i1=n10.edAddInputPort("i1",ti)
+ o2=n10.edAddOutputPort("o2",ti)
+ p.edAddChild(n1)
+ p.edAddLink(o0,n1.edGetSeqOfSamplesPort())
+ p.edAddLink(n1.edGetSamplePort(),i1)
+ p.edAddCFLink(n0,n1)
+ n1.edGetNbOfBranchesPort().edInitPy(2)
+ n2=self.r.createScriptNode("","n2")
+ n2.setScript("o4=i3")
+ i3=n2.edAddInputPort("i3",tsi)
+ o4=n2.edAddOutputPort("o4",tsi)
+ n2.setScript("o4=i3")
+ p.edAddChild(n2)
+ p.edAddCFLink(n1,n2)
+ p.edAddLink(o2,i3)
+ p.saveSchema(fname)
+ #
+ l=loader.YACSLoader()
+ p=l.load(fname)
+ self.assertEqual(p.getChildByName("n1").getWeight(),3.0)
+ pass
+
pass
if __name__ == '__main__':