当前位置: 首页>>代码示例>>Python>>正文


Python Tools.debug方法代码示例

本文整理汇总了Python中Tools.Tools.debug方法的典型用法代码示例。如果您正苦于以下问题:Python Tools.debug方法的具体用法?Python Tools.debug怎么用?Python Tools.debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tools.Tools的用法示例。


在下文中一共展示了Tools.debug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from Tools import Tools [as 别名]
# 或者: from Tools.Tools import debug [as 别名]
 def __init__(self):
     """
     Creates a gear instance.
     """
     self.speed = SharedConstants.GEAR_DEFAULT_SPEED
     self.state = GearState.UNDEFINED
     Tools.debug("Gear instance created")
开发者ID:Aegidius,项目名称:apluraspi,代码行数:9,代码来源:Gear.py

示例2: exit

# 需要导入模块: from Tools import Tools [as 别名]
# 或者: from Tools.Tools import debug [as 别名]
    def exit(self):
        """
        Cleans-up and releases all resources.
        """
        global _isButtonEnabled
        Tools.debug("Calling Robot.exit()")
        self.setButtonEnabled(False)

        # Stop motors
        SharedConstants.LEFT_MOTOR_PWM[0].ChangeDutyCycle(0)
        SharedConstants.LEFT_MOTOR_PWM[1].ChangeDutyCycle(0)
        SharedConstants.RIGHT_MOTOR_PWM[0].ChangeDutyCycle(0)
        SharedConstants.RIGHT_MOTOR_PWM[1].ChangeDutyCycle(0)

        # Stop button thread, if necessary
        if _buttonThread != None:
            _buttonThread.stop()

        # Stop display
        display = Display._myInstance
        if display != None:
            display.stopTicker()
            display.clear()

        Led.clearAll()
        Tools.delay(2000)  # avoid "sys.excepthook is missing"
开发者ID:Aegidius,项目名称:apluraspi,代码行数:28,代码来源:Robot.py

示例3: exit

# 需要导入模块: from Tools import Tools [as 别名]
# 或者: from Tools.Tools import debug [as 别名]
    def exit(self):
        """
        Cleans-up and releases all resources.
        """
        global _isButtonEnabled
        Tools.debug("Calling Robot.exit()")
        self.setButtonEnabled(False)

        # Stop motors
        SharedConstants.LEFT_MOTOR_PWM[0].ChangeDutyCycle(0)
        SharedConstants.LEFT_MOTOR_PWM[1].ChangeDutyCycle(0)
        SharedConstants.RIGHT_MOTOR_PWM[0].ChangeDutyCycle(0)
        SharedConstants.RIGHT_MOTOR_PWM[1].ChangeDutyCycle(0)

        # Stop button thread, if necessary
        if _buttonThread != None:
            _buttonThread.stop()

        # Stop display
        display = Display._myInstance
        if display != None:
            display.stopTicker()
            display.clear()

        Led.clearAll()
        MyRobot.closeSound()

        if self.sensorThread != None:
            self.sensorThread.stop()
            self.sensorThread.join(2000)

        # GPIO.cleanup() Do not cleanup, otherwise button will not work any more when coming back
        # from remote execution
        Tools.delay(2000)  # avoid "sys.excepthook is missing"
开发者ID:raspibrick,项目名称:install,代码行数:36,代码来源:Robot.py

示例4: run

# 需要导入模块: from Tools import Tools [as 别名]
# 或者: from Tools.Tools import debug [as 别名]
    def run(self):
        Tools.debug("Led blinker thread starting")
        nb = 0
        self._isRunning = True
        while self._isRunning:
            self.led.setColor(self._onColor)
            startTime = time.time()
            while time.time() - startTime < self._onTime / 1000.0 and self._isRunning:
                time.sleep(0.001)
            if not self._isRunning:
                break

            self.led.setColor(self._offColor)
            startTime = time.time()
            while time.time() - startTime < self._offTime  / 1000.0 and self._isRunning:
                time.sleep(0.001)
            if not self._isRunning:
                break

            nb += 1
            if nb == self._count:
                self._isRunning = False
        self.led.setColor(0, 0, 0)
        self.led._blinkerThread = None
        self._isAlive = False
        Tools.debug("Led blinker thread finished")
开发者ID:raspibrick,项目名称:install,代码行数:28,代码来源:Led.py

示例5: rightArc

# 需要导入模块: from Tools import Tools [as 别名]
# 或者: from Tools.Tools import debug [as 别名]
 def rightArc(self, radius, duration=0):
     """
     Starts turning to the right on an arc with given radius (in m) with preset speed.
     If duration = 0, the method returns immediately, while the rotation continues.
     Otherwise the method blocks until the duration is expired. Then the gear stops.
     If the radius is negative, turns right backwards.
     @param duration:
     """
     Tools.debug("Calling Gear.rigthArc() with radius: " + str(radius))
     self._checkRobot()
     speed1 = (
         self.speed
         * (abs(radius) - SharedConstants.GEAR_AXE_LENGTH)
         / (abs(radius) + SharedConstants.GEAR_AXE_LENGTH)
     )
     Tools.debug("Calling rightArc(). Left speed: " + str(self.speed) + ". Right speed: " + str(speed1))
     if self.state != GearState.RIGHTARC:
         leftDuty = self.speedToDutyCycle(self.speed)
         rightDuty = self.speedToDutyCycle(speed1)
         if radius >= 0:
             SharedConstants.LEFT_MOTOR_PWM[0].ChangeDutyCycle(leftDuty)
             SharedConstants.LEFT_MOTOR_PWM[1].ChangeDutyCycle(0)
             SharedConstants.RIGHT_MOTOR_PWM[0].ChangeDutyCycle(rightDuty)
             SharedConstants.RIGHT_MOTOR_PWM[1].ChangeDutyCycle(0)
         else:
             SharedConstants.LEFT_MOTOR_PWM[0].ChangeDutyCycle(0)
             SharedConstants.LEFT_MOTOR_PWM[1].ChangeDutyCycle(rightDuty)
             SharedConstants.RIGHT_MOTOR_PWM[0].ChangeDutyCycle(0)
             SharedConstants.RIGHT_MOTOR_PWM[1].ChangeDutyCycle(leftDuty)
         self.state = GearState.RIGHTARC
     if duration > 0:
         Tools.delay(duration)
         self.stop()
开发者ID:Aegidius,项目名称:apluraspi,代码行数:35,代码来源:Gear.py

示例6: __init__

# 需要导入模块: from Tools import Tools [as 别名]
# 或者: from Tools.Tools import debug [as 别名]
 def __init__(self, id, **kwargs):
     '''
     Creates an infrared sensor at given port.
     For the Pi2Go the following infrared sensors are used:
     id = 0: front center; id = 1: front left; id = 2: front right;
     id = 3: line left; id = 4: line right. The following global constants are defined:
     IR_CENTER = 0, IR_LEFT = 1, IR_RIGHT = 2, IR_LINE_LEFT = 3, IR_LINE_RIGHT = 4
     @param id: sensor identifier
     '''
     self.id = id
     self.sensorState = "PASSIVATED"
     self.sensorType = "InfraredSensor"
     self.activateCallback = None
     self.passivateCallback = None
     for key in kwargs:
         if key == "activated":
             self.activateCallback = kwargs[key]
         elif key == "passivated":
             self.passivateCallback = kwargs[key]
     robot = RobotInstance.getRobot()
     if robot == None:  # deferred registering, because Robot not yet created
         RobotInstance._sensorsToRegister.append(self)
     else:
         if self.activateCallback != None or self.passivateCallback != None:
             robot.registerSensor(self)
     Tools.debug("InfraredSensor instance with ID " + str(id) + " created")
开发者ID:raspibrick,项目名称:install,代码行数:28,代码来源:InfraredSensor.py

示例7: __init__

# 需要导入模块: from Tools import Tools [as 别名]
# 或者: from Tools.Tools import debug [as 别名]
 def __init__(self, id, **kwargs):
     '''
     Creates a light sensor instance with given id.
     IDs: 0: front left, 1: front right, 2: rear left, 3: rear right
     The following global constants are defined:
     LS_FRONT_LEFT = 0, LS_FRONT_RIGHT = 1, LS_REAR_LEFT = 2, LS_REAR_RIGHT = 3.
     @param id: the LightSensor identifier
     '''
     self.id = id
     self.sensorState = "DARK"
     self.sensorType = "LightSensor"
     self.triggerLevel = 500
     self.brightCallback = None
     self.darkCallback = None
     self.isRegistered = False
     for key in kwargs:
         if key == "bright":
             self.brightCallback = kwargs[key]
         elif key == "dark":
             self.darkCallback = kwargs[key]
     robot = RobotInstance.getRobot()
     if robot == None:  # deferred registering, because Robot not yet created
         RobotInstance._sensorsToRegister.append(self)
     else:
         if self.brightCallback != None or self.darkCallback != None:
             robot.registerSensor(self)
     Tools.debug("LightSensor instance with ID " + str(id) + " created")
开发者ID:raspibrick,项目名称:install,代码行数:29,代码来源:LightSensor.py

示例8: _readByte

# 需要导入模块: from Tools import Tools [as 别名]
# 或者: from Tools.Tools import debug [as 别名]
 def _readByte(self, reg):
     try:
         result = self.bus.read_byte_data(self.address, reg)
         return result
     except:
         Tools.debug("Error while reading from I2C device at address: " + str(self.address))
         return None
开发者ID:raspibrick,项目名称:install,代码行数:9,代码来源:PCA9685.py

示例9: setButtonEnabled

# 需要导入模块: from Tools import Tools [as 别名]
# 或者: from Tools.Tools import debug [as 别名]
 def setButtonEnabled(self, enable):
     """
     Enables/disables the push button. The button is enabled, when the Robot is created.
     @param enable: if True, the button is enabled; otherwise disabled
     """
     Tools.debug("Calling setButtonEnabled() with enable = " + str(enable))
     global _isButtonEnabled
     _isButtonEnabled = enable
开发者ID:raspibrick,项目名称:install,代码行数:10,代码来源:Robot.py

示例10: __init__

# 需要导入模块: from Tools import Tools [as 别名]
# 或者: from Tools.Tools import debug [as 别名]
 def __init__(self, id):
     '''
     Creates a Led instance with given ID.
     IDs of the double LEDs: 0: front, 1: left side , 2: rear, 3: right side.
     The following global constants are defined:
     LED_FRONT = 0, LED_LEFT = 1, LED_REAR = 2, RED_RIGHT = 3.
     @param id: the LED identifier
     '''
     self.id = id
     Tools.debug("Led instance with ID " + str(id) + " created")
开发者ID:Aegidius,项目名称:apluraspi,代码行数:12,代码来源:Led.py

示例11: run

# 需要导入模块: from Tools import Tools [as 别名]
# 或者: from Tools.Tools import debug [as 别名]
 def run(self):
     Tools.debug("===>ButtonThread started")
     self.isRunning = True
     startTime = time.time()
     while self.isRunning and (time.time() - startTime < SharedConstants.BUTTON_LONGPRESS_DURATION):
         time.sleep(0.1)
     if self.isRunning:
         if _buttonListener != None:
             _buttonListener(SharedConstants.BUTTON_LONGPRESSED)
     Tools.debug("===>ButtonThread terminated")
开发者ID:raspibrick,项目名称:install,代码行数:12,代码来源:Robot.py

示例12: __init__

# 需要导入模块: from Tools import Tools [as 别名]
# 或者: from Tools.Tools import debug [as 别名]
 def __init__(self, id):
     '''
     Creates a light sensor instance with given id.
     IDs: 0: front left, 1: front right, 2: rear left, 3: rear right
     The following global constants are defined:
     LS_FRONT_LEFT = 0, LS_FRONT_RIGHT = 1, LS_REAR_LEFT = 2, LS_REAR_RIGHT = 3.
     @param id: the LightSensor identifier
     '''
     self.id = id
     Tools.debug("LightSensor instance with ID " + str(id) + " created")
开发者ID:Aegidius,项目名称:apluraspi,代码行数:12,代码来源:LightSensor.py

示例13: stop

# 需要导入模块: from Tools import Tools [as 别名]
# 或者: from Tools.Tools import debug [as 别名]
 def stop(self):
     """
     Stops the gear.
     (If gear is already stopped, returns immediately.)
     """
     Tools.debug("Calling Gear.stop()")
     self._checkRobot()
     if self.state != GearState.STOPPED:
         SharedConstants.LEFT_MOTOR_PWM[0].ChangeDutyCycle(0)
         SharedConstants.LEFT_MOTOR_PWM[1].ChangeDutyCycle(0)
         SharedConstants.RIGHT_MOTOR_PWM[0].ChangeDutyCycle(0)
         SharedConstants.RIGHT_MOTOR_PWM[1].ChangeDutyCycle(0)
         self.state = GearState.STOPPED
开发者ID:Aegidius,项目名称:apluraspi,代码行数:15,代码来源:Gear.py

示例14: __init__

# 需要导入模块: from Tools import Tools [as 别名]
# 或者: from Tools.Tools import debug [as 别名]
 def __init__(self, id, home, inc):
     '''
     Creates a servo motor instance and sets it at home position. For most servos:
     home = 300, inc = 2
     @param id: the id of the motor (0..3)
     @param home: the PWM duty cycle for the home position (0..4095)
     @param inc: the increment factor (inc_duty/inc_position)
     '''
     self.id = id
     self.home = home
     self.inc = inc
     self._checkRobot()
     self.robot = RobotInstance.getRobot()
     self.robot.pwm.setDuty(SharedConstants.SERVO_0 + self.id, home)
     Tools.debug("ServoMotor instance created")
开发者ID:raspibrick,项目名称:install,代码行数:17,代码来源:ServoMotor.py

示例15: setSpeed

# 需要导入模块: from Tools import Tools [as 别名]
# 或者: from Tools.Tools import debug [as 别名]
 def setSpeed(self, speed):
     """
     Sets the speed to the given value (arbitrary units).
     The speed will be changed to the new value at the next movement call only.
     The speed is limited to 0..100.
     @param speed: the new speed 0..100
     """
     Tools.debug("Calling Gear.setSpeed with speed: " + str(speed))
     if self.speed == speed:
         return
     if speed > 100:
         speed = 100
     if speed < 0:
         speed = 0
     self.speed = speed
     self.state = GearState.UNDEFINED
开发者ID:Aegidius,项目名称:apluraspi,代码行数:18,代码来源:Gear.py


注:本文中的Tools.Tools.debug方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。