Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix auto-setting spool ID in spoolman pull mode. #424

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 26 additions & 25 deletions extras/mmu.py
Original file line number Diff line number Diff line change
Expand Up @@ -3206,10 +3206,11 @@ def _pending_spool_id_handler(self, eventtime):

def _check_pending_spool_id(self, gate):
if self.pending_spool_id is not None:
self.gcode.run_script_from_command("MMU_GATE_MAP GATE=%d SPOOLID=%d" % (gate, self.pending_spool_id))
self.log_info("Spool ID: %s automatically applied to Gate %d" % (self.pending_spool_id, gate))
self.gate_spool_id[gate] = self.pending_spool_id
self._pending_spool_id_handler(0) # Prevent resue
self._spoolman_update_filaments(gate) # Request update of material & color from Spoolman

def _handle_idle_timeout_printing(self, eventtime):
self._handle_idle_timeout_event(eventtime, "printing")
Expand Down Expand Up @@ -7062,7 +7063,7 @@ def _persist_gate_map(self, sync=False, gate_ids=None):
self._update_t_macros()

# Also persist to spoolman db if pushing updates for visability
if sync and self.spoolman_support == self.SPOOLMAN_PUSH:
if sync and self.spoolman_support in [self.SPOOLMAN_PUSH, self.SPOOLMAN_PULL]:
if gate_ids is None:
gate_ids = [(gate, spool_id) for gate, spool_id in enumerate(self.gate_spool_id)]
if gate_ids:
Expand Down Expand Up @@ -7427,28 +7428,28 @@ def cmd_MMU_GATE_MAP(self, gcmd):
name = gcmd.get('NAME', self.gate_filament_name[gate])
speed_override = gcmd.get_int('SPEED', self.gate_speed_override[gate], minval=10, maxval=150)

if not self.spoolman_support == self.SPOOLMAN_PULL:
# Local gate map
if spool_id != self.gate_spool_id[gate]:
if spool_id in self.gate_spool_id:
old_gate = self.gate_spool_id.index(spool_id)
if old_gate != gate:
self.gate_spool_id[old_gate] = -1
gate_ids.append((old_gate, -1))
gate_ids.append((gate, spool_id))
color = self._validate_color(color)
if color is None:
raise gcmd.error("Color specification must be in form 'rrggbb' hexadecimal value (no '#') or valid color name or empty string")
self.gate_material[gate] = material
self.gate_color[gate] = color
self.gate_filament_name[gate] = name
self.gate_status[gate] = available
self.gate_spool_id[gate] = spool_id
self.gate_speed_override[gate] = speed_override
else:
# Remote (spoolman) gate map
self.gate_status[gate] = available
self.gate_speed_override[gate] = speed_override
if spool_id != self.gate_spool_id[gate]:
if spool_id in self.gate_spool_id:
old_gate = self.gate_spool_id.index(spool_id)
if old_gate != gate:
self.gate_spool_id[old_gate] = -1
gate_ids.append((old_gate, -1))
gate_ids.append((gate, spool_id))
color = self._validate_color(color)
if color is None:
raise gcmd.error("Color specification must be in form 'rrggbb' hexadecimal value (no '#') or valid color name or empty string")
self.gate_material[gate] = material
self.gate_color[gate] = color
self.gate_filament_name[gate] = name
self.gate_status[gate] = available
self.gate_spool_id[gate] = spool_id
self.gate_speed_override[gate] = speed_override

self._update_gate_color(self.gate_color)
self._persist_gate_map(sync=bool(gate_ids), gate_ids=gate_ids) # This will also update LED status
Expand Down