From 062e3ec24efe8f4b6e7065718b89d9175f1500a3 Mon Sep 17 00:00:00 2001 From: jimmyjon711 Date: Mon, 9 Dec 2024 20:18:21 -0700 Subject: [PATCH] Adding code to pause print if prep sensor goes false --- extras/AFC_stepper.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/extras/AFC_stepper.py b/extras/AFC_stepper.py index 1c8498c..89d6356 100644 --- a/extras/AFC_stepper.py +++ b/extras/AFC_stepper.py @@ -237,14 +237,20 @@ def prep_callback(self, eventtime, state): if self.load_state == True and self.prep_state == True: self.status = 'Loaded' self.AFC.afc_led(self.AFC.led_ready, led) - elif self.name == self.AFC.current and self.IDLE.state == 'Printing' and self.AFC.lanes[self.unit][self.name]['runout_lane'] != 'NONE': - self.status = None - self.AFC.afc_led(self.AFC.led_not_ready, led) - self.AFC.gcode.respond_info("Infinite Spool triggered") - empty_LANE = self.printer.lookup_object('AFC_stepper ' + self.AFC.current) - change_LANE = self.printer.lookup_object('AFC_stepper ' + self.AFC.lanes[self.unit][self.name]['runout_lane']) - self.gcode.run_script_from_command(change_LANE.map) - self.gcode.run_script_from_command('SET_MAP LANE=' + change_LANE.name + ' MAP=' + empty_LANE.map) + elif self.name == self.AFC.current and self.AFC.IDLE.state == 'Printing': + # Checking to make sure runout_lane is set and does not equal 'NONE' + if self.AFC.lanes[self.unit][self.name]['runout_lane'] and self.AFC.lanes[self.unit][self.name]['runout_lane'] != 'NONE': + self.status = None + self.AFC.afc_led(self.AFC.led_not_ready, led) + self.AFC.gcode.respond_info("Infinite Spool triggered for {}".format(self.name)) + empty_LANE = self.printer.lookup_object('AFC_stepper ' + self.AFC.current) + change_LANE = self.printer.lookup_object('AFC_stepper ' + self.AFC.lanes[self.unit][self.name]['runout_lane']) + self.gcode.run_script_from_command(change_LANE.map) + self.gcode.run_script_from_command('SET_MAP LANE=' + change_LANE.name + ' MAP=' + empty_LANE.map) + else: + # Pause print + self.AFC.gcode.respond_info("Runout triggered for lane {} and runout lane is not setup to switch to another lane".format(self.name)) + self.AFC.ERROR.pause_print() else: self.status = None self.AFC.afc_led(self.AFC.led_not_ready, led)