-
Notifications
You must be signed in to change notification settings - Fork 1
/
limatools.mac
969 lines (868 loc) · 26.1 KB
/
limatools.mac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
#%TITLE% limaroi.mac
#%NAME% LIMA CCD tools
#%DESCRIPTION%
# Tools to set/get LIMA CCD parameters, define those parameters as
# pseudo motors/counters if possible
#
#
#%END%
#%CATEGORY% Detection, Ccd
#%LOG%
#
#%IU% (ccdname)
#%MDESC%
# Check ccdname and exit if it does not exist
def _lima_checkccdname(ccdname) '{
if (list_check(LIMA_DEV, ccdname) <= 0) {
_lima_error; printf("<%s> is not a LIMA CCD device\n", ccdname)
exit
}
return ccdname
}'
#%IU% (ccdname, argname, pars)
#%MDESC%
# check argname and replay in ass. array pars["name"] and pars["index"]
# %BR% pars["index"] is set to -1 if no specific index is parsed in argname
#
def _limapar_checkarg(ccdname, argname, pars) '{
local found parname paridx arrname
# -- parse array syntax
if ((found= index(argname, "["))>0) {
parname= substr(argname, 1, found-1)
sscanf(substr(argname, found+1), "%d", paridx)
} else {
parname= argname
paridx= -1
}
# -- check parameter exist
arrname= LIMA_DEV[ccdname]["arrname"]
if (list_check(@arrname, parname)<=0) {
_lima_error; printf("Unknown parameters <%s>\n", parname)
exit
}
# -- if array index, check it
if (paridx != -1) {
if (@arrname[parname]["size"]<=1) {
_lima_error; printf("<%s> is not an array\n", parname)
exit
}
if (paridx > @arrname[parname]["size"]) {
_lima_error; printf("<%s> paridx should be in range [0..%d]\n", \
parname, @arrname[parname]["size"])
exit
}
}
# -- return pars
pars["name"]= parname
pars["index"]= paridx
}'
#%IU% (ccdname, argname, pars)
#%MDESC%
# Check if argname define a list of parameters.
#%BR% argname can be either "config" or any first string of lima parameters splitted by _
#
def _limapar_checkarglist(ccdname, argname, pars) '{
local npar ipar arrname vals[]
arrname= LIMA_DEV[ccdname]["arrname"]
npar= 0
if (argname == "config") {
for (ipar=1; ipar<=list_n(@arrname); ipar++) {
parname= list_item(@arrname, ipar)
if (@arrname[parname]["devtype"] == "config") {
pars[npar]= parname
npar += 1
}
}
return (npar)
}
for (ipar=1; ipar<=list_n(@arrname); ipar++) {
parname= list_item(@arrname, ipar)
if (@arrname[parname]["devtype"] == "control") {
if (split(parname, vals, "_") > 1) {
if (vals[0] == argname) {
pars[npar]= parname
npar += 1
}
}
}
}
return (npar)
}'
#%IU% (ccdname, propmask)
#%MDESC%
# Print a list of parameters (control or config) which has a specific property
#
def _limapar_printlist(ccdname, propmask) '{
local nval ival vals[]
local arrname str
arrname= LIMA_DEV[ccdname]["arrname"]
printf("<%s> parameters :\n", ccdname)
nval= _limapar_list(ccdname, "control", propmask, vals)
if (nval) {
printf("\n* \"control\" parameters :\n")
for (ival= 0; ival<nval; ival++) {
printf(" - %-20s (%s)\n", vals[ival], @arrname[vals[ival]]["desc"])
}
}
nval= _limapar_list(ccdname, "config", propmask, vals)
if (nval) {
printf("\n* \"config\" parameters :\n")
for (ival= 0; ival<nval; ival++) {
printf(" - %-20s (%s)\n", vals[ival], @arrname[vals[ival]]["desc"])
}
}
}'
#%UU% <ccdname> [<parname>]
#%MDESC%
# Without <parname>, print out all readable parmaters for CCD <ccdname>
#%BR% With valid <parname>, get parameter value for CCD <ccdname>.
#%BR% For array-type parameters :
#%BR% - use syntax <parname>[index] to print out one array value
#%BR% - use syntax <parname> to print all array values
#%BR% Examples:
#%BR% \t > %B%limaget%B% myccd shutter_mode
#%BR% \t > - shutter_mode = AUTO_SEQUENCE
#%BR% \t > %B%limaget%B% myccd threshold_noise
#%BR% \t > - threshold_noise = 6100 6200 6300 6400
#%BR% \t > %B%limaget%B% myccd threshold_noise[2]
#%BR% \t > - threshold_noise[2] = 6300
#%BR% Several parameters can be asked like:
#%BR% \t > %B%limaget%B% myccd saving_prefix saving_suffix
#%BR% You can also read some standard list of parameters:
#%BR% \t > %B%limaget%B% myccd config will print out all config parameters
#%BR% \t > %B%limaget%B% myccd saving will print out all control parameters of the form saving_*
#%BR% \t This can be applied to all lima pars (acq, acc, image, shutter, ...)
#
def limaget '{
if ($#<1) {
print "Usage: $0 <ccdname> [<parname1> <parname2> ...]"
exit
}
local ccdname
ccdname= _lima_checkccdname("$1")
if ($#==1) {
_limapar_printlist(ccdname, LP_READ)
} else {
local iarg narg args[]
local ipar npar pars[]
narg= split("$*", args)
for (iarg= 1; iarg<narg; iarg++) {
npar= _limapar_checkarglist(ccdname, args[iarg], pars)
if (npar > 1) {
for (ipar= 0; ipar<npar; ipar++) {
_limapar_printpar(ccdname, pars[ipar], -1)
}
}
else {
_limapar_checkarg(ccdname, args[iarg], pars)
_limapar_printpar(ccdname, pars["name"], pars["index"])
}
}
}
}'
def _limapar_printpar(ccdname, parname, paridx) '{
local arrname parsize partype
local str nval value
arrname= LIMA_DEV[ccdname]["arrname"]
parsize= @arrname[parname]["size"]
partype= @arrname[parname]["type"]
if ((parsize>1)&&(paridx==-1)) {
_limapar_initarr(parsize, partype)
nval= _limapar_get(ccdname, parname, paridx)
str= sprintf(" - %20s = ", parname)
for (ival=0; ival<nval; ival++) {
str= str LIMA_VALS[ival] " "
}
print str
} else {
value= _limapar_get(ccdname, parname, paridx)
value= (value==-1) ? "NONE" : value
str= sprintf(" - %20s = ", parname)
print str value
}
}'
#%UU% <ccdname> [<parname> [<value> ... <value>]]
#%MDESC%
# Without <parname>, print out all writable parmaters for CCD <ccdname>
#%BR% With valid <parname>:
#%BR% if <value> given, set parameter value to <value> for CCD <ccdname>.
#%BR% if <value> not given, ask for parameter new value and set it if different from the previous one.
#%BR% For array-type parameters :
#%BR% - use syntax <parname>[index] <value> to set one array value
#%BR% - use syntax <parname> <value1> ... <valueN> to set all array values
#%BR% Example:
#%BR% \t > %B%limaset%B% threshold_noise 6100 6200 6300 6400
#%BR% \t > %B%limaset%B% threshold_noise[2] 6300
#
def limaset '{
if ($#<1) {
print "Usage: $0 <ccdname> [<parname> [<value> ... <value>]]"
exit
}
local ccdname
ccdname= _lima_checkccdname("$1")
if ($#==1) {
_limapar_printlist(ccdname, LP_WRITE)
} else {
local parsize partype value parname paridx arrname
local iarg narg args[] pars[]
_limapar_checkarg(ccdname, "$2", pars)
arrname= LIMA_DEV[ccdname]["arrname"]
parname= pars["name"]
paridx = pars["index"]
parsize= @arrname[parname]["size"]
partype= @arrname[parname]["type"]
if (($#==2)&&(parsize==1)) {
value= _limapar_get(ccdname, parname)
_limapar_ask(ccdname, parname, value)
} else {
if ((paridx==-1)&&(parsize>1)) {
narg= split("$*", args)
if ((narg-2) != parsize) {
_lima_error; printf("Number of values should be <%s>\n", parsize)
} else {
_limapar_initarr(parsize, partype)
for (iarg= 2; iarg<narg; iarg++) {
LIMA_VALS[iarg-2]= args[iarg]
}
_limapar_set(ccdname, parname, LIMA_VALS, -1)
}
} else {
value= "$3"
if (value == value+0) {
_limapar_set(ccdname, parname, value*1., paridx)
} else {
_limapar_set(ccdname, parname, value, paridx)
}
}
}
}
}'
#%UU% <ccdname> [<parname>]
#%MDESC%
# For string-list type parameters, get the list of possible string values.
# %BR% if <parname> is omitted, print string list-type parameters of ccd <ccdname>
#
def limagetvaluelist '{
if ($#<1) {
print "Usage: $0 <ccdname> [<parname>]"
exit
}
local ccdname
ccdname= _lima_checkccdname("$1")
if ($#==1) {
_limapar_printlist(ccdname, LP_LIST)
} else {
local nval ival vals[] str pars[] parname
_limapar_checkarg(ccdname, "$2", pars)
parname= pars["name"]
nval= _limapar_getvaluelist(ccdname, parname, vals)
if (nval>0) {
printf("Possible values for <%s> are:\n", parname)
for (ival= 0; ival<nval; ival++) {
print " *", vals[ival]
}
} else if (nval==-1) {
_lima_error ccdname ; printf("Cannot get value list for <%s>\n", parname)
} else {
_lima_error ccdname ; printf("<%s> is not a value list type !!\n", parname)
}
}
}'
# -----------------------------------------------------------------------------
# PSEUDO MOTORS
# -----------------------------------------------------------------------------
#%IU%
#%MDESC%
#
def _limamot_init() '{
global LIMA_MOT[] LIMA_MOTON[]
list_test LIMA_MOT
cdef("user_getangles", "_limamot_getangles\n", "limamot")
cdef("user_checkall", "_limamot_moveall\n", "limamot")
}'
#%UU% <ccdname> [<parname> <mot_mne>]
#%MDESC%
# With all parameters, %BR%
# - setup parameter <parname> for CCD <ccdname> as pseudo motor <mot_mne>
#%BR% \t For array-type parameter, specify array index as parname[index]
#%BR% With only <ccdname> parameter: %BR%
# - print out list of parameters for CCD <ccdname> which can be set as pseudo-motors
#%BR%
#%B%Warning%B%: pseudo motors are used as soon as the device is responsive, no
# matter if %B%ccdon%B% has been set on that device. To activate/de-activate pseudo
# motors use the macros %B%limamoton/off%B%.
#
def limamotsetup '{
if (($#!=1)&&($#!=3)) {
print "Usage: $0 <ccdname> [<parname> <mot_mne>]"
print "Use $0 <ccdname> to get the list of parameters"
}
else if ($#==1) {
local ccdname
ccdname= _lima_checkccdname("$1")
_limapar_printlist(ccdname, LP_MOT)
}
else {
local motmne ccdname arrname parname paridx pars[]
ccdname= _lima_checkccdname("$1")
_limapar_checkarg(ccdname, "$2", pars)
arrname= LIMA_DEV[ccdname]["arrname"]
parname= pars["name"]
paridx = pars["index"]
motmne= "$3"
if (motor_num(motmne)==-1) {
_lima_error; printf("Invalid motor <%s>\n", motmne)
} else if ((@arrname[parname]["property"]&LP_MOT) != LP_MOT) {
_lima_error; printf("Cannot set <%s> as a motor\n", name)
} else {
_limamot_init()
list_add(LIMA_MOT, motmne)
LIMA_MOT[motmne]["ccdname"]= ccdname
LIMA_MOT[motmne]["parname"]= parname
LIMA_MOT[motmne]["paridx"]= paridx
LIMA_MOTON[ccdname]= 1
setup_tail("limamot", motmne)
}
}
}'
#%UU% [<motmne>]
#%MDESC%
# Remove <motmne> or all pseudo motors
#
def limamotunsetup '{
local motmne
if ($#==1) {
motmne= "$1"
list_remove(LIMA_MOT, motmne)
if (list_n(LIMA_MOT)<1) {
cdef("", "", "limamot", "delete")
}
} else {
list_init LIMA_MOT
cdef("", "", "limamot", "delete")
}
}'
#%IU% (ccdname)
#%MDESC%
# Remove all pseudo motors belonging to <ccdname>
def _limamot_reset(ccdname) '{
local imot nbdel todel[]
nbdel= 0
for (imot=1; imot<=list_n(LIMA_MOT); imot++) {
motmne= list_item(LIMA_MOT, imot)
if (LIMA_MOT[motmne]["ccdname"]==ccdname) {
todel[nbdel]= motmne
nbdel++
}
}
for (imot=0; imot<nbdel; imot++) {
list_remove(LIMA_MOT, todel[imot])
}
if (list_n(LIMA_MOT)<1) {
cdef("", "", "limamot", "delete")
}
}'
#%UU% [<ccdname>]
#%MDESC%
# activate all pseudo motors for all CCDs or just <ccdname>
#
def limamoton '{
if ($#==1) {
ccdname= "$1"
if (list_check(LIMA_DEV, ccdname)>=1)
LIMA_MOTON[ccdname]= 1
} else {
for (idev=1; idev<=list_n(LIMA_DEV); idev++) {
LIMA_MOTON[list_item(LIMA_DEV, idev)]= 1
}
}
}'
#%UU%
#%MDESC%
# set inactive all pseudo motors for all CCDs or just <ccdname>
#
def limamotoff '{
if ($#==1) {
ccdname= "$1"
if (list_check(LIMA_DEV, ccdname)>=1)
LIMA_MOTON[ccdname]= 0
} else {
for (idev=1; idev<= list_n(LIMA_DEV); idev++) {
LIMA_MOTON[list_item(LIMA_DEV, idev)]= 0
}
}
}'
#%IU%
def _limamot_getangles '{
local imot mmne mnum ccdunit value
local ccdname ccdunit
for (imot= 1; imot<=list_n(LIMA_MOT); imot++) {
mmne= list_item(LIMA_MOT, imot)
mnum= motor_num(mmne)
if ((mnum!=-1)&&(!motor_par(mnum, "disable"))) {
ccdname= LIMA_MOT[mmne]["ccdname"]
ccdunit= LIMA_DEV[ccdname]["unit"]
value= -1
if (LIMA_MOTON[ccdname] && image_par(ccdunit, "responsive")) {
value= _limapar_get(ccdname, LIMA_MOT[mmne]["parname"], LIMA_MOT[mmne]["paridx"])
}
LIMA_MOT[mmne]["old"]= value
LIMA_MOT[mmne]["err"]= (value == -1)
A[mnum]= LIMA_MOT[mmne]["old"]
}
}
}'
#%IU%
def _limamot_moveall '{
local imot mmne mnum
local ccdname
for (imot= 1; imot<=list_n(LIMA_MOT); imot++) {
mmne= list_item(LIMA_MOT, imot)
mnum= motor_num(mmne)
ccdname= LIMA_MOT[mmne]["ccdname"]
if ((LIMA_MOTON[ccdname]&&(mnum!=-1))&&(!motor_par(mnum, "disable"))) {
if ((!LIMA_MOT[mmne]["err"])&&(A[mnum]!=LIMA_MOT[mmne]["old"])) {
_limapar_set(ccdname, LIMA_MOT[mmne]["parname"], \
A[mnum], LIMA_MOT[mmne]["paridx"])
}
}
}
}'
# -----------------------------------------------------------------------------
# PSEUDO COUNTERS
# -----------------------------------------------------------------------------
#%IU%
def _limacnt_init() '{
global LIMA_CNT[]
list_test LIMA_CNT
cdef("user_getcounts", "_limacnt_getcounts\n", "limacnt", 0x10)
}'
#%UU% <ccdname> [<parname> <cnt_mne>]
#%MDESC%
# With all parameters, %BR%
# - setup parameter <parname> for CCD <ccdname> as pseudo motor <cnt_mne>
#%BR% \t For array-type parameter, specify array index as parname[index]
#%BR% With only <ccdname> parameter: %BR%
# - print out list of parameters for CCD <ccdname> which can be set as pseudo-counters
#%BR%
#%B%Warning%B%:
# Pseudo-counters are read depending if the CCD is activated with %B%ccdon%B%
#
def limacntsetup '{
if (($#!=1)&&($#!=3)) {
print "Usage: $0 <ccdname> [<parname> <cnt_mne>]"
print "Use $0 <ccdname> to get the list of parameters"
}
else if ($#==1) {
local ccdname
ccdname= _lima_checkccdname("$1")
_limapar_printlist(ccdname, LP_CNT)
}
else {
local cntmne ccdname arrname parname paridx pars[]
ccdname= _lima_checkccdname("$1")
_limapar_checkarg(ccdname, "$2", pars)
arrname= LIMA_DEV[ccdname]["arrname"]
parname= pars["name"]
paridx = pars["index"]
cntmne= "$3"
if (cnt_num(cntmne)==-1) {
_lima_error; printf("Invalid counter <%s>\n", cntmne)
} else if (@arrname[parname]["property"]&LP_CNT != LP_CNT) {
_lima_error; printf("Cannot set <%s> as a counter\n", name)
} else {
_limacnt_init()
list_add(LIMA_CNT, cntmne)
LIMA_CNT[cntmne]["ccdname"]= ccdname
LIMA_CNT[cntmne]["parname"]= parname
LIMA_CNT[cntmne]["paridx"]= paridx
setup_tail("limacnt", cntmne)
}
}
}'
#%UU% [<cnt_mne>]
#%MDESC%
# Remove pseudo counter <cnt_mne> or all pseudo counters
#
def limacntunsetup '{
local cmne cnum icnt
if ($#==1) {
cmne= "$1"
cnum= cnt_num(cmne)
list_remove(LIMA_CNT, cmne)
if (list_n(LIMA_CNT)<1) {
cdef("", "", "limacnt", "delete")
}
if (cnum!=-1) S[cnum]= 0
} else {
for (icnt=1; icnt<=list_n(LIMA_CNT); icnt++) {
cnum= cnt_num(list_item(LIMA_CNT, icnt))
if (cnum != -1) S[cnum]= 0
}
list_init LIMA_CNT
cdef("", "", "limacnt", "delete")
}
}'
#%IU% (ccdname)
#%MDESC%
# Remove all pseudo counters belonging to <ccdname>
#
def _limacnt_reset(ccdname) '{
for (icnt=1; icnt<=list_n(LIMA_CNT); icnt++) {
cmne= list_item(LIMA_CNT, icnt)
if (LIMA_CNT[cmne]["ccdname"]==ccdname) {
cnum= cnt_num(cmne)
if (cnum != -1) S[cnum]= 0
todel[nbdel]= cmne
nbdel++
}
}
for (icnt=0; icnt<nbdel; icnt++) {
list_remove(LIMA_CNT, todel[icnt])
}
if (list_n(LIMA_CNT)<1) {
cdef("", "", "limacnt", "delete")
}
LIMA_MOTON[ccdname]= 0
}'
#%IU%
def _limacnt_getcounts '{
local icnt cmne cnum ccdunit
for (icnt=1; icnt<=list_n(LIMA_CNT); icnt++) {
cmne= list_item(LIMA_CNT, icnt)
cnum= cnt_num(cmne)
if ((cnum!=-1)&&(!counter_par(cnum, "disable"))) {
ccdunit= LIMA_DEV[LIMA_CNT[cmne]["ccdname"]]["unit"]
if (CCD_ON[ccdunit]) {
S[cnum]= _limapar_get(LIMA_CNT[cmne]["ccdname"], LIMA_CNT[cmne]["parname"], \
LIMA_CNT[cmne]["paridx"])
} else {
S[cnum]= -1
}
}
}
}'
# -----------------------------------------------------------------------------
# WRITE STATS UTILS
# -----------------------------------------------------------------------------
#%UU% <ccdname>
#%MDESC%
# Print out write speed statistics
#
def limastat '{
local ccdname hlen nval
if ($# != 1) {
print "Usage: $0 <ccdname>"
exit
}
ccdname= _lima_checkccdname("$1")
hlen= _limapar_get(ccdname, "saving_statistics_history")
nval= _limapar_get(ccdname, "saving_statistics", -1)
if (nval == 4) {
_lima_trace ccdname
printf("Saving statistics (history max=%d)\n", hlen)
printf("* write speed = %.2f MB/sec\n", LIMA_VALS[0]/1024./1024.)
printf("* compression speed = %.2f MB/sec\n", LIMA_VALS[1]/1024./1024.)
printf("* compression ratio = %.3f\n", LIMA_VALS[2])
printf("* incoming speed = %.2f MB/sec\n", LIMA_VALS[3]/1024./1024.)
} else {
_lima_error ccdname
printf("Could not read statistics\n")
}
}'
# -----------------------------------------------------------------------------
# DEBUG UTILS
# -----------------------------------------------------------------------------
#%UU% <ccdname>
#%MDESC%
# Activate ALL debug types and modules on given lima server
#
def limadebugon '{
local ccdname
if ($# != 1) {
print "Usage: $0 <ccdname>"
exit
}
ccdname= _lima_checkccdname("$1")
_lima_debug_all(ccdname, 1)
}'
#%UU% <ccdname>
#%MDESC%
# De-activate ALL debug types and modules on given lima server
#
def limadebugoff '{
local ccdname
if ($# != 1) {
print "Usage: $0 <ccdname>"
exit
}
ccdname= _lima_checkccdname("$1")
_lima_debug_all(ccdname, 0)
}'
#%IU% (ccdname, onflag)
# Activate or remove all debug modules and types on lima server of ccdname
#
def _lima_debug_all(ccdname, onflag) '{
local debmod debmods[]
local debtype debtypes[]
_lima_debug_get(ccdname, "debug_modules", debmods)
for (debmod in debmods) {
debmods[debmod]= onflag
}
debmods["None"]=1
_lima_debug_set(ccdname, "debug_modules", debmods)
_lima_debug_get(ccdname, "debug_types", debtypes)
for (debtype in debtypes) {
debtypes[debtype]= onflag
}
debtypes["Fatal"]=1
_lima_debug_set(ccdname, "debug_types", debtypes)
}'
#%UU% <ccdname> [ <DebugModule|-DebugModule> ... ]
#%MDESC%
#Get/Set Lima debug modules:
#%BR%limadebugmodules <ccdname> will print out current debug modules
#%BR%limadebugmodules <ccdname> <DebugModule1> <DebugModule2> will
# activate debug modules <DebugModule1> <DebugModule2> without changing
# other already active debug modules
#%BR%limadebugmodules <ccdname> <-DebugModule1> will remove DebugModule1
# from debug output stream
#%BR%special key %B%All%B% or %B%-All%B% can be used to activate/remove
# all debug modules (all or ALL works also)
#%BR%Examples:
#%BR% > limadebugmodules pcoedge All -Hardware : will activate all debug modules
# except Harware ones
#%BR% > limadebugmodules pcoedge -All Common Control : will remove all debug
# modules and activate only Common and Control debug
#
def limadebugmodules '{
local ccdname narg args[]
if ($# == 0) {
print "Usage: $0 <ccdname> [ <DebugModule|-DebugModule> ... ]"
exit
}
ccdname= _lima_checkccdname("$1")
narg= split("$*", args)
_lima_debug(ccdname, "debug_modules", narg, args)
}'
#%UU% <ccdname> [ <DebugType|-DebugType> ... ]
#%MDESC%
#Get/Set Lima debug types:
#%BR%limadebugtypes <ccdname> will print out current debug types
#%BR%limadebugtypes <ccdname> <DebugType1> <DebugType2> will
# activate debug types <DebugType> <DebugType> without changing
# other already active debug types
#%BR%limadebugtypes <ccdname> <-DebugType> will remove DebugType
# from debug output stream
#%BR%special key %B%All%B% or %B%-All%B% can be used to activate/remove
# all debug types (all or ALL works also)
#%BR%Examples:
#%BR% > limadebugtypes pcoedge All -Trace : will activate all debug types
# except Trace ones
#%BR% > limadebugtypes pcoedge -All Warning Error : will remove all debug
# modules and activate only Warning and Error debug
#
def limadebugtypes '{
local ccdname narg args[]
if ($# == 0) {
print "Usage: $0 <ccdname> [ <DebugType|-DebugType> ... ]"
exit
}
ccdname= _lima_checkccdname("$1")
narg= split("$*", args)
_lima_debug(ccdname, "debug_types", narg, args)
}'
#%IU% (ccdname, attrname, narg, args)
#
def _lima_debug(ccdname, attrname, narg, args) '{
local debvals[] debname debstate
local iarg
_lima_debug_get(ccdname, attrname, debvals)
if (narg > 1) {
for (iarg=1; iarg<narg; iarg++) {
if (substr(args[iarg], 1, 1)=="-") {
debname= substr(args[iarg], 2)
debstate= 0
} else {
debname= args[iarg]
debstate= 1
}
if ((debname == "All") || (debname == "ALL") || (debname == "all")) {
for (debname in debvals) {
debvals[debname]= debstate
}
} else {
if (debname in debvals) {
debvals[debname]= debstate
} else {
printf("Invalid LIMA %s : %s\n", attrname, debname)
}
}
}
_lima_debug_set(ccdname, attrname, debvals)
}
printf("\nLIMA %s on <%s>:\n", attrname, ccdname)
for (name in debvals) {
printf(" - %15.15s : ", name)
tty_cntl("md")
printf("%s\n", debvals[name]==1 ? "YES" : "NO")
tty_cntl("me")
}
}'
#%IU% (ccdname, attrname, debvals)
#
def _lima_debug_get(ccdname, attrname, debvals) '{
local allvars[] vars[] dev allname
local nall iall nset iset
dev= LIMA_DEV[ccdname]["control"]
nset= tango_get(dev, attrname, vars)
if (TANGO_ERR == "API_EmptyDeviceAttribute") {
nset= 0
}
if ((nset==1)&&(vars["0"]=="")) {
nset= 0
}
allname= sprintf("%s_possible", attrname)
nall= tango_get(dev, allname, allvars)
if (TANGO_ERR == "API_EmptyDeviceAttribute") {
nall= 0
}
for (iall=0; iall<nall; iall++) {
debvals[allvars[iall]]= 0
}
for (iset=0; iset<nset; iset++) {
debvals[vars[iset]]= 1
}
}'
#%IU% (ccdname, attrname, debvals)
#
def _lima_debug_set(ccdname, attrname, debvals) '{
local vars[] dev name ivar
dev= LIMA_DEV[ccdname]["control"]
ivar= 0
for (name in debvals) {
if (debvals[name] == 1) {
vars[ivar]= name
ivar++
}
}
tango_put(dev, attrname, vars)
}'
# -----------------------------------------------------------------------------
# COMMON HEADER UTILS
# -----------------------------------------------------------------------------
#%UU% [motors] [machine] [counters]
#%MDESC%
# Put some standard stuff in user_limaacq_common_header:
#%BR% motors : will add all active motor positions
#%BR% counters : will add all active counters
#%BR% machine : add SRCURR and SRMODE (direct reading)
#
def limacommonheadersetup '{
local iarg narg argv[]
if (!$#) {
print "Usage: $0 [motors] [machine] [counters]"
exit
}
cdef("", "", "limachead", "delete")
narg= split("$*", argv)
for (iarg=1; iarg<narg; iarg++) {
if (argv[iarg]=="motors") {
cdef("user_limaacq_common_header", "_lima_common_header_motors;", "limachead")
}
else if (argv[iarg]=="machine") {
cdef("user_limaacq_common_header", "_lima_common_header_machine;", "limachead")
}
else if (argv[iarg]=="counters") {
cdef("user_limaacq_common_header", "_lima_common_header_counters;", "limachead")
}
}
setup_tail("limacommonheader")
}'
#%IU%
def limacommonheaderunsetup '{
cdef("", "", "limachead", "delete")
}'
def _lima_common_header_motors '{
local imot
for (imot=0; imot<MOTORS; imot++) {
if (is_using_motor(imot)) {
LIMA_COMMON_HEADER[sprintf("%s", motor_mne(imot))]= sprintf("%g", A[imot])
}
}
}'
#%IU%
def _lima_common_header_machine '{
local srcurr mode
srcurr= mi_SR_Current_fast()
mode= mi_mode()
LIMA_COMMON_HEADER["SRCURR"]= sprintf("%g", srcurr)
LIMA_COMMON_HEADER["SRMODE"]= sprintf("%s", mode)
}'
#%IU%
def _lima_common_header_counters '{
local icnt
for (icnt=0; icnt<COUNTERS; icnt++) {
if (is_using_counter(icnt)) {
LIMA_COMMON_HEADER[sprintf("%s", cnt_mne(icnt))]= sprintf("%g", S[icnt])
}
}
}'
# -----------------------------------------------------------------------------
# FRAME HEADER UTILS
# -----------------------------------------------------------------------------
#%UU%
#%MDESC%
# Put all counters in ass array %B%LIMA_FRAME_HEADER_DATA%B% in user_getcounts
# to be used by another spec session to update frame headers
#
def limaframeheaderserversetup '{
cdef("user_getcounts", "_lima_frame_header_server_update;", "limafhsrv", 0x20)
setup_tail("limaframeheaderserver")
}'
#%IU%
def limaframeheaderserverunsetup '{
cdef("", "", "limafhsrv", "delete")
}'
#%IU%
def _lima_frame_header_server_update '{
global LIMA_FRAME_HEADER_DATA[]
local icnt
for (icnt=0; icnt<COUNTERS; icnt++) {
if (is_using_counter(icnt)) {
LIMA_FRAME_HEADER_DATA[sprintf("%s", cnt_mne(icnt))]= sprintf("%f", S[icnt])
}
}
}'
#%UU%
#%MDESC%
# Hook to user_limaacq_frame_header reading counters of ass array %B%LIMA_FRAME_HEADER_DATA%B%
# from a remote spec session
#
def limaframeheaderremotesetup '{
if (!$#) {
print "Usage: $0 <remote_spec_session>"
exit
}
cmd= sprintf("_lima_frame_header_remote_update(\"%s\");", "$1")
cdef("user_limaacq_frame_header", cmd, "limafhrem")
setup_tail("limaframeheaderremote")
}'
#%IU%
def limaframeheaderremoteunsetup '{
cdef("", "", "limafhrem", "delete")
}'
#%IU%
def _lima_frame_header_remote_update(specname) '{
local head_data[]
local name
head_data= prop_get(specname, "var/LIMA_FRAME_HEADER_DATA")
for (name in head_data) {
LIMA_FRAME_HEADER[name]= head_data[name]
}
}'
#%MACROS%
#%IMACROS%
#%TOC%
#%AUTHOR% E.Papillon