mirror of
https://github.com/openglow-org/forgefirm.git
synced 2026-10-19 02:51:42 -07:00
setup.focus: the head's place read from /status and judged at X0 Y0 before the burn starts
The focus burn answers the wizard's home prompt with HOME from a dict, and the wizard takes the operator's word the same way: nothing reads where the head stands. A read at that prompt places nothing either: the wizard restarts the controller before it, and a fresh controller drops the X/Y reference. The one read with meaning comes before POST /wiz/laser.focus/start, under the campaign's own controller, when a manual home references X and Y: with manual_home_x and manual_home_y blank or 0, it is the one provider that declares X0 Y0 at the gantry stops. head_at_home(ctx), called after the ready gate and before anything starts, waits up to 10 s for a /status that serves a position (a transient miss is not a stop; ten seconds of none fails the test before any energy), records the read as head_at_start (pos, homed_axes, home_source, judged), and judges the head at X0 Y0 within HOME_TOL_MM (0.05 mm) when homed_axes carries X and Y and home_source is manual: off its home, the test fails before any wizard start, so no controller lever is touched. Unreferenced, the head's place rests on the operator's word at the ready gate, the log says so, and judged is False. The HOME answer and the steps stay; the description names the read. The strict form, a manual home before every focus burn, is a procedure the operator must add to every campaign; this change records and judges what it can read. Proof: tests/test_setup_burns.py, the Unit tests step of forgetest-ci.yml (python -B -m unittest discover -s tests), 22 tests OK on Windows and on Linux, with tests/test_setup_dark.py (20 OK) and tests/test_laser_dwell.py (10 OK). The scripted daemon's /status carries homed_axes 7 and home_source manual: at X0 Y0 the burn runs and the evidence carries the read with judged True; at X 12.5 the test fails before any start, with no burn started, no /controller/ lever posted, and the settings as found; unreferenced (homed_axes 4, home_source startup) the burn runs with judged False. pyflakes reports no undefined name. Negative control on a scratch copy: with setup_burns.py as it was before this change (the HOME answer alone), the X 12.5 case burns (Failed not raised) and the two evidence cases find no head_at_start; the three tests catch it. Acceptance: setup.focus's fingerprint moves (its own text and setup_burns.py's shared text); no other suite module imports from .setup_burns, so nothing else moves. The next campaign runs setup.focus with the head's place on record.
This commit is contained in:
@@ -290,6 +290,9 @@ class BurnRunTests(unittest.TestCase):
|
||||
self.saved_root = os.environ.get("GF_SYSFS_ROOT")
|
||||
os.environ["GF_SYSFS_ROOT"] = self.sysfs + "/"
|
||||
self.fake = helpers.FakeForgectrl().start()
|
||||
# the head at its home against the gantry stops, X and Y referenced
|
||||
# by a manual home (the fake's pos is X0 Y0 Z0)
|
||||
self.fake.state["status"].update({"homed": True, "homed_axes": 7, "home_source": "manual"})
|
||||
self.daemon = ScriptedDaemon(self.fake)
|
||||
self.poll = setup_dark.POLL_S
|
||||
setup_dark.POLL_S = 0.01
|
||||
@@ -333,6 +336,10 @@ class BurnRunTests(unittest.TestCase):
|
||||
self.assertNotIn("lens_hall_edge_z_mm", start)
|
||||
self.assertEqual((start["lens_stop_below_steps"], start["lens_stop_above_steps"]), ("14", "20"))
|
||||
self.assertEqual(run.evidence["result"]["emission"]["hv_max"], 610)
|
||||
# the head's place on record before the start, judged at X0 Y0
|
||||
self.assertEqual(run.evidence["head_at_start"],
|
||||
{"pos": {"x": 0.0, "y": 0.0, "z": 0.0}, "homed_axes": 7, "home_source": "manual",
|
||||
"judged": True})
|
||||
# the witnesses read from here at every poll: each at its peak
|
||||
seen = run.evidence["emission_seen"]
|
||||
self.assertEqual((seen["laser_on_max"], seen["hv_max"]), (118, 431))
|
||||
@@ -429,6 +436,27 @@ class BurnRunTests(unittest.TestCase):
|
||||
self.assertIn("the tube current never rose", str(cm.exception))
|
||||
self.assert_found()
|
||||
|
||||
def test_a_head_off_its_home_fails_before_any_start(self):
|
||||
# X and Y referenced by a manual home, and the head 12.5 mm from
|
||||
# the stops: nothing starts, no controller lever is touched.
|
||||
self.fake.state["status"]["pos"] = {"x": 12.5, "y": 0.0, "z": 0.0}
|
||||
with self.assertRaises(Failed) as cm:
|
||||
self.run_test("setup.focus")
|
||||
self.assertIn("not at its home", str(cm.exception))
|
||||
self.assertEqual(self.daemon.order, [])
|
||||
self.assertEqual(self.daemon.lever_posts(), [])
|
||||
self.assert_found()
|
||||
|
||||
def test_an_unreferenced_head_runs_on_the_operators_word(self):
|
||||
# A fresh controller's counters-only position places nothing: the
|
||||
# read is recorded, not judged, and the burn runs.
|
||||
self.fake.state["status"].update({"homed": False, "homed_axes": 4, "home_source": "startup",
|
||||
"pos": {"x": 12.5, "y": 0.0, "z": 0.0}})
|
||||
run = self.run_test("setup.focus")
|
||||
self.assertEqual(run.evidence["head_at_start"]["judged"], False)
|
||||
self.assertEqual(run.evidence["head_at_start"]["home_source"], "startup")
|
||||
self.assertEqual(self.daemon.order, ["laser.focus"])
|
||||
|
||||
def test_a_burn_the_test_itself_never_saw_fails_and_still_restores(self):
|
||||
# The burn's result reports a lit burn, and the test's own reads
|
||||
# of the two witnesses never leave zero: the burn is judged on
|
||||
|
||||
Reference in New Issue
Block a user