CC2 Control copies take the colour the printer reports for the tray
CC2 Control compares a spool's colour exactly with the tray's, which is the tag's colour from the display palette (e.g. #F72221 for Spoolman's #FF0000), and flags the slot or asks again when they differ. New copies take the tag's colour; copies in a slot are set to the tray's colour, others keep theirs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014GcEk5tkfFSYD6NTF66NkC
This commit is contained in:
1 parent
87c5decc1c
commit
d863287f1f
2 files changed
+42
-12
No files matched your search
+24
-7
@@ -69,14 +69,14 @@ def poll(e, n=1, step=5):
|
||||
|
||||
def test_scan_creates_assigns_and_sets_location(env):
|
||||
env["sm"].add(5, vendor="Sunlu", material="PLA+", color="1E40AF", remaining=812.5)
|
||||
insert(env, 1, 5)
|
||||
insert(env, 1, 5, color="0x2850E0") # the tag carries the nearest colour of the display palette
|
||||
poll(env)
|
||||
cc2 = env["cc2"]
|
||||
saves = [c for c in cc2.calls if c[0] == "save"]
|
||||
assert len(saves) == 1
|
||||
f = saves[0][1]
|
||||
assert f["name"] == "SUNLU005" and f["brand"] == "Sunlu" and f["material"] == "PLA+"
|
||||
assert f["color"] == "#1E40AF" and f["note"] == "spoolman:5" and f["remaining"] == 812.5
|
||||
assert f["color"] == "#2850E0" and f["note"] == "spoolman:5" and f["remaining"] == 812.5 # as the printer reports it
|
||||
assert f["net"] == 1000 and f["tare"] == 150 and f["diameter"] == 1.75 and f["density"] == 1.24
|
||||
assert ("assign", 1, "s0001") in cc2.calls
|
||||
assert cc2.slots[1]["spool"] == "s0001" and cc2.slots[1]["question"] == ""
|
||||
@@ -356,7 +356,8 @@ def test_fields_use_tag_material_when_spoolman_material_does_not_fit():
|
||||
sm = FakeSpoolman().add(3, material="Silk PLA", color="FFD700")
|
||||
fields, notes = cc2_spool_fields(sm, channel(10003, type_="PLA", detailed="PLA Silk"))
|
||||
assert fields["material"] == "PLA Silk" and notes
|
||||
assert fields["color"] == "#FFD700"
|
||||
assert fields["color"] == "#000000" # the tray's (tag's) colour, which CC2 Control compares with
|
||||
assert cc2_spool_fields(sm, None)[0]["color"] == "#FFD700" # no tray known: Spoolman's
|
||||
|
||||
|
||||
# ---------- v2: several printers, Spoolman location and extra fields ----------
|
||||
@@ -883,18 +884,34 @@ def test_rest_not_adjusted_before_use_is_booked(env):
|
||||
|
||||
def test_master_data_follows_spoolman(env):
|
||||
env["sm"].add(5, color="4A4A4A")
|
||||
insert(env, 0, 5)
|
||||
insert(env, 0, 5, color="0x898989")
|
||||
poll(env, 2)
|
||||
env["sm"].db[5]["filament"]["color_hex"] = "898989"
|
||||
assert env["cc2"].library[0]["color"] == "#898989" # created with the tag's colour
|
||||
env["sm"].db[5]["filament"]["density"] = 1.3
|
||||
env["sm"].db[5]["lot_nr"] = "SUNLU005B"
|
||||
env["bridge"].spool_cache.clear()
|
||||
poll(env, 14)
|
||||
assert ("save", {"id": "s0001", "color": "#898989", "density": 1.3}) in env["cc2"].calls
|
||||
assert env["cc2"].library[0]["color"] == "#898989"
|
||||
assert ("save", {"id": "s0001", "name": "SUNLU005B", "density": 1.3}) in env["cc2"].calls
|
||||
poll(env, 14)
|
||||
assert len([c for c in env["cc2"].calls if c[0] == "save" and "id" in c[1]]) == 1
|
||||
|
||||
|
||||
def test_copy_colour_follows_the_printers_report(env):
|
||||
"""A copy made with Spoolman's exact colour is flagged by CC2 Control; it gets the tray's colour."""
|
||||
env["sm"].add(4, color="FF0000")
|
||||
env["cc2"].save_spool({"name": "SUNLU004", "brand": "SUNLU", "material": "PLA+", "color": "#FF0000",
|
||||
"note": "spoolman:4", "net": 1000, "tare": 150, "density": 1.24, "diameter": 1.75})
|
||||
insert(env, 0, 4, color="0xF72221")
|
||||
env["cc2"].slots[0]["printer"] = {"status": 1, "color": "#F72221", "type": "PLA"}
|
||||
poll(env, 14)
|
||||
assert env["cc2"].library[0]["color"] == "#F72221"
|
||||
take_out_of_tray(env, 0)
|
||||
env["sm"].db[4]["filament"]["color_hex"] = "00FF00"
|
||||
env["bridge"].spool_cache.clear()
|
||||
poll(env, 14)
|
||||
assert env["cc2"].library[0]["color"] == "#F72221" # not in a tray: colour left alone
|
||||
|
||||
|
||||
def test_copies_of_archived_or_deleted_spools_are_removed_when_not_loaded(env):
|
||||
env["sm"].add(5)
|
||||
env["sm"].add(6)
|
||||
|
||||
Reference in new issue
Block a user