Salome HOME
c0590c20bb12da98846be141be5d3ac266872c6c
[modules/kernel.git] / src / DSC / DSC_Python / dsccalcium.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 ## @package dsccalcium
22 # \brief Module that provides the base class for DSC components implemented in python
23 #
24
25 import calcium
26 import SALOME_ComponentPy
27 import SALOME_DriverPy
28 import Engines
29
30 ## The SALOME base class for all DSC components implemented in python (interface Engines::Superv_Component).
31 #
32 #
33 class PyDSCComponent(SALOME_ComponentPy.SALOME_ComponentPy_i,
34                      SALOME_DriverPy.SALOME_DriverPy_i):
35   """
36      A Python DSC component is implemented by a Python class that has
37      the name of the component and is located in a python module that has the
38      name of the component.
39
40      You must derive it and implement init_service and those methods
41      that are services of the component.
42   """
43   def __init__ ( self, orb, poa, contID, containerName, instanceName, interfaceName ):
44     SALOME_ComponentPy.SALOME_ComponentPy_i.__init__(self, orb, poa,
45                     contID, containerName, instanceName, interfaceName, 0)
46     SALOME_DriverPy.SALOME_DriverPy_i.__init__(self, interfaceName)
47     # create the DSC proxy
48     self.proxy=calcium.PySupervCompo(orb,poa,contID,instanceName,interfaceName )
49     # Store a reference on naming service in _naming_service attribute 
50     self._naming_service = SALOME_ComponentPy.SALOME_NamingServicePy_i( self._orb )
51
52   def init_service(self,service):
53     return True
54
55   enums={Engines.DSC.RemovingConnection:calcium.DSC.RemovingConnection,
56          Engines.DSC.AddingConnection:calcium.DSC.AddingConnection,
57          Engines.DSC.ApplicationError:calcium.DSC.ApplicationError,
58         }
59   def get_provides_port(self,name,error):
60     return self.proxy.get_provides_port(name,error)
61
62   def connect_uses_port(self,name,port):
63     self.proxy.connect_uses_port(name,port)
64
65   def connect_provides_port(self,name):
66     self.proxy.connect_provides_port(name)
67
68   def disconnect_provides_port(self,name,message):
69     self.proxy.disconnect_provides_port(name,message._v)
70     #self.proxy.disconnect_provides_port(name,self.enums[message])
71
72   def disconnect_uses_port(self,name,port,message):
73     self.proxy.disconnect_uses_port(name,port,message._v)
74     #self.proxy.disconnect_uses_port(name,port,self.enums[message])
75
76   def get_port_properties(self,name):
77     return self.proxy.get_port_properties(name)
78
79   def setInputFileToService(self,service_name,Salome_file_name):
80     return self.proxy.setInputFileToService(service_name,Salome_file_name)
81
82   def checkInputFilesToService(self,service_name):
83     return self.proxy.checkInputFilesToService(service_name)
84
85   def getInputFileToService(self,service_name,Salome_file_name):
86     return self.proxy.getInputFileToService(service_name,Salome_file_name)
87
88   def setOutputFileToService(self,service_name,Salome_file_name):
89     return self.proxy.setOutputFileToService(service_name,Salome_file_name)
90
91   def getOutputFileToService(self,service_name,Salome_file_name):
92     return self.proxy.getOutputFileToService(service_name,Salome_file_name)
93
94   def checkOutputFilesToService(self,service_name):
95     return self.proxy.checkOutputFilesToService(service_name)
96
97   def beginService(self,service_name):
98     SALOME_ComponentPy.SALOME_ComponentPy_i.beginService(self,service_name)
99     self.proxy.setTimeOut()
100