Salome HOME
d363c84cfc187101f8054a82094bee18a5567b92
[modules/kernel.git] / doc / salome / kernel_services.dox
1 /*!
2   \page KERNEL_Services KERNEL Services for end user (Python interface)
3
4 <b>WORK in PROGRESS, INCOMPLETE DOCUMENT</b>
5
6 In a %SALOME application, distributed components, servers and clients use
7 the CORBA middleware for comunication. CORBA interfaces are defined via idl
8 files. All the different CORBA interfaces are available for users in Python,
9 see CORBA interfaces below.
10
11 For some general purpose services, CORBA interfaces have been encapsulated
12 in order to provide a simple interface (encapsulation is generally done in
13 C++ classes, and a Python SWIG interface is also generated from C++, to 
14 ensure a consistent behavior between C++ modules and Python modules or user
15 script).
16
17 \section S1_kernel_ser General purpose services
18
19 <ol>
20 <li>
21 <b>%SALOME services access from a Python shell</b>
22
23 See \ref SALOME_Application for detailed instructions to launch a Python
24 interpreter with full acces to the %SALOME environment and services.
25
26 You can use the embedded Python interpreter in Grahic User Interface, or an
27 external interpreter, with:
28
29 \code
30 ./runSession
31 python
32 \endcode
33
34 In either cases, %SALOME services access is done with:
35
36 \code
37 import salome
38 salome.salome_init()
39 \endcode
40
41 In the embedded interpreter, it is already done, but there is no problem to
42 do it several times, so it is preferable to add these instructions
43 systematically in your scripts, to allow them to work in all configurations.
44
45 </li>
46 <li>
47 <b>Container and component instanciation</b>
48
49 See LifeCycleCORBA for the C++ interface (Python interface obtained with SWIG
50 is very similar).
51
52 In the following example, a test component provided in KERNEL is launched
53 in the local container, "FactoryServer", created when %SALOME starts:
54
55 \code
56 import salome
57 salome.salome_init()
58    
59 import LifeCycleCORBA
60 lcc = LifeCycleCORBA.LifeCycleCORBA()
61 obj=lcc.FindOrLoad_Component("FactoryServer","SalomeTestComponent")
62    
63 import Engines
64 comp=obj._narrow(Engines.TestComponent)
65  
66 comp.Coucou(1)
67 \endcode   
68
69 The answer is something like:
70
71 \code
72 'TestComponent_i : L = 1'
73 \endcode
74
75 The _narrow() instruction is not always mandatory in Python, but sometimes 
76 useful to be sure you have got the right type of %object. Here, Testcomponent
77 interface is defined in CORBA module Engines. With this example, it works also
78 without the _narrow() instruction:
79
80 \code
81    obj.Coucou(1)
82 \endcode
83
84 In the next example, a component instance is created in a specific Container
85 defined by it's computer hostname and it's name. Here we use the local
86 computer. Note that in Utils_Identity, getShortHostName() gives the short
87 hostname of the computer, without domain suffixes, which is used in %SALOME.
88 The container process is created here if it does not exists, and a new
89 component instance is created:
90
91 \code
92 import salome
93 salome.salome_init()
94 import LifeCycleCORBA
95 lcc = LifeCycleCORBA.LifeCycleCORBA()
96
97 import Utils_Identity
98 host  = Utils_Identity.getShortHostName()
99
100 import Engines
101 params={}
102 params['hostname']=host
103 params['container_name']='myContainer'
104 comp=lcc.LoadComponent(params,'SalomeTestComponent')
105 comp.Coucou(1)
106 \endcode
107
108 If you want to get a list of containers and component instances, client %object
109 from orbmodule provides a list:
110
111 \code
112 import orbmodule
113 clt=orbmodule.client()
114 clt.showNS()
115 \endcode
116
117 The list looks like:
118
119 \code
120 Logger.
121 ContainerManager.object
122 Containers.dir
123   cli70ac.dir
124     FactoryServerPy.object
125     SuperVisionContainer.object
126     FactoryServer.object
127     FactoryServer.dir
128       SalomeTestComponent_inst_1.object
129     myContainer.object
130     myContainer.dir
131       SalomeTestComponent_inst_1.object
132       SalomeTestComponent_inst_2.object
133 Registry.object
134 Kernel.dir
135   ModulCatalog.object
136   Session.object
137 Study.dir
138   Study2.object
139   extStudy_1.object
140   extStudy_2.object
141   extStudy_3.object
142 myStudyManager.object
143 SalomeAppEngine.object
144 \endcode
145
146 </li>
147 <li>
148 <b>File transfer service</b>
149
150 See SALOME_FileTransferCORBA for the C++ interface (Python interface obtained with
151 SWIG is very similar).
152
153 The following example shows how to tranfer a file from a remote host to the
154 client computer. Remote hostname is 'cli76cc', we would like to copy
155 'tkcvs_8_0_3.tar.gz' from remote to local computer. %A full pathname is
156 required. %A container is created on remote computer if it does not exist,
157 to handle the file transfer:
158
159 \code
160 import salome
161 salome.salome_init()
162
163 import LifeCycleCORBA
164 remotefile="/home/prascle/tkcvs_8_0_3.tar.gz"
165 aFileTransfer=LifeCycleCORBA.SALOME_FileTransferCORBA('cli76cc',remotefile)
166 localFile=aFileTransfer.getLocalFile()
167 \endcode
168
169 </li>
170 <li>
171 <b>CORBA Naming service access</b>
172
173 See SALOME_NamingService for the C++ interface. The Python interface
174 SALOME_NamingServicePy is not yet derived from the C++ interface and offers
175 only the most useful functions.
176
177 </li>
178 <li>
179 <b>Batch services</b>
180
181 See \ref batch_page documentation (in french only).
182
183 </li>
184 </ol>
185
186 \section S2_kernel_ser All IDL Interfaces
187
188 <ol>
189 <li>
190 <b>Containers and component life cycle, File transfer service</b>
191
192 - Engines : engines CORBA module.                         
193 - Engines::Component : generic component interface. All %SALOME components inherit this interface.
194 - Engines::Container : host for C++ and Python components components instances                          
195 - Engines::fileTransfer : agent for file transfer created by a container copy a local file to a distent client         
196 - Engines::fileRef : reference to a file, used by a container for file transfers                                
197 - Engines::ContainerManager : unique instance, in charge of container creation on remote computers                  
198 - Engines::MPIContainer : an exemple of parallel implementation for containers and components                     
199 - Engines::MPIObject
200
201 </li>
202 <li>
203 <b>Study management</b>
204
205 - SALOMEDS : SALOMEDS CORBA module
206 - SALOMEDS.idl
207 - SALOMEDS_Attributes.idl
208
209 </li>
210 <li>
211 <b>High speed transfer, object life cycle, exceptions, GUI interface...</b>
212
213 - SALOME : %SALOME CORBA module
214 - SALOME_Comm.idl
215 - SALOME_GenericObj.idl
216 - SALOME_Exception
217 - SALOME_Session.idl
218
219 </li>
220 <li>
221 <b>Miscelleanous</b>
222
223 - SALOME_ModuleCatalog
224 - SALOME_RessourcesCatalog
225 - SALOME_Registry.idl
226 - Logger.idl
227
228 <b>Other idl for test purposes</b>
229 \n
230 - nstest.idl
231 - SALOME_TestComponent.idl
232 - SALOME_TestModuleCatalog.idl
233 - SALOME_TestMPIComponent.idl
234 - TestNotif.idl
235
236 */