Runout sets Spoolman to zero; surface prints waiting on a spool

- A roll that ran out is set to 0 g in Spoolman (like a weigh-in) instead
  of booking CC2 Control's delta, so a mirror whose count was off cannot
  book too much or too little.
- A tray that printed while CC2 Control still asked which spool it holds
  (untagged roll) shows the waiting millimetres on the status page and
  gets one log warning after the print.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014GcEk5tkfFSYD6NTF66NkC
This commit is contained in:
Jonas MenzelandClaude Opus 5.5 committed 2026-10-25 20:45:05 +01:00
1 parent c04964066f
commit d03668e3c5
3 files changed
+85 -9

No files matched your search

+34 -1
View File
@@ -740,8 +740,41 @@ def test_runout_and_backup_roll(env):
cc2.job = {"active": False}
cc2.add_log(env["clock"](), "print", "s0002", 1, -12.0, 4000.0, "vase.gcode", "complete")
poll(env, 10)
assert sorted(uses(env)) == [("use", 5, 40.0), ("use", 8, 12.0)]
assert uses(env) == [("use", 8, 12.0)]
assert ("used", 5, 1000.0) in env["sm"].calls # ran out: Spoolman's rest is 0, whatever the count said
assert env["sm"].db[5]["remaining_weight"] == 0
assert any("Rolle leergelaufen" in m for m in msgs(env))
assert booked(env)["s0001"]["last"]["grams"] == 40.0
def test_runout_sets_spoolman_to_zero_even_if_the_mirror_was_off(env):
env["sm"].add(5, remaining=300)
insert(env, 0, 5)
poll(env)
cc2 = env["cc2"]
cc2.library[0]["remaining"] = 400.0 # e.g. an old mirror reused after the roll printed elsewhere
booked(env)["s0001"]["remaining"] = 400.0
cc2.job = {"active": True}
cc2.consume("s0001", 380.0)
poll(env)
cc2.slots[0]["printer"] = {"status": 0}
cc2.slots[0]["spool"] = ""
t = env["clock"]()
cc2.add_log(t, "runout", "s0001", 0, -20.0, 0, "big.gcode", "runout")
cc2.library[0]["remaining"] = 0.0
cc2.job = {"active": False}
cc2.add_log(t + 5, "print", "s0001", 0, -380.0, 127000.0, "big.gcode", "runout")
poll(env, 15)
assert uses(env) == [] and env["sm"].db[5]["remaining_weight"] == 0
def test_open_question_after_print_is_reported_once(env):
cc2 = env["cc2"]
cc2.slots[3].update({"printer": {"status": 1}, "question": "changed", "question_since": 100, "question_mm": 2605.0})
poll(env, 3)
warn = [m for m in msgs(env) if "ohne Spule gedruckt" in m]
assert len(warn) == 1 and "2605 mm" in warn[0] and "7.8 g" in warn[0]
assert env["bridge"].snapshot["printers"][0]["slots"][3]["cc2_question_mm"] == 2605.0
def test_multicolour_print_books_each_roll(env):