-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfrontend_shutter.py
executable file
·55 lines (45 loc) · 1.54 KB
/
frontend_shutter.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
# -*- coding: utf-8 -*-
import time
import gevent
try:
import tango
except:
import PyTango as tango
from md2_mockup import md2_mockup
class frontend_mockup:
#def __init__(self):
#self.name = 'obx_mockup'
def Open(self):
return 'Open'
def Close(self):
return 'Close'
def State(self):
return 'State'
class frontend_shutter(object):
def __init__(self):
try:
self.shutter = tango.DeviceProxy('tdl-i11-ma/vi/tdl.1')
self.security = tango.DeviceProxy('i11-ma-co/pss/db_data-parser')
except:
self.shutter = frontend_mockup()
def open(self, checktime=0.2, timeout=10):
start = time.time()
if self.security.pssStatusOH == 1 and self.state != 'OPEN':
self.shutter.Open()
while self.state() != 'OPEN' and abs(time.time()-start) < timeout:
gevent.sleep(checktime)
self.shutter.Open()
elif self.security.pssStatusOH != 1:
print('Not possible to open the safety shutter due to a security issue. Has the hutch been searched and locked?')
def close(self, checktime=2., timeout=10.):
start = time.time()
while not self.closed() and time.time() - start < timeout:
try:
self.shutter.Close()
except:
pass
gevent.sleep(checktime)
def state(self):
return self.shutter.State().name
def closed(self):
return self.state() == 'CLOSE'