Validator enable/disable must follow state transitions #28
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The bill validator runs continuously after initialization. In brain.js, the validator is carefully enabled only during
acceptingBillsstates and disabled everywhere else. Without this, bills could be accepted during QR display, dispensing, errors, or idle — causing undefined behavior.Current behavior
hal.ts:connectValidator()wires validator events to the state machine but never callsenableValidator()/disableValidator()based on state transitions. The validator accepts bills at all times after init.Required behavior (from brain.js)
Enable validator when entering:
cashIn.insertingBills(after exchange rate fetched)Disable validator when leaving:
cashIn.insertingBills→ any other state (FINISH_INSERTING, CANCEL, TIMEOUT, error)Also needed:
validator.lightOn()when enabling,validator.lightOff()when disablingbillsReadwith null denomination →validator.reject()(already handled)standbyevent → re-enable if still in accepting stateImplementation
Add XState
entry/exitactions on theinsertingBillsstate that callhalServices.enableValidator()andhalServices.disableValidator(). The HAL services ref is already available in the ATM store.Impact
Blocker for hardware testing. Without this, inserting a bill while the machine is displaying a QR code or dispensing cash would corrupt the state machine.