-
Notifications
You must be signed in to change notification settings - Fork 0
/
abstract.py
56 lines (41 loc) · 1.22 KB
/
abstract.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from abc import ABC, abstractmethod
import time
import logging
class AbstractMonitor(ABC):
def __init__(self):
self.sleep = 1
self._blank_monitor = False
def check_wait_temp(self):
wait_threshold = self.get_wait_threshold()
continue_threshold = self.get_continue_threshold()
if(self._blank_monitor):
print("Blank Monitor, no monitoring is available!!")
return
if (continue_threshold > wait_threshold):
raise ValueError("continue threshold is larger than wait threshold, it would wait forever!!")
curr_t = self.get_temp()
if (curr_t > wait_threshold):
self._above_wait_threshold(curr_t)
while(not curr_t < continue_threshold):
time.sleep(self.sleep)
curr_t = self.get_temp()
self._below_continue_threshold(curr_t)
def set_sleep(self, sleep_sec):
self.sleep = sleep_sec
def get_sleep(self):
return self.sleep
@abstractmethod
def get_temp(self):
pass
@abstractmethod
def get_wait_threshold(self):
pass
@abstractmethod
def get_continue_threshold(self):
pass
@abstractmethod
def _above_wait_threshold(self, temp):
pass
@abstractmethod
def _below_continue_threshold(self, temp):
pass