forked from mxcube/HardwareObjects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Q315dist.py
67 lines (45 loc) · 2.15 KB
/
Q315dist.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
from HardwareRepository import BaseHardwareObjects
import logging
class Q315dist(BaseHardwareObjects.Equipment):
def _init(self):
self.connect("equipmentReady", self.equipmentReady)
self.connect("equipmentNotReady", self.equipmentNotReady)
return BaseHardwareObjects.Equipment._init(self)
def init(self):
self.detm = self.getDeviceByRole("detm")
self.dtox = self.getDeviceByRole("dtox")
self.connect(self.detm, "stateChanged", self.detmStateChanged)
self.connect(self.dtox, "limitsChanged", self.dtoxLimitsChanged)
self.connect(self.detm, "positionChanged", self.detmPositionChanged)
def equipmentReady(self):
self.emit("deviceReady")
def equipmentNotReady(self):
self.emit("deviceNotReady")
def isValid(self):
return self.getDeviceByRole("detm") is not None and self.getDeviceByRole("dtox") is not None
def __getattr__(self, attr):
"""Delegation to underlying motors"""
if not attr.startswith("__"):
if attr in ("getPosition", "getDialPosition", "getState", "getLimits"):
#logging.getLogger().info("calling detm %s ; ready ? %s", attr, self.detm.isReady())
return getattr(self.detm, attr)
else:
#logging.getLogger().info("calling dtox %s", attr)
return getattr(self.dtox, attr)
else:
raise AttributeError(attr)
def connectNotify(self, signal):
if signal == "stateChanged":
self.detmStateChanged(self.detm.getState())
elif signal == "positionChanged":
self.detmPositionChanged(self.detm.getPosition())
def detmStateChanged(self, state):
if (state == self.detm.NOTINITIALIZED) or (state > self.detm.UNUSABLE):
self.emit("stateChanged", (state, ))
else:
self.detm.motorState = self.detm.READY
self.detm.motorStateChanged(self.detm.motorState)
def dtoxLimitsChanged(self, limits):
self.emit("limitsChanged", (limits, ))
def detmPositionChanged(self, pos):
self.emit("positionChanged", (pos, ))