Skip to content

Commit

Permalink
added lane status
Browse files Browse the repository at this point in the history
  • Loading branch information
MG-longshot committed Dec 18, 2024
1 parent 4ea9234 commit 34436ee
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
22 changes: 18 additions & 4 deletions extras/AFC.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions extras/AFC_prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
10 changes: 5 additions & 5 deletions extras/AFC_spool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:
Expand Down Expand Up @@ -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 '').
Expand Down Expand Up @@ -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 '').
Expand All @@ -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:
Expand Down

0 comments on commit 34436ee

Please sign in to comment.