def init(self): EmotionMotor.init(self) self.predefinedPositions = {} self.predefinedPositionsNamesList = [] self.delta = self.getProperty('delta') or 0 try: positions = self['positions'] except: logging.getLogger("HWR").error('%s does not define positions.', str(self.name())) else: for definedPosition in positions: positionUsername = definedPosition.getProperty('username') try: offset = float(definedPosition.getProperty('offset')) except: logging.getLogger("HWR").warning( '%s, ignoring position %s: invalid offset.', str(self.name()), positionUsername) else: self.predefinedPositions[positionUsername] = offset self.sortPredefinedPositionsList()
def updateState(self, state=None): EmotionMotor.updateState(self, state) if self.motorState==EmotionMotor.READY: pos = self.getPosition() for positionName in self.predefinedPositions: if self.predefinedPositions[positionName] >= pos-self.delta and self.predefinedPositions[positionName] <= pos+self.delta: self.emit('predefinedPositionChanged', (positionName, pos, )) return self.emit('predefinedPositionChanged', ('', None, ))
def connectNotify(self, signal): EmotionMotor.connectNotify(self, signal) if signal == 'predefinedPositionChanged': positionName = self.getCurrentPositionName() try: pos = self.predefinedPositions[positionName] except KeyError: self.emit(signal, ('', None)) else: self.emit(signal, (positionName, pos)) elif signal == 'stateChanged': self.emit(signal, (self.getState(), ))
def updateState(self, state=None): EmotionMotor.updateState(self, state) if self.motorState == EmotionMotor.READY: pos = self.getPosition() for positionName in self.predefinedPositions: if self.predefinedPositions[ positionName] >= pos - self.delta and self.predefinedPositions[ positionName] <= pos + self.delta: self.emit('predefinedPositionChanged', ( positionName, pos, )) return self.emit('predefinedPositionChanged', ( '', None, ))
def init(self): EmotionMotor.init(self) self.predefinedPositions = {} self.predefinedPositionsNamesList = [] self.delta = self.getProperty('delta') or 0 try: positions = self['positions'] except: logging.getLogger("HWR").error('%s does not define positions.', str(self.name())) else: for definedPosition in positions: positionUsername = definedPosition.getProperty('username') try: offset = float(definedPosition.getProperty('offset')) except: logging.getLogger("HWR").warning('%s, ignoring position %s: invalid offset.', str(self.name()), positionUsername) else: self.predefinedPositions[positionUsername] = offset self.sortPredefinedPositionsList()
def __init__(self, name): EmotionMotor.__init__(self, name)