forked from mxcube/HardwareObjects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MotorMockup.py
60 lines (44 loc) · 1.58 KB
/
MotorMockup.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
from HardwareRepository.BaseHardwareObjects import Device
import math
import logging
import time
import gevent
import types
class MotorMockup(Device):
(NOTINITIALIZED, UNUSABLE, READY, MOVESTARTED, MOVING, ONLIMIT) = (0,1,2,3,4,5)
def __init__(self, name):
Device.__init__(self, name)
def init(self):
self.motorState = MotorMockup.READY
self.username = self.name()
# this is ugly : I added it to make the centring procedure happy
self.specName = self.name()
self.motorPosition = 0
def getState(self):
return self.motorState
def motorLimitsChanged(self):
self.emit('limitsChanged', (self.getLimits(), ))
def getLimits(self):
return (-1E3, 1E3)
def getPosition(self):
return self.motorPosition
def getDialPosition(self):
return self.getPosition()
def move(self, position):
self.motorPosition = position
self.emit('positionChanged', (self.motorPosition, ))
self.emit('stateChanged', (self.motorState, ))
def moveRelative(self, relativePosition):
self.move(self.getPosition() + relativePosition)
def syncMoveRelative(self, relative_position, timeout=None):
return self.syncMove(self.getPosition() + relative_position)
def waitEndOfMove(self, timeout=None):
pass
def syncMove(self, position, timeout=None):
return
def motorIsMoving(self):
return self.motorState == 'MOVING'
def getMotorMnemonic(self):
return self.name()
def stop(self):
return