Salome HOME
CCAR: add a python component PYCOMPO which uses NUMPY API to DSC
authorcaremoli <caremoli>
Thu, 8 Nov 2007 18:40:38 +0000 (18:40 +0000)
committercaremoli <caremoli>
Thu, 8 Nov 2007 18:40:38 +0000 (18:40 +0000)
configure.ac
idl/DSCCODE.idl
resources/DSCCODECatalog.xml
src/Makefile.am
src/PYCOMPO/Makefile.am [new file with mode: 0644]
src/PYCOMPO/PYCOMPO.py [new file with mode: 0644]

index 12b9bc9374f31a437f94b7f2a74e3df32c507556..b2ba75831e4258df15e978b49a75935e3d8661c4 100644 (file)
@@ -33,5 +33,6 @@ AC_CONFIG_FILES([
         src/FLUIDE/Makefile
         src/SOLIDE/Makefile
         src/INTERPI/Makefile
+        src/PYCOMPO/Makefile
         ])
 AC_OUTPUT
index ac8cd1363f2bb9abb064cab46a5d720fa4c87edf..866afc3a814f92670d5d7bbdc86cdd1efa9697b0 100644 (file)
@@ -49,6 +49,10 @@ module DSCCODE {
         void prun() raises (SALOME::SALOME_Exception);
         void trun() raises (SALOME::SALOME_Exception);
     };
+    interface PYCOMPO: Engines::Superv_Component
+    {
+        void run() raises (SALOME::SALOME_Exception);
+    };
 };
 
 #endif // _DSCCODE_IDL_
index c23c1dc57e6d25c1cda7814f9bed09b803d54f18..46f4143057ce1370fbb15fae5c74285d2b1c88d8 100644 (file)
         </component-interface-list>
   </component>
 
+  <component>
+        <!-- Component identification -->
+        <component-name>PYCOMPO</component-name>
+        <component-username>PYCOMPO</component-username>
+        <component-type>Data</component-type>
+        <component-author>C. Caremoli</component-author>
+        <component-version>3.2.0</component-version>
+        <component-comment>EDF - RD</component-comment>
+        <component-multistudy>1</component-multistudy>
+        <component-icone>INTERPI.png</component-icone>
+        <constraint>'linux' ~ OS</constraint>
+        <component-interface-list>
+            <component-interface-name>PYCOMPO</component-interface-name>
+            <component-interface-comment>No comment</component-interface-comment>
+            <component-service-list>
+                <component-service>
+                    <!-- service-identification -->
+                    <service-name>run</service-name>
+                    <service-author>CCar</service-author>
+                    <service-version>1.0</service-version>
+                    <service-comment>run</service-comment>
+                    <service-by-default>1</service-by-default>
+                    <!-- service-connexion -->
+                    <inParameter-list>
+                    </inParameter-list>
+                    <outParameter-list>
+                    </outParameter-list>
+            </component-service>
+            </component-service-list>
+        </component-interface-list>
+  </component>
+
 </component-list>
 </begin-catalog>
index 210162bf9c0523fea49fcfdbf6375f3286378bcc..a24d983e530fbcc5614d8bc024e5ffebc27b7d1f 100644 (file)
@@ -1 +1 @@
-SUBDIRS =DSCCODAENG DSCCODBENG DSCCODCENG DSCCODDENG NEUTRO FLUIDE SOLIDE INTERPI
+SUBDIRS =DSCCODAENG DSCCODBENG DSCCODCENG DSCCODDENG NEUTRO FLUIDE SOLIDE INTERPI PYCOMPO
diff --git a/src/PYCOMPO/Makefile.am b/src/PYCOMPO/Makefile.am
new file mode 100644 (file)
index 0000000..9a1f6c4
--- /dev/null
@@ -0,0 +1,4 @@
+include $(top_srcdir)/adm_local/make_common_starter.am
+
+salomepython_PYTHON = PYCOMPO.py
+
diff --git a/src/PYCOMPO/PYCOMPO.py b/src/PYCOMPO/PYCOMPO.py
new file mode 100644 (file)
index 0000000..3a7dbeb
--- /dev/null
@@ -0,0 +1,45 @@
+import sys,traceback,os
+import DSCCODE__POA
+import calcium
+import dsccalcium
+import numpy
+
+class PYCOMPO(DSCCODE__POA.PYCOMPO,dsccalcium.PyDSCComponent):
+  """
+     To be identified as a SALOME component this Python class
+     must have the same name as the component, inherit omniorb
+     class DSCCODE__POA.PYCOMPO and DSC class dsccalcium.PyDSCComponent
+     that implements DSC API.
+  """
+  def __init__ ( self, orb, poa, contID, containerName, instanceName, interfaceName ):
+    print "PYCOMPO.__init__: ", containerName, ';', instanceName,interfaceName
+    dsccalcium.PyDSCComponent.__init__(self, orb, poa,contID,containerName,instanceName,interfaceName)
+
+  def init_service(self,service):
+    print "init_service:",service
+    calcium.create_calcium_port(self.proxy,"tabin","CALCIUM_double","IN","I");
+    calcium.create_calcium_port(self.proxy,"tabout","CALCIUM_double","OUT","I");
+    return True
+
+  def run( self):
+    print "PYCOMPO.run"
+    ndim=10
+
+    force=calcium.doubleArray(ndim)
+    for i in xrange(ndim):
+      force[i]=i
+    err=calcium.cp_edb(self.proxy,calcium.CP_ITERATION ,0.,1,"tabout",ndim,force)
+
+    #val=calcium.doubleArray(ndim)
+    val=numpy.zeros(ndim,'d')
+    err,t,i,nval=calcium.cp_ldb(self.proxy,calcium.CP_ITERATION,0.,0.,1,"tabin",ndim,val)
+    print err,t,i,nval
+    #for i in xrange(ndim):
+    #  print val[i],
+    #print
+    print val
+
+    print "End of PYCOMPO.run"
+    sys.stdout.flush()
+
+