forked from gjover/Lima-tango
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LimaCCDs.py
2083 lines (1835 loc) · 67.3 KB
/
LimaCCDs.py
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
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
############################################################################
# This file is part of LImA, a Library for Image Acquisition
#
# Copyright (C) : 2009-2011
# European Synchrotron Radiation Facility
# BP 220, Grenoble 38043
# FRANCE
#
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
############################################################################
#=============================================================================
#
# file : LimaCCDs.py
#
# description : Python source for the LimaCCDs and its commands.
# The class is derived from Device. It represents the
# CORBA servant object which will be accessed from the
# network. All commands which can be executed on the
# LimaCCDs are implemented in this file.
#
# project : TANGO Device Server
#
# copyleft : European Synchrotron Radiation Facility
# BP 220, Grenoble 38043
# FRANCE
#
#=============================================================================
# This file is generated by seb
#
# (c) - BLISS - ESRF
#=============================================================================
#
import sys,os,glob
import PyTango
import weakref
import itertools
import numpy
import struct
# Before loading Lima.Core, must find out the version the plug-in
# was compiled with - horrible hack ...
if 'linux' in sys.platform:
from EnvHelper import setup_lima_env
setup_lima_env(sys.argv)
from Lima import Core
import plugins
import camera
try:
import EdfFile
except ImportError:
EdfFile = None
class LimaCCDs(PyTango.Device_4Impl) :
Core.DEB_CLASS(Core.DebModApplication, 'LimaCCDs')
_debugModuleList = ["None",
"Common",
"Hardware",
"HardwareSerial",
"Control",
"Espia",
"EspiaSerial",
"Focla",
"Camera",
"CameraCom",
"Test",
"Application"]
_debugTypeList = ["Fatal",
"Error",
"Warning",
"Trace",
"Funct",
"Param",
"Return",
"Always"]
#------------------------------------------------------------------
# Device constructor
#------------------------------------------------------------------
def __init__(self,*args) :
PyTango.Device_4Impl.__init__(self,*args)
self.__className2deviceName = {}
self.init_device()
self.__lima_control = None
self.__key_header_delimiter = '='
self.__entry_header_delimiter = '\n'
self.__image_number_header_delimiter = ';'
self.__readImage_frame_number = 0
#------------------------------------------------------------------
# Device destructor
#------------------------------------------------------------------
@Core.DEB_MEMBER_FUNCT
def delete_device(self) :
try:
m = __import__('camera.%s' % (self.LimaCameraType),None,None,'camera.%s' % (self.LimaCameraType))
except ImportError:
pass
else:
try:
m.close_interface()
except AttributeError: pass
#------------------------------------------------------------------
# Device initialization
#------------------------------------------------------------------
@Core.DEB_MEMBER_FUNCT
def init_device(self) :
self.set_state(PyTango.DevState.ON)
self.get_device_properties(self.get_device_class())
self.__className2deviceName = get_sub_devices()
dataBase = PyTango.Database()
try:
m = __import__('camera.%s' % (self.LimaCameraType),None,None,'camera.%s' % (self.LimaCameraType))
except ImportError:
import traceback
traceback.print_exc()
self.set_state(PyTango.DevState.FAULT)
else:
properties = {}
try:
specificClass,specificDevice = m.get_tango_specific_class_n_device()
except AttributeError: pass
else:
Core.DebParams.setTypeFlags(0)
util = PyTango.Util.instance()
deviceName = self.__className2deviceName.get(specificDevice.__name__,None)
if deviceName:
propertiesNames = dataBase.get_device_property_list(deviceName,"*")
for pName in propertiesNames.value_string:
key,value = dataBase.get_device_property(deviceName,pName).popitem()
if len(value) == 1:
value = value[0]
properties[key] = value
self.__control = m.get_control(**properties)
_set_control_ref(weakref.ref(self.__control))
try:
nb_thread = int(self.NbProcessingThread)
except ValueError:
pass
else:
Core.Processlib.PoolThreadMgr.get().setNumberOfThread(nb_thread)
self.__accThresholdCallback = None
accThresholdCallbackModule = self.AccThresholdCallbackModule
if not accThresholdCallbackModule:
# if NO property accThresholdCallbackModule has been set the member var. is set to []
pass
else:
try:
m = __import__('plugins.%s' % (accThresholdCallbackModule),None,None,
'plugins.%s' % (accThresholdCallbackModule))
except ImportError:
deb.Error("Couldn't import plugins.%s" % accThresholdCallbackModule)
else:
try:
func = getattr(m,'get_acc_threshold_callback')
self.__accThresholdCallback = func()
acc = self.__control.accumulation()
acc.registerThresholdCallback(self.__accThresholdCallback)
except AttributeError:
deb.Error("Accumulation threshold plugins module don't have get_acc_threshold_callback function")
#Tango Enum to Lima Enum
self.__Prefix2SubClass = {'acc' : self.__control.acquisition,
'acq' : self.__control.acquisition,
'shutter' : self.__control.shutter,
'saving' : self.__control.saving,
'image' : self.__control.image,
'video' : self.__control.video}
self.__Attribute2FunctionBase = {'acq_trigger_mode':'TriggerMode',
'saving_overwrite_policy' : 'OverwritePolicy',
'saving_format' : 'Format',
'shutter_mode' : 'Mode',
'image_rotation':'Rotation',
'video_mode':'Mode'}
self.__ShutterMode = {'MANUAL': Core.ShutterManual,
'AUTO_FRAME': Core.ShutterAutoFrame,
'AUTO_SEQUENCE': Core.ShutterAutoSequence}
self.__AcqMode = {'SINGLE': Core.Single,
'CONCATENATION': Core.Concatenation,
'ACCUMULATION': Core.Accumulation}
try:
self.__AccTimeMode = {'LIVE' : Core.CtAcquisition.Live,
'REAL' : Core.CtAcquisition.Real}
except AttributeError: # Core too Old
self.__AccTimeMode = {}
self.__SavingFormat = {'RAW' : Core.CtSaving.RAW,
'EDF' : Core.CtSaving.EDF,
'CBF' : Core.CtSaving.CBFFormat}
self.__SavingFormatDefaultSuffix = {Core.CtSaving.RAW : '.raw',
Core.CtSaving.EDF : '.edf',
Core.CtSaving.CBFFormat : '.cbf'}
self.__SavingMode = {'MANUAL' : Core.CtSaving.Manual,
'AUTO_FRAME' : Core.CtSaving.AutoFrame,
'AUTO_HEADER' : Core.CtSaving.AutoHeader}
self.__SavingOverwritePolicy = {'ABORT' : Core.CtSaving.Abort,
'OVERWRITE' : Core.CtSaving.Overwrite,
'APPEND' : Core.CtSaving.Append}
self.__AcqTriggerMode = {'INTERNAL_TRIGGER' : Core.IntTrig,
'EXTERNAL_TRIGGER' : Core.ExtTrigSingle,
'EXTERNAL_TRIGGER_MULTI' : Core.ExtTrigMult,
'EXTERNAL_GATE' : Core.ExtGate,
'EXTERNAL_START_STOP' : Core.ExtStartStop}
try:
self.__AcqTriggerMode['INTERNAL_TRIGGER_MULTI'] = Core.IntTrigMult
except AttributeError:
pass
try:
self.__AcqTriggerMode['EXTERNAL_TRIGGER_READOUT'] = Core.ExtTrigReadout
except AttributeError:
pass
try:
self.__ImageRotation = {'NONE' : Core.Rotation_0,
'90' : Core.Rotation_90,
'180' : Core.Rotation_180,
'270' : Core.Rotation_270}
except AttributeError:
pass
try:
self.__VideoMode = {'Y8' : Core.Y8,
'Y16' : Core.Y16,
'Y32' : Core.Y32,
'Y64' : Core.Y64,
'RGB555' : Core.RGB555,
'RGB565' : Core.RGB565,
'RGB24' : Core.RGB24,
'RGB32' : Core.RGB32,
'BGR24' : Core.BGR24,
'BGR32' : Core.BGR32,
'BAYER RG8' : Core.BAYER_RG8,
'BAYER RG16' : Core.BAYER_RG16,
'I420' : Core.I420,
'YUV411' : Core.YUV411,
'YUV422' : Core.YUV422,
'YUV444' : Core.YUV444}
except AttributeError:
import traceback
traceback.print_exc()
#INIT display shared memory
try:
self.__shared_memory_names = ['LimaCCds',self.LimaCameraType]
shared_memory = self.__control.display()
shared_memory.setNames(*self.__shared_memory_names)
except AttributeError:
self.__shared_memory_names = ['','']
def __getattr__(self,name) :
if name.startswith('is_') and name.endswith('_allowed') :
split_name = name.split('_')[1:-1]
attr_name = ''.join([x.title() for x in split_name])
dict_name = '_' + self.__class__.__name__ + '__' + attr_name
d = getattr(self,dict_name,None)
func = _allowed
if d is not None:
if not d:
func = _not_allowed
self.__dict__[name] = func
return func
elif name.startswith('read_') or name.startswith('write_') :
split_name = name.split('_')[1:]
attr_name = ''.join([x.title() for x in split_name])
dict_name = '_' + self.__class__.__name__ + '__' + attr_name
d = getattr(self,dict_name,None)
getObjectFunc = self.__Prefix2SubClass.get(split_name[0],None)
attr_name = self.__Attribute2FunctionBase.get('_'.join(split_name),attr_name)
if d and getObjectFunc:
obj = getObjectFunc()
if name.startswith('read_') :
functionName = 'get' + attr_name
function2Call = getattr(obj,functionName)
callable_obj = CallableReadEnum(d,function2Call)
else:
functionName = 'set' + attr_name
function2Call = getattr(obj,functionName)
callable_obj = CallableWriteEnum('_'.join(split_name),
d,function2Call)
self.__dict__[name] = callable_obj
return callable_obj
raise AttributeError('LimaCCDs has no attribute %s' % name)
#==================================================================
#
# LimaCCDs read/write attribute methods
#
#==================================================================
## @brief Read the Lima Type
#
@Core.DEB_MEMBER_FUNCT
def read_lima_type(self,attr) :
value = self.LimaCameraType
attr.set_value(value)
## @brief Read the Camera Type
#
@Core.DEB_MEMBER_FUNCT
def read_camera_type(self,attr) :
interface = self.__control.hwInterface()
det_info = interface.getHwCtrlObj(Core.HwCap.DetInfo)
value = det_info.getDetectorType()
attr.set_value(value)
## @brief Read the Camera Model
#
@Core.DEB_MEMBER_FUNCT
def read_camera_model(self,attr) :
interface = self.__control.hwInterface()
det_info = interface.getHwCtrlObj(Core.HwCap.DetInfo)
value = det_info.getDetectorModel()
attr.set_value(value)
## @brief Read the Camera pixelsize
#
@Core.DEB_MEMBER_FUNCT
def read_camera_pixelsize(self,attr) :
interface = self.__control.hwInterface()
det_info = interface.getHwCtrlObj(Core.HwCap.DetInfo)
value = det_info.getPixelSize()
attr.set_value(value)
## @brief get the status of the acquisition
#
@Core.DEB_MEMBER_FUNCT
def read_acq_status(self,attr) :
status = self.__control.getStatus()
state2string = {Core.AcqReady : "Ready",
Core.AcqRunning : "Running",
Core.AcqFault : "Fault"}
try:
state2string[Core.AcqConfig] = "Configuration"
except AttributeError:
pass
attr.set_value(state2string.get(status.AcquisitionStatus,"?"))
## @brief get the errir message when acq_status is in Fault stat
#
@Core.DEB_MEMBER_FUNCT
def read_acq_status_fault_error(self,attr) :
status = self.__control.getStatus()
state2string = {Core.CtControl.NoError : "No error",
Core.CtControl.SaveUnknownError : "Saving: unknown error",
Core.CtControl.SaveOpenError : "Saving: file open error",
Core.CtControl.SaveCloseError : "Saving: file close error",
Core.CtControl.SaveAccessError : "Saving: access error",
Core.CtControl.SaveOverwriteError : "Saving: overwrite error",
Core.CtControl.SaveDiskFull : "Saving: disk full",
Core.CtControl.SaveOverun : "Saving: overun",
Core.CtControl.ProcessingOverun : "Processing: overun",
Core.CtControl.CameraError : "Camera: error"}
attr.set_value(state2string.get(status.Error,"?"))
## @brief read the number of frame for an acquisition
#
@Core.DEB_MEMBER_FUNCT
def read_acq_nb_frames(self,attr) :
acquisition = self.__control.acquisition()
nb_frames = acquisition.getAcqNbFrames()
attr.set_value(nb_frames)
## @brief write the number of frame for an acquisition
#
@Core.DEB_MEMBER_FUNCT
def write_acq_nb_frames(self,attr) :
data = []
attr.get_write_value(data)
acquisition = self.__control.acquisition()
acquisition.setAcqNbFrames(data[0])
## @brief read the number of frame for an acquisition
#
@Core.DEB_MEMBER_FUNCT
def read_acq_expo_time(self,attr) :
acquisition = self.__control.acquisition()
expo_time = acquisition.getAcqExpoTime()
attr.set_value(expo_time)
## @brief write the number of frame for an acquisition
#
@Core.DEB_MEMBER_FUNCT
def write_acq_expo_time(self,attr) :
data = []
attr.get_write_value(data)
acquisition = self.__control.acquisition()
acquisition.setAcqExpoTime(data[0])
## @brief Read maximum accumulation exposure time
#
@Core.DEB_MEMBER_FUNCT
def read_acc_max_expo_time(self,attr) :
acq = self.__control.acquisition()
value = acq.getAccMaxExpoTime()
if value is None: value = -1
attr.set_value(value)
## @brief Write the accumulation max exposure time
#
@Core.DEB_MEMBER_FUNCT
def write_acc_max_expo_time(self,attr) :
data = []
attr.get_write_value(data)
acq = self.__control.acquisition()
acq.setAccMaxExpoTime(*data)
## @brief Read maximum accumulation exposure time
#
@Core.DEB_MEMBER_FUNCT
def read_concat_nb_frames(self,attr) :
acq = self.__control.acquisition()
value = acq.getConcatNbFrames()
attr.set_value(value)
## @brief Write the accumulation max exposure time
#
@Core.DEB_MEMBER_FUNCT
def write_concat_nb_frames(self,attr) :
data = []
attr.get_write_value(data)
acq = self.__control.acquisition()
acq.setConcatNbFrames(*data)
## @brief Read calculated accumulation exposure time
#
@Core.DEB_MEMBER_FUNCT
def read_acc_expo_time(self,attr) :
acq = self.__control.acquisition()
value = acq.getAccExpoTime()
if value is None: value = -1
attr.set_value(value)
## @brief Read calculated accumulation number of frames
#
@Core.DEB_MEMBER_FUNCT
def read_acc_nb_frames(self,attr) :
acq = self.__control.acquisition()
value = acq.getAccNbFrames()
if value is None: value = -1
attr.set_value(value)
## @brief Read calculated accumulation dead time
#
@Core.DEB_MEMBER_FUNCT
def read_acc_dead_time(self,attr) :
acq = self.__control.acquisition()
value = acq.getAccDeadTime()
attr.set_value(value)
## @brief Read calculated accumulation live time
#
@Core.DEB_MEMBER_FUNCT
def read_acc_live_time(self,attr) :
acq = self.__control.acquisition()
value = acq.getAccLiveTime()
attr.set_value(value)
## @brief Read if saturated calculation is active
#
@Core.DEB_MEMBER_FUNCT
def read_acc_saturated_active(self,attr) :
acc = self.__control.accumulation()
value = acc.getActive()
attr.set_value(value)
## @brief active/unactive calculation of saturated images and counters
#
@Core.DEB_MEMBER_FUNCT
def write_acc_saturated_active(self,attr) :
data = []
attr.get_write_value(data)
acc = self.__control.accumulation()
acc.setActive(data[0])
## @brief Read saturated threshold
#
@Core.DEB_MEMBER_FUNCT
def read_acc_saturated_threshold(self,attr) :
acc = self.__control.accumulation()
value = acc.getPixelThresholdValue()
attr.set_value(value)
## @brief Set saturated threshold
#
@Core.DEB_MEMBER_FUNCT
def write_acc_saturated_threshold(self,attr) :
data = []
attr.get_write_value(data)
acc = self.__control.accumulation()
acc.setPixelThresholdValue(data[0])
## @brief Read if saturated calculation is active
#
@Core.DEB_MEMBER_FUNCT
def read_acc_saturated_cblevel(self,attr) :
if self.__accThresholdCallback is not None:
attr.set_value(self.__accThresholdCallback.m_max)
else:
msg = "Accumulation threshold plugins not loaded"
deb.Error(msg)
raise Exception, msg
## @brief active/unactive calculation of saturated images and counters
#
@Core.DEB_MEMBER_FUNCT
def write_acc_saturated_cblevel(self,attr) :
data = []
attr.get_write_value(data)
if self.__accThresholdCallback is not None:
self.__accThresholdCallback.m_max = data[0]
else:
msg = "Accumulation threshold plugins not loaded"
deb.Error(msg)
raise Exception, msg
## @brief Read latency time
#
@Core.DEB_MEMBER_FUNCT
def read_latency_time(self,attr) :
acq = self.__control.acquisition()
value = acq.getLatencyTime()
if value is None: value = -1
attr.set_value(value)
## @brief Write Latency time
#
@Core.DEB_MEMBER_FUNCT
def write_latency_time(self,attr) :
data = []
attr.get_write_value(data)
acq = self.__control.acquisition()
acq.setLatencyTime(*data)
## @brief Read image Roi
#
@Core.DEB_MEMBER_FUNCT
def read_image_roi(self,attr) :
image = self.__control.image()
roi = image.getRoi()
point = roi.getTopLeft()
size = roi.getSize()
attr.set_value([point.x,point.y,
size.getWidth(),size.getHeight()])
## @brief Write image Roi
#
@Core.DEB_MEMBER_FUNCT
def write_image_roi(self,attr) :
data = []
attr.get_write_value(data)
image = self.__control.image()
roi = Core.Roi(*data)
image.setRoi(roi)
## @brief Read image type
#
@Core.DEB_MEMBER_FUNCT
def read_image_sizes(self,attr) :
imageType2NbBytes = {
Core.Bpp8 : (1,0) ,
Core.Bpp8S : (1,1) ,
Core.Bpp10 : (2,0) ,
Core.Bpp10S : (2,1) ,
Core.Bpp12 : (2,0) ,
Core.Bpp12S : (2,1) ,
Core.Bpp14 : (2,0) ,
Core.Bpp14S : (2,1) ,
Core.Bpp16 : (2,0),
Core.Bpp16S : (2,1),
Core.Bpp32 : (4,0) ,
Core.Bpp32S : (4,1)
}
image = self.__control.image()
imageType = image.getImageType()
dim = image.getImageDim()
depth, signed = imageType2NbBytes.get(imageType,(0,0))
sizes = [signed, depth, dim.getSize().getWidth(), dim.getSize().getHeight()]
attr.set_value(sizes)
## @brief Read image type
#
@Core.DEB_MEMBER_FUNCT
def read_image_type(self,attr) :
imageType2String = {
Core.Bpp8 : "Bpp8" ,
Core.Bpp8S : "Bpp8S" ,
Core.Bpp10 : "Bpp10" ,
Core.Bpp10S : "Bpp10S" ,
Core.Bpp12 : "Bpp12" ,
Core.Bpp12S : "Bpp12S" ,
Core.Bpp14 : "Bpp14" ,
Core.Bpp14S : "Bpp14S" ,
Core.Bpp16 : "Bpp16" ,
Core.Bpp16S : "Bpp16S" ,
Core.Bpp32 : "Bpp32" ,
Core.Bpp32S : "Bpp32S"
}
image = self.__control.image()
imageType = image.getImageType()
stringType = imageType2String.get(imageType,"?")
attr.set_value(stringType)
## @brief Read image width
#
@Core.DEB_MEMBER_FUNCT
def read_image_width(self,attr) :
image = self.__control.image()
dim = image.getImageDim()
attr.set_value(dim.getSize().getWidth())
## @brief Read image height
#
@Core.DEB_MEMBER_FUNCT
def read_image_height(self,attr) :
image = self.__control.image()
dim = image.getImageDim()
attr.set_value(dim.getSize().getHeight())
## @brief Read image binning
#
@Core.DEB_MEMBER_FUNCT
def read_image_bin(self,attr) :
image = self.__control.image()
binValues = image.getBin()
attr.set_value([binValues.getX(),
binValues.getY()],2)
## @brief Write image binning
#
@Core.DEB_MEMBER_FUNCT
def write_image_bin(self,attr) :
data = []
attr.get_write_value(data)
image = self.__control.image()
binValue = Core.Bin(*data)
image.setBin(binValue)
## @brief Read image flip
#
@Core.DEB_MEMBER_FUNCT
def read_image_flip(self,attr) :
image = self.__control.image()
flip = image.getFlip()
attr.set_value([flip.x,flip.y],2)
## @brief Write image flip
#
@Core.DEB_MEMBER_FUNCT
def write_image_flip(self,attr) :
data = []
attr.get_write_value(data)
flip = Core.Flip(*data)
image = self.__control.image()
image.setFlip(flip)
## @brief Read common header
#
@Core.DEB_MEMBER_FUNCT
def read_saving_common_header(self,attr) :
saving = self.__control.saving()
header = saving.getCommonHeader()
headerArr = ['%s%s%s' % (k,self.__key_header_delimiter,v) for k,v in header.iteritems()]
attr.set_value(headerArr,len(headerArr))
## @brief Write common header
#
@Core.DEB_MEMBER_FUNCT
def write_saving_common_header(self,attr) :
data = []
attr.get_write_value(data)
header = dict([x.split(self.__key_header_delimiter) for x in data])
saving = self.__control.saving()
saving.setCommonHeader(header)
## @brief Read header delimiter
#
@Core.DEB_MEMBER_FUNCT
def read_saving_header_delimiter(self,attr) :
attr.set_value([self.__key_header_delimiter,
self.__entry_header_delimiter,
self.__image_number_header_delimiter],3)
##@brief Write header delimiter
#
def write_saving_header_delimiter(self,attr) :
data = []
attr.get_write_value(data)
self.__key_header_delimiter = data[0]
self.__entry_header_delimiter = data[1]
self.__image_number_header_delimiter = data[2]
def read_saving_index_format(self,attr) :
saving = self.__control.saving()
params = saving.getParameters()
attr.set_value(params.indexFormat)
def write_saving_index_format(self,attr) :
data = []
attr.get_write_value(data)
saving = self.__control.saving()
params = saving.getParameters()
params.indexFormat = data[0]
saving.setParameters(params)
## @brief last image acquired
#
@Core.DEB_MEMBER_FUNCT
def read_last_image_acquired(self,attr) :
status = self.__control.getStatus()
img_counters = status.ImageCounters
value = img_counters.LastImageAcquired
attr.set_value(value)
## @brief last base image acquired
#
@Core.DEB_MEMBER_FUNCT
def read_last_base_image_ready(self,attr) :
status = self.__control.getStatus()
img_counters = status.ImageCounters
value = img_counters.LastBaseImageReady
attr.set_value(value)
## @brief Read last image ready
#
@Core.DEB_MEMBER_FUNCT
def read_last_image_ready(self,attr) :
status = self.__control.getStatus()
img_counters= status.ImageCounters
value = img_counters.LastImageReady
attr.set_value(value)
## @brief last counter ready
#
@Core.DEB_MEMBER_FUNCT
def read_last_counter_ready(self,attr) :
status = self.__control.getStatus()
img_counters= status.ImageCounters
value = img_counters.LastCounterReady
attr.set_value(value)
## @brief Read last image saved
#
@Core.DEB_MEMBER_FUNCT
def read_last_image_saved(self,attr) :
status = self.__control.getStatus()
img_counters= status.ImageCounters
value = img_counters.LastImageSaved
if value is None: value = -1
attr.set_value(value)
## @brief this flag is true just after
# the detector readout.
#
# This attribute should be use
# to test is client can re-trigger an other image
@Core.DEB_MEMBER_FUNCT
def read_ready_for_next_image(self,attr) :
interface = self.__control.hwInterface()
status = interface.getStatus()
attr.set_value(status.det == Core.DetIdle)
## @brief this flag is true when acquisition is finished
#
@Core.DEB_MEMBER_FUNCT
def read_ready_for_next_acq(self,attr) :
status = self.__control.getStatus()
attr.set_value(status.AcquisitionStatus == Core.AcqReady)
## @brief read write statistic
#
@Core.DEB_MEMBER_FUNCT
def read_write_statistic(self,attr) :
saving = self.__control.saving()
stat = saving.getWriteTimeStatistic()
if not len(stat) :
attr.set_value([-1],1)
else:
attr.set_value(stat,len(stat))
## @brief Read current shutter state
# True-Open, False-Close
@Core.DEB_MEMBER_FUNCT
def read_shutter_manual_state(self,attr) :
shutter = self.__control.shutter()
if shutter.hasCapability() and shutter.getModeList().count(Core.ShutterManual):
if shutter.getState(): state = "OPEN"
else: state = "CLOSED"
else:
state = "NO_MANUAL_MODE"
attr.set_value(value)
## @brief Read shutter open time
# True-Open, False-Close
@Core.DEB_MEMBER_FUNCT
def read_shutter_open_time(self,attr) :
shutter = self.__control.shutter()
value = shutter.getOpenTime()
if value is None: value = -1
attr.set_value(value)
## @brief Write shutter open time
#
@Core.DEB_MEMBER_FUNCT
def write_shutter_open_time(self,attr) :
data = []
attr.get_write_value(data)
shutter = self.__control.shutter()
shutter.setOpenTime(*data)
## @brief Read shutter close time
# in seconds
@Core.DEB_MEMBER_FUNCT
def read_shutter_close_time(self,attr) :
shutter = self.__control.shutter()
value = shutter.getCloseTime()
if value is None: value = -1
attr.set_value(value)
## @brief Write shutter close time
# in seconds
@Core.DEB_MEMBER_FUNCT
def write_shutter_close_time(self,attr) :
data = []
attr.get_write_value(data)
shutter = self.__control.shutter()
shutter.setCloseTime(*data)
@Core.DEB_MEMBER_FUNCT
def read_saving_directory(self,attr) :
saving = self.__control.saving()
attr.set_value(saving.getDirectory())
@Core.DEB_MEMBER_FUNCT
def write_saving_directory(self,attr) :
data = []
attr.get_write_value(data)
saving = self.__control.saving()
newDirectory = data[0]
if os.access(newDirectory,os.W_OK|os.X_OK) :
saving.setDirectory(newDirectory)
else:
PyTango.Except.throw_exception('Access Error',\
'Directory %s is not writtable'%(newDirectory),\
'LimaCCD Class')
@Core.DEB_MEMBER_FUNCT
def read_saving_prefix(self,attr) :
saving = self.__control.saving()
attr.set_value(saving.getPrefix())
@Core.DEB_MEMBER_FUNCT
def write_saving_prefix(self,attr) :
data = []
attr.get_write_value(data)
saving = self.__control.saving()
prefix = data[0]
directory = saving.getDirectory()
suffix = saving.getSuffix()
overwritePolicy = saving.getOverwritePolicy()
if overwritePolicy == Core.CtSaving.Abort:
matchFiles = glob.glob(os.path.join(directory,'%s*%s' % (prefix,suffix)))
lastnumber = _getLastFileNumber(prefix,suffix,matchFiles)
else:
lastnumber = -1
saving.setPrefix(prefix)
saving.setNextNumber(lastnumber + 1)
@Core.DEB_MEMBER_FUNCT
def read_saving_suffix(self,attr) :
saving = self.__control.saving()
attr.set_value(saving.getSuffix())
@Core.DEB_MEMBER_FUNCT
def write_saving_suffix(self,attr) :
data = []
attr.get_write_value(data)
saving = self.__control.saving()
saving.setSuffix(*data)
@Core.DEB_MEMBER_FUNCT
def read_saving_next_number(self,attr) :
saving = self.__control.saving()
attr.set_value(saving.getNextNumber())
@Core.DEB_MEMBER_FUNCT
def write_saving_next_number(self,attr) :
data = []
attr.get_write_value(data)
saving = self.__control.saving()
saving.setNextNumber(*data)
@Core.DEB_MEMBER_FUNCT
def read_saving_frame_per_file(self,attr) :
saving = self.__control.saving()
attr.set_value(saving.getFramePerFile())
@Core.DEB_MEMBER_FUNCT
def write_saving_frame_per_file(self,attr) :
data = []
attr.get_write_value(data)
saving = self.__control.saving()
saving.setFramesPerFile(*data)
## @brief Change the saving Format
#
@Core.DEB_MEMBER_FUNCT
def write_saving_format(self,attr) :
data = []
attr.get_write_value(data)
saving = self.__control.saving()
value = _getDictValue(self.__SavingFormat,data[0].upper())
if value is None:
PyTango.Except.throw_exception('WrongData',\
'Wrong value %s: %s'%('saving_format',data[0].upper()),\
'LimaCCD Class')