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