Commit 9f4f31a
committed
fix: Wire SpoolmanUsageTracker to PrintStateMonitor for filament deduction
PROBLEM:
Users reported that Spoolman was not deducting filament usage after print
completion, despite being able to see and select spools in the WebUI.
ROOT CAUSE:
The SpoolmanUsageTracker was never being created and wired to the
PrintStateMonitor for each printer context. While the
MultiContextSpoolmanTracker.createTrackerForContext() method existed,
it was never called during initialization or when backends were created.
This was identified by comparing with the FlashForgeUI-Electron codebase,
which properly wires up the trackers in its backend-initialized event handler.
SOLUTION:
1. Added backend-initialized event handler to create monitors when printers
are connected dynamically (e.g., via API reconnect/discovery)
2. Added initializeMonitors() function to create monitors for printers
connected during startup
3. Both paths now create:
- PrintStateMonitor for each context
- SpoolmanUsageTracker for each context (wired to PrintStateMonitor)
The SpoolmanUsageTracker now properly listens to print-completed events
and updates Spoolman server with filament usage data when prints finish.
TESTING:
- Filament deduction should now work for all connected printers
- Usage is updated immediately when print completes
- Works for both startup connections and dynamic connections1 parent 07aaa64 commit 9f4f31a
1 file changed
Lines changed: 85 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
238 | 276 | | |
239 | 277 | | |
240 | 278 | | |
| |||
434 | 472 | | |
435 | 473 | | |
436 | 474 | | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
437 | 516 | | |
438 | 517 | | |
439 | 518 | | |
440 | 519 | | |
441 | 520 | | |
442 | 521 | | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
443 | 528 | | |
444 | 529 | | |
445 | 530 | | |
| |||
0 commit comments