mirror of https://github.com/Desuuuu/klipper.git
klippy: Add an is_shutdown() method
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
86a99cf38e
commit
44f868a802
|
@ -54,7 +54,7 @@ class Printer:
|
||||||
self.reactor = reactor.Reactor()
|
self.reactor = reactor.Reactor()
|
||||||
self.reactor.register_callback(self._connect)
|
self.reactor.register_callback(self._connect)
|
||||||
self.state_message = message_startup
|
self.state_message = message_startup
|
||||||
self.is_shutdown = False
|
self.in_shutdown_state = False
|
||||||
self.run_result = None
|
self.run_result = None
|
||||||
self.event_handlers = {}
|
self.event_handlers = {}
|
||||||
gc = gcode.GCodeParser(self, input_fd)
|
gc = gcode.GCodeParser(self, input_fd)
|
||||||
|
@ -65,6 +65,8 @@ class Printer:
|
||||||
return self.reactor
|
return self.reactor
|
||||||
def get_state_message(self):
|
def get_state_message(self):
|
||||||
return self.state_message
|
return self.state_message
|
||||||
|
def is_shutdown(self):
|
||||||
|
return self.in_shutdown_state
|
||||||
def _set_state(self, msg):
|
def _set_state(self, msg):
|
||||||
if self.state_message in (message_ready, message_startup):
|
if self.state_message in (message_ready, message_startup):
|
||||||
self.state_message = msg
|
self.state_message = msg
|
||||||
|
@ -188,10 +190,10 @@ class Printer:
|
||||||
logging.exception("Unhandled exception during post run")
|
logging.exception("Unhandled exception during post run")
|
||||||
return run_result
|
return run_result
|
||||||
def invoke_shutdown(self, msg):
|
def invoke_shutdown(self, msg):
|
||||||
if self.is_shutdown:
|
if self.in_shutdown_state:
|
||||||
return
|
return
|
||||||
logging.error("Transition to shutdown state: %s", msg)
|
logging.error("Transition to shutdown state: %s", msg)
|
||||||
self.is_shutdown = True
|
self.in_shutdown_state = True
|
||||||
self._set_state("%s%s" % (msg, message_shutdown))
|
self._set_state("%s%s" % (msg, message_shutdown))
|
||||||
for cb in self.event_handlers.get("klippy:shutdown", []):
|
for cb in self.event_handlers.get("klippy:shutdown", []):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue