shell_std_func.md 10.9 KB
Newer Older
Cyril Guilloud's avatar
Cyril Guilloud committed
1
2
# BLISS shell standard functions

Cyril Guilloud's avatar
Cyril Guilloud committed
3
4
Standard shell functions are automatically accessible in shell of any BLISS
session.
Cyril Guilloud's avatar
Cyril Guilloud committed
5
6
7
8

## motors

### move
9
* `move([<motor>, <position>]+)` or `mv([<motor>, <position>]+)`: moves one or
10
many motors to given position(s).
Cyril Guilloud's avatar
Cyril Guilloud committed
11

12
13
14
15
```
DEMO [10]: mv(simot1, 2)
DEMO [11]: mv(simot1, 3, spec_m3, 5)
```
Cyril Guilloud's avatar
Cyril Guilloud committed
16
17
18

NB: `move()` can take `wait=False` argument to be non-bloquant.

19
20
21
22
23
24
25
### mvd (dial move)
* `mvd([<motor>, <position>]+)`: moves motor(s) to given dial position(s).

```
DEMO [12]: mvd(simot1, 2, spec_m3, 4)
```

Cyril Guilloud's avatar
Cyril Guilloud committed
26
### umv (updated move)
27
* `umv([<motor>, <position>]+)`: same than `move([<motor>, <position>]+)` but
28
29
30
31
shows continuously updated positions of motors.

```
DEMO [13]: umv(simot1, 1, spec_m3, 4)
Cyril Guilloud's avatar
Cyril Guilloud committed
32

33
34
35
        simot1    spec_m3
user    0.390     3.258
dial    1.390     2.258
36
```
Cyril Guilloud's avatar
Cyril Guilloud committed
37

38
39
40
41
### umvd (updated dial move)
* `umvd([<motor>, <position>]+)`: same than `mvd([<motor>, <position>]+)` but
shows continuously updated positions of motors.

Cyril Guilloud's avatar
Cyril Guilloud committed
42
### mvr (relative move)
43
* `mvr([<motor>, <position>]+)`: move motor(s) relatively to current positions.
44
* `mvdr([<motor>, <position>]+)`: move motor(s) relatively to current dial positions.
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

```python
DEMO [5]: wa()
Current Positions (user, dial)

   simot1    spec_m3
 --------  ---------
  3.00000    7.00000
  3.00000    7.00000

DEMO [6]: mvr(simot1, 1, spec_m3, 2)

DEMO [7]: wa()
Current Positions (user, dial)

  simot1    spec_m3
--------  ---------
 4.00000    9.00000
 4.00000    9.00000
```

Cyril Guilloud's avatar
Cyril Guilloud committed
66
### umvr (updated relative move)
67
* `umvr([<motor>, <position_increment>]+)`: Same than `mvr()` but shows
68
continuously updated positions of motors.
Cyril Guilloud's avatar
Cyril Guilloud committed
69

70
71
```python
CC4 [4]: umvr(m1, 1)
72
73
74
        simot1
user    5.000
dial    4.000
75
```
Cyril Guilloud's avatar
Cyril Guilloud committed
76

77
78
79
80
### umvdr (updated dial relative move)
* `umdvr([<motor>, <position_increment>]+)`: Same than `mvdr()` but shows
continuously updated positions of motors.

81
### wa (where all)
82
* `wa()`: Shows user and dial positions of configured motors.
83
84
85
86
87
88
89
90
91
92

```python
 DEMO [2]: wa()
 Current Positions (user, dial)
 
 pzth      simot1    spec_m3
 ------  --------  ---------
 !ERR     1.10000    1.46150
 !ERR     1.10000    1.46150
```
Cyril Guilloud's avatar
Cyril Guilloud committed
93

Cyril Guilloud's avatar
Cyril Guilloud committed
94
### wm (where motor)
95
* `wm([<mot_name>]+)`: Show user, dial and offset values of positions and limits
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
for given motor(s).

```python
DEMO [2]: wm(m1, m2)

             m1[mm]          m2
-------  ----------  ----------
User
High      128.00000  -123.00000
Current     7.00000   -12.00000
Low      -451.00000   456.00000
Offset      5.00000     0.00000
Dial
High      123.00000   123.00000
Current     2.00000    12.00000
Low      -456.00000  -456.00000
```
Cyril Guilloud's avatar
Cyril Guilloud committed
113

114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129

### lsmot
* `lsmot()` : Print Motors configured in current session.

```python
DEMO [2]: lsmot()
Motors configured in current session:
-------------------------------------
att1z        bad              bsy        bsz        calc_mot1  calc_mot2
custom_axis  hooked_error_m0  hooked_m0  hooked_m1  jogger     m0
m1           omega            roby       robz       robz2      s1b
s1d          s1f              s1hg       s1ho       s1u        s1vg
s1vo
```


Cyril Guilloud's avatar
Cyril Guilloud committed
130
### sync
131
* `sync([<motor>]*)`: Force axes synchronization with the hardware. If no axis is
132
  given, it syncs all all axes present in the session
Cyril Guilloud's avatar
Cyril Guilloud committed
133

134
135
136
```python
DEMO [38]: sync(simot1)
```
Cyril Guilloud's avatar
Cyril Guilloud committed
137

Cyril Guilloud's avatar
Cyril Guilloud committed
138
### sta (all motors status)
139
* `sta()`: Show status of all configured motors.
Cyril Guilloud's avatar
Cyril Guilloud committed
140
141
142
143
144
145
146
147
148
149
150

```python
DEMO [13]: sta()
Axis     Status
-------  ----------------------
pzth     <status not available>
simot1   READY (Axis is READY)
spec_m3  READY (Axis is READY)
```

### stm (motors status)
151
* `stm(<mot>)`: Show status of motors given as parameters.
Cyril Guilloud's avatar
Cyril Guilloud committed
152
153
154
155
156
157
158
159
160

```python
DEMO [3]: stm(mm1, mm2)
Axis    Status
------  ---------------------
mm1     READY (Axis is READY)
mm2     READY (Axis is READY)
```

161
162
### rockit (rock a motor around current position)

163
* `rockit(mot, total_move):` Rock the motor **mot** around it's current
164
165
166
167
168
169
170
171
172
173
174
175
position +/- total_move/2.

i.e: Rock the motor mm1 during a ascan. At the end of the *context*,
the rocking will stop and the motor **mm1** will be moved back the
previous position.

```python
with rockit(mm1, 10):
     ascan(mm2,0,2,10,0.1,diode)

```

176
177
178
179
180
### tw (Tweak)
* `tw(<mot>)`: View motors in an user interface and move them
```python
tw(robz, roby, m0)
```
Cyril Guilloud's avatar
Cyril Guilloud committed
181

182
![Tweak screenshot](img/tweak_ui.png)
Cyril Guilloud's avatar
Cyril Guilloud committed
183
184
## counters

185
186
### lscnt (list counters)
* `lscnt()`:
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204

```python
DEMO [1]: lscnt()

Name                     Shape    Controller
-----------------------  -------  ------------
simct1                   0D       None
simct2                   0D       None
simct3                   0D       None
simct4                   0D       None
simul_mca.AuLa           0D       simul_mca
simul_mca.AuLa_det0      0D       simul_mca
simul_mca.AuLa_det1      0D       simul_mca
simul_mca.AuLa_det2      0D       simul_mca
simul_mca.AuLa_det3      0D       simul_mca
simul_mca.deadtime_det0  0D       simul_mca
simul_mca.deadtime_det1  0D       simul_mca
```
Cyril Guilloud's avatar
Cyril Guilloud committed
205
206


207
208
## Bliss Objects

209
210

### lsobj
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
* `lsobj()`: print the list of BLISS objects defined in a session. Can be used
  with usual jocker characters:

    - `*`: matches everything
    - `?`: matches any single character
    - `[seq]`: matches any character in seq
    - `[!seq]`: matches any character not in seq

Examples:
```python
TEST_SESSION [2]: lsobj("dio*")      # all objects starting by 'dio'
diode  diode2  diode3  diode4  diode5  diode6  diode7  diode8  diode9

TEST_SESSION [3]: lsobj("[abc]*")    # all objects starting by 'a', 'b' or 'c'
beamstop  att1  bad  calc_mot1  calc_mot2  custom_axis

TEST_SESSION [6]: lsobj("???")       # all objects with 3-lettres names
MG1  MG2  bad  s1b  s1d  s1f  s1u
```

231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277

### lsconfig

* `lsconfig()`: print the list of BLISS objects in config, not only objects
  declared in current session.

Example:
```python
DEMO [2]: lsconfig()

MeasurementGroup:
----------------
demo_counters  MG_tomo  MG_sim  MG_gauss  MG_align

MultiplePositions:
-----------------
beamstop  att1

Motor:
-----
wl_mono     u42c     u42b    spec_m3  pzth_enc  pzth      psho         pshg
psf         psb      motor7  motor6   mono      mme       mm_enc       mm9
mm8         mm7      mm6     mm5      mm4       mm3       mm2          mm16
mm15        mm14     mm13    mm12     mm11      mm10      mm1          mech1
mc2         mc1_enc  mc1     mbv4mot  m5        m4        m3           m2
m1          kbvo     kbvg    kbho     kbhg      ice2      ice1         gal
fsh         e_mono   dummy2  dummy1   calc_mot  blade_up  blade_front  blade_down
blade_back  bend_u   bend_d

None:
----
ser0                 out1     kb1      hpz_rx               hpz_off_2
hpz_off_1            hppstc2  hppstc1  controller_setting3  controller_setting2
controller_setting1

SimulationCounter:
-----------------
sim_ct_calib_gauss3  sim_ct_calib_gauss2  sim_ct_calib_gauss  sim_ct_5  sim_ct_4
sim_ct_3             sim_ct_2             sim_ct_1            ct1

Session:
-------
test_session demo  cyril
```



278
279
280
281
282
## Data Policy
* `newproposal()` `newsample()` `newdataset()`: Change the **proposal** **sample**
and **dataset** names used to determine the saving path.

For more info about these three functions, see [data policy
283
section](bliss_data_policy.md#directory-structure)
284
285
286
287


## Display

288
* `plotselect()`: select counter(s) to plot in [Flint](bliss_flint.md#command-line-selection)
289
290
291
292
293
294
295

* `clear()`: clear the screen.

* `silx_view()`: launch Silx View on last scan's data file.

* `pymca()`: launch PyMca on last scan's data file.

296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
## Dialogs

Some bliss objects can be used with dialogs.

To check if an object has dialogs implemented you can use the `menu` function.

Using `menu()` without further arguments will display all objects that has
dialogs implemented.

Using using `menu(object)` will launch the dialog with his effects. If more than
one dialog exists for the same object you can either pass the dialog name as a string
like `menu(lima_simulator, "saving")` or just use `menu(lima_simulator)` and first
you will select between available dialogs and than use the selected one.

Using

```python
TEST_SESSION [2]: menu()  
         Out [2]: Dialog available for the following objects:

                  ACTIVE_MG
                  MG1
                  MG2
                  ascan
                  lima_simulator
                  test_mg
                  transfocator_simulator
                  wago_simulator
                  ...

TEST_SESSION [3]: show(trasfocator_simulator)
                  .. HERE THE DIALOG DISPLAYS ..
         Out [3]: Transfocator transfocator_simulator:  # effects of dialog
                  P0  L1  L2   L3  L4   L5   L6  L7  L8
                  IN  IN  OUT  IN  OUT  OUT  IN  IN  IN

TEST_SESSION [4]: show(lima_simulator, "saving")
                  .. HERE THE DIALOG DISPLAYS ..
         Out [4]: # display of return status if present

TEST_SESSION [5]: show(lima_simulator)
                  .. HERE SUBMENU DIALOG DISPLAYS ..
                  .. THAN SELECTED DIALOG DISPLAYS ..
         Out [5]: # display of return status if present
```

342
343
344
345
346
347
348
349
350
351

## Wago Interlocks

* `interlock_show([wago]*)`: display interlocks info for given Wagos (for all
wagos if no parameter is given).

* `interlock_state()`: return a tuple containing the actual state of the
  interlocks.


Cyril Guilloud's avatar
Cyril Guilloud committed
352
353
## introspection, doc, logging

354
355
### Logging and Debug

356
* `lslog()`: display the list of [loggers](shell_logging.md#lslog).
357
358

* `lsdebug()`: display the list of [loggers currently in debug
359
  mode](shell_logging.md#lslog).
360
361

* `debugon()`/`debugoff()`: activate/deactivate
362
  [debug](shell_logging.md#debugon-debugoff) on a BLISS object.
363

Piergiorgio Pancino's avatar
Piergiorgio Pancino committed
364

365
### elog_print
Piergiorgio Pancino's avatar
Piergiorgio Pancino committed
366

367
`elog_print()` can be used like python's standard `print()` to send messages to the logbook.
Piergiorgio Pancino's avatar
Piergiorgio Pancino committed
368

369
### elog_add
Piergiorgio Pancino's avatar
Piergiorgio Pancino committed
370

371
372
373
374
375
The output from a previously execute command can be sent to the logbook
simply using `elog_add(num)`.
The parameter `num` con refer to the number of shell paragraph or be a
negative number relative to the current paragraph number.
If no parameter is specify the previous paragraph is sent (corresponds to -1).
376

377
Following an example sending to the logbook for three times the same output:
378
379

```python
380
381
382
383
384
385
386
387
388

TEST_SESSION [1]: transfocator_simulator
         Out [1]: Transfocator transfocator_simulator:
                  P0   L1  L2  L3  L4   L5  L6   L7  L8
                  OUT  IN  IN  IN  OUT  IN  OUT  IN  OUT

TEST_SESSION [2]: elog_add()  # adds previous paragraph (-1)
TEST_SESSION [3]: elog_add(1)  # can be used with reference to the paragraph number
TEST_SESSION [4]: elog_add(-3)  # can be also used with relative negative reference
389
```
Piergiorgio Pancino's avatar
Piergiorgio Pancino committed
390

391

Cyril Guilloud's avatar
Cyril Guilloud committed
392
### prdef (print definition)
393
* `prdef(<function>)`: Display information about given function :
Cyril Guilloud's avatar
Cyril Guilloud committed
394
395
 definition file, docstring and source code.

396
397
398
```python
CC4 [17]: prdef(umv)
'umv' is defined in:
399
/users/blissadm/..../site-packages/bliss/common/standard.py:217
Cyril Guilloud's avatar
Cyril Guilloud committed
400

401
402
403
404
def umv(*args):
    """
    Moves given axes to given absolute positions providing updated display of
    the motor(s) position(s) while it(they) is(are) moving.
Cyril Guilloud's avatar
Cyril Guilloud committed
405

406
407
408
409
    Arguments are interleaved axis and respective absolute target position.
    """
    __umove(*args)
```
Cyril Guilloud's avatar
Cyril Guilloud committed
410

411
412
413

### bench

414
* `bench()`: context manager to help benchmarking functions.
415

416
Example:
417
418
419
420
421
422

```python
DEMO [14]: with bench():
       ...:     time.sleep(1.987654)
Execution time: 1s 987ms 970μs
```