skip sink on API start with start time set

pull/126/head
James Kirikland Garner 2022-12-26 20:32:51 -08:00
rodzic b960bb4710
commit 3c515761e8
4 zmienionych plików z 14 dodań i 6 usunięć

Wyświetl plik

@ -8,7 +8,7 @@ import busio
# General options
### Logging
log_level = logging.INFO
log_level = logging.DEBUG
log_format = '%(asctime)s %(levelname)s %(name)s: %(message)s'
### Server

Wyświetl plik

@ -73,6 +73,11 @@ def handle_api():
if 'startat' in bottle.request.json:
startat = bottle.request.json['startat']
#Shut off seek if start time has been set
allow_seek = True
if startat > 0:
allow_seek = False
# get the wanted profile/kiln schedule
profile = find_profile(wanted)
if profile is None:
@ -81,7 +86,7 @@ def handle_api():
# FIXME juggling of json should happen in the Profile class
profile_json = json.dumps(profile)
profile = Profile(profile_json)
oven.run_profile(profile,startat=startat)
oven.run_profile(profile, startat=startat, allow_seek=allow_seek)
ovenWatcher.record(profile)
if bottle.request.json['cmd'] == 'stop':

Wyświetl plik

@ -334,14 +334,15 @@ class Oven(threading.Thread):
target_temp = profile.get_target_temperature(0)
if temp > target_temp + 5:
startat = profile.find_next_time_from_temperature(temp)
log.info("seek_start is in effect")
log.info("seek_start is in effect, starting at: {} s, {} deg".format(round(startat), round(temp)))
else:
startat = 0
return startat
def run_profile(self, profile, startat=0, auto_start=False):
def run_profile(self, profile, startat=0, allow_seek=True):
log.debug('run_profile run on thread' + threading.current_thread().name)
runtime = startat * 60
if not auto_start:
if allow_seek:
if self.state == 'IDLE':
if config.seek_start:
temp = self.board.temp_sensor.temperature() # Defined in a subclass
@ -485,7 +486,7 @@ class Oven(threading.Thread):
with open(profile_path) as infile:
profile_json = json.dumps(json.load(infile))
profile = Profile(profile_json)
self.run_profile(profile,startat=startat, auto_start=True)
self.run_profile(profile, startat=startat, allow_seek=False) # We don't want a seek on an auto restart.
self.cost = d["cost"]
time.sleep(1)
self.ovenwatcher.record(profile)
@ -496,6 +497,7 @@ class Oven(threading.Thread):
def run(self):
while True:
log.debug('Oven running on ' + threading.current_thread().name)
if self.state == "IDLE":
if self.should_i_automatic_restart() == True:
self.automatic_restart()

Wyświetl plik

@ -79,6 +79,7 @@ class OvenWatcher(threading.Thread):
def notify_all(self,message):
message_json = json.dumps(message)
log.debug("sending to %d clients: %s"%(len(self.observers),message_json))
for wsock in self.observers:
if wsock:
try: