Salome HOME
0021196: [CEA 456] Integration and merge modification for debian packages
[modules/kernel.git] / doc / salome / kernel_services.dox
1 /*!
2   \page KERNEL_Services KERNEL Services for end user (Python interface)
3
4 In a %SALOME application, distributed components, servers and clients use
5 the CORBA middleware for comunication. CORBA interfaces are defined via idl
6 files. All the different CORBA interfaces are available for users in Python,
7 see CORBA interfaces below.
8
9 For some general purpose services, CORBA interfaces have been encapsulated
10 in order to provide a simple interface (encapsulation is generally done in
11 C++ classes, and a Python SWIG interface is also generated from C++, to 
12 ensure a consistent behavior between C++ modules and Python modules or user
13 script).
14
15 \section S1_kernel_ser General purpose services
16
17 \subsection subsection11 SALOME services access from a Python shell
18
19 See \ref SALOME_Application for detailed instructions on how to launch a Python
20 interpreter with full access to the %SALOME environment and services.
21
22 You can use the embedded Python interpreter in Graphical User Interface, or an
23 external interpreter, with:
24
25 \code
26 ./runSession
27 python
28 \endcode
29
30 In either cases, %SALOME services access is done with:
31
32 \code
33 import salome
34 salome.salome_init()
35 \endcode
36
37 In the embedded interpreter, it is already done, but there is no problem to
38 do it several times, so it is preferable to add these instructions
39 systematically in your scripts, to allow them to work in all configurations.
40 See \ref kernel_salome for a short description of most useful variables and
41 functions.
42
43 \subsection subsection12 Container and component instanciation
44
45 See SALOME_LifeCycleCORBA for the C++ interface (Python interface obtained with SWIG
46 is very similar).
47
48 In the following example, a test component provided in KERNEL is launched
49 in the local container, "FactoryServer", created when %SALOME starts:
50
51 \code
52 import salome
53 salome.salome_init()
54    
55 import LifeCycleCORBA
56 lcc = LifeCycleCORBA.LifeCycleCORBA()
57 obj=lcc.FindOrLoad_Component("FactoryServer","SalomeTestComponent")
58    
59 import Engines
60 comp=obj._narrow(Engines.TestComponent)
61  
62 comp.Coucou(1)
63 \endcode   
64
65 The answer is something like:
66
67 \code
68 'TestComponent_i : L = 1'
69 \endcode
70
71 The _narrow() instruction is not always mandatory in Python, but sometimes 
72 useful to be sure you have got the right type of %object. Here, Testcomponent
73 interface is defined in CORBA module Engines. With this example, it works also
74 without the _narrow() instruction:
75
76 \code
77    obj.Coucou(1)
78 \endcode
79
80 In the next example, a component instance is created in a specific Container
81 defined by it's computer hostname and it's name. Here we use the local
82 computer. Note that in Utils_Identity, Utils_Identity::getShortHostName() gives the short
83 hostname of the computer, without domain suffixes, which is used in %SALOME.
84 The container process is created here if it does not exists, and a new
85 component instance is created:
86
87 \code
88 import salome
89 salome.salome_init()
90 import LifeCycleCORBA
91 lcc = LifeCycleCORBA.LifeCycleCORBA()
92
93 import Utils_Identity
94 host  = Utils_Identity.getShortHostName()
95
96 import Engines
97 params={}
98 params['hostname']=host
99 params['container_name']='myContainer'
100 comp=lcc.LoadComponent(params,'SalomeTestComponent')
101 comp.Coucou(1)
102 \endcode
103
104 If you want to get a list of containers and component instances, client %object
105 from orbmodule provides a list:
106
107 \code
108 import orbmodule
109 clt=orbmodule.client()
110 clt.showNS()
111 \endcode
112
113 The list looks like:
114
115 \code
116 Logger.
117 ContainerManager.object
118 Containers.dir
119   cli70ac.dir
120     FactoryServerPy.object
121     SuperVisionContainer.object
122     FactoryServer.object
123     FactoryServer.dir
124       SalomeTestComponent_inst_1.object
125     myContainer.object
126     myContainer.dir
127       SalomeTestComponent_inst_1.object
128       SalomeTestComponent_inst_2.object
129 Registry.object
130 Kernel.dir
131   ModulCatalog.object
132   Session.object
133 Study.dir
134   Study2.object
135   extStudy_1.object
136   extStudy_2.object
137   extStudy_3.object
138 myStudyManager.object
139 SalomeAppEngine.object
140 \endcode
141
142 \subsection subsection13 File transfer service
143
144 See SALOME_FileTransferCORBA for the C++ interface (Python interface obtained with
145 SWIG is very similar).
146
147 The following example shows how to tranfer a file from a remote host to the
148 client computer. Remote hostname is 'cli76cc', we would like to copy
149 'tkcvs_8_0_3.tar.gz' from remote to local computer. %A full pathname is
150 required. %A container is created on remote computer if it does not exist,
151 to handle the file transfer:
152
153 \code
154 import salome
155 salome.salome_init()
156
157 import LifeCycleCORBA
158 remotefile="/home/prascle/tkcvs_8_0_3.tar.gz"
159 aFileTransfer=LifeCycleCORBA.SALOME_FileTransferCORBA('cli76cc',remotefile)
160 localFile=aFileTransfer.getLocalFile()
161 \endcode
162
163 \subsection subsection14 CORBA Naming service access
164
165 See SALOME_NamingService for the C++ interface. The Python interface
166 SALOME_NamingServicePy::SALOME_NamingServicePy_i is not yet derived from the C++ interface and offers
167 only the most useful functions.
168
169 \subsection subsection5 Batch services
170
171 See <a href="Batch.html/index.html"> Batch documentation </a> (in french only).
172
173 \section S2_kernel_ser All IDL Interfaces
174
175 -# <b>Containers and component life cycle, File transfer service</b>
176    - Engines : engines CORBA module.                         
177    - Engines::EngineComponent : generic component interface. All %SALOME components inherit this interface.
178    - Engines::Container : host for C++ and Python components components instances                          
179    - Engines::fileTransfer : agent for file transfer created by a container copy a local file to a distent client         
180    - Engines::fileRef : reference to a file, used by a container for file transfers                                
181    - Engines::ContainerManager : unique instance, in charge of container creation on remote computers                  
182    - Engines::MPIContainer : a parallel implementation for containers and components                     
183    - Engines::MPIObject
184    .
185 -# <b>Study management</b>
186    - SALOMEDS : SALOMEDS CORBA module
187    - SALOMEDS.idl : \copybrief SALOMEDS.idl
188    - SALOMEDS_Attributes.idl : \copybrief SALOMEDS_Attributes.idl
189    .
190 -# <b>High speed transfer, object life cycle, exceptions, GUI interface...</b>
191    - SALOME : \copybrief SALOME
192    - SALOME_Comm.idl : \copybrief SALOME_Comm.idl
193    - SALOME_GenericObj.idl : \copybrief SALOME_GenericObj.idl
194    - SALOME_Exception.idl : \copybrief SALOME_Exception.idl
195    - SALOME_Session.idl : \copybrief SALOME_Session.idl
196    .
197 -# <b>Miscelleanous</b>
198    - SALOME_ModuleCatalog : \copybrief SALOME_ModuleCatalog
199    - SALOME_RessourcesCatalog : \copybrief SALOME_RessourcesCatalog
200    - Registry : \copybrief Registry
201    - SALOME_Logger : \copybrief SALOME_Logger
202    .
203 -# <b>Other idl for test purposes</b>
204    - NSTEST : for naming service test
205    - SALOME_TestComponent.idl : for EngineComponent test
206    - SALOME_TestModuleCatalog : for SALOME_ModuleCatalog test
207    - SALOME_TestMPIComponent.idl : \copybrief SALOME_TestMPIComponent.idl
208    - TestNotif.idl : \copybrief TestNotif.idl
209    .
210 -# <b>Some useful command scripts </b>
211    - waitNS.py : \copybrief waitNS.py
212    - waitContainers.py : \copybrief waitContainers.py
213    - showNS.py : \copybrief showNS.py
214    - shutdownSalome.py : \copybrief shutdownSalome.py
215    - killSalome.py : \copybrief killSalome.py
216    - killSalomeWithPort.py : \copybrief killSalomeWithPort.py
217    - appli_gen.py : \copybrief appli_gen.py
218    .
219
220 */
221
222 /** \example example1
223 AttributeReal interface (creations/saving/restoring)
224 \n
225 Methods : FindOrCreateAttribute, Value, SaveAs, SetValue, FindComponent, FindAttribute, Open
226  */
227 /** \example example3
228 AttributeSequenceOfReal interface(creations/saving/restoring)\n
229 AttributeSequenceOfReal  : ChangeValue, Add,  Value,  Remove,  Length\n
230 SALOMEDS methods : FindOrCreateAttribute, SaveAs, FindComponent, FindAttribute, Open
231  */
232 /** \example example16
233 Methods : GetAvailableUndos, ChangeValue, FindOrCreateAttribute, SaveAs, GetAvailableRedos, Undo, FindComponent, Redo, FindAttribute, Open, CommitCommand, NewCommand
234  */
235 /** \example example17
236 SALOMEDS methods : RemoveAttribute, FindOrCreateAttribute, NewStudy, GetAllAttributes, NewCommand, CommitCommand, AbortCommand, NewComponent
237  */
238 /** \example example18
239 AttributeTreeNode interface(creations/saving/restoring)\n
240 SALOMEDS methods : FindOrCreateAttribute, NewObject\n
241 Attribute methods : HasFirst, HasFather, SetPrevious, Next, InsertAfter, GetFather, HasNext, SetValue, Append, NewStudy, Label, IsRoot, Prepend, SetFather, Depth, HasPrevious
242  */
243 /** \example example19
244  SALOMEDS methods :  FindOrCreateAttribute, Save, SaveAs, Close, Open, FindComponent, FindAttribute, FindObject, LoadWith
245 \n
246  Attribute methods : Value, SetValue
247  */
248 /** \example example20
249 SALOMEDS methods : FindOrCreateAttribute, SaveAs, FindComponent, FindAttribute, NewCommand, GetProperties, Open, CommitCommand, NewBuilder\n
250 Attribute methods : SetLocked, IsLocked, GetCreationMode, SetCreationDate, IsModified, GetUserName, Value, SetUserName, SetValue, GetCreationDate
251  */
252 /** \example example23
253 Methods:
254  */
255 /** \example example8
256 AttributeDrawable interface(creations/saving/restoring)\n
257 SALOMEDS methods : FindOrCreateAttribute, SaveAs, FindComponent, FindAttribute, Open\n
258 Attribute methods : SetDrawable, IsDrawable
259  */
260 /** \example example9
261 AttributeSelectable interface(creations/saving/restoring)\n
262 SALOMEDS methods: FindOrCreateAttribute, SaveAs, FindComponent, FindAttribute, Open\n
263 Attribute methods: SetSelectable, IsSelectable
264  */
265 /** \example example10
266 AttributeExpandable interface(creations/saving/restoring)\n
267 SALOMEDS methods : SaveAs FindComponent  FindAttribute Open\n
268 Attribute methods : SetExpandable IsExpandable
269  */
270 /** \example example11
271 Test AttributeOpened (creations/saving/restoring)\n
272 SALOMEDS methods : FindOrCreateAttribute SaveAs, FindComponent, FindAttribute, Open\n
273 Attribute methods : SetOpened, IsOpened
274  */
275 /** \example example12
276 AttributeTextColor interface (creations/saving/restoring)\n
277 SALOMEDS methods : FindOrCreateAttribute, SaveAs, FindComponent, FindAttribute, Open\n
278 Attribute methods : SetTextColor  TextColor
279  */
280 /** \example example13
281 Test AttributeTextHighlightColor interface(creations/saving/restoring)\n
282 SALOMEDS methods : FindOrCreateAttribute, SaveAs, FindComponent, FindAttribute, Open\n
283 Attribute methods :  SetTextHighlightColor TextHighlightColor
284  */
285 /** \example example14
286 AttributePixMap interface (creations/saving/restoring)\n
287 SALOMEDS methods  : FindOrCreateAttribute, SaveAs, FindComponent, FindAttribute, Open\n
288 Attribute methods : SetPixMap, GetPixMap
289  */
290
291 /** \example example21
292 SALOMEDS methods : FindOrCreateAttribute, SaveAs, FindComponent, FindAttribute, Open\n
293 Attribute methods: GetValue, GetNbColumns, AddColumn, SetRowTitles, PutValue, GetColumn, GetColumnTitles, GetTitle, SetRow, GetRowTitles, SetColumnTitles, SetColumn, GetRow, GetNbRows, SetColumnTitle, AddRow, SetTitle, SetRowTitle
294  */
295 /** \example example15
296 AttributeLocalID interface(creations/saving/restoring)\n
297 SALOMEDS methods : FindOrCreateAttribute, SaveAs, FindComponent, FindAttribute, Open\n
298 Attribute methods : Value,  SetValue
299 */
300 /** \example example22
301 SALOMEDS methods  : FindOrCreateAttribute, SaveAs, FindComponent, FindAttribute, Open\n
302 Attribute methods : GetValue, GetNbColumns, AddColumn, SetRowTitles, PutValue,  GetColumn,  GetColumnTitles, GetTitle, SetRow, GetRowTitles, SetColumnTitles,  SetColumn,  GetRow,  GetNbRows, SetColumnTitle, AddRow, SetTitle, SetRowTitle
303 */
304 /** \example example4
305 AttributeSequenceOfInteger interface(creations/saving/restoring)\n
306 SALOMEDS methods : FindOrCreateAttribute FindComponent FindAttribute Open Add SaveAs
307 AttributeSequenceOfInteger methods :  Value, Remove, Length
308 */
309 /** \example example5
310 AttributeName interface(creations/saving/restoring)\n
311 SALOMEDS methods : FindOrCreateAttribute,  SaveAs, FindComponent FindAttribute Open\n
312 Attribute methods : SetValue, Value
313 */
314 /** \example example6
315 AttributeComment interface(creations/saving/restoring)\n
316 SALOMEDS methods : FindOrCreateAttribute, SaveAs FindComponent FindAttribute  Open\n
317 Attribute methods : Value, SetValue
318 */
319 /** \example example7
320 AttributePersistentRef interface(creations/saving/restoring)\n
321 SALOMEDS methods : FindOrCreateAttribute,  SaveAs, FindComponent FindAttribute Open\n
322 Attribute methods : SetValue, Value
323 */