diff --git a/scripts/course/course.toml b/scripts/course/course.toml index 06781f85..81eb5192 100644 --- a/scripts/course/course.toml +++ b/scripts/course/course.toml @@ -138,6 +138,12 @@ label = "2.1" slug = "the-station-screen" title = "The station screen — one machine at arm's length" one_line = "State, queue, booking output, issuing material, a quality check, what maintenance is owed." +outcomes = [ + "Read one machine on its station screen: its state, its queue of released work, and what maintenance is owed.", + "Book good and scrap against the order at the head of its queue, issue a lot, and record a quality reading.", + "Say why only released work can be booked at a station, and why a typed count is the operator's word.", +] +scene = "scripts/scenes/course/03-01-the-station-screen.toml" [[module.lesson]] order = 2 diff --git a/scripts/record-scene.py b/scripts/record-scene.py index 1301ae02..e9e6b1bb 100644 --- a/scripts/record-scene.py +++ b/scripts/record-scene.py @@ -809,6 +809,29 @@ def scroll_to(self, selector: str, block: str, offset: int, text: str | None = N }""", [selector, block, offset, text], ) + # A row at the very foot of a short page cannot reach its offset, and + # can be left under the caption bar: the station screen's "Nothing owed + # on this machine" in the second take of class 2.1. Room is added below + # the page, as `clear_of_caption` adds it, and the row is lifted clear, + # but never higher than the offset the scene asked for, so a row that + # reached its offset, or a panel taller than the window, stays put. + self.page.evaluate( + """([selector, offset, text, bar]) => { + const nodes = [...document.querySelectorAll(selector)]; + const node = text ? nodes.find((n) => (n.innerText || '').includes(text)) : nodes[0]; + const box = node.getBoundingClientRect(); + const lift = Math.min(box.bottom - (window.innerHeight - bar), box.top - offset); + if (lift <= 0) return; + if (!document.getElementById('fs-scene-room')) { + const room = document.createElement('div'); + room.id = 'fs-scene-room'; + room.style.height = (2 * bar) + 'px'; + document.body.appendChild(room); + } + window.scrollBy(0, lift); + }""", + [selector, offset, text, CAPTION_HEIGHT * 2], + ) self.page.wait_for_timeout(int(SCROLL_SECONDS * 1000)) to_y = self.page.evaluate("() => Math.round(window.scrollY)") # Page pixels, the window's scroll: a box that scrolls inside the page diff --git a/scripts/scenes/course/03-01-the-station-screen.toml b/scripts/scenes/course/03-01-the-station-screen.toml new file mode 100644 index 00000000..161544a8 --- /dev/null +++ b/scripts/scenes/course/03-01-the-station-screen.toml @@ -0,0 +1,443 @@ +# Class 2.1 of the course, *The station screen — one machine at arm's length*: +# what an operator standing at one machine reads and does on its screen. +# +# It starts from the operator at the press with a tablet (a card of words, no +# drawing), names the four words of the class (station, book, issue, queue), +# and reads the station screen of the fork mould, FORK1_Mold, top to bottom, +# one action per card: its state, its queue, 500 good and 3 scrap booked +# against the order at the head of the queue, two kilos of the line's resin lot +# issued to it, one length reading recorded and judged in spec, and what +# maintenance is owed. Then what it refuses: an order that is planned, not +# released, is not on the screen to book against; and what it does not refuse: +# a Good figure the machine's own counter contradicts is taken as typed. +# Filmed on a scratch cutlery plant, every screen as the product draws it. + +name = "the-station-screen" +title = "The station screen — one machine at arm's length" +lesson = "2.1" +take_is = "lesson" +part = "hook" +base = "http://127.0.0.1:8040" +badge = "pre-alpha · simulated plant · v{version}" +# Four to six minutes, as the outline says this class runs. +budget_seconds = 360 +gif_skip_seconds = 2.0 +width = 1280 +height = 720 +# Booking, issuing and recording a reading are writes, and they are the story. +allow_writes = true +what_is_written = "which is how the class books output, issues material and records a quality reading: Book, Issue and Record are real `POST`s to the take's own scratch plant, made with the station screen's own buttons, and its audit trail names the person signed in as having made them." + +notes = [ + "The plant was started from the cutlery pack at ten times wall clock. The camera waited, off camera, until the pack's own released fork order, WO-FORK1-0001, had booked its first forks, so that the mould's queue has a running order with a count on it when the class arrives.", + "The simulated floor was told `MES_OPS_FINISH_ORDERS=false`, so its simulated supervisor neither finishes WO-FORK1-0001 nor releases the next fork order, WO-FORK1-0002, while the camera rolls: the class needs WO-FORK1-0002 to stay planned for its refusal. The switch belongs to the simulated floor; the MES is configured as anybody installs it.", + "The lot issued is LOT-PP-FORK1-001, the pack's polypropylene lot for the fork line. Two kilos is about what 500 forks weigh: the pack's fork weighs 3.6 to 4.2 grams.", + "The reading recorded is 165.1 mm on length_mm, inside the pack's UT-FORK limits of 164 to 166 mm. The simulated floor records length readings too, so the recent results show its readings beside ADMIN's.", + "The cutlery pack carries no maintenance plan, so the maintenance card says nothing is owed. That is the product's answer for this plant, filmed as drawn.", + "The second booking, 5,000 good, is typed to show that the station does not check a typed figure against the mould's own counter. It is a write to a scratch plant that is thrown away when the take ends.", + "At any speed but 1x every 2D page carries the product's REPLAY 10× banner across its top. It is filmed as the product draws it.", + "The opening beat is a plain card with words on it. There is no artwork of a machine, a tablet or a person.", +] + +honesty = [ + "the mould's counter books every shot by itself on this plant; the 500 good and 3 scrap typed in the class are added on top of what it counted, not instead of it", + "the station does not refuse a Good figure the machine's own counter contradicts: 5,000 typed against a mould whose whole count, counter and typed, was short of 5,000 is taken as typed, and nothing on the screen says the two disagree; the class shows that rather than a refusal the product does not make", + "the refusal to book against an order not released to this machine is drawn as an absence: the Against list holds only the machine's own released queue, so the planned order WO-FORK1-0002 is not offered; the class does not call the API behind the screen, which books to any order named with an explicit step, on whatever machine that step is", + "the simulated floor was told not to finish or release orders itself (MES_OPS_FINISH_ORDERS=false), so WO-FORK1-0002 stays planned while the camera rolls; on a plant left to itself the simulated supervisor would release it when WO-FORK1-0001 is done", + "the Lot list at the station offers every available lot on the plant, paper plates among them, not only the resin this machine takes; the class picks the fork line's resin lot from it", + "the maintenance card is empty because the cutlery pack has no maintenance plan, not because the machine was just serviced", + "the plant is a scratch plant a few minutes old, replaying at ten times wall clock, which is the banner across the top of the 2D pages", +] + +[plant] +pack = "labs/cutlery" +speed = 10 +env = { MES_OPS_FINISH_ORDERS = "false" } +roll_when_timeout_seconds = 900 + +# A running order with a count on it at the head of the mould's queue. +[[plant.roll_when_order]] +code = "WO-FORK1-0001" +booked = 100 + +# ----------------------------------------------------------------- the hook + +[[step]] +do = "slide" +name = "the-operator-at-the-press" +title = "An operator at the press, a tablet in hand" +lines = [ + "One machine: the fork mould", + "What is it doing? What is next?", + "What did I make? What did I put in?", + "Is it good? What is owed to it?", +] +hold = 1.5 + +[[step]] +do = "say" +line = "An operator stands at one press for a whole shift, a tablet in hand. Not the plant, not the line: this one machine." + +[[step]] +do = "say" +line = "Through the shift they ask the same few things. What is it doing, and what is next for it?" + +[[step]] +do = "say" +line = "What did I make, what did I put in, is it good, and is anything owed to the machine? One screen answers all of them." + +[[step]] +do = "mark" +name = "the-operator-at-the-press" + +# ----------------------------------------------------------------- the idea + +[[step]] +part = "idea" +do = "slide" +name = "four-words" +title = "Four words" +lines = [ + "Station: one machine's screen, for the person standing at it", + "Queue: the released work this machine has next, in order", + "Book: write down how many good and how many scrap, against an order", + "Issue: write down which lot of material went into that order", +] +hold = 1.5 + +[[step]] +do = "say" +line = "Four words. A station is one machine's screen, made for the person standing at it, not for the office." + +[[step]] +do = "say" +line = "The queue is the work released to this machine, in the order it should run. Only released work is in it." + +[[step]] +do = "say" +line = "To book is to write down how many good and how many scrap, always against an order and its step." + +[[step]] +do = "say" +line = "To issue is to write down which lot of material went into that order, so it can be traced later." + +[[step]] +do = "mark" +name = "four-words" + +# ------------------------------------------------------------ on the screen + +[[step]] +part = "screen" +do = "goto" +url = "/dashboard/station?m=FORK1_Mold" +settle = 3 + +[[step]] +do = "wait_for" +selector = "#queue" +text = "WO-FORK1-0001" + +[[step]] +do = "say" +line = "The station screen of the fork mould, FORK1_Mold. The machine is chosen at the top; the operator starts the shift here." + +[[step]] +do = "say" +line = "First card, its state: running, and since when. Going down asks why, which is the next class." + +[[step]] +do = "mark" +name = "its-state" + +[[step]] +do = "say" +line = "Second card, its queue: the order it is running, WO-FORK1-0001, step 10, Mold, and how many good of how many ordered." + +[[step]] +do = "say" +line = "That count moves by itself: the mould's own counter books every shot it makes." + +[[step]] +do = "mark" +name = "its-queue" + +[[step]] +do = "wait_for" +selector = "#book-order" +text = "WO-FORK1-0001" +scroll_to = "#queue" +scroll_block = "start" +scroll_offset = 300 + +[[step]] +do = "say" +line = "Third card, book output. Against: the order at the head of the queue, step 10. The operator counts a box." + +[[step]] +do = "choose" +selector = "#book-order" +value = "WO-FORK1-0001" + +[[step]] +do = "fill" +selector = "#book-good" +text = "500" + +[[step]] +do = "fill" +selector = "#book-scrap" +text = "3" + +[[step]] +do = "say" +line = "Five hundred good, three scrap. Book." + +[[step]] +do = "click" +selector = "#book-submit" + +[[step]] +do = "wait_for" +selector = "#toast" +text = "Booked 500 good, 3 scrap." + +[[step]] +do = "wait_for" +selector = "#queue" +text = "WO-FORK1-0001" +scroll_to = "#queue" +scroll_block = "start" +scroll_offset = 300 + +[[step]] +do = "say" +line = "Booked, against WO-FORK1-0001 step 10, under the name of the person signed in. The queue's count is up by five hundred." + +[[step]] +do = "mark" +name = "booked-500-good-3-scrap" + +[[step]] +do = "say" +line = "Fourth card, issue material. It issues to the order running here, WO-FORK1-0001." + +[[step]] +do = "choose" +selector = "#issue-lot" +value = "LOT-PP-FORK1-001" + +[[step]] +do = "fill" +selector = "#issue-qty" +text = "2" + +[[step]] +do = "say" +line = "The lot is the fork line's polypropylene resin, LOT-PP-FORK1-001. Two kilos: about what five hundred forks weigh. Issue." + +[[step]] +do = "click" +selector = "#issue-submit" + +[[step]] +do = "wait_for" +js = "[...document.querySelectorAll('#issue-lot option')].some(o => o.value === 'LOT-PP-FORK1-001' && o.textContent.includes('4,485.5'))" + +[[step]] +do = "say" +line = "Issued. The lot is two kilos lighter, and the order now says which resin went into it." + +[[step]] +do = "mark" +name = "issued-two-kilos-of-resin" + +[[step]] +do = "wait_for" +selector = "#q-spec" +text = "Spec 164 to 166 mm." +scroll_to = "#quality" +scroll_block = "start" +scroll_offset = 300 + +[[step]] +do = "say" +line = "Fifth card, quality, on what this machine is running: forks, UT-FORK. Only characteristics with a specification are offered." + +[[step]] +do = "choose" +selector = "#q-char" +value = "length_mm" + +[[step]] +do = "say" +line = "Length: the specification is 164 to 166 millimetres. The operator puts a fork on the gauge." + +[[step]] +do = "fill" +selector = "#q-value" +text = "165.1" + +[[step]] +do = "click" +selector = "#q-submit" + +[[step]] +do = "wait_for" +js = "(document.querySelector('#q-recent').innerText || '').includes('165.1') && (document.querySelector('#q-recent').innerText || '').includes('in spec')" + +[[step]] +do = "say" +line = "165.1 millimetres: in spec. It is in the recent results, with the time and who measured it." + +[[step]] +do = "mark" +name = "a-reading-in-spec" + +[[step]] +do = "wait_for" +selector = "#maint" +text = "Nothing owed on this machine." +scroll_to = "#maint" +scroll_block = "start" +scroll_offset = 320 + +[[step]] +do = "say" +line = "Last card, maintenance on this machine. Here, nothing is owed: this plant has no maintenance plan set up." + +[[step]] +do = "say" +line = "Where a plan is set up, the jobs due on this machine are listed here, and the operator can start and complete them." + +[[step]] +do = "mark" +name = "what-maintenance-is-owed" + +# -------------------------------------------------------------- it refuses + +[[step]] +part = "refuses" +do = "goto" +url = "/dashboard/orders?q=WO-FORK1-0002" +settle = 2 + +[[step]] +do = "click" +selector = "#order-list tbody tr:has-text(\"WO-FORK1-0002\")" + +[[step]] +do = "wait_for" +js = "document.querySelector('#detail-code').innerText === 'WO-FORK1-0002' && document.querySelector('#d-status').innerText === 'planned'" +scroll_to = "#detail-panel" +scroll_block = "start" +scroll_offset = 220 + +[[step]] +do = "say" +line = "Now what it refuses. This is the next fork order, WO-FORK1-0002. Its first step is on the same mould, but it is only planned." + +[[step]] +do = "mark" +name = "the-next-order-is-planned" + +[[step]] +do = "goto" +url = "/dashboard/station?m=FORK1_Mold" +settle = 3 + +[[step]] +do = "wait_for" +js = "[...document.querySelectorAll('#book-order option')].map(o => o.value).join() === 'WO-FORK1-0001'" +scroll_to = "#book" +scroll_block = "start" +scroll_offset = 300 + +[[step]] +do = "say" +line = "Back at the mould, the Against list holds one order: WO-FORK1-0001. The planned order is not there to book against." + +[[step]] +do = "say" +line = "Nor is any order of another line. An operator can only book to work released to this machine." + +[[step]] +do = "mark" +name = "only-released-work-to-book-against" + +# The claim the next caption makes, checked on the take: the mould's count, +# its counter's shots and the 500 typed, is still short of what is typed next. +[[step]] +do = "wait_for" +js = "Number(((document.querySelector('#queue').innerText.match(/Mold\\D+([0-9,]+) of/) || [])[1] || 'NaN').replace(/,/g, '')) < 5000" + +[[step]] +do = "say" +line = "And what it does not refuse. Type five thousand good: more forks than this mould has made since the plant started." + +[[step]] +do = "fill" +selector = "#book-good" +text = "5000" + +[[step]] +do = "click" +selector = "#book-submit" + +[[step]] +do = "wait_for" +selector = "#toast" +text = "Booked 5,000 good, 0 scrap." + +[[step]] +do = "say" +line = "Booked. The station took the figure as typed. Nothing on the screen says the counter disagrees." + +[[step]] +do = "mark" +name = "a-figure-the-counter-contradicts-is-taken" + +[[step]] +do = "wait_for" +selector = "#queue" +text = "WO-FORK1-0001" +scroll_to = "#queue" +scroll_block = "start" +scroll_offset = 300 + +[[step]] +do = "say" +line = "The queue now says the mould has made thousands more than its counter saw. A typed booking is added to the count; it is not checked against it." + +[[step]] +do = "say" +line = "So a typed figure is the operator's word. The audit trail says who typed it, and the counter's own shots stay counted beside it." + +[[step]] +do = "mark" +name = "the-queue-takes-the-typed-figure" + +# ------------------------------------------------------------ you now know + +[[step]] +part = "know" +do = "slide" +name = "you-now-know" +title = "You now know how to" +lines = [ + "Read one machine on its station screen: its state, its queue of released work, and what maintenance is owed.", + "Book good and scrap against the order at the head of its queue, issue a lot, and record a quality reading.", + "Say why only released work can be booked at a station, and why a typed count is the operator's word.", +] + +[[step]] +do = "say" +line = "That is the station screen: one machine, read top to bottom, and the work done at it written down. You now know how to do three things." + +[[step]] +do = "mark" +name = "you-now-know" + +[[step]] +do = "hold" +seconds = 3 diff --git a/tests/test_a_scene_scrolled_to_the_foot_of_a_short_page_lifts_the_row_clear_of_the_caption_bar.py b/tests/test_a_scene_scrolled_to_the_foot_of_a_short_page_lifts_the_row_clear_of_the_caption_bar.py new file mode 100644 index 00000000..0d734dce --- /dev/null +++ b/tests/test_a_scene_scrolled_to_the_foot_of_a_short_page_lifts_the_row_clear_of_the_caption_bar.py @@ -0,0 +1,74 @@ +"""A row a scene scrolls to at the foot of a short page is lifted clear of the caption bar, and no higher than asked. + +A `scroll_to` puts its row `offset` pixels from the top of the window, as near +as the page can. At the foot of a short page it cannot, and the second take of +class 2.1 left the station screen's "Nothing owed on this machine" under the +caption bar for that reason. The recorder now adds room below the page and +lifts the row clear, but only as far as the offset the scene asked for, so a +row that reached its offset, or a panel taller than the window, is where it +always was. This drives the runner's own stage in Chromium; no plant is needed. +""" + +from __future__ import annotations + +import importlib.util +from pathlib import Path + +import pytest + +pytestmark = [pytest.mark.slow, pytest.mark.browser] + +REPO = Path(__file__).resolve().parents[1] +RUNNER = REPO / "scripts" / "record-scene.py" + +VIEWPORT = {"width": 800, "height": 600} +# A maintenance list that is the last thing on a page a little taller than the window. +SHORT = ( + "