Skip to content

Verify device is opened and claimed before health check (#10)#94

Open
ba-00001 wants to merge 3 commits into
target:mainfrom
ba-00001:issue-10-health-opened-claimed-gate
Open

Verify device is opened and claimed before health check (#10)#94
ba-00001 wants to merge 3 commits into
target:mainfrom
ba-00001:issue-10-health-opened-claimed-gate

Conversation

@ba-00001

Copy link
Copy Markdown

Fixes #10.

Health endpoints could fail when called before a device was opened and claimed. Each device manager's getHealth() now checks state first: if the device is not both opened and claimed it returns NOT_READY and skips the health check; only an opened+claimed device proceeds.

  • DynamicDevice: add isOpened()/isClaimed(); isConnected() composes them (behavior unchanged).
  • All 6 device classes expose isOpened()/isClaimed(). Printer/scale/cash drawer (single cached connection flag) mirror isConnected() so the gate and the health check use one source of truth; scanner/line display/MICR delegate to the dynamic device's live state.
  • SimulatedDynamicDevice overrides isOpened()/isClaimed() so simulation health stays correct.
  • Added DynamicDeviceTest, SimulatedDynamicDeviceTest, and per-manager gate tests. Full suite passes; verified live in simulation (all devices READY).

ba-00001 added 3 commits June 26, 2026 22:13
Health endpoints previously failed when called before a device was
opened and claimed. getHealth() now checks device state first: if the
device is not both opened and claimed it immediately returns NOT_READY
and skips the health check; only an opened+claimed device proceeds to
the health check.

- DynamicDevice: add isOpened()/isClaimed(); isConnected() composes them
- All device classes expose isOpened()/isClaimed()
- All device managers gate getHealth() on opened+claimed
- Add DynamicDeviceTest and per-manager gate tests
SimulatedDynamicDevice overrides isConnected() but not the new
isOpened()/isClaimed(), so in simulation mode the health gate read the
underlying JavaPOS control (never opened/claimed) and forced NOT_READY
for scanner/printer/scale/cash drawer. Override isOpened()/isClaimed()
to track the simulated connection state.
For printer, scale, and cash drawer, isConnected() returns a cached
connection flag while isOpened()/isClaimed() read live JPOS state, so a
transient getClaimed() failure could flip a healthy device to NOT_READY.
These devices only track a single connection flag (set after a
successful open + claim + enable), so make isOpened()/isClaimed() mirror
isConnected(). Scanner, line display, and MICR keep delegating to the
dynamic device, where all three already read the same live state.
@ba-00001
ba-00001 requested a review from arpal7 as a code owner July 21, 2026 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Verify that a Device is Opened and Claimed Before Calling Health

1 participant