-
Notifications
You must be signed in to change notification settings - Fork 0
/
pytango_PMT1002.py
109 lines (85 loc) · 2.53 KB
/
pytango_PMT1002.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
#!/usr/bin/env python3
#
import sys
import os
import time
from enum import IntEnum
import numpy as np
from tango import AttrQuality, AttrWriteType, DispLevel, DevState, DebugIt
from tango.server import Device, attribute, command, pipe, device_property
from PMT1002 import Photomultiplier
class PMT1002(Device):
# -----------------
# Device Properties
# -----------------
serial = device_property(dtype='DevString', default_value = 'L2730020')
# ----------
# Attributes
# ----------
lpfilter = attribute(dtype = 'DevEnum',
label = 'lowpass filter frequency',
enum_labels = ['250 kHz', '2.5 MHz', '80 MHz'],
access = AttrWriteType.READ_WRITE,)
voltage = attribute(
dtype='DevFloat',
access=AttrWriteType.READ_WRITE,
label="Voltage",
unit="V",
format="%3.2f",
min_value = 0.5,
max_value = 1.09,
doc="Applied voltage; must be between 0.5V and 1.09V",
)
output = attribute(
dtype='DevBoolean',
access=AttrWriteType.READ_WRITE,
label="Active",
doc="is on?",
)
# ---------------
# General methods
# ---------------
def init_device(self):
Device.init_device(self)
self.device = Photomultiplier(self.serial)
self.device.Off()
self.FREQUENCIES = [250000, 2500000, 80000000]
# ------------------
# Attributes methods
# ------------------
### READ COMMANDS ###
def read_lpfilter(self):
ret = int(self.device.get_FilterFreq()[:-2])
if ret == 250000:
return 0
elif ret == 2500000:
return 1
elif ret == 80000000:
return 2
def read_voltage(self):
ret = float(self.device.get_Voltage()[:-1])
return ret
def read_output(self):
ret = int(self.device.Status())
if ret == 1:
self.set_state(DevState.ON)
return True
else:
self.set_state(DevState.OFF)
return False
### WRITE COMMANDS ###
def write_lpfilter(self,value):
return self.device.set_FilterFreq(self.FREQUENCIES[value])
def write_voltage(self,value):
return self.device.set_Voltage(value)
def write_output(self,value):
if value:
self.device.On()
time.sleep(0.1)
return self.read_output()
else:
self.device.Off()
time.sleep(0.1)
return self.read_output()
if __name__ == "__main__":
PMT1002.run_server()