Skip to content

Millennia eV: status snapshot + preserve init error#98

Merged
dccote merged 1 commit into
masterfrom
millennia-status-and-init-error
Jun 27, 2026
Merged

Millennia eV: status snapshot + preserve init error#98
dccote merged 1 commit into
masterfrom
millennia-status-and-init-error

Conversation

@dccote

@dccote dccote commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

Two small gaps on the MillenniaEv25Device driver that currently push logic into downstream callers (found while building a GUI on top of it).

1. Preserve the underlying init error

doInitializeDevice caught any failure and raised a bare PhysicalDevice.UnableToInitialize(), discarding the original serial.SerialException. A caller could no longer distinguish a busy port ([Errno 16] Resource busy, e.g. the port held by another app) from a missing one — the GUI had to re-open the port itself just to classify the error. Now:

raise PhysicalDevice.UnableToInitialize(error) from error

so the cause is preserved through the exception chain.

2. Implement doGetStatusUserInfo() for the eV

The framework already ships background monitoring (startBackgroundStatusUpdates()PhysicalDeviceNotification.status via NotificationCenter), but MillenniaEv25Device didn't override doGetStatusUserInfo(), so the base returned None and the monitoring loop posted empty status for this device. Added an override returning a one-call snapshot:

{"power": ..., "isLaserOn": ..., "isShutterOpen": ...}

usable both by the background loop and by GUI polling.

Tests

Adds testStatusUserInfoSnapshotsPowerOnOffAndShutter to the debug-device suite; all TestDebugMillenniaEv25Device tests pass. No API breakage — both changes are additive/behaviour-preserving on success.

🤖 Generated with Claude Code

Two small gaps on the eV driver that pushed work into downstream callers:

* doInitializeDevice caught the failure and raised a bare
  PhysicalDevice.UnableToInitialize(), discarding the underlying
  serial error. Callers could no longer tell a busy port ("[Errno 16]
  Resource busy") from a missing one. Now re-raises
  UnableToInitialize(error) from error so the cause is preserved.

* MillenniaEv25Device did not override doGetStatusUserInfo(), so the
  base returned None and PhysicalDevice.startBackgroundStatusUpdates()
  posted empty status notifications for the eV. Added an override
  returning {power, isLaserOn, isShutterOpen} — a one-call snapshot for
  background monitoring and for GUI polling.

Adds a debug-device test for the status snapshot.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K6LVhfM3d9CcJdkuSMMqag
dccote added a commit to DCC-Lab/MilleniaUI that referenced this pull request Jun 27, 2026
…ved init error

Builds on DCC-Lab/PyHardwareLibrary#98:

* _poll_once now takes a single snapshot via device.doGetStatusUserInfo()
  instead of three separate isLaserOn/isShutterOpen/power queries, with a
  fallback to the individual queries for libraries without the eV status hook.
* Connecting no longer does a pre-flight probe_port(): it just opens the
  device, and the new _connection_message() reads the now-preserved serial
  error off the exception chain to explain busy / missing / permission. A
  one-shot probe remains only as a fallback for older library versions and to
  gate auto-reconnect attempts.

Shared the serial-error keyword classification (serial_reason) and added
exception_chain_text. Behaviour verified headlessly against both the current
installed library (fallback path) and the updated library (primary path).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K6LVhfM3d9CcJdkuSMMqag
@dccote
dccote merged commit b9c9d9b into master Jun 27, 2026
14 checks passed
@dccote
dccote deleted the millennia-status-and-init-error branch June 27, 2026 21:13
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.

1 participant