timer.py
Go to the documentation of this file.
1 # License: Apache 2.0. See LICENSE file in root directory.
2 # Copyright(c) 2020 Intel Corporation. All Rights Reserved.
3 import time
4 from rspy.stopwatch import Stopwatch
5 
6 # A timer counting backwards in time(vs forwards in the `stopwatch` class )
7 # It supply basic timer API, start, has_expired..
8 class Timer:
9 
10  _delta = 0
11  _sw = Stopwatch()
12 
13  def __init__(self, timeout_in_sec):
14  self._delta = timeout_in_sec
15 
16  # Start timer
17  def start(self):
18  self._sw.reset()
19 
20  # Check if timer time expired
21  def has_expired(self):
22  return self._sw.get_elapsed() >= self._delta
23 
24  # Force time expiration
25  def set_expired(self):
26  self._sw.reset(time.perf_counter() - (self._delta + 0.00001));
27 
28 
def set_expired(self)
Definition: timer.py:25
def has_expired(self)
Definition: timer.py:21
def __init__(self, timeout_in_sec)
Definition: timer.py:13
def start(self)
Definition: timer.py:17


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:50:11