paneldue: re-initalize if the paneldue disconnects
If 10 seconds passes without an update request, re-initialize the PanelDue. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
119b0bf60c
commit
70501772c1
|
@ -16,6 +16,7 @@ from tornado.ioloop import IOLoop
|
||||||
from tornado.locks import Lock
|
from tornado.locks import Lock
|
||||||
|
|
||||||
MIN_EST_TIME = 10.
|
MIN_EST_TIME = 10.
|
||||||
|
INITIALIZE_TIMEOUT = 10.
|
||||||
|
|
||||||
class PanelDueError(ServerError):
|
class PanelDueError(ServerError):
|
||||||
pass
|
pass
|
||||||
|
@ -47,6 +48,7 @@ class SerialConnection:
|
||||||
self.ser.close()
|
self.ser.close()
|
||||||
self.ser = None
|
self.ser = None
|
||||||
self.partial_input = b""
|
self.partial_input = b""
|
||||||
|
self.paneldue.initialized = False
|
||||||
logging.info("PanelDue Disconnected")
|
logging.info("PanelDue Disconnected")
|
||||||
if reconnect and not self.attempting_connect:
|
if reconnect and not self.attempting_connect:
|
||||||
self.attempting_connect = True
|
self.attempting_connect = True
|
||||||
|
@ -170,6 +172,7 @@ class PanelDue:
|
||||||
self.is_shutdown = False
|
self.is_shutdown = False
|
||||||
self.initialized = False
|
self.initialized = False
|
||||||
self.last_printer_state = 'C'
|
self.last_printer_state = 'C'
|
||||||
|
self.last_update_time = 0.
|
||||||
|
|
||||||
# Set up macros
|
# Set up macros
|
||||||
self.confirmed_gcode = ""
|
self.confirmed_gcode = ""
|
||||||
|
@ -518,6 +521,11 @@ class PanelDue:
|
||||||
sequence = arg_r
|
sequence = arg_r
|
||||||
response_type = arg_s
|
response_type = arg_s
|
||||||
|
|
||||||
|
curtime = self.ioloop.time()
|
||||||
|
if curtime - self.last_update_time > INITIALIZE_TIMEOUT:
|
||||||
|
self.initialized = False
|
||||||
|
self.last_update_time = curtime
|
||||||
|
|
||||||
if not self.initialized:
|
if not self.initialized:
|
||||||
response['dir'] = "/macros"
|
response['dir'] = "/macros"
|
||||||
response['files'] = list(self.available_macros.keys())
|
response['files'] = list(self.available_macros.keys())
|
||||||
|
|
Loading…
Reference in New Issue