Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
unit-tests
py
rspy
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
rspy.timer.Timer.set_expired
def set_expired(self)
Definition:
timer.py:25
rspy.stopwatch.Stopwatch
Definition:
stopwatch.py:7
rspy.stopwatch
Definition:
stopwatch.py:1
rspy.timer.Timer._delta
int _delta
Definition:
timer.py:10
rspy.timer.Timer.has_expired
def has_expired(self)
Definition:
timer.py:21
rspy.timer.Timer.__init__
def __init__(self, timeout_in_sec)
Definition:
timer.py:13
rspy.timer.Timer.start
def start(self)
Definition:
timer.py:17
rspy.timer.Timer
Definition:
timer.py:8
librealsense2
Author(s): Sergey Dorodnicov
, Doron Hirshberg
, Mark Horn
, Reagan Lopez
, Itay Carpis
autogenerated on Mon May 3 2021 02:50:11