Salome HOME
updated copyright message
[modules/kernel.git] / src / DSC / DSC_Python / dsccalcium.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2023  CEA, EDF, 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, False)
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
50   def init_service(self,service):
51     return True
52
53   enums={Engines.DSC.RemovingConnection:calcium.DSC.RemovingConnection,
54          Engines.DSC.AddingConnection:calcium.DSC.AddingConnection,
55          Engines.DSC.ApplicationError:calcium.DSC.ApplicationError,
56         }
57   def get_provides_port(self,name,error):
58     return self.proxy.get_provides_port(name,error)
59
60   def connect_uses_port(self,name,port):
61     self.proxy.connect_uses_port(name,port)
62
63   def connect_provides_port(self,name):
64     self.proxy.connect_provides_port(name)
65
66   def disconnect_provides_port(self,name,message):
67     self.proxy.disconnect_provides_port(name,message._v)
68     #self.proxy.disconnect_provides_port(name,self.enums[message])
69
70   def disconnect_uses_port(self,name,port,message):
71     self.proxy.disconnect_uses_port(name,port,message._v)
72     #self.proxy.disconnect_uses_port(name,port,self.enums[message])
73
74   def get_port_properties(self,name):
75     return self.proxy.get_port_properties(name)
76
77   def setInputFileToService(self,service_name,Salome_file_name):
78     return self.proxy.setInputFileToService(service_name,Salome_file_name)
79
80   def checkInputFilesToService(self,service_name):
81     return self.proxy.checkInputFilesToService(service_name)
82
83   def getInputFileToService(self,service_name,Salome_file_name):
84     return self.proxy.getInputFileToService(service_name,Salome_file_name)
85
86   def setOutputFileToService(self,service_name,Salome_file_name):
87     return self.proxy.setOutputFileToService(service_name,Salome_file_name)
88
89   def getOutputFileToService(self,service_name,Salome_file_name):
90     return self.proxy.getOutputFileToService(service_name,Salome_file_name)
91
92   def checkOutputFilesToService(self,service_name):
93     return self.proxy.checkOutputFilesToService(service_name)
94
95   def beginService(self,service_name):
96     SALOME_ComponentPy.SALOME_ComponentPy_i.beginService(self,service_name)
97     self.proxy.setTimeOut()
98