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


Python Move.exit方法代码示例

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


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

示例1: MotionInterface

# 需要导入模块: from Move import Move [as 别名]
# 或者: from Move.Move import exit [as 别名]
class MotionInterface(object):
    def __init__(self, mode=1):
        self._Height = 75
        self._Length = 65
        self._DefaultPulse = 375
        self._Multiplier = 1
        self._currentModeInt = mode
        pulses = self.calculatePulse(self._Height, self._Length)
        
        self._Legs = [
            Leg([0x41, 0x41, 0x41], [0, 1, 2], [375, pulses[0], pulses[1]], [0, 0, 0]), #leg 1
            Leg([0x40, 0x40, 0x40], [0, 1, 2], [375, pulses[0], pulses[1]], True, [0, 0, 0]), #leg 2
            Leg([0x41, 0x41, 0x41], [4, 5, 6], [375, pulses[0], pulses[1]], [0, 0, 0]), #leg 3
            Leg([0x40, 0x40, 0x40], [4, 5, 6], [375, pulses[0], pulses[1]], True, [0, 0, 0]), #leg 4
            Leg([0x41, 0x41, 0x41], [8, 9, 10], [375, pulses[0], pulses[1]], [0, 0, 0]), #leg 5
            Leg([0x40, 0x40, 0x40], [8, 9, 10], [375, pulses[0], pulses[1]], True, [0, 0, 0]), #leg 6
        ]
        self._CurrentCommand = 10
        self._Exit = False
        self._Semaphore = threading.Semaphore(1)
        self._ExitSemaphore = threading.Semaphore(1)

        self.SleepTime = 0.0005
        
        if mode == 1:
            self._CurrentMode = Move(self)
        if mode == 2:
            self._CurrentMode = FingerControl(self)
        if mode == 3:
            self._CurrentMode = SpiderGap(self)
        if mode == 4:
            self._CurrentMode = Dance(self)
        if mode == 5:
            self._CurrentMode = BalloonRace(self)
        if mode == 6:
            self._CurrentMode = Move(self)
        if mode == 7:
            self._CurrentMode = Move(self)
        if mode == 8:
            self._CurrentMode = Dance2(self)
        if mode == 9:
            self._CurrentMode = SpiderGap2(self)

    def get_CurrentCommand(self):
        self._Semaphore.acquire()
        try:
            if self._CurrentCommand is None:
                self._Semaphore.release()
                return 10
            else:
                temp = self._CurrentCommand
                self._Semaphore.release()
                return temp
        except:
            return 10

    def set_CurrentCommand(self, _CurrentCommand):
        self._Semaphore.acquire()
        self._CurrentCommand = _CurrentCommand
        self._Semaphore.release()
        return "Command " + str(_CurrentCommand) + " has been received"

    def runThread(self):
        self._ExitSemaphore.acquire()
        while self.isExited() == False:
            self._CurrentMode.executeCommand(self.get_CurrentCommand())
            self._ExitSemaphore.release()
            time.sleep(0.001)

    def exit(self):
        self._ExitSemaphore.acquire()
        self._Exit = True
        self._CurrentMode.exit()
        self._ExitSemaphore.release()

    def getSemaphore(self):
        return self._Semaphore

    def getExitSemaphore(self):
        return self._ExitSemaphore

    def isExited(self):
        return self._Exit

    def setHeight(self, height):
        try:
            height = int(height)
        except:
            height = self._Height
        
        if height < 40:
            self._Height = 40
        elif height > 150:
            self._Height = 150
        else:
            self._Height = height

        self.set_CurrentCommand(9)

    def getHeight(self):
#.........这里部分代码省略.........
开发者ID:Speedydown,项目名称:SpindpWindowsPhone,代码行数:103,代码来源:MotionInterface.py


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