Salome HOME
A test of foreach of foreach of foreach + debug of the swig of engine.
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 28 Jul 2014 14:34:42 +0000 (16:34 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 28 Jul 2014 14:34:42 +0000 (16:34 +0200)
src/engine/DynParaLoop.cxx
src/engine/DynParaLoop.hxx
src/yacsloader_swig/Test/CMakeLists.txt
src/yacsloader_swig/Test/StdAloneYacsLoaderTest1.py [new file with mode: 0755]

index 2371afada293f9a81f6da1b8013cc10b41a0aba0..582ca5680706d18cd57f5bfc45e6a5596fd9d3ab 100644 (file)
@@ -226,9 +226,9 @@ void DynParaLoop::edRemoveChild(Node *node) throw(YACS::Exception)
   modified();
 }
 
-bool DynParaLoop::edAddChild(Node *node) throw(YACS::Exception)
+bool DynParaLoop::edAddChild(Node *DISOWNnode) throw(YACS::Exception)
 {
-  return edSetNode(node);
+  return edSetNode(DISOWNnode);
 }
 
 std::list<Node *> DynParaLoop::edGetDirectDescendants() const
index 902d86eb38ac7f0812a524daa2b76f94732146f3..2ce21b66c89571d717c151fbcb2082a12cbd5a26 100644 (file)
@@ -87,7 +87,7 @@ namespace YACS
       //! For the moment false is returned : impovement about it coming soon.
       bool isPlacementPredictableB4Run() const;
       void edRemoveChild(Node *node) throw(Exception);
-      virtual bool edAddChild(Node *node) throw(Exception);
+      virtual bool edAddChild(Node *DISOWNnode) throw(Exception);
       std::list<Node *> edGetDirectDescendants() const;
       std::list<InputPort *> getSetOfInputPort() const;
       std::list<InputPort *> getLocalInputPorts() const;
index 70fcaba45d5ccbd9186c97a742f67a528f768106..c1d43df31ebba0882e1cf222383916b2d28fafcf 100644 (file)
@@ -25,4 +25,5 @@ IF(NOT WIN32)
   CONFIGURE_FILE(YacsLoaderTest.sh.in YacsLoaderTest.sh)
   CONFIGURE_FILE(YacsLoaderInSessionTest.sh.in YacsLoaderInSessionTest.sh)
   ADD_TEST(NAME YacsLoaderTest_swig COMMAND ${SHELL} ${CMAKE_CURRENT_BINARY_DIR}/YacsLoaderTest.sh)
+  ADD_TEST(NAME StdAloneYacsLoaderTest1 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/StdAloneYacsLoaderTest1.py)
 ENDIF() 
diff --git a/src/yacsloader_swig/Test/StdAloneYacsLoaderTest1.py b/src/yacsloader_swig/Test/StdAloneYacsLoaderTest1.py
new file mode 100755 (executable)
index 0000000..1059186
--- /dev/null
@@ -0,0 +1,94 @@
+# Copyright (C) 2006-2014  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+import pilot
+import SALOMERuntime
+import loader
+import unittest
+
+class StdAloneYacsLoaderTest1(unittest.TestCase):
+
+  def setUp(self):
+    SALOMERuntime.RuntimeSALOME_setRuntime()
+    self.r = pilot.getRuntime()
+    self.l = loader.YACSLoader()# self.l.load("foreachImbr_tmp.xml")
+    pass
+
+  def test1(self):
+    """tests imbrication od"""
+    SALOMERuntime.RuntimeSALOME_setRuntime()
+    l=loader.YACSLoader()
+    ex=pilot.ExecutorSwig()
+    p=self.r.createProc("pr")
+    td=p.createType("double","double")
+    td2=p.createSequenceTc("seqdbl","seqdbl",td)
+    td3=p.createSequenceTc("seqdblvec","seqdblvec",td2)
+    td4=p.createSequenceTc("seqseqdblvec","seqseqdblvec",td3)
+    node1=self.r.createScriptNode("","node1")
+    node1.setScript("o1=[([1,1],[2,2,2]),([10],[11,11],[12,12,12]),([20],[21,21],[22,22,22],[23,23,23,23])]")
+    o1=node1.edAddOutputPort("o1",td4)
+    p.edAddChild(node1)
+    node2=self.r.createForEachLoop("node2",td3)
+    p.edAddChild(node2)
+    p.edAddCFLink(node1,node2)
+    p.edAddLink(o1,node2.edGetSeqOfSamplesPort())
+    node2.edGetNbOfBranchesPort().edInitInt(2)
+    #
+    node20=self.r.createBloc("node20")
+    node2.edAddChild(node20)
+    node200=self.r.createForEachLoop("node200",td2)
+    node20.edAddChild(node200)
+    node200.edGetNbOfBranchesPort().edInitInt(2)
+    p.edAddLink(node2.edGetSamplePort(),node200.edGetSeqOfSamplesPort())
+    node2000=self.r.createForEachLoop("node2000",td)
+    node2000.edGetNbOfBranchesPort().edInitInt(2)
+    node200.edAddChild(node2000)
+    p.edAddLink(node200.edGetSamplePort(),node2000.edGetSeqOfSamplesPort())
+    node20000=self.r.createScriptNode("","node20000")
+    node2000.edAddChild(node20000)
+    i1=node20000.edAddInputPort("i1",td)
+    o2=node20000.edAddOutputPort("o2",td)
+    node20000.setScript("o2=i1+2")
+    p.edAddLink(node2000.edGetSamplePort(),i1)
+    #
+    node3=self.r.createScriptNode("","node3")
+    node3.setScript("o3=i2")
+    p.edAddChild(node3)
+    i2=node3.edAddInputPort("i2",td4)
+    o3=node3.edAddOutputPort("o3",td4)
+    p.edAddCFLink(node2,node3)
+    p.edAddLink(o2,i2)
+    ex = pilot.ExecutorSwig()
+    self.assertEqual(p.getState(),pilot.READY)
+    ex.RunW(p,0)
+    self.assertEqual(p.getState(),pilot.DONE)
+    zeResu=node3.getOutputPort("o3").get()
+    self.assertEqual(zeResu,[[[3.,3.],[4.,4.,4.]],[[12.],[13.,13.],[14.,14.,14.]],[[22.],[23.,23.],[24.,24.,24.],[25.,25.,25.,25.]]])
+    p.saveSchema("foreachImbrBuildFS.xml")
+    pass
+
+  def tearDown(self):
+    del self.r
+    del self.l
+    pass
+
+  pass
+
+if __name__ == '__main__':
+    unittest.main()