Eiger.py 9.94 KB
Newer Older
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
############################################################################
# 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 :        Eiger.py
#
# description : Python source for the Eiger 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
#                Eiger are implemented in this file.
#
# project :     TANGO Device Server
#
# copyleft :    European Synchrotron Radiation Facility
#               BP 220, Grenoble 38043
#               FRANCE
#
#=============================================================================
#          This file is generated by POGO
#    (Program Obviously used to Generate tango Object)
#
#         (c) - Software Engineering Group - ESRF
#=============================================================================
#


import PyTango
import sys

from Lima import Core
from Lima.Server import AttrHelper

#==================================================================
#   Eiger Class Description:
#
#
#==================================================================


class Eiger(PyTango.Device_4Impl):

#--------- Add you global variables here --------------------------
    Core.DEB_CLASS(Core.DebModApplication, 'LimaCCDs')

#------------------------------------------------------------------
#    Device constructor
#------------------------------------------------------------------
    def __init__(self,cl, name):
        PyTango.Device_4Impl.__init__(self,cl,name)
        self.init_device()

72
73
        self.__ApiGeneration = {'Eiger1': EigerAcq.Camera.Eiger1,
                                'Eiger2': EigerAcq.Camera.Eiger2}
74
75
76
77
78
79
80
81
82
83
84
85
        self.__CountrateCorrection = {'ON':True,
                                      'OFF':False}
        self.__FlatfieldCorrection = {'ON':True,
                                      'OFF':False}
        self.__AutoSummation = {'ON':True,
                                'OFF':False}
        self.__EfficiencyCorrection = {'ON':True,
                                       'OFF':False}
        self.__VirtualPixelCorrection = {'ON':True,
                                         'OFF':False}
        self.__PixelMask = {'ON':True,
                            'OFF':False}
86
87
        self.__CompressionType = {'NONE': EigerAcq.Camera.NoCompression,
                                  'LZ4': EigerAcq.Camera.LZ4,
88
                                  'BSLZ4': EigerAcq.Camera.BSLZ4}
89
90
91
        self.__Status = {'INITIALIZING': EigerAcq.Camera.Initializing,
                         'READY': EigerAcq.Camera.Ready,
                         'ARMED': EigerAcq.Camera.Armed,
92
93
                         'EXPOSURE': EigerAcq.Camera.Exposure,
                         'FAULT': EigerAcq.Camera.Fault}
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

#------------------------------------------------------------------
#    Device destructor
#------------------------------------------------------------------
    def delete_device(self):
        pass


#------------------------------------------------------------------
#    Device initialization
#------------------------------------------------------------------
    def init_device(self):
        self.set_state(PyTango.DevState.ON)
        self.get_device_properties(self.get_device_class())

#------------------------------------------------------------------
#    getAttrStringValueList command:
#
#    Description: return a list of authorized values if any
#    argout: DevVarStringArray
#------------------------------------------------------------------
    @Core.DEB_MEMBER_FUNCT
    def getAttrStringValueList(self, attr_name):
        return AttrHelper.get_attr_string_value_list(self,attr_name)

#==================================================================
#
#    Eiger read/write attribute methods
#
#==================================================================
    def __getattr__(self,name) :
125
126
        if name == 'read_plugin_status':
            name = 'read_status'
127
128
        return AttrHelper.get_attr_4u(self,name,_EigerCamera)

129
130
131
132
133
134
135
136
137
138
139
140
141
#==================================================================
#
#    stream_last_info
#
#==================================================================
    @Core.DEB_MEMBER_FUNCT
    def read_stream_last_info(self, attr):
        last_info = _EigerInterface.getLastStreamInfo()
        last_info_strarr = [str(last_info.encoding),
                            str(last_info.frame_dim),
                            str(last_info.packed_size)]
        attr.set_value(last_info_strarr)

142
143
144
145
146
147
#==================================================================
#
#    Eiger command methods
#
#==================================================================

148
149
150
151
152
153
154
155
156
157
158
159
160
161
#----------------------------------------------------------------------------
#                      delete all memory files
#----------------------------------------------------------------------------
    @Core.DEB_MEMBER_FUNCT
    def deleteMemoryFiles(self):
        _EigerCamera.deleteMemoryFiles()

#----------------------------------------------------------------------------
#                      initialize detector
#----------------------------------------------------------------------------
    @Core.DEB_MEMBER_FUNCT
    def initialize(self):
        _EigerCamera.initialize()

162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#==================================================================
#
#    EigerClass class definition
#
#==================================================================
class EigerClass(PyTango.DeviceClass):

    #    Class Properties
    class_property_list = {
        }


    #    Device Properties
    device_property_list = {
        'detector_ip_address':
        [PyTango.DevString,
         "Detector ip address",[]],
179
180
181
        'api_generation':
        [PyTango.DevString,
         "Detector API generation: Eiger1, Eiger2",[]],
182
183
184
185
186
187
188
189
190
        }


    #    Command definitions
    cmd_list = {
        'getAttrStringValueList':
        [[PyTango.DevString, "Attribute name"],
         [PyTango.DevVarStringArray, "Authorized String value list"]],
        'deleteMemoryFiles':
191
192
193
        [[PyTango.DevVoid, ""],
         [PyTango.DevVoid, ""]],
        'initialize':
194
195
196
197
198
199
200
        [[PyTango.DevVoid, ""],
         [PyTango.DevVoid, ""]],
        }


    #    Attribute definitions
    attr_list = {
201
202
203
204
        'api_generation':
            [[PyTango.DevString,
            PyTango.SCALAR,
            PyTango.READ]],
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
        'temperature':
            [[PyTango.DevFloat,
            PyTango.SCALAR,
            PyTango.READ]],
        'humidity':
            [[PyTango.DevFloat,
            PyTango.SCALAR,
            PyTango.READ]],
        'countrate_correction':
            [[PyTango.DevString,
            PyTango.SCALAR,
            PyTango.READ_WRITE]],
        'flatfield_correction':
            [[PyTango.DevString,
            PyTango.SCALAR,
            PyTango.READ_WRITE]],
        'auto_summation':
            [[PyTango.DevString,
            PyTango.SCALAR,
            PyTango.READ_WRITE]],
        'efficiency_correction':
            [[PyTango.DevString,
            PyTango.SCALAR,
            PyTango.READ_WRITE]],
        'virtual_pixel_correction':
            [[PyTango.DevString,
            PyTango.SCALAR,
            PyTango.READ_WRITE]],
        'pixel_mask':
            [[PyTango.DevString,
            PyTango.SCALAR,
            PyTango.READ_WRITE]],
237
238
239
240
        'compression_type':
            [[PyTango.DevString,
            PyTango.SCALAR,
            PyTango.READ_WRITE]],
241
242
243
244
245
246
247
248
        'threshold_energy':
            [[PyTango.DevFloat,
            PyTango.SCALAR,
            PyTango.READ_WRITE]],
        'photon_energy':
            [[PyTango.DevFloat,
            PyTango.SCALAR,
            PyTango.READ_WRITE]],
249
250
251
252
        'serie_id':
            [[PyTango.DevLong,
            PyTango.SCALAR,
            PyTango.READ]],
253
254
255
256
        'stream_last_info':
            [[PyTango.DevString,
            PyTango.SPECTRUM,
            PyTango.READ, 16]],
257
258
259
260
261
262
263
264
        'cam_status':
            [[PyTango.DevString,
            PyTango.SCALAR,
            PyTango.READ]],
        'plugin_status':
            [[PyTango.DevString,
            PyTango.SCALAR,
            PyTango.READ]],
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
        }


#------------------------------------------------------------------
#    EigerClass Constructor
#------------------------------------------------------------------
    def __init__(self, name):
        PyTango.DeviceClass.__init__(self, name)
        self.set_type(name)

#----------------------------------------------------------------------------
# Plugins
#----------------------------------------------------------------------------
from Lima import Eiger as EigerAcq

280
_EigerInterface = None
281
282
_EigerCamera = None

283
def get_control(detector_ip_address = "0", api_generation = "", **keys) :
284
    global _EigerInterface
285
    global _EigerCamera
286
    if _EigerInterface is None:
287
288
        args = [getattr(EigerAcq.Camera, api_generation)] if api_generation else []
        _EigerCamera = EigerAcq.Camera(detector_ip_address, *args)
289
290
        _EigerInterface = EigerAcq.Interface(_EigerCamera)
    return Core.CtControl(_EigerInterface)
291
292
293

def get_tango_specific_class_n_device() :
    return EigerClass,Eiger