-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPIMTETangoTwoDController.py
115 lines (97 loc) · 4.21 KB
/
PIMTETangoTwoDController.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
##############################################################################
##
# This file is part of Sardana
##
# http://www.sardana-controls.org/
##
# Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
##
# Sardana is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
##
# Sardana 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 Lesser General Public License for more details.
##
# You should have received a copy of the GNU Lesser General Public License
# along with Sardana. If not, see <http://www.gnu.org/licenses/>.
##
##############################################################################
from tango import DeviceProxy
from sardana.pool.controller import TwoDController, Referable, Type, Description, DefaultValue, FGet, FSet
class PIMTETangoTwoDController(TwoDController, Referable):
"""The most basic controller intended from demonstration purposes only.
This is the absolute minimum you have to implement to set a proper counter
controller able to get a counter value, get a counter state and do an
acquisition.
This example is so basic that it is not even directly described in the
documentation"""
ctrl_properties = {'tangoFQDN': {Type: str,
Description: 'The FQDN of the PI-MTE tango DS',
DefaultValue: 'domain/family/member'},
}
# axis_attributes = {
# "SavingEnabled": {
# Type: bool,
# FGet: "isSavingEnabled",
# FSet: "setSavingEnabled",
# Description: ("Enable/disable saving of images in HDF5 files."
# " Use with care in high demanding (fast)"
# " acquisitions. Trying to save at high rate may"
# " hang the acquisition process."),
# }
# }
def AddDevice(self, axis):
self._axes[axis] = {}
def DeleteDevice(self, axis):
self._axes.pop(axis)
def __init__(self, inst, props, *args, **kwargs):
"""Constructor"""
TwoDController.__init__(self,inst,props, *args, **kwargs)
print('PI-MTE Tango Initialization ...')
self.proxy = DeviceProxy(self.tangoFQDN)
print('SUCCESS')
self._axes = {}
def ReadOne(self, axis):
"""Get the specified counter value"""
return self.proxy.image
def RefOne(self, axis):
return self.proxy.save_index
def SetAxisPar(self, axis, parameter, value):
# if parameter == "value_ref_pattern":
# print('value_ref_pattern ' + str(value))
# elif parameter == "value_ref_enabled":
# print('value_ref_enabled ' + str(value))
# self.setSavingEnabled(axis, value)
pass
def StateOne(self, axis):
"""Get the specified counter state"""
return self.proxy.State(), "Counter is acquiring or not"
def PrepareOne(self, axis, value, repetitions, latency, nb_starts):
# set exporsure time of cam convert from s to ms
self.proxy.exposure = float(value*1000)
def LoadOne(self, axis, value, repetitions, latency):
pass
def StartOne(self, axis, value=None):
"""acquire the specified counter"""
self.proxy.acquire()
return
def StopOne(self, axis):
"""Stop the specified counter"""
self.proxy.stop()
def AbortOne(self, axis):
"""Abort the specified counter"""
self.proxy.stop()
# def isSavingEnabled(self, axis):
# return bool(self.proxy.SaveImageFiles)
# def setSavingEnabled(self, axis, value):
# self.proxy.SaveImageFiles = bool(value)
def GetAxisPar(self, axis, par):
if par == "shape":
roi = self.proxy.get_roi_size()
print('########################################################')
print(roi)
return [roi[3]/roi[5], roi[2]/roi[4]]