Ejemplo n.º 1
0
    def init(self):
        RobodiffMotor.init(self)

        self.predefinedPositions = {}
        self.predefinedPositionsNamesList = []
        self.delta = self.get_property("delta") or 0

        try:
            positions = self["positions"]
        except Exception:
            logging.getLogger("HWR").error("%s does not define positions.",
                                           str(self.name()))
        else:
            for definedPosition in positions:
                positionUsername = definedPosition.get_property("username")

                try:
                    offset = float(definedPosition.get_property("offset"))
                except Exception:
                    logging.getLogger("HWR").warning(
                        "%s, ignoring position %s: invalid offset.",
                        str(self.name()),
                        positionUsername,
                    )
                else:
                    self.predefinedPositions[positionUsername] = offset

            self.sortPredefinedPositionsList()
    def init(self):
        RobodiffMotor.init(self)

        self.predefinedPositions = {}
        self.predefinedPositionsNamesList = []
        self.delta = self.getProperty("delta") or 0

        try:
            positions = self["positions"]
        except BaseException:
            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 BaseException:
                    logging.getLogger("HWR").warning(
                        "%s, ignoring position %s: invalid offset.",
                        str(self.name()),
                        positionUsername,
                    )
                else:
                    self.predefinedPositions[positionUsername] = offset

            self.sortPredefinedPositionsList()
Ejemplo n.º 3
0
    def connect_notify(self, signal):
        RobodiffMotor.connect_notify(self, signal)

        if signal == "predefinedPositionChanged":
            positionName = self.get_current_position_name()

            try:
                pos = self.predefinedPositions[positionName]
            except KeyError:
                self.emit(signal, ("", None))
            else:
                self.emit(signal, (positionName, pos))
    def connectNotify(self, signal):
        RobodiffMotor.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))
Ejemplo n.º 5
0
    def updateState(self, state=None, emit=False):
        RobodiffMotor.updateState(self, state)

        if self.motorState == RobodiffMotor.READY:
            pos = self.get_value()

            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 updateState(self, state=None, emit=False):
        RobodiffMotor.updateState(self, state)

        if self.motorState == RobodiffMotor.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))
Ejemplo n.º 7
0
 def __init__(self, name):
     RobodiffMotor.__init__(self, name)
 def __init__(self, name):
     RobodiffMotor.__init__(self, name)