From 7595aacf065876fe5b3ccf0d41ac54ff6b007010 Mon Sep 17 00:00:00 2001 From: jimmyjon711 Date: Sat, 21 Dec 2024 13:06:50 -0700 Subject: [PATCH 1/9] Removing .name from lane since lane is already the name --- extras/AFC_spool.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/extras/AFC_spool.py b/extras/AFC_spool.py index 15534ab3..979835ee 100644 --- a/extras/AFC_spool.py +++ b/extras/AFC_spool.py @@ -58,7 +58,7 @@ def cmd_SET_MAP(self, gcmd): if lane not in self.AFC.stepper: self.AFC.gcode.respond_info('{} Unknown'.format(lane.upper())) return - CUR_LANE = self.AFC.stepper[lane.name] + CUR_LANE = self.AFC.stepper[lane] for UNIT_SERACH in self.AFC.units.keys(): self.gcode.respond_info("looking for "+lane+" in " + UNIT_SERACH) if lane in self.AFC.units[UNIT_SERACH]: @@ -100,7 +100,7 @@ def cmd_SET_COLOR(self, gcmd): if lane not in self.AFC.stepper: self.AFC.gcode.respond_info('{} Unknown'.format(lane.upper())) return - CUR_LANE = self.AFC.stepper[lane.name] + CUR_LANE = self.AFC.stepper[lane] CUR_LANE.color = '#' + color self.AFC.save_vars() @@ -131,7 +131,7 @@ def cmd_SET_WEIGHT(self, gcmd): if lane not in self.AFC.stepper: self.AFC.gcode.respond_info('{} Unknown'.format(lane.upper())) return - CUR_LANE = self.AFC.stepper[lane.name] + CUR_LANE = self.AFC.stepper[lane] CUR_LANE.weight = weight self.AFC.save_vars() @@ -162,7 +162,7 @@ def cmd_SET_MATERIAL(self, gcmd): if lane not in self.AFC.stepper: self.AFC.gcode.respond_info('{} Unknown'.format(lane.upper())) return - CUR_LANE = self.AFC.stepper[lane.name] + CUR_LANE = self.AFC.stepper[lane] CUR_LANE.material = material self.AFC.save_vars() def set_active_spool(self, ID): @@ -207,10 +207,10 @@ def cmd_SET_SPOOLID(self, gcmd): if lane not in self.AFC.stepper: self.AFC.gcode.respond_info('{} Unknown'.format(lane.upper())) return - CUR_LANE = self.AFC.stepper[lane.name] + CUR_LANE = self.AFC.stepper[lane] self.set_spoolID(CUR_LANE, SpoolID) - def set_spoolID(self, CUR_LANE, SpoolID): + def set_spoolID(self, CUR_LANE, SpoolID, save_vars=True): if self.AFC.spoolman_ip !=None: if SpoolID !='': try: @@ -233,7 +233,7 @@ def set_spoolID(self, CUR_LANE, SpoolID): CUR_LANE.material = '' CUR_LANE.color = '' CUR_LANE.weight = '' - self.AFC.save_vars() + if save_vars: self.AFC.save_vars() cmd_SET_RUNOUT_help = "change filaments ID" def cmd_SET_RUNOUT(self, gcmd): @@ -262,7 +262,7 @@ def cmd_SET_RUNOUT(self, gcmd): if lane not in self.AFC.stepper: self.AFC.gcode.respond_info('{} Unknown'.format(lane.upper())) return - CUR_LANE = self.AFC.stepper[lane.name] + CUR_LANE = self.AFC.stepper[lane] CUR_LANE.runout_lane = runout self.AFC.save_vars() self.gcode.respond_info("This is a feature WIP. Not functioning yet") From d37951a2753ce20a0b01a5097f7f3729c61e0fed Mon Sep 17 00:00:00 2001 From: jimmyjon711 Date: Sat, 21 Dec 2024 13:09:06 -0700 Subject: [PATCH 2/9] Changing hub_loaded to loaded_to_hub since this is what is going into vars file now - Added backwards compatibility check for hub_loaded to set loaded_to_hub value --- extras/AFC.py | 27 +++++++++------------ extras/AFC_BoxTurtle.py | 8 +++---- extras/AFC_NightOwl.py | 2 +- extras/AFC_error.py | 4 +++- extras/AFC_prep.py | 52 ++++++++++++++++++++++++----------------- extras/AFC_stepper.py | 4 +--- 6 files changed, 51 insertions(+), 46 deletions(-) diff --git a/extras/AFC.py b/extras/AFC.py index f59124d6..a8cf640b 100644 --- a/extras/AFC.py +++ b/extras/AFC.py @@ -23,7 +23,6 @@ def __init__(self, config): self.current = None self.error_state = False self.units = {} - self.lanes = {} self.extruders = {} self.stepper = {} self.tool_cmds={} @@ -448,7 +447,7 @@ def cmd_HUB_LOAD(self, gcmd): CUR_LANE.do_enable(True) while CUR_LANE.load_state == False: CUR_LANE.move( CUR_HUB.move_dis, self.short_moves_speed, self.short_moves_accel) - if CUR_LANE.hub_load == False: + if CUR_LANE.loaded_to_hub == False: CUR_LANE.move(CUR_LANE.dist_hub, CUR_LANE.dist_hub_move_speed, CUR_LANE.dist_hub_move_accel, True if CUR_LANE.dist_hub > 200 else False) while CUR_HUB.state == False: CUR_LANE.move(CUR_HUB.move_dis, self.short_moves_speed, self.short_moves_accel) @@ -457,7 +456,7 @@ def cmd_HUB_LOAD(self, gcmd): CUR_LANE.status = '' self.save_vars() CUR_LANE.do_enable(False) - CUR_LANE.hub_load = True + CUR_LANE.loaded_to_hub = True self.save_vars() cmd_LANE_UNLOAD_help = "Unload lane from extruder" @@ -477,10 +476,6 @@ def cmd_LANE_UNLOAD(self, gcmd): Returns: None """ - if not self.is_homed(): - self.ERROR.AFC_error("Please home printer before doing a tool unload", False) - return False - lane = gcmd.get('LANE', None) if lane not in self.stepper: self.gcode.respond_info('{} Unknown'.format(lane.upper())) @@ -494,9 +489,9 @@ def cmd_LANE_UNLOAD(self, gcmd): CUR_LANE.status = 'ejecting' self.save_vars() CUR_LANE.do_enable(True) - if CUR_LANE.hub_load: + if CUR_LANE.loaded_to_hub: CUR_LANE.move(CUR_LANE.dist_hub * -1, CUR_LANE.dist_hub_move_speed, CUR_LANE.dist_hub_move_accel, True if CUR_LANE.dist_hub > 200 else False) - CUR_LANE.hub_load = False + CUR_LANE.loaded_to_hub = False while CUR_LANE.load_state == True: CUR_LANE.move( CUR_HUB.move_dis * -1, self.short_moves_speed, self.short_moves_accel, True) CUR_LANE.move( CUR_HUB.move_dis * -5, self.short_moves_speed, self.short_moves_accel) @@ -597,10 +592,10 @@ def TOOL_LOAD(self, CUR_LANE): CUR_LANE.do_enable(True) # Move filament to the hub if it's not already loaded there. - if not CUR_LANE.hub_load: + if not CUR_LANE.loaded_to_hub: CUR_LANE.move(CUR_LANE.dist_hub, CUR_LANE.dist_hub_move_speed, CUR_LANE.dist_hub_move_accel, CUR_LANE.dist_hub > 200) - CUR_LANE.hub_load = True + CUR_LANE.loaded_to_hub = True hub_attempts = 0 # Ensure filament moves past the hub. @@ -658,7 +653,7 @@ def TOOL_LOAD(self, CUR_LANE): break CUR_LANE.extruder_stepper.sync_to_extruder(CUR_LANE.extruder_name) # Update tool and lane status. - CUR_LANE.status = 'tool' + CUR_LANE.status = 'Tooled' CUR_LANE.tool_loaded = True self.current = CUR_LANE.name CUR_EXTRUDER.enable_buffer() @@ -675,7 +670,6 @@ def TOOL_LOAD(self, CUR_LANE): self.gcode.run_script_from_command(self.wipe_cmd) # Update lane and extruder state for tracking. - CUR_LANE.hub_loaded = True self.extruders[CUR_LANE.extruder_name]['lane_loaded'] = CUR_LANE.name self.SPOOL.set_active_spool(CUR_LANE.spool_id) self.afc_led(self.led_tool_loaded, CUR_LANE.led_index) @@ -887,7 +881,7 @@ def TOOL_UNLOAD(self, CUR_LANE): return False # Finalize unloading and reset lane state. - CUR_LANE.hub_load = True + CUR_LANE.loaded_to_hub = True self.afc_led(self.led_ready, CUR_LANE.led_index) CUR_LANE.status = None self.save_vars() @@ -1023,6 +1017,7 @@ def get_status(self, eventtime): screen_mac = 'None' str[UNIT]={} for NAME in self.units[UNIT].keys(): + if NAME == "system": continue CUR_LANE=self.stepper[NAME] str[UNIT][NAME]={} str[UNIT][NAME]['LANE'] = CUR_LANE.index @@ -1057,9 +1052,9 @@ def get_status(self, eventtime): for EXTRUDE in self.extruders.keys(): str["system"]["extruders"][EXTRUDE]={} CUR_EXTRUDER = self.printer.lookup_object('AFC_extruder ' + EXTRUDE) - str["system"]["extruders"][EXTRUDE]['lane_loaded'] = self.extruders[CUR_LANE.extruder_name]['lane_loaded'] + str["system"]["extruders"][EXTRUDE]['lane_loaded'] = self.extruders[CUR_EXTRUDER.name]['lane_loaded'] if CUR_EXTRUDER.tool_start == "buffer": - if self.extruders[CUR_LANE.extruder_name]['lane_loaded'] == '': + if self.extruders[CUR_EXTRUDER.name]['lane_loaded'] == '': str ["system"]["extruders"][EXTRUDE]['tool_start_sensor'] = False else: str["system"]["extruders"][EXTRUDE]['tool_start_sensor'] = True diff --git a/extras/AFC_BoxTurtle.py b/extras/AFC_BoxTurtle.py index db6dda43..04884866 100644 --- a/extras/AFC_BoxTurtle.py +++ b/extras/AFC_BoxTurtle.py @@ -53,7 +53,6 @@ def system_Test(self, UNIT, LANE, delay): msg += 'EMPTY READY FOR SPOOL' else: self.AFC.afc_led(self.AFC.led_fault, CUR_LANE.led_index) - CUR_LANE.status = None msg +=" NOT READY" CUR_LANE.do_enable(False) msg = 'CHECK FILAMENT Prep: False - Load: True' @@ -79,6 +78,7 @@ def system_Test(self, UNIT, LANE, delay): msg += "\n Ram sensor enabled, confirm tool is loaded" self.AFC.SPOOL.set_active_spool(CUR_LANE.spool_id) self.AFC.afc_led(self.AFC.led_tool_loaded, CUR_LANE.led_index) + CUR_LANE.status = 'Tooled' if len(self.AFC.extruders) == 1: self.AFC.current = CUR_LANE.name CUR_EXTRUDER.enable_buffer() @@ -143,8 +143,8 @@ def find_lane_to_calibrate(lane_name): Returns: The lane name if found, otherwise None """ - for UNIT in self.AFC.lanes.keys(): - if lane_name in self.AFC.lanes[UNIT]: + for UNIT in self.AFC.unit.keys(): + if lane_name in self.AFC.unit[UNIT]: return lane_name # If the lane was not found @@ -201,7 +201,7 @@ def calibrate_lane(LANE): hub_pos = calibrate_hub(CUR_LANE, CUR_HUB) if CUR_HUB.state: CUR_LANE.move(CUR_HUB.move_dis * -1, self.AFC.short_moves_speed, self.AFC.short_moves_accel, True) - CUR_LANE.hub_load = True + CUR_LANE.loaded_to_hub = True CUR_LANE.do_enable(False) cal_msg = "\n{} dist_hub: {}".format(CUR_LANE.name.upper(), (hub_pos - CUR_HUB.hub_clear_move_dis)) return True, cal_msg diff --git a/extras/AFC_NightOwl.py b/extras/AFC_NightOwl.py index f753c72d..ce5405c9 100644 --- a/extras/AFC_NightOwl.py +++ b/extras/AFC_NightOwl.py @@ -46,7 +46,6 @@ def system_Test(self, UNIT, LANE, delay): msg += 'EMPTY READY FOR SPOOL' else: self.AFC.afc_led(self.AFC.led_fault, CUR_LANE.led_index) - CUR_LANE.status = None msg +=" NOT READY" CUR_LANE.do_enable(False) msg = 'CHECK FILAMENT Prep: False - Load: True' @@ -73,6 +72,7 @@ def system_Test(self, UNIT, LANE, delay): msg += "\n Ram sensor enabled, confirm tool is loaded" self.AFC.SPOOL.set_active_spool(CUR_LANE.spool_id) self.AFC.afc_led(self.AFC.led_tool_loaded, CUR_LANE.led_index) + CUR_LANE.status = 'Tooled' if len(self.AFC.extruders) == 1: self.AFC.current = CUR_LANE.name CUR_EXTRUDER.enable_buffer() diff --git a/extras/AFC_error.py b/extras/AFC_error.py index f4a6561a..d0f64c71 100644 --- a/extras/AFC_error.py +++ b/extras/AFC_error.py @@ -52,7 +52,9 @@ def ToolHeadFix(self, CUR_LANE): CUR_LANE.move(-5, self.AFC.short_moves_speed, self.AFC.short_moves_accel, True) while CUR_LANE.load_state == False: # reload lane extruder CUR_LANE.move(5, self.AFC.short_moves_speed, self.AFC.short_moves_accel, True) - self.AFC.lanes[CUR_LANE.unit][CUR_LANE.name]['tool_loaded'] = False + + CUR_LANE.tool_load = False + CUR_LANE.loaded_to_hub = False self.AFC.extruders[CUR_LANE.extruder_name]['lane_loaded']= '' self.AFC.save_vars() self.pause = False diff --git a/extras/AFC_prep.py b/extras/AFC_prep.py index dd9cbd15..02500669 100644 --- a/extras/AFC_prep.py +++ b/extras/AFC_prep.py @@ -52,45 +52,55 @@ def PREP(self, gcmd): self._rename_resume() + extruders={} + units={} ## load Unit variables if os.path.exists(self.AFC.VarFile + '.unit') and os.stat(self.AFC.VarFile + '.unit').st_size > 0: - self.AFC.lanes=json.load(open(self.AFC.VarFile + '.unit')) + units=json.load(open(self.AFC.VarFile + '.unit')) ## load Toolhead variables if os.path.exists(self.AFC.VarFile + '.tool') and os.stat(self.AFC.VarFile + '.tool').st_size > 0: - self.AFC.extruders=json.load(open(self.AFC.VarFile + '.tool')) - else: - self.AFC.extruders={} - - temp=[] + extruders=json.load(open(self.AFC.VarFile + '.tool')) self.AFC.tool_cmds={} + for PO in self.printer.objects: if 'AFC_stepper' in PO and 'tmc' not in PO: LANE=self.printer.lookup_object(PO) self.AFC.stepper[LANE.name]=LANE - temp.append(LANE.name) - if LANE.extruder_name not in self.AFC.extruders: self.AFC.extruders[LANE.extruder_name]={} - if LANE.unit not in self.AFC.units: self.AFC.units[LANE.unit] = {} - if LANE.unit not in self.AFC.lanes: self.AFC.lanes[LANE.unit] = {} + + if LANE.extruder_name not in extruders: self.AFC.extruders[LANE.extruder_name]={} + else: self.AFC.extruders[LANE.extruder_name] = extruders[LANE.extruder_name] + + if LANE.unit not in units: self.AFC.units[LANE.unit] = {} + else: + if LANE.unit not in self.AFC.units: + self.AFC.units[LANE.unit] = units[LANE.unit] + self.AFC.units[LANE.unit].pop("system", None) + if LANE.name not in self.AFC.units[LANE.unit]: self.AFC.units[LANE.unit][LANE.name]={} - if 'spool_id' in self.AFC.lanes[LANE.unit][LANE.name]: LANE.spool_id = self.AFC.lanes[LANE.unit][LANE.name]['spool_id'] + else: self.AFC.units[LANE.unit][LANE.name] = units[LANE.unit][LANE.name] + + if 'spool_id' in self.AFC.units[LANE.unit][LANE.name]: LANE.spool_id = self.AFC.units[LANE.unit][LANE.name]['spool_id'] if self.AFC.spoolman_ip !=None and LANE.spool_id != None: - self.AFC.SPOOL.set_spoolID(LANE, LANE.spool_id) + self.AFC.SPOOL.set_spoolID(LANE, LANE.spool_id, save_vars=False) else: - if 'material' in self.AFC.lanes[LANE.unit][LANE.name]: LANE.material = self.AFC.lanes[LANE.unit][LANE.name]['material'] - if 'color' in self.AFC.lanes[LANE.unit][LANE.name]: LANE.color = self.AFC.lanes[LANE.unit][LANE.name]['color'] - if 'weight' in self.AFC.lanes[LANE.unit][LANE.name]: LANE.weight=self.AFC.lanes[LANE.unit][LANE.name]['weight'] + if 'material' in self.AFC.units[LANE.unit][LANE.name]: LANE.material = self.AFC.units[LANE.unit][LANE.name]['material'] + if 'color' in self.AFC.units[LANE.unit][LANE.name]: LANE.color = self.AFC.units[LANE.unit][LANE.name]['color'] + if 'weight' in self.AFC.units[LANE.unit][LANE.name]: LANE.weight=self.AFC.units[LANE.unit][LANE.name]['weight'] - if 'runout_lane' in self.AFC.lanes[LANE.unit][LANE.name]: LANE.runout_lane = self.AFC.lanes[LANE.unit][LANE.name]['runout_lane'] + if 'runout_lane' in self.AFC.units[LANE.unit][LANE.name]: LANE.runout_lane = self.AFC.units[LANE.unit][LANE.name]['runout_lane'] if LANE.runout_lane == '': LANE.runout_lane='NONE' - if 'map' in self.AFC.lanes[LANE.unit][LANE.name]: LANE.map = self.AFC.lanes[LANE.unit][LANE.name]['map'] + if 'map' in self.AFC.units[LANE.unit][LANE.name]: LANE.map = self.AFC.units[LANE.unit][LANE.name]['map'] if LANE.map != 'NONE': self.AFC.tool_cmds[LANE.map] = LANE.name - if 'hub_loaded' in self.AFC.lanes[LANE.unit][LANE.name]: LANE.hub_loaded = self.AFC.lanes[LANE.unit][LANE.name]['hub_loaded'] - if 'tool_loaded' in self.AFC.lanes[LANE.unit][LANE.name]: LANE.tool_loaded = self.AFC.lanes[LANE.unit][LANE.name]['tool_loaded'] - if 'status' in self.AFC.lanes[LANE.unit][LANE.name]: LANE.status = self.AFC.lanes[LANE.unit][LANE.name]['status'] - self.AFC.lanes={} + # Check first for hub_loaded as this was the old name in software with version <= 1030 + if 'hub_loaded' in self.AFC.units[LANE.unit][LANE.name]: LANE.loaded_to_hub = self.AFC.units[LANE.unit][LANE.name]['hub_loaded'] + # Check for loaded_to_hub as this is how its being saved version > 1030 + if 'loaded_to_hub' in self.AFC.units[LANE.unit][LANE.name]: LANE.loaded_to_hub = self.AFC.units[LANE.unit][LANE.name]['loaded_to_hub'] + if 'tool_loaded' in self.AFC.units[LANE.unit][LANE.name]: LANE.tool_loaded = self.AFC.units[LANE.unit][LANE.name]['tool_loaded'] + if 'status' in self.AFC.units[LANE.unit][LANE.name]: LANE.status = self.AFC.units[LANE.unit][LANE.name]['status'] + self.AFC.save_vars() if self.enable == False: self.AFC.gcode.respond_info('Prep Checks Disabled') diff --git a/extras/AFC_stepper.py b/extras/AFC_stepper.py index eff2a517..be1f7361 100644 --- a/extras/AFC_stepper.py +++ b/extras/AFC_stepper.py @@ -64,7 +64,7 @@ def __init__(self, config): self.color = None self.weight = None self.runout_lane = 'NONE' - self.status = None + self.status = 'Not Loaded' unit = config.get('unit', None) if unit != None: self.unit = unit.split(':')[0] @@ -75,8 +75,6 @@ def __init__(self, config): self.hub= '' self.motion_queue = None - self.status = None - self.hub_load = False self.next_cmd_time = 0. ffi_main, ffi_lib = chelper.get_ffi() self.trapq = ffi_main.gc(ffi_lib.trapq_alloc(), ffi_lib.trapq_free) From 778e5ea80164ce58dc1e531d595cc6ec3466c6e6 Mon Sep 17 00:00:00 2001 From: jimmyjon711 Date: Sat, 21 Dec 2024 13:18:47 -0700 Subject: [PATCH 3/9] Adding printing out of git version --- extras/AFC.py | 12 ++++++++++++ extras/AFC_prep.py | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/extras/AFC.py b/extras/AFC.py index a8cf640b..75a370b6 100644 --- a/extras/AFC.py +++ b/extras/AFC.py @@ -8,6 +8,8 @@ import json from configparser import Error as error +AFC_VERSION="1.0.0" + class afc: def __init__(self, config): self.printer = config.get_printer() @@ -101,6 +103,9 @@ def __init__(self, config): #self.debug = True == config.get('debug', 0) self.debug = False + # Printing here will not display in console but it will go to klippy.log + self.print_version() + def _update_trsync(self, config): # Logic to update trsync values update_trsync = config.getboolean("trsync_update", False) @@ -140,6 +145,13 @@ def handle_connect(self): self.gcode.register_command('HUB_CUT_TEST', self.cmd_HUB_CUT_TEST, desc=self.cmd_HUB_CUT_TEST_help) self.gcode.register_mux_command('SET_BOWDEN_LENGTH', 'AFC', None, self.cmd_SET_BOWDEN_LENGTH, desc=self.cmd_SET_BOWDEN_LENGTH_help) self.gcode.register_command('AFC_STATUS', self.cmd_AFC_STATUS, desc=self.cmd_AFC_STATUS_help) + + def print_version(self): + import subprocess, os + afc_dir = os.path.dirname(os.path.realpath(__file__)) + git_hash = subprocess.check_output(['git', '-C', '{}'.format(afc_dir), 'rev-parse', '--short', 'HEAD']).decode('ascii').strip() + git_commit_num = subprocess.check_output(['git', '-C', '{}'.format(afc_dir), 'rev-list', 'HEAD', '--count']).decode('ascii').strip() + self.gcode.respond_info("AFC Version: v{}-{}-{}".format(AFC_VERSION, git_commit_num, git_hash)) cmd_AFC_STATUS_help = "Return current status of AFC" def cmd_AFC_STATUS(self, gcmd): diff --git a/extras/AFC_prep.py b/extras/AFC_prep.py index 02500669..a12ff564 100644 --- a/extras/AFC_prep.py +++ b/extras/AFC_prep.py @@ -51,7 +51,7 @@ def PREP(self, gcmd): self.AFC.reactor.pause(self.AFC.reactor.monotonic() + 1) self._rename_resume() - + self.AFC.print_version() extruders={} units={} ## load Unit variables From ac2e713fb2638963dcefe9f4d3bd28647ccb58ae Mon Sep 17 00:00:00 2001 From: jimmyjon711 Date: Sat, 21 Dec 2024 14:17:01 -0700 Subject: [PATCH 4/9] Added lane_loaded to AFC_extruder so status can look at this instead of the array --- extras/AFC.py | 11 +++++------ extras/AFC_BoxTurtle.py | 12 +++++++----- extras/AFC_NightOwl.py | 12 +++++++----- extras/AFC_error.py | 2 +- extras/AFC_extruder.py | 2 ++ extras/AFC_prep.py | 8 ++++---- extras/AFC_stepper.py | 1 + 7 files changed, 27 insertions(+), 21 deletions(-) diff --git a/extras/AFC.py b/extras/AFC.py index 75a370b6..9763c945 100644 --- a/extras/AFC.py +++ b/extras/AFC.py @@ -682,7 +682,7 @@ def TOOL_LOAD(self, CUR_LANE): self.gcode.run_script_from_command(self.wipe_cmd) # Update lane and extruder state for tracking. - self.extruders[CUR_LANE.extruder_name]['lane_loaded'] = CUR_LANE.name + CUR_EXTRUDER.lane_loaded = CUR_LANE.name self.SPOOL.set_active_spool(CUR_LANE.spool_id) self.afc_led(self.led_tool_loaded, CUR_LANE.led_index) self.save_vars() @@ -855,7 +855,7 @@ def TOOL_UNLOAD(self, CUR_LANE): # Clear toolhead's loaded state for easier error handling later. CUR_LANE.tool_loaded = False - self.extruders[CUR_LANE.extruder_name]['lane_loaded'] = '' + CUR_EXTRUDER.lane_loaded = '' CUR_LANE.status = None self.current = None @@ -996,7 +996,7 @@ def cmd_CHANGE_TOOL(self, gcmd): def get_filament_status(self, LANE): if LANE.prep_state: if LANE.load_state: - if self.extruders[LANE.extruder_name]['lane_loaded'] == LANE.name: + if LANE.extruder_obj is not None and LANE.extruder_obj.lane_loaded == LANE.name: return 'In Tool:' + self.HexConvert(self.led_tool_loaded) return "Ready:" + self.HexConvert(self.led_ready) return 'Prep:' + self.HexConvert(self.led_prep_loaded) @@ -1029,7 +1029,6 @@ def get_status(self, eventtime): screen_mac = 'None' str[UNIT]={} for NAME in self.units[UNIT].keys(): - if NAME == "system": continue CUR_LANE=self.stepper[NAME] str[UNIT][NAME]={} str[UNIT][NAME]['LANE'] = CUR_LANE.index @@ -1064,9 +1063,9 @@ def get_status(self, eventtime): for EXTRUDE in self.extruders.keys(): str["system"]["extruders"][EXTRUDE]={} CUR_EXTRUDER = self.printer.lookup_object('AFC_extruder ' + EXTRUDE) - str["system"]["extruders"][EXTRUDE]['lane_loaded'] = self.extruders[CUR_EXTRUDER.name]['lane_loaded'] + str["system"]["extruders"][EXTRUDE]['lane_loaded'] = CUR_EXTRUDER.lane_loaded if CUR_EXTRUDER.tool_start == "buffer": - if self.extruders[CUR_EXTRUDER.name]['lane_loaded'] == '': + if CUR_EXTRUDER.lane_loaded == '': str ["system"]["extruders"][EXTRUDE]['tool_start_sensor'] = False else: str["system"]["extruders"][EXTRUDE]['tool_start_sensor'] = True diff --git a/extras/AFC_BoxTurtle.py b/extras/AFC_BoxTurtle.py index 04884866..f12c0d1c 100644 --- a/extras/AFC_BoxTurtle.py +++ b/extras/AFC_BoxTurtle.py @@ -35,7 +35,8 @@ def system_Test(self, UNIT, LANE, delay): self.AFC.gcode.respond_info('{} Unknown'.format(LANE.upper())) return CUR_LANE = self.AFC.stepper[LANE] - try: CUR_EXTRUDER = self.printer.lookup_object('AFC_extruder ' + CUR_LANE.extruder_name) + try: + CUR_LANE.extruder_obj = self.printer.lookup_object('AFC_extruder ' + CUR_LANE.extruder_name) except: error_string = 'Error: No config found for extruder: ' + CUR_LANE.extruder_name + ' in [AFC_stepper ' + CUR_LANE.name + ']. Please make sure [AFC_extruder ' + CUR_LANE.extruder_name + '] config exists in AFC_Hardware.cfg' self.AFC.ERROR.AFC_error(error_string, False) @@ -70,20 +71,21 @@ def system_Test(self, UNIT, LANE, delay): msg +=" AND LOADED" if CUR_LANE.tool_loaded: - if CUR_EXTRUDER.tool_start_state == True or CUR_EXTRUDER.tool_start == "buffer": + if CUR_LANE.extruder_obj.tool_start_state == True or CUR_LANE.extruder_obj.tool_start == "buffer": if self.AFC.extruders[CUR_LANE.extruder_name]['lane_loaded'] == CUR_LANE.name: CUR_LANE.extruder_stepper.sync_to_extruder(CUR_LANE.extruder_name) msg +=" in ToolHead" - if CUR_EXTRUDER.tool_start == "buffer": + if CUR_LANE.extruder_obj.tool_start == "buffer": msg += "\n Ram sensor enabled, confirm tool is loaded" self.AFC.SPOOL.set_active_spool(CUR_LANE.spool_id) self.AFC.afc_led(self.AFC.led_tool_loaded, CUR_LANE.led_index) CUR_LANE.status = 'Tooled' if len(self.AFC.extruders) == 1: self.AFC.current = CUR_LANE.name - CUR_EXTRUDER.enable_buffer() + CUR_LANE.extruder_obj.enable_buffer() + CUR_LANE.extruder_obj.lane_loaded = CUR_LANE.name else: - if CUR_EXTRUDER.tool_start_state == True: + if CUR_LANE.extruder_obj.tool_start_state == True: msg +=" error in ToolHead. \nLane identified as loaded in AFC.vars.unit file\n but not identified as loaded in AFC.var.tool file" succeeded = False else: diff --git a/extras/AFC_NightOwl.py b/extras/AFC_NightOwl.py index ce5405c9..e9502019 100644 --- a/extras/AFC_NightOwl.py +++ b/extras/AFC_NightOwl.py @@ -28,7 +28,8 @@ def system_Test(self, UNIT, LANE, delay): self.AFC.gcode.respond_info('{} Unknown'.format(LANE.upper())) return CUR_LANE = self.AFC.stepper[LANE] - try: CUR_EXTRUDER = self.printer.lookup_object('AFC_extruder ' + CUR_LANE.extruder_name) + try: + CUR_LANE.extruder_obj = self.printer.lookup_object('AFC_extruder ' + CUR_LANE.extruder_name) except: error_string = 'Error: No config found for extruder: ' + CUR_LANE.extruder_name + ' in [AFC_stepper ' + CUR_LANE.name + ']. Please make sure [AFC_extruder ' + CUR_LANE.extruder_name + '] config exists in AFC_Hardware.cfg' self.AFC.ERROR.AFC_error(error_string, False) @@ -64,20 +65,21 @@ def system_Test(self, UNIT, LANE, delay): msg +=" AND LOADED" if CUR_LANE.tool_loaded: - if CUR_EXTRUDER.tool_start_state == True or CUR_EXTRUDER.tool_start == "buffer": + if CUR_LANE.extruder_obj.tool_start_state == True or CUR_LANE.extruder_obj.tool_start == "buffer": if self.AFC.extruders[CUR_LANE.extruder_name]['lane_loaded'] == CUR_LANE.name: CUR_LANE.extruder_stepper.sync_to_extruder(CUR_LANE.extruder_name) msg +=" in ToolHead" - if CUR_EXTRUDER.tool_start == "buffer": + if CUR_LANE.extruder_obj.tool_start == "buffer": msg += "\n Ram sensor enabled, confirm tool is loaded" self.AFC.SPOOL.set_active_spool(CUR_LANE.spool_id) self.AFC.afc_led(self.AFC.led_tool_loaded, CUR_LANE.led_index) CUR_LANE.status = 'Tooled' if len(self.AFC.extruders) == 1: self.AFC.current = CUR_LANE.name - CUR_EXTRUDER.enable_buffer() + CUR_LANE.extruder_obj.enable_buffer() + CUR_LANE.extruder_obj.lane_loaded = CUR_LANE.name else: - if CUR_EXTRUDER.tool_start_state == True: + if CUR_LANE.extruder_obj.tool_start_state == True: msg +=" error in ToolHead. \nLane identified as loaded in AFC.vars.unit file\n but not identified as loaded in AFC.var.tool file" succeeded = False else: diff --git a/extras/AFC_error.py b/extras/AFC_error.py index d0f64c71..34727ffc 100644 --- a/extras/AFC_error.py +++ b/extras/AFC_error.py @@ -55,7 +55,7 @@ def ToolHeadFix(self, CUR_LANE): CUR_LANE.tool_load = False CUR_LANE.loaded_to_hub = False - self.AFC.extruders[CUR_LANE.extruder_name]['lane_loaded']= '' + CUR_LANE.extruder_obj.lane_loaded = '' self.AFC.save_vars() self.pause = False return True diff --git a/extras/AFC_extruder.py b/extras/AFC_extruder.py index 30982aed..064ac640 100644 --- a/extras/AFC_extruder.py +++ b/extras/AFC_extruder.py @@ -26,6 +26,8 @@ def __init__(self, config): self.tool_start = config.get('pin_tool_start', None) self.tool_end = config.get('pin_tool_end', None) + self.lane_loaded = '' + # RAMMING # Use buffer sensors for loading and unloading filament if self.tool_start == "buffer": diff --git a/extras/AFC_prep.py b/extras/AFC_prep.py index a12ff564..fd47e55a 100644 --- a/extras/AFC_prep.py +++ b/extras/AFC_prep.py @@ -70,10 +70,10 @@ def PREP(self, gcmd): if LANE.extruder_name not in extruders: self.AFC.extruders[LANE.extruder_name]={} else: self.AFC.extruders[LANE.extruder_name] = extruders[LANE.extruder_name] - - if LANE.unit not in units: self.AFC.units[LANE.unit] = {} - else: - if LANE.unit not in self.AFC.units: + + if LANE.unit not in self.AFC.units: + if LANE.unit not in units: self.AFC.units[LANE.unit] = {} + else: self.AFC.units[LANE.unit] = units[LANE.unit] self.AFC.units[LANE.unit].pop("system", None) diff --git a/extras/AFC_stepper.py b/extras/AFC_stepper.py index be1f7361..36bf6d4c 100644 --- a/extras/AFC_stepper.py +++ b/extras/AFC_stepper.py @@ -55,6 +55,7 @@ def __init__(self, config): #stored status variables self.name = config.get_name().split()[-1] self.extruder_name = config.get('extruder') + self.extruder_obj = None self.map = config.get('cmd','NONE') self.tool_loaded = False From 5d1de7804690a6a7c8ca77a94ce1cb806ee7de70 Mon Sep 17 00:00:00 2001 From: jimmyjon711 Date: Sat, 21 Dec 2024 14:32:51 -0700 Subject: [PATCH 5/9] Adding comments --- extras/AFC_prep.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/extras/AFC_prep.py b/extras/AFC_prep.py index fd47e55a..b01cc19f 100644 --- a/extras/AFC_prep.py +++ b/extras/AFC_prep.py @@ -68,15 +68,20 @@ def PREP(self, gcmd): LANE=self.printer.lookup_object(PO) self.AFC.stepper[LANE.name]=LANE + # If extruder section exists in vars file add currently stored data to AFC.extruders array if LANE.extruder_name not in extruders: self.AFC.extruders[LANE.extruder_name]={} else: self.AFC.extruders[LANE.extruder_name] = extruders[LANE.extruder_name] - + + # If units section exists in vars file add currently stored data to AFC.units array if LANE.unit not in self.AFC.units: + # Only adding unit to array if it does not already exist if LANE.unit not in units: self.AFC.units[LANE.unit] = {} else: self.AFC.units[LANE.unit] = units[LANE.unit] + # Removing system as this causes problems with AFC.get_status function self.AFC.units[LANE.unit].pop("system", None) + # If lane section exists in vars file add currently stored data to AFC.units array if LANE.name not in self.AFC.units[LANE.unit]: self.AFC.units[LANE.unit][LANE.name]={} else: self.AFC.units[LANE.unit][LANE.name] = units[LANE.unit][LANE.name] From 916a4af9995665835c06cc5df9a72efdabffa849 Mon Sep 17 00:00:00 2001 From: jimmyjon711 Date: Sat, 21 Dec 2024 14:46:27 -0700 Subject: [PATCH 6/9] Fixing self.AFC.stepper( changed to self.AFC.stepper[] --- extras/AFC_spool.py | 2 +- extras/AFC_stepper.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extras/AFC_spool.py b/extras/AFC_spool.py index 979835ee..a08807da 100644 --- a/extras/AFC_spool.py +++ b/extras/AFC_spool.py @@ -68,7 +68,7 @@ def cmd_SET_MAP(self, gcmd): for UNIT_SERACH in self.AFC.units.keys(): if lane_switch in self.AFC.units[UNIT_SERACH]: - SW_LANE = self.AFC.stepper(lane_switch) + SW_LANE = self.AFC.stepper[lane_switch] self.AFC.tool_cmds[map_switch]=lane_switch SW_LANE.map = map_switch SW_LANE.map=map_switch diff --git a/extras/AFC_stepper.py b/extras/AFC_stepper.py index 36bf6d4c..6e8823d3 100644 --- a/extras/AFC_stepper.py +++ b/extras/AFC_stepper.py @@ -253,8 +253,8 @@ def prep_callback(self, eventtime, state): 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.AFC.stepper(self.AFC.current) - change_LANE = self.AFC.stepper(self.runout_lane) + empty_LANE = self.AFC.stepper[self.AFC.current] + change_LANE = self.AFC.stepper[self.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) self.gcode.run_script_from_command('LANE_UNLOAD LANE=' + empty_LANE.name) From d6bba5ba2229031e0a507f22cfe136145446a246 Mon Sep 17 00:00:00 2001 From: jimmyjon711 Date: Sat, 21 Dec 2024 15:02:42 -0700 Subject: [PATCH 7/9] Fixing SET_SPOOL_ID function name so it matches the actual macro --- extras/AFC_spool.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/extras/AFC_spool.py b/extras/AFC_spool.py index a08807da..161fd10b 100644 --- a/extras/AFC_spool.py +++ b/extras/AFC_spool.py @@ -24,7 +24,7 @@ def handle_connect(self): self.gcode.register_mux_command('SET_COLOR',None,None, self.cmd_SET_COLOR, desc=self.cmd_SET_COLOR_help) self.gcode.register_mux_command('SET_WEIGHT',None,None, self.cmd_SET_WEIGHT, desc=self.cmd_SET_WEIGHT_help) self.gcode.register_mux_command('SET_MATERIAL',None,None, self.cmd_SET_MATERIAL, desc=self.cmd_SET_MATERIAL_help) - self.gcode.register_mux_command('SET_SPOOL_ID',None,None, self.cmd_SET_SPOOLID, desc=self.cmd_SET_SPOOLID_help) + self.gcode.register_mux_command('SET_SPOOL_ID',None,None, self.cmd_SET_SPOOL_ID, desc=self.cmd_SET_SPOOL_ID_help) self.gcode.register_mux_command('SET_RUNOUT',None,None, self.cmd_SET_RUNOUT, desc=self.cmd_SET_RUNOUT_help) self.gcode.register_mux_command('SET_MAP',None,None, self.cmd_SET_MAP, desc=self.cmd_SET_MAP_help) @@ -179,15 +179,15 @@ def set_active_spool(self, ID): except self.printer.command_error as e: self.gcode._respond_error("Error trying to set active spool \n{}".format(e)) - cmd_SET_SPOOLID_help = "change filaments ID" - def cmd_SET_SPOOLID(self, gcmd): + cmd_SET_SPOOL_ID_help = "change filaments ID" + def cmd_SET_SPOOL_ID(self, gcmd): """ This function handles setting the spool ID for a specified lane. It retrieves the lane specified by the 'LANE' parameter and updates its spool ID, material, color, and weight based on the information retrieved from the Spoolman API. - Usage: `SET_SPOOLID LANE= SPOOL_ID=` - Example: `SET_SPOOLID LANE=leg1 SPOOL_ID=12345` + Usage: `SET_SPOOL_ID LANE= SPOOL_ID=` + Example: `SET_SPOOL_IDD LANE=leg1 SPOOL_ID=12345` Args: gcmd: The G-code command object containing the parameters for the command. From 1e6f1e69d1f8d62c1db70ab77aae90d5c8574bd5 Mon Sep 17 00:00:00 2001 From: jimmyjon711 Date: Sat, 21 Dec 2024 15:06:53 -0700 Subject: [PATCH 8/9] Updating docs --- docs/command_reference.md | 46 +++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/docs/command_reference.md b/docs/command_reference.md index 6476416f..8a10d64f 100644 --- a/docs/command_reference.md +++ b/docs/command_reference.md @@ -79,15 +79,6 @@ current lane and loading the new lane. Usage: ``CHANGE_TOOL LANE=`` Example: ``CHANGE_TOOL LANE=leg1`` -### CALIBRATE_AFC -_Description_: This function performs the calibration of the hub and Bowden length for one or more lanes within an AFC -(Automated Filament Changer) system. The function uses precise movements to adjust the positions of the -steppers, check the state of the hubs and tools, and calculate distances for calibration based on the -user-provided input. If no specific lane is provided, the function defaults to notifying the user that no lane has been selected. The function also includes -the option to calibrate the Bowden length for a particular lane, if specified. -Usage: ``CALIBRATE_AFC LANES= DISTANCE= TOLERANCE= BOWDEN=`` -Example: `CALIBRATE_AFC LANES=all Bowden=leg1` - ### SET_MULTIPLIER _Description_: This function handles the adjustment of the buffer multipliers for the turtleneck buffer. It retrieves the multiplier type ('HIGH' or 'LOW') and the factor to be applied. The function @@ -119,20 +110,41 @@ specified by the 'LANE' parameter and sets its color to the value provided by th Usage: ``SET_COLOR LANE= COLOR=`` Example: ``SET_COLOR LANE=leg1 COLOR=FF0000`` -### SET_SPOOLID +### SET_WEIGHT +_Description_: This function handles changing the material of a specified lane. It retrieves the lane +specified by the 'LANE' parameter and sets its material to the value provided by the 'MATERIAL' parameter. +Usage: `SET_WEIGHT LANE= WEIGHT=` +Example: `SET_WEIGHT LANE=leg1 WEIGHT=850` + +### SET_MATERIAL +_Description_: This function handles changing the material of a specified lane. It retrieves the lane +specified by the 'LANE' parameter and sets its material to the value provided by the 'MATERIAL' parameter. +Usage: `SET_MATERIAL LANE= MATERIAL=` +Example: `SET_MATERIAL LANE=leg1 MATERIAL=ABS` + +### SET_SPOOL_ID _Description_: This function handles setting the spool ID for a specified lane. It retrieves the lane specified by the 'LANE' parameter and updates its spool ID, material, color, and weight based on the information retrieved from the Spoolman API. -Usage: ``SET_SPOOLID LANE= SPOOL_ID=`` -Example: ``SET_SPOOLID LANE=leg1 SPOOL_ID=12345`` +Usage: ``SET_SPOOL_ID LANE= SPOOL_ID=`` +Example: ``SET_SPOOL_IDD LANE=leg1 SPOOL_ID=12345`` ### SET_RUNOUT -_Description_: This function handles setting the runout lane (infanet spool) for a specified lane. It retrieves the lane +_Description_: This function handles setting the runout lane (infinite spool) for a specified lane. It retrieves the lane specified by the 'LANE' parameter and updates its the lane to use if filament is empty based on the information retrieved from the Spoolman API. Usage: ``SET_RUNOUT LANE= RUNOUT=`` Example: ``SET_RUNOUT LANE=lane1 RUNOUT=lane4`` +### CALIBRATE_AFC +_Description_: This function performs the calibration of the hub and Bowden length for one or more lanes within an AFC +(Automated Filament Changer) system. The function uses precise movements to adjust the positions of the +steppers, check the state of the hubs and tools, and calculate distances for calibration based on the +user-provided input. If no specific lane is provided, the function defaults to notifying the user that no lane has been selected. The function also includes +the option to calibrate the Bowden length for a particular lane, if specified. +Usage: ``CALIBRATE_AFC LANES= DISTANCE= TOLERANCE= BOWDEN=`` +Example: `CALIBRATE_AFC LANE=leg1` + ## AFC Macros The following macros are defined in the `config/macros/AFC_macros.cfg` file. @@ -151,11 +163,3 @@ _Description_: Move the specified lane the specified amount _Description_: Resume the print after an error ### BT_PREP _Description_: Run the AFC PREP sequence -### T0 -_Description_: Change to tool 0 -### T1 -_Description_: Change to tool 1 -### T2 -_Description_: Change to tool 2 -### T3 -_Description_: Change to tool 3 From add2657baab219f854f01cad6c64be10cb56ae80 Mon Sep 17 00:00:00 2001 From: jimmyjon711 Date: Sat, 21 Dec 2024 15:12:27 -0700 Subject: [PATCH 9/9] Fixing errors found by linter --- extras/AFC.py | 5 +++-- extras/AFC_BoxTurtle.py | 2 +- extras/AFC_NightOwl.py | 2 +- extras/AFC_error.py | 2 +- extras/AFC_prep.py | 10 +++++----- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/extras/AFC.py b/extras/AFC.py index 9763c945..5645668b 100644 --- a/extras/AFC.py +++ b/extras/AFC.py @@ -145,9 +145,10 @@ def handle_connect(self): self.gcode.register_command('HUB_CUT_TEST', self.cmd_HUB_CUT_TEST, desc=self.cmd_HUB_CUT_TEST_help) self.gcode.register_mux_command('SET_BOWDEN_LENGTH', 'AFC', None, self.cmd_SET_BOWDEN_LENGTH, desc=self.cmd_SET_BOWDEN_LENGTH_help) self.gcode.register_command('AFC_STATUS', self.cmd_AFC_STATUS, desc=self.cmd_AFC_STATUS_help) - + def print_version(self): - import subprocess, os + import subprocess + import os afc_dir = os.path.dirname(os.path.realpath(__file__)) git_hash = subprocess.check_output(['git', '-C', '{}'.format(afc_dir), 'rev-parse', '--short', 'HEAD']).decode('ascii').strip() git_commit_num = subprocess.check_output(['git', '-C', '{}'.format(afc_dir), 'rev-list', 'HEAD', '--count']).decode('ascii').strip() diff --git a/extras/AFC_BoxTurtle.py b/extras/AFC_BoxTurtle.py index f12c0d1c..bab831f2 100644 --- a/extras/AFC_BoxTurtle.py +++ b/extras/AFC_BoxTurtle.py @@ -35,7 +35,7 @@ def system_Test(self, UNIT, LANE, delay): self.AFC.gcode.respond_info('{} Unknown'.format(LANE.upper())) return CUR_LANE = self.AFC.stepper[LANE] - try: + try: CUR_LANE.extruder_obj = self.printer.lookup_object('AFC_extruder ' + CUR_LANE.extruder_name) except: error_string = 'Error: No config found for extruder: ' + CUR_LANE.extruder_name + ' in [AFC_stepper ' + CUR_LANE.name + ']. Please make sure [AFC_extruder ' + CUR_LANE.extruder_name + '] config exists in AFC_Hardware.cfg' diff --git a/extras/AFC_NightOwl.py b/extras/AFC_NightOwl.py index e9502019..4bdd60c7 100644 --- a/extras/AFC_NightOwl.py +++ b/extras/AFC_NightOwl.py @@ -28,7 +28,7 @@ def system_Test(self, UNIT, LANE, delay): self.AFC.gcode.respond_info('{} Unknown'.format(LANE.upper())) return CUR_LANE = self.AFC.stepper[LANE] - try: + try: CUR_LANE.extruder_obj = self.printer.lookup_object('AFC_extruder ' + CUR_LANE.extruder_name) except: error_string = 'Error: No config found for extruder: ' + CUR_LANE.extruder_name + ' in [AFC_stepper ' + CUR_LANE.name + ']. Please make sure [AFC_extruder ' + CUR_LANE.extruder_name + '] config exists in AFC_Hardware.cfg' diff --git a/extras/AFC_error.py b/extras/AFC_error.py index 34727ffc..6569fb0d 100644 --- a/extras/AFC_error.py +++ b/extras/AFC_error.py @@ -52,7 +52,7 @@ def ToolHeadFix(self, CUR_LANE): CUR_LANE.move(-5, self.AFC.short_moves_speed, self.AFC.short_moves_accel, True) while CUR_LANE.load_state == False: # reload lane extruder CUR_LANE.move(5, self.AFC.short_moves_speed, self.AFC.short_moves_accel, True) - + CUR_LANE.tool_load = False CUR_LANE.loaded_to_hub = False CUR_LANE.extruder_obj.lane_loaded = '' diff --git a/extras/AFC_prep.py b/extras/AFC_prep.py index b01cc19f..b0e3df22 100644 --- a/extras/AFC_prep.py +++ b/extras/AFC_prep.py @@ -59,10 +59,10 @@ def PREP(self, gcmd): units=json.load(open(self.AFC.VarFile + '.unit')) ## load Toolhead variables if os.path.exists(self.AFC.VarFile + '.tool') and os.stat(self.AFC.VarFile + '.tool').st_size > 0: - extruders=json.load(open(self.AFC.VarFile + '.tool')) + extruders=json.load(open(self.AFC.VarFile + '.tool')) self.AFC.tool_cmds={} - + for PO in self.printer.objects: if 'AFC_stepper' in PO and 'tmc' not in PO: LANE=self.printer.lookup_object(PO) @@ -73,18 +73,18 @@ def PREP(self, gcmd): else: self.AFC.extruders[LANE.extruder_name] = extruders[LANE.extruder_name] # If units section exists in vars file add currently stored data to AFC.units array - if LANE.unit not in self.AFC.units: + if LANE.unit not in self.AFC.units: # Only adding unit to array if it does not already exist if LANE.unit not in units: self.AFC.units[LANE.unit] = {} else: self.AFC.units[LANE.unit] = units[LANE.unit] # Removing system as this causes problems with AFC.get_status function self.AFC.units[LANE.unit].pop("system", None) - + # If lane section exists in vars file add currently stored data to AFC.units array if LANE.name not in self.AFC.units[LANE.unit]: self.AFC.units[LANE.unit][LANE.name]={} else: self.AFC.units[LANE.unit][LANE.name] = units[LANE.unit][LANE.name] - + if 'spool_id' in self.AFC.units[LANE.unit][LANE.name]: LANE.spool_id = self.AFC.units[LANE.unit][LANE.name]['spool_id'] if self.AFC.spoolman_ip !=None and LANE.spool_id != None: