From 250e47a1f689ccf9ea32ba9051e7b2455643a421 Mon Sep 17 00:00:00 2001 From: caremoli Date: Fri, 23 Jan 2009 18:13:31 +0000 Subject: [PATCH] CCAR: add C++ example (standalone component) --- Examples/cpp2/README.txt | 22 +++++++++++++ Examples/cpp2/components.py | 47 +++++++++++++++++++++++++++ Examples/cpp2/coupling.xml | 63 +++++++++++++++++++++++++++++++++++++ Examples/cpp2/prog.cxx | 8 +++++ 4 files changed, 140 insertions(+) create mode 100644 Examples/cpp2/README.txt create mode 100644 Examples/cpp2/components.py create mode 100644 Examples/cpp2/coupling.xml create mode 100644 Examples/cpp2/prog.cxx diff --git a/Examples/cpp2/README.txt b/Examples/cpp2/README.txt new file mode 100644 index 0000000..f012293 --- /dev/null +++ b/Examples/cpp2/README.txt @@ -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 + 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 index 0000000..b008576 --- /dev/null +++ b/Examples/cpp2/components.py @@ -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 index 0000000..07b3a26 --- /dev/null +++ b/Examples/cpp2/coupling.xml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + compo1 + s1 + + + + + + + + + + compo1 + s1 + + + + + + + + + + + node1ba + node2aa + + + node2ba + node1aa + + + + node1 a + 23 + + + node1 b + 53 + + + node2 a + 63 + + + node2 b + 73 + + + + diff --git a/Examples/cpp2/prog.cxx b/Examples/cpp2/prog.cxx new file mode 100644 index 0000000..363c697 --- /dev/null +++ b/Examples/cpp2/prog.cxx @@ -0,0 +1,8 @@ + +extern "C" void yacsinit(); + +int main(int argc, char* argv[]) +{ + yacsinit(); + return 0; +} -- 2.39.2