Proc::savestate is now deprecated.
You have to use VisitorSalomeSaveState (c++) or SALOMERuntime.schemaSaveState (python).
virtual void setEdition(bool edition);
virtual void modified();
virtual void saveSchema(const std::string& xmlSchemaFile);
+ //! deprecated. See VisitorSalomeSaveState and schemaSaveState in order
+ //! to deal with the execution state of ForEachLoop.
virtual void saveState(const std::string& xmlStateFile);
protected:
void removeContainers();
_out << " </node>" << std::endl;
}
-
-SchemaSaveState::SchemaSaveState(Proc* proc, Executor* exec)
-: _p(proc),
- _exec(exec)
-{
- YASSERT(_p);
- YASSERT(_exec);
-}
-
-SchemaSaveState::~SchemaSaveState()
-{
-}
-
-void SchemaSaveState::save(std::string xmlSchemaFile)
+void YACS::ENGINE::schemaSaveState(Proc* proc,
+ Executor* exec,
+ const std::string& xmlSchemaFile)
{
- YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&(_exec->getTheMutexForSchedulerUpdate()));
- VisitorSalomeSaveState vss(_p);
+ YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&(exec->getTheMutexForSchedulerUpdate()));
+ VisitorSalomeSaveState vss(proc);
vss.openFileDump(xmlSchemaFile);
- _p->accept(&vss);
+ proc->accept(&vss);
vss.closeFileDump();
}
virtual void visitForEachLoop(ForEachLoop *node);
};
- class YACSLIBENGINE_EXPORT SchemaSaveState
- {
- public:
- SchemaSaveState(Proc* proc, Executor* exec);
- virtual ~SchemaSaveState();
- virtual void save(std::string xmlSchemaFile);
- private:
- Proc* _p;
- Executor* _exec;
- };
+ YACSLIBENGINE_EXPORT void schemaSaveState(Proc* proc,
+ Executor* exec,
+ const std::string& xmlSchemaFile);
}
}
#endif // VISITORSALOMESAVESTATE_HXX
{
namespace ENGINE
{
- class SchemaSaveState
- {
- public:
- SchemaSaveState(Proc* proc, Executor* exec);
- virtual void save(std::string xmlSchemaFile);
- };
+ void schemaSaveState(Proc* proc,
+ Executor* exec,
+ const std::string& xmlSchemaFile);
}
}
myRun.start()
import time
time.sleep(5)
- p.saveState(xmlStateFileName)
+ SALOMERuntime.schemaSaveState(p, ex, xmlStateFileName)
a,b,c=n1.getPassedResults(ex)
myRun.join()
t0=datetime.now()-startt
pass
pass
+ def test22(self):
+ """Restart from a saved state in a foreach loop without using assignPassedResults.
+ This test uses the files test21.xml and saveState21.xml produced by test21.
+ """
+ fname="test21.xml"
+ xmlStateFileName="saveState21.xml"
+
+ ex=pilot.ExecutorSwig()
+ l=loader.YACSLoader()
+ q=l.load(fname)
+ q.getChildByName("n0").setScript("o0=[ 3*elt for elt in range(6) ]")
+ q.getChildByName("n1").getChildByName("n10").setScript("""
+import time
+time.sleep(0.1)
+print "execution n10:", i1
+o2=5*i1
+""")
+ q.getChildByName("n2").setScript("""
+print "execution n2:", i3
+o4=i3
+""")
+ loader.loadState(q, xmlStateFileName)
+ q.resetState(1)
+ q.exUpdateState()
+ #
+ ex.RunW(q,0,False)
+ #
+ self.assertEqual(q.getChildByName("n1").getState(),pilot.DONE)
+ self.assertEqual(q.getState(),pilot.DONE)
+ self.assertEqual(q.getChildByName("n2").getOutputPort("o4").getPyObj(),[0L,2L,10L,15L,20L,25L])
+ pass
+ pass
+
if __name__ == '__main__':
import os,sys
U = os.getenv('USER')