MCPcopy Create free account
hub / github.com/PiSCSI/piscsi / Timer

Class Timer

python/ctrlboard/src/menu/timer.py:6–26  ·  view source on GitHub ↗

Class implementing a timer class. Takes an activation delay and sets a flag if the activation delay exprires.

Source from the content-addressed store, hash-verified

4
5
6class Timer:
7 """Class implementing a timer class. Takes an activation delay and
8 sets a flag if the activation delay exprires."""
9
10 def __init__(self, activation_delay):
11 self.start_timestamp = int(time.time())
12 self.activation_delay = activation_delay
13 self.enabled = False
14
15 def check_timer(self):
16 """Checks the timer whether it has reached the activation delay."""
17 current_timestamp = int(time.time())
18 timestamp_diff = current_timestamp - self.start_timestamp
19
20 if timestamp_diff >= self.activation_delay:
21 self.enabled = True
22
23 def reset_timer(self):
24 """Resets the timer and starts from the beginning."""
25 self.start_timestamp = int(time.time())
26 self.enabled = False

Callers 3

__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected