Add new logic for checking the kiln state and displaying a new message based on that.
This commit is contained in:
parent
75ce5d4fe1
commit
615a97bcf7
1 changed files with 20 additions and 4 deletions
|
|
@ -73,6 +73,10 @@ def logger(hostname, csvfile, noprofilestats, pidstats, stdout):
|
||||||
|
|
||||||
# end setup seven segment display
|
# end setup seven segment display
|
||||||
|
|
||||||
|
# store the current state, default to IDLE
|
||||||
|
prev_kiln_state = "IDLE"
|
||||||
|
kiln_state = "IDLE"
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
msg = json.loads(status_ws.recv())
|
msg = json.loads(status_ws.recv())
|
||||||
|
|
@ -88,6 +92,18 @@ def logger(hostname, csvfile, noprofilestats, pidstats, stdout):
|
||||||
if msg.get('type') == 'backlog':
|
if msg.get('type') == 'backlog':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# get the current state, if the state changes from RUNNING to IDLE
|
||||||
|
if msg.get('state') == 'RUNNING':
|
||||||
|
if kiln_state == 'IDLE':
|
||||||
|
kiln_state = 'RUNNING'
|
||||||
|
prev_kiln_state = 'IDLE'
|
||||||
|
continue
|
||||||
|
if msg.get('state') == 'IDLE':
|
||||||
|
if kiln_state == 'RUNNING':
|
||||||
|
kiln_state = 'IDLE'
|
||||||
|
prev_kiln_state = 'RUNNING'
|
||||||
|
continue
|
||||||
|
|
||||||
if not noprofilestats:
|
if not noprofilestats:
|
||||||
msg['stamp'] = time.time()
|
msg['stamp'] = time.time()
|
||||||
if pidstats and 'pidstats' in msg:
|
if pidstats and 'pidstats' in msg:
|
||||||
|
|
@ -125,15 +141,15 @@ def logger(hostname, csvfile, noprofilestats, pidstats, stdout):
|
||||||
temp = round(msg['temperature'])
|
temp = round(msg['temperature'])
|
||||||
# time remaining for the display, calculated for rounded seconds
|
# time remaining for the display, calculated for rounded seconds
|
||||||
time_rem = msg['totaltime'] - msg['runtime']
|
time_rem = msg['totaltime'] - msg['runtime']
|
||||||
if time_rem == -1 or msg['state'] == "IDLE":
|
if time_rem == -1 or kiln_state == 'IDLE':
|
||||||
if msg['state'] == "IDLE":
|
if prev_kiln_state == 'IDLE':
|
||||||
seg.text = f"READY...TEMP{temp:4.0f}"
|
seg.text = f"READY....TEMP{temp:4.0f}"
|
||||||
else:
|
else:
|
||||||
seg.text = f"DONE....TEMP{temp:4.0f}"
|
seg.text = f"DONE....TEMP{temp:4.0f}"
|
||||||
else:
|
else:
|
||||||
hours = round(time_rem // 3600)
|
hours = round(time_rem // 3600)
|
||||||
minutes = round((time_rem - (hours * 3600)) // 60)
|
minutes = round((time_rem - (hours * 3600)) // 60)
|
||||||
seconds = round((time_rem - (hours * 3600) - (minutes * 60)))
|
seconds = round((time_rem - (hours * 3600) - (minutes * 60))) - 1
|
||||||
seg.text = f"{hours:2.0f}-{minutes:2.0f}-{seconds:2.0f}TEMP{temp:4.0f}"
|
seg.text = f"{hours:2.0f}-{minutes:2.0f}-{seconds:2.0f}TEMP{temp:4.0f}"
|
||||||
# END ADD TEMP
|
# END ADD TEMP
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue