コード例 #1
0
    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()
コード例 #2
0
    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, ))
コード例 #3
0
    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(), ))
コード例 #4
0
    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(), ))
コード例 #5
0
    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,
            ))
コード例 #6
0
    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()
コード例 #7
0
 def __init__(self, name):
     EmotionMotor.__init__(self, name)
コード例 #8
0
 def __init__(self, name):
     EmotionMotor.__init__(self, name)