forked from mxcube/HardwareObjects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MicrodiffApertureAlign.py
73 lines (51 loc) · 2.23 KB
/
MicrodiffApertureAlign.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
from HardwareRepository.BaseHardwareObjects import Equipment
import logging
class MicrodiffApertureAlign(Equipment):
def init(self):
self.apertureAlignPosition = self.addChannel({"type":"tango", "name":"bs_pos", "tangoname":self.tangoname, "polling":"events" }, "AperturePredefinedPosition")
self.apertureAlignPosition.connectSignal("update", self.checkPosition)
self.apertureAlignSetInPosition = self.addCommand({"type":"tango", "name":"bs_set_in", "tangoname":self.tangoname},"ApertureSaveInPosition")
self.motors = self["motors"]
self.roles = self.motors.getRoles()
self.amplitude = 0 #just to make the beamstop brick happy
self.positions = { "in": 1, "out": 2 }
#self.positionsIndex = ["in", "out" ]
self.connect("equipmentReady", self.equipmentReady)
self.connect("equipmentNotReady", self.equipmentNotReady)
def moveToPosition(self, name):
if name == "in":
self.apertureAlignPosition.setValue(1)
elif name == "out":
self.apertureAlignPosition.setValue(2)
def connectNotify(self, signal):
self.checkPosition()
def equipmentReady(self, *args):
self.checkPosition()
return Equipment.equipmentReady(self, *args)
def equipmentNotReady(self, *args):
self.checkPosition()
return Equipment.equipmentNotReady(self, *args)
def isReady(self):
return True
def getState(self):
return "READY"
def getPosition(self):
return self.checkPosition(noEmit=True)
def checkPosition(self, pos=None, noEmit=False):
if pos is None:
pos = self.apertureAlignPosition.getValue()
if pos == 1:
# in
if not noEmit: self.emit("positionReached", ("in", ))
return "in"
elif pos == 2:
if not noEmit: self.emit("positionReached", ("out", ))
return "out"
else:
if not noEmit: self.emit("noPosition", ())
return None
def setNewPositions(self, name, newPositions):
if name == "in":
self.apertureAlignSetInPosition()
def getRoles(self):
return self.roles