A public charger’s connector
One step from the seed lot: a public charging station’s connector, whose charges are sessions with their own numbers, as the lot’s tests are runs. Events arrive from the cable, the driver’s app, the charger and an operator, and the charger’s messages can arrive late. Each level starts from the previous level’s finished code, so you can begin at any of them.
Drivers now pay by card: start moves the connector to authorizing and asks the payment service to authorize the card; its answer comes back as approved or declined, stamped with the session, and only an approval closes the relay. The author also moved the charger’s work into transition “so no caller can forget it”, and, because the payment service retries an approval until the station answers, accepts a repeated approval while charging “so a retry is not an error”. You are reviewing the pull request.
Every time the app draws the Start button it asks for a card authorization; drawing Stop opens the relay of a car that is still charging. A retried approval closes the relay again and resets the session’s energy, so the driver is billed only for what they draw after the retry.
Reproduce plug, then the app previews start, then start: the charger has made two card authorizations for one attempt.
Acceptance criteria Start authorizes the card and moves to authorizing; approved closes the relay and starts the energy count; declined goes back to plugged; unplug or a fault while authorizing ends the attempt. A preview says what an event would do and changes nothing: not the connector, not the charger. The charger performs each effect once, for a decision the station has committed. A repeated approval for the session already charging changes nothing and asks the charger for nothing. Answers stamped with another session are stale, as readings are. Notes Each case makes one station. A step the app only previews prints “preview”, then the reason and effect; other steps print the log line, reason and effect. After the steps, the charger’s counts: authorizations, relay closes and relay opens. Keep Station, its dispatch and preview methods, describe and the Charger’s counts; the checker calls them. There is one charger per station, and it is real hardware: don’t make another one to absorb effects.