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

diff --git a/Examples/cpp2/README.txt b/Examples/cpp2/README.txt
new file mode 100644 (file)
index 0000000..f012293
--- /dev/null
@@ -0,0 +1,22 @@
+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 (cppcompos_SRC), its installation (install) and
+a SALOME application (appli) composed of modules KERNEL, GUI, YACS and cppcompos.
+
+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/cpp2/components.py b/Examples/cpp2/components.py
new file mode 100644 (file)
index 0000000..b008576
--- /dev/null
@@ -0,0 +1,47 @@
+import os
+from module_generator import Generator,Module,Service,CPPComponent
+
+context={'update':1,
+         "prerequisites":"/local/cchris/.packages.d/envSalome50",
+         "kernel":"/local/chris/SALOME2/RELEASES/Install/KERNEL_V5",
+        }
+
+cwd=os.getcwd()
+
+body="""
+std::cerr << "a: " << a << std::endl;
+std::cerr << "b: " << b << std::endl;
+int info;
+double t1,t2;
+int i=1;
+int mval;
+double val[10],rval[10];
+val[0]=3.2;
+cp_edb(component,CP_ITERATION,0.,1,"ba",1,val);
+info=cp_ldb(component,CP_ITERATION,&t1,&t2,&i,"aa",1,&mval,rval);
+std::cerr << "rval: " << rval[0] << std::endl;
+c=2*rval[0];
+std::cerr << "c: " << c << std::endl;
+"""
+c1=CPPComponent("compo1",services=[
+          Service("s1",inport=[("a","double"),("b","double")],
+                       outport=[("c","double")],
+                       instream=[("aa","CALCIUM_double","I"),],
+                       outstream=[("ba","CALCIUM_double","I"),],
+                       defs="//def1",body=body,
+                 ),
+          ],
+         includes="-I/usr/include",
+         kind="exe",
+         exe_path=os.path.join(cwd,"prog"),
+         )
+
+
+g=Generator(Module("cppcompos",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/cpp2/coupling.xml b/Examples/cpp2/coupling.xml
new file mode 100644 (file)
index 0000000..07b3a26
--- /dev/null
@@ -0,0 +1,63 @@
+
+<proc>
+
+<!-- types -->
+
+
+<container name="A">
+</container>
+
+<container name="B">
+</container>
+
+<service name="node1" >
+  <component>compo1</component>
+  <method>s1</method>
+  <load container="A"/>
+  <inport name="a" type="double"/>
+  <inport name="b" type="double"/>
+  <outport name="c" type="double"/>
+  <instream name="aa" type="CALCIUM_double"/>
+  <outstream name="ba" type="CALCIUM_double"/>
+</service>
+
+<service name="node2" >
+  <component>compo1</component>
+  <method>s1</method>
+  <load container="B"/>
+  <inport name="a" type="double"/>
+  <inport name="b" type="double"/>
+  <outport name="c" 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>
+
diff --git a/Examples/cpp2/prog.cxx b/Examples/cpp2/prog.cxx
new file mode 100644 (file)
index 0000000..363c697
--- /dev/null
@@ -0,0 +1,8 @@
+
+extern "C" void yacsinit();
+
+int main(int argc, char* argv[])
+{
+  yacsinit();
+  return 0;
+}