-
Notifications
You must be signed in to change notification settings - Fork 11
/
MicrodiffMotorMockup.py
90 lines (67 loc) · 2.77 KB
/
MicrodiffMotorMockup.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
import logging
from AbstractMotor import AbstractMotor
from HardwareRepository.BaseHardwareObjects import Device
class MicrodiffMotorMockup(AbstractMotor, Device):
(NOTINITIALIZED, UNUSABLE, READY, MOVESTARTED, MOVING, ONLIMIT) = (0,1,2,3,4,5)
EXPORTER_TO_MOTOR_STATE = { "Invalid": NOTINITIALIZED,
"Fault": UNUSABLE,
"Ready": READY,
"Moving": MOVING,
"Created": NOTINITIALIZED,
"Initializing": NOTINITIALIZED,
"Unknown": UNUSABLE }
def __init__(self, name):
AbstractMotor.__init__(self)
Device.__init__(self, name)
def init(self):
# this is ugly : I added it to make the centring procedure happy
self.motorState = MicrodiffMotorMockup.READY
self.motorPosition = 10.124
def isReady(self):
return True
def connectNotify(self, signal):
if signal == 'positionChanged':
self.emit('positionChanged', (self.getPosition(), ))
elif signal == 'stateChanged':
self.motorStateChanged(self.getState())
elif signal == 'limitsChanged':
self.motorLimitsChanged()
def updateState(self):
pass
def updateMotorState(self, motor_states):
pass
def motorStateChanged(self, state):
self.emit('stateChanged', (self.motorState, ))
def getState(self):
return self.motorState
def motorLimitsChanged(self):
self.emit('limitsChanged', (self.getLimits(), ))
def getLimits(self):
return (-1E4,1E4)
def getPosition(self):
return self.motorPosition
def getDialPosition(self):
return self.getPosition()
def move(self, absolutePosition):
self.motorPosition = absolutePosition
self.emit('positionChanged', (self.motorPosition, ))
self.emit('stateChanged', (self.motorState, ))
def moveRelative(self, relativePosition):
self.motorPosition = self.motorPosition + relativePosition
self.emit('positionChanged', (self.motorPosition, ))
self.emit('stateChanged', (self.motorState, ))
def syncMoveRelative(self, relative_position, timeout=None):
self.syncMove(self.getPosition() + relative_position)
def waitEndOfMove(self, timeout=None):
pass
def syncMove(self, position, timeout=None):
self.move(position)
def motorIsMoving(self):
return False
def getMotorMnemonic(self):
return self.motor_name
def stop(self):
pass
def getPredefinedPositionsList(self):
#For zoom
return {"Zoom 1": 1, "Zoom 2": 2, "Zoom 3": 3, "Zoom 4": 4, "Zoom 5": 5}