Files
qlcplus/tests/test_chataigne.py
T
jimmyandClaude Opus 5.5 fc8abf9c99 Set the movers' zeros and pan directions, swap M1/M2's patch, and model tilt in the simulator.
The front right mover is on DMX 1 and the front left on 45, so M1 and M2
swap addresses in the stage map and test.qxw. Measured on the rig, pan 0
faces forward on the front pair and into the middle on the back pair, back
at 85. M1 and M4 turn anticlockwise, so movers get a pan_reverse flag.

Tilt 127 now points straight down: the simulator draws a spot under the
head, and past 127 the beam flips behind the pan heading.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 22:54:14 +13:00

74 lines
3.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Chataigne export: channel mapping and the project file."""
from __future__ import annotations
import json
import subprocess
import sys
import tempfile
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "scripts" / "shows"))
import make_chataigne # noqa: E402
class ChataigneExportTest(unittest.TestCase):
def setUp(self) -> None:
self.show = json.loads((ROOT / "shows" / "test.show.json").read_text())
self.stage = json.loads((ROOT / self.show["stage"]).read_text())
def test_channels_are_one_based_dmx(self) -> None:
levels = make_chataigne.absolute_levels(self.show, self.stage, {"#1": {"0": 255, "2": 10}, "M2": {"8": 7}})
self.assertEqual(levels, {88: 255, 90: 10, 9: 7})
def test_groups_hold_pads_and_sliders(self) -> None:
groups = make_chataigne.collect(self.show, self.stage)
self.assertEqual(list(groups), ["Colour 1", "Colour 2", "Dimmers"])
cans = groups["Colour 1"]
self.assertEqual([p["note"] for p in cans["pads"]][:2], [52, 53])
self.assertEqual(cans["sliders"], [])
self.assertEqual(cans["pads"][0]["fade"], [1000, 1000])
self.assertNotIn(88, cans["pads"][0]["levels"]) # the dimmer is the knob's
def test_dimmers_are_on_knobs_15_5_7_and_8(self) -> None:
dimmers = make_chataigne.collect(self.show, self.stage)["Dimmers"]["sliders"]
self.assertEqual([(s["name"], s["cc"], s["value"]) for s in dimmers],
[("Movers", 44, 1.0), ("Cans 9–15", 34, 1.0), ("Cans 3–6", 36, 1.0), ("Cans 1, 2, 7, 8", 37, 1.0)])
dmx = lambda *cans: {88 + 8 * (n - 1): 255 for n in cans}
self.assertEqual(dimmers[1]["levels"], dmx(*range(9, 16)))
self.assertEqual(dimmers[2]["levels"], dmx(3, 4, 5, 6))
self.assertEqual(dimmers[3]["levels"], dmx(1, 2, 7, 8))
self.assertEqual(dimmers[0]["levels"][9], 255)
def test_writes_project_and_script(self) -> None:
with tempfile.TemporaryDirectory() as tmp:
subprocess.run(
[sys.executable, str(ROOT / "scripts" / "shows" / "make_chataigne.py"), str(ROOT / "shows" / "test.show.json"), tmp],
check=True,
capture_output=True,
)
project = json.loads((Path(tmp) / "test.noisette").read_text())
script = (Path(tmp) / "test.js").read_text()
settings = project["projectSettings"]["containers"]["dashboardSettings"]["parameters"]
self.assertIn({"value": True, "controlAddress": "/enableDashboardServer"}, settings)
board = project["dashboardManager"]["items"][0]["itemManager"]["items"]
targets = [item["controllable"] for item in board]
self.assertEqual(len(board), 32 * 2 + 4 + 3)
self.assertEqual(len(set(targets)), len(targets))
for item in board:
self.assertIn(item["controllable"].rsplit("/", 1)[1].removesuffix("Lamp"), script)
canvas = project["dashboardManager"]["items"][0]["itemManager"]["parameters"][0]
self.assertEqual((canvas["value"], canvas["enabled"]), ([1574.0, 953.0], True))
names = [m["niceName"] for m in project["modules"]["items"]]
self.assertEqual(names, ["Lights", "Preview", "Pad"])
self.assertEqual(project["modules"]["items"][1]["device"]["containers"]["output"]["parameters"][0]["value"], "127.0.0.1")
self.assertIn("var GROUPS", script)
self.assertNotIn("__DATA__", script)
if __name__ == "__main__":
unittest.main()