]> SALOME platform Git repositories - tools/yacsgen.git/commitdiff
Salome HOME
CCAR : add example pyth2 (standalone component python)
authorcaremoli <caremoli>
Fri, 23 Jan 2009 18:17:22 +0000 (18:17 +0000)
committercaremoli <caremoli>
Fri, 23 Jan 2009 18:17:22 +0000 (18:17 +0000)
Examples/pyth2/README.txt [new file with mode: 0644]
Examples/pyth2/components.py [new file with mode: 0644]
Examples/pyth2/coupling.xml [new file with mode: 0644]

diff --git a/Examples/pyth2/README.txt b/Examples/pyth2/README.txt
new file mode 100644 (file)
index 0000000..2f25931
--- /dev/null
@@ -0,0 +1,25 @@
+A Python component
+====================
+
+To build this example, modify the components.py file
+to take into account your configuration.
+
+1- your prerequisite file 
+2- your KERNEL_ROOT_DIR
+
+Then set the environment (including PYTHONPATH for YACGEN, ../.. from here and execute components.py ::
+
+  source <your prerequisite file>
+  python components.py
+
+You should get a SALOME module in source form (pycompos_SRC), its installation (install) and
+a SALOME application (appli) composed of modules KERNEL, GUI, YACS and pycompos.
+
+To run a coupling:
+
+ 1. start SALOME in background : ./appli/runAppli -t
+ 2. start a SALOME session : ./appli/runSession
+ 3. start YACS coupler with coupling file : driver coupling.xml
+ 4. examine output files in /tmp
+ 5. shutdown SALOME : shutdowSalome.py
+ 6. exit session : CTRL-D (or exit)
diff --git a/Examples/pyth2/components.py b/Examples/pyth2/components.py
new file mode 100644 (file)
index 0000000..336c58c
--- /dev/null
@@ -0,0 +1,46 @@
+import os
+from module_generator import Generator,Module,Service,PYComponent
+
+context={'update':1,
+         "prerequisites":"/local/cchris/.packages.d/envSalome50",
+         "kernel":"/local/chris/SALOME2/RELEASES/Install/KERNEL_V5",
+        }
+
+cwd=os.getcwd()
+
+
+body="""
+      #b1
+      dep=calcium.CP_ITERATION
+      val=numpy.zeros(10,'d')
+      val[5]=a*b
+      nval=10
+      print "--------> Appel calcium.cp_edb"
+      info=calcium.cp_edb(component, dep, 0., 1, "ba", nval,val)
+      val=numpy.zeros(10,'d')
+      info,tt,ii,mval=calcium.cp_ldb(component, dep, 0.,1., 1, "aa", nval,val)
+      print mval,val
+      c=a+b
+      d=a-b
+      err=calcium.cp_fin(component,calcium.CP_ARRET)
+"""
+c1=PYComponent("compo2",services=[
+          Service("s1",inport=[("a","double"),("b","double")],
+                       outport=[("c","double"),("d","double")],
+                       instream=[("aa","CALCIUM_double","I"),],
+                       outstream=[("ba","CALCIUM_double","I"),],
+                       defs="#def1",body=body,
+                 ),
+         ],
+         kind="exe",
+         )
+
+
+g=Generator(Module("pycompos",components=[c1],prefix="./install"),context)
+g.generate()
+g.bootstrap()
+g.configure()
+g.make()
+g.install()
+g.make_appli("appli",restrict=["KERNEL","GUI","YACS"])
+
diff --git a/Examples/pyth2/coupling.xml b/Examples/pyth2/coupling.xml
new file mode 100644 (file)
index 0000000..cd9b441
--- /dev/null
@@ -0,0 +1,65 @@
+
+<proc>
+
+<!-- types -->
+
+
+<container name="A">
+</container>
+
+<container name="B">
+</container>
+
+<service name="node1" >
+  <component>compo2</component>
+  <method>s1</method>
+  <load container="A"/>
+  <inport name="a" type="double"/>
+  <inport name="b" type="double"/>
+  <outport name="c" type="double"/>
+  <outport name="d" type="double"/>
+  <instream name="aa" type="CALCIUM_double"/>
+  <outstream name="ba" type="CALCIUM_double"/>
+</service>
+
+<service name="node2" >
+  <component>compo2</component>
+  <method>s1</method>
+  <load container="B"/>
+  <inport name="a" type="double"/>
+  <inport name="b" type="double"/>
+  <outport name="c" type="double"/>
+  <outport name="d" type="double"/>
+  <instream name="aa" type="CALCIUM_double"/>
+  <outstream name="ba" type="CALCIUM_double"/>
+</service>
+
+<!--datalinks -->
+<stream>
+  <fromnode>node1</fromnode><fromport>ba</fromport>
+  <tonode>node2</tonode><toport>aa</toport>
+</stream>
+<stream>
+  <fromnode>node2</fromnode><fromport>ba</fromport>
+  <tonode>node1</tonode><toport>aa</toport>
+</stream>
+
+<parameter>
+  <tonode>node1</tonode> <toport>a</toport>
+  <value><double>23</double> </value>
+</parameter>
+<parameter>
+  <tonode>node1</tonode> <toport>b</toport>
+  <value><double>53</double> </value>
+</parameter>
+<parameter>
+  <tonode>node2</tonode> <toport>a</toport>
+  <value><double>63</double> </value>
+</parameter>
+<parameter>
+  <tonode>node2</tonode> <toport>b</toport>
+  <value><double>73</double> </value>
+</parameter>
+
+</proc>
+