From 34436ee34b92e3ba55aa363b25f2507469111701 Mon Sep 17 00:00:00 2001 From: MG-longshot Date: Tue, 17 Dec 2024 22:18:48 -0600 Subject: [PATCH] added lane status --- extras/AFC.py | 22 ++++++++++++++++++---- extras/AFC_prep.py | 1 + extras/AFC_spool.py | 10 +++++----- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/extras/AFC.py b/extras/AFC.py index 31d76f5..5767837 100644 --- a/extras/AFC.py +++ b/extras/AFC.py @@ -27,6 +27,8 @@ def __init__(self, config): self.tool_cmds={} self.afc_monitoring = False + self.desired_order_list = config.get('Vdesired_order_list','') + # tool position when tool change was requested self.change_tool_pos = None self.in_toolchange = False @@ -441,7 +443,9 @@ def cmd_HUB_LOAD(self, gcmd): CUR_LANE.move(CUR_HUB.move_dis, self.short_moves_speed, self.short_moves_accel) while CUR_HUB.state == True: CUR_LANE.move(CUR_HUB.move_dis * -1, self.short_moves_speed, self.short_moves_accel) - CUR_LANE.status = 'Hubed' + CUR_LANE.status = '' + self.lanes[CUR_LANE.unit][CUR_LANE.name]['status']=CUR_LANE.status + self.save_vars() CUR_LANE.do_enable(False) CUR_LANE.hub_load = True self.lanes[CUR_LANE.unit][CUR_LANE.name]['hub_loaded'] = CUR_LANE.hub_load @@ -472,6 +476,8 @@ def cmd_LANE_UNLOAD(self, gcmd): # extruder motors are still running it does not trigger infinite spool or pause logic # once user removes filament lanes status will go to None CUR_LANE.status = 'ejecting' + self.lanes[CUR_LANE.unit][CUR_LANE.name]['status']=CUR_LANE.status + self.save_vars() CUR_LANE.do_enable(True) if CUR_LANE.hub_load: 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) @@ -481,6 +487,8 @@ def cmd_LANE_UNLOAD(self, gcmd): CUR_LANE.move( CUR_HUB.move_dis * -5, self.short_moves_speed, self.short_moves_accel) CUR_LANE.do_enable(False) self.lanes[CUR_LANE.unit][CUR_LANE.name]['hub_loaded'] = CUR_LANE.hub_load + CUR_LANE.status = '' + self.lanes[CUR_LANE.unit][CUR_LANE.name]['status']=CUR_LANE.status self.save_vars() # Removing spool from vars since it was ejected @@ -549,6 +557,8 @@ def TOOL_LOAD(self, CUR_LANE): # Set the lane status to 'loading' and activate the loading LED. CUR_LANE.status = 'loading' + self.lanes[CUR_LANE.unit][CUR_LANE.name]['status']=CUR_LANE.status + self.save_vars() self.afc_led(self.led_loading, CUR_LANE.led_index) # Check if the lane is in a state ready to load and hub is clear. @@ -598,6 +608,8 @@ def TOOL_LOAD(self, CUR_LANE): # Synchronize lane's extruder stepper and finalize tool loading. CUR_LANE.status = 'Tooled' + self.lanes[CUR_LANE.unit][CUR_LANE.name]['status']=CUR_LANE.status + self.save_vars() CUR_LANE.extruder_stepper.sync_to_extruder(CUR_LANE.extruder_name) # Adjust tool position for loading. @@ -723,7 +735,8 @@ def TOOL_UNLOAD(self, CUR_LANE): extruder = self.toolhead.get_extruder() self.heater = extruder.get_heater() CUR_LANE.status = 'unloading' - + self.lanes[CUR_LANE.unit][CUR_LANE.name]['status']=CUR_LANE.status + self.save_vars() # Disable the buffer if it's active. CUR_EXTRUDER.disable_buffer() @@ -846,6 +859,8 @@ def TOOL_UNLOAD(self, CUR_LANE): CUR_LANE.hub_load = True self.afc_led(self.led_ready, CUR_LANE.led_index) CUR_LANE.status = None + self.lanes[CUR_LANE.unit][CUR_LANE.name]['status']=CUR_LANE.status + self.save_vars() self.current = None CUR_LANE.do_enable(False) @@ -983,9 +998,8 @@ def get_status(self, eventtime): str[UNIT][NAME]["runout_lane"]=self.lanes[LANE.unit][LANE.name]['runout_lane'] filiment_stat=self.get_filament_status(LANE).split(':') str[UNIT][NAME]['filament_status']=filiment_stat[0] - self.lanes[UNIT][NAME]['filament_status']=filiment_stat[0] str[UNIT][NAME]['filament_status_led']=filiment_stat[1] - self.lanes[UNIT][NAME]['filament_status_led']=filiment_stat[1] + str[UNIT][NAME]['status'] = LANE.status if LANE.status is not None else '' numoflanes +=1 str[UNIT]['system']={} str[UNIT]['system']['type'] = self.printer.lookup_object('AFC_hub '+ UNIT).type diff --git a/extras/AFC_prep.py b/extras/AFC_prep.py index dc96a2f..54bc393 100644 --- a/extras/AFC_prep.py +++ b/extras/AFC_prep.py @@ -110,6 +110,7 @@ def PREP(self, gcmd): if 'tool_loaded' not in self.AFC.lanes[LANE.unit][LANE.name]: self.AFC.lanes[LANE.unit][LANE.name]['tool_loaded'] = False if 'hub_loaded' not in self.AFC.lanes[LANE.unit][LANE.name]: self.AFC.lanes[LANE.unit][LANE.name]['hub_loaded'] = False if 'tool_loaded' not in self.AFC.lanes[LANE.unit][LANE.name]: self.AFC.lanes[LANE.unit][LANE.name]['tool_loaded'] = False + if 'status' not in self.AFC.lanes[LANE.unit][LANE.name]: self.AFC.lanes[LANE.unit][LANE.name]['status'] = '' tmp=[] for UNIT in self.AFC.lanes.keys(): diff --git a/extras/AFC_spool.py b/extras/AFC_spool.py index 12aed8c..86ccbf6 100644 --- a/extras/AFC_spool.py +++ b/extras/AFC_spool.py @@ -31,7 +31,7 @@ def handle_connect(self): self.URL = 'http://{}:{}/api/v1/spool/'.format(self.AFC.spoolman_ip, self.AFC.spoolman_port) - cmd_SET_MAP_help = "change filaments color" + cmd_SET_MAP_help = "change filaments map" def cmd_SET_MAP(self, gcmd): """ This function handles changing the GCODE tool change command for a Lane. @@ -42,7 +42,7 @@ def cmd_SET_MAP(self, gcmd): Args: gcmd: The G-code command object containing the parameters for the command. Expected parameters: - - LANE: The name of the lane whose color is to be changed. + - LANE: The name of the lane whose map is to be changed. - MAP: The new tool change gcode for lane (optional, defaults to None). Returns: @@ -112,7 +112,7 @@ def cmd_SET_WEIGHT(self, gcmd): Args: gcmd: The G-code command object containing the parameters for the command. Expected parameters: - + LANE: The name of the lane whose weight is to be changed. WEIGHT: The new weight (optional, defaults to ''). @@ -141,7 +141,7 @@ def cmd_SET_MATERIAL(self, gcmd): Args: gcmd: The G-code command object containing the parameters for the command. Expected parameters: - + LANE: The name of the lane whose material is to be changed. MATERIAL: The new material (optional, defaults to ''). @@ -157,7 +157,7 @@ def cmd_SET_MATERIAL(self, gcmd): CUR_LANE.material = material self.AFC.lanes[CUR_LANE.unit][CUR_LANE.name]['material'] = material self.AFC.save_vars() - + def set_active_spool(self, ID): webhooks = self.printer.lookup_object('webhooks') if self.AFC.spoolman_ip != None: