paneldue: 'gcode' status is now in 'gcode_move'

Also toolhead.status is no longer available, use idle_timeout.state.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2020-08-17 19:55:53 -04:00
parent 88bbd66a3b
commit 2848b4e9c1
1 changed files with 17 additions and 13 deletions

View File

@ -142,8 +142,9 @@ class PanelDue:
# Initialize tracked state. # Initialize tracked state.
self.printer_state = { self.printer_state = {
'gcode': {}, 'toolhead': {}, 'virtual_sdcard': {}, 'gcode_move': {}, 'toolhead': {}, 'virtual_sdcard': {},
'fan': {}, 'display_status': {}, 'print_stats': {}} 'fan': {}, 'display_status': {}, 'print_stats': {},
'idle_timeout': {}}
self.extruder_count = 0 self.extruder_count = 0
self.heaters = [] self.heaters = []
self.is_ready = False self.is_ready = False
@ -247,8 +248,9 @@ class PanelDue:
# Initalize printer state and make subscription request # Initalize printer state and make subscription request
self.printer_state = { self.printer_state = {
'gcode': {}, 'toolhead': {}, 'virtual_sdcard': {}, 'gcode_move': {}, 'toolhead': {}, 'virtual_sdcard': {},
'fan': {}, 'display_status': {}, 'print_stats': {}} 'fan': {}, 'display_status': {}, 'print_stats': {},
'idle_timeout': {}}
sub_args = {k: None for k in self.printer_state.keys()} sub_args = {k: None for k in self.printer_state.keys()}
self.extruder_count = 0 self.extruder_count = 0
self.heaters = [] self.heaters = []
@ -462,8 +464,8 @@ class PanelDue:
return 'S' return 'S'
printer_state = self.printer_state printer_state = self.printer_state
th_busy = printer_state['toolhead'].get( p_busy = printer_state['idle_timeout'].get(
'status', 'Ready') == "Printing" 'state', 'Idle') == "Printing"
sd_state = printer_state['print_stats'].get('state', "standby") sd_state = printer_state['print_stats'].get('state', "standby")
if sd_state == "printing": if sd_state == "printing":
if self.last_printer_state == 'A': if self.last_printer_state == 'A':
@ -472,14 +474,14 @@ class PanelDue:
# Printing # Printing
return 'P' return 'P'
elif sd_state == "paused": elif sd_state == "paused":
if th_busy and self.last_printer_state != 'A': if p_busy and self.last_printer_state != 'A':
# Pausing # Pausing
return 'D' return 'D'
else: else:
# Paused # Paused
return 'A' return 'A'
if th_busy: if p_busy:
# Printer is "busy" # Printer is "busy"
return 'B' return 'B'
@ -514,15 +516,15 @@ class PanelDue:
p_state = self.printer_state p_state = self.printer_state
self.last_printer_state = self._get_printer_status() self.last_printer_state = self._get_printer_status()
response['status'] = self.last_printer_state response['status'] = self.last_printer_state
response['babystep'] = round(p_state['gcode'].get( response['babystep'] = round(p_state['gcode_move'].get(
'homing_zpos', 0.), 3) 'homing_origin', [0., 0., 0., 0.])[2], 3)
# Current position # Current position
pos = p_state['toolhead'].get('position', [0., 0., 0., 0.]) pos = p_state['toolhead'].get('position', [0., 0., 0., 0.])
response['pos'] = [round(p, 2) for p in pos[:3]] response['pos'] = [round(p, 2) for p in pos[:3]]
homed_pos = p_state['toolhead'].get('homed_axes', "") homed_pos = p_state['toolhead'].get('homed_axes', "")
response['homed'] = [int(a in homed_pos) for a in "xyz"] response['homed'] = [int(a in homed_pos) for a in "xyz"]
sfactor = round(p_state['gcode'].get('speed_factor', 1.) * 100, 2) sfactor = round(p_state['gcode_move'].get('speed_factor', 1.) * 100, 2)
response['sfactor'] = sfactor response['sfactor'] = sfactor
# Print Progress Tracking # Print Progress Tracking
@ -552,7 +554,8 @@ class PanelDue:
# object height estimate # object height estimate
obj_height = self.file_metadata.get('object_height') obj_height = self.file_metadata.get('object_height')
if obj_height: if obj_height:
cur_height = p_state['gcode'].get('move_zpos', 0.) cur_height = p_state['gcode_move'].get(
'gcode_position', [0., 0., 0., 0.])[2]
hpct = min(1., cur_height / obj_height) hpct = min(1., cur_height / obj_height)
times_left.append(int(est_time - est_time * hpct)) times_left.append(int(est_time - est_time * hpct))
else: else:
@ -579,7 +582,8 @@ class PanelDue:
response['tool'] = tool response['tool'] = tool
# Report Heater Status # Report Heater Status
efactor = round(p_state['gcode'].get('extrude_factor', 1.) * 100., 2) efactor = round(p_state['gcode_move'].get(
'extrude_factor', 1.) * 100., 2)
for name in self.heaters: for name in self.heaters:
temp = round(p_state[name].get('temperature', 0.0), 1) temp = round(p_state[name].get('temperature', 0.0), 1)