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


Python termios.TCIFLUSH属性代码示例

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


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

示例1: reset_input_buffer

# 需要导入模块: import termios [as 别名]
# 或者: from termios import TCIFLUSH [as 别名]
def reset_input_buffer(self):
        """Clear input buffer, discarding all that is in the buffer."""
        if not self.is_open:
            raise portNotOpenError
        termios.tcflush(self.fd, termios.TCIFLUSH) 
开发者ID:cedricp,项目名称:ddt4all,代码行数:7,代码来源:serialposix.py

示例2: clear

# 需要导入模块: import termios [as 别名]
# 或者: from termios import TCIFLUSH [as 别名]
def clear(self):
        termios.tcflush(self.stdread, termios.TCIFLUSH) 
开发者ID:Rockhopper-Technologies,项目名称:enlighten,代码行数:4,代码来源:__init__.py

示例3: getch

# 需要导入模块: import termios [as 别名]
# 或者: from termios import TCIFLUSH [as 别名]
def getch(self):
                termios.tcflush(0, termios.TCIFLUSH) # XXX Leave this in?
                return os.read(self._fd, 1) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:5,代码来源:randpool.py

示例4: close

# 需要导入模块: import termios [as 别名]
# 或者: from termios import TCIFLUSH [as 别名]
def close(self, delay = 0):
                if delay:
                    time.sleep(delay)
                    termios.tcflush(self._fd, termios.TCIFLUSH)
                termios.tcsetattr(self._fd, termios.TCSAFLUSH, self._old) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:7,代码来源:randpool.py

示例5: run

# 需要导入模块: import termios [as 别名]
# 或者: from termios import TCIFLUSH [as 别名]
def run():
    """execute the TraCI control loop"""
    step = 0
    
    traci.trafficlight.setPhase("0", 0)
    while traci.simulation.getMinExpectedNumber() > 0:
        
        traci.simulationStep()
        # timeout = 0.2
        # print("Time right now - ",step)
        # rlist, wlist, xlist = select([sys.stdin],[],[],timeout)

        # if rlist:
        #     print("Key pressed - ")
        #     print(rlist)
        #     traci.vehicle.addFull(vehID='left_'+str(step),routeID='r0',typeID='car',depart='triggered',departLane='random',departPos='random')
        #     termios.tcflush(sys.stdin,termios.TCIFLUSH)

        key = stdscr.getch()
        stdscr.addch(20,25,key)
        stdscr.refresh()

        if key == curses.KEY_RIGHT: 
            stdscr.addstr(2, 20, "Up")
            traci.vehicle.addFull(vehID='right_'+str(step),routeID='r0',typeID='car',depart='triggered',departLane='random',departPos='random')

        elif key == curses.KEY_DOWN: 
            stdscr.addstr(3, 20, "Down")
            traci.vehicle.addFull(vehID='down_'+str(step),routeID='r3',typeID='car',depart='triggered',departLane='random',departPos='random')

        elif key == curses.KEY_LEFT: 
            stdscr.addstr(4, 20, "Left")
            traci.vehicle.addFull(vehID='left_'+str(step),routeID='r6',typeID='car',depart='triggered',departLane='random',departPos='random')

        elif key == curses.KEY_UP: 
            stdscr.addstr(5, 20, "Up")
            traci.vehicle.addFull(vehID='up_'+str(step),routeID='r9',typeID='car',depart='triggered',departLane='random',departPos='random')

        step += 1
    curses.endwin()
    traci.close()
    sys.stdout.flush() 
开发者ID:Ujwal2910,项目名称:Smart-Traffic-Signals-in-India-using-Deep-Reinforcement-Learning-and-Advanced-Computer-Vision,代码行数:44,代码来源:runner.py

示例6: run

# 需要导入模块: import termios [as 别名]
# 或者: from termios import TCIFLUSH [as 别名]
def run(self):
        import traci
        """execute the TraCI control loop"""
        step = 0
        phase = 0
        states = [0,1,2,3,4,5,6,7]
        traci.trafficlight.setPhase("0", 0)
        while traci.simulation.getMinExpectedNumber() > 0:
            
            traci.simulationStep()
            
            action = random.choice(states)
            traci.trafficlight.setPhase("0", action)
            phase = traci.trafficlight.getPhase("0")
            #print(phase)
            # timeout = 0.2
            # print("Time right now - ",step)
            # rlist, wlist, xlist = select([sys.stdin],[],[],timeout)

            # if rlist:
            #     print("Key pressed - ")
            #     print(rlist)
            #     traci.vehicle.addFull(vehID='left_'+str(step),routeID='r0',typeID='car',depart='triggered',departLane='random',departPos='random')
            #     termios.tcflush(sys.stdin,termios.TCIFLUSH)
            '''
            key = fstdscr.getch()
            stdscr.addch(20,25,key)
            stdscr.refresh()

            if key == curses.KEY_RIGHT: 
                stdscr.addstr(2, 20, "Up")
                traci.vehicle.addFull(vehID='right_'+str(step),routeID='r0',typeID='car',depart='triggered',departLane='random',departPos='random')

            elif key == curses.KEY_DOWN: 
                stdscr.addstr(3, 20, "Down")
                traci.vehicle.addFull(vehID='down_'+str(step),routeID='r3',typeID='car',depart='triggered',departLane='random',departPos='random')

            elif key == curses.KEY_LEFT: 
                stdscr.addstr(4, 20, "Left")
                traci.vehicle.addFull(vehID='left_'+str(step),routeID='r6',typeID='car',depart='triggered',departLane='random',departPos='random')

            elif key == curses.KEY_UP: 
                stdscr.addstr(5, 20, "Up")
                traci.vehicle.addFull(vehID='up_'+str(step),routeID='r9',typeID='car',depart='triggered',departLane='random',departPos='random')
               ''' 

            step += 1
        #.curses.endwin()
        traci.close()
        sys.stdout.flush() 
开发者ID:Ujwal2910,项目名称:Smart-Traffic-Signals-in-India-using-Deep-Reinforcement-Learning-and-Advanced-Computer-Vision,代码行数:52,代码来源:runner.py


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