當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。