Beispiel #1
0
def cap_loop(ver, rb, sleep_time):
    global lock, STATE
    key = KeyControl()
    cap = ImgCap(ver)
    if ver == 0:
        key.first_run()
    key.start()
    while True:
        if STATE == -1:
            cap.create_dir()
            print('clean save dir')
            while key.get_key() != 10:
                pass
            # rb.start_simulation()
            STATE = 10
        if STATE == -2:
            print('thread exit')
            key.end()
            sys.exit(0)
        state = key.get_key()
        if state is not None:
            STATE = state
        lock.acquire()
        try:
            cap.capture(rb.get_image(), STATE)
        except Exception as e:
            time.sleep(sleep_time)
            continue
        finally:
            lock.release()
        time.sleep(sleep_time)
def thread_loop():
    global STATE
    key = KeyControl()
    key.start()
    while True:
        state = key.get_key()
        if state is not None:
            STATE = state
Beispiel #3
0
def only_control_loop(ver, rb, sleep_time):
    global lock, STATE
    key = KeyControl()
    key.start()
    while True:
        state = key.get_key()
        if state is not None:
            STATE = state
        time.sleep(0.2)