Skip to content

XRD plans for the Perkin Elmer and plan tabs in the GUI XRD view - #110

Open
Anthony Sligar (sligara7) wants to merge 3 commits into
NSLS2:mainfrom
sligara7:xrd-plans-perkin-elmer
Open

Anthony Sligar (sligara7) wants to merge 3 commits into
NSLS2:mainfrom
sligara7:xrd-plans-perkin-elmer

Conversation

@sligara7

Copy link
Copy Markdown
Contributor

Adds xrd_count, xrd_scan and xrd_dark (thin wrappers over take_radiograph / bp.scan) and gives the GUI XRD tab Count / Scan / Dark / Calibration plan tabs, like the EDXD tab. ensure_cont_acq_exposure restarts the continuous-acquisition Perkin Elmer at the requested exposure, as the pyepics scripts did. Plans are exported from hextools.xrd and imported into the profile.

First step of converting hex-acq-pyepics/techniques/xrd; the Pilatus comes in a follow-up.

Verified: mock tests only (mocked Perkin Elmer ContAcqDetector, shutters, SimMotor) plus an offscreen GUI test; 403 non-GUI + 49 GUI tests pass, ruff/ty clean. Not yet run on the beamline.

…n tabs in the GUI XRD view

Thin wrappers over take_radiograph and bp.scan. ensure_cont_acq_exposure restarts the continuous-acquisition Perkin Elmer at the requested exposure, as the pyepics scripts did. The XRD tab gets Count / Scan / Dark / Calibration plan tabs, like the EDXD tab.

Assisted-by: copilot:claude-opus-5-5

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Acquisition restart synchronization and the newly exposed calibration plan’s invalid setup call need correction before approval.

2 open issues
What changed in this PR

Adds Perkin Elmer XRD acquisition plans and integrates them into the collection profile and GUI, reusing existing radiography and scan infrastructure.

Changes:

  • Adds count, scan, and dark plans with exposure setup, averaging, metadata, and shutter handling.
  • Exports XRD plans and adds Count, Scan, Dark, and Calibration GUI tabs.
  • Adds mocked acquisition tests and an offscreen GUI tab test.
File Description
tests/​xrd/​test_plans.py Tests acquisition, averaging, exposure changes, and failure cleanup.
tests/​gui/​test_xrd_view.py Checks the four XRD plan tab labels.
src/​hextools/​xrd/​plans.py Implements acquisition plans and continuous-acquisition exposure setup.
src/​hextools/​xrd/​__init__.py Exports XRD plans and the exposure helper.
src/​hextools/​profiles/​collection.py Imports XRD exports into the collection profile.
src/​hextools/​gui/​__main__.py Adds plan tabs beside the live Perkin Elmer viewer.

Review effort: Balanced

Comment thread src/hextools/gui/__main__.py
Comment thread src/hextools/xrd/plans.py Outdated
ensure_cont_acq_exposure started the busy Acquire record with abs_set(wait=False), so prepare could read Acquire before it updated, and prepare(wait=True) waited on the never-finishing put (group None). It now waits for the readback with set_and_wait_for_value(wait_for_set_completion=False). xrd_calibration passed six arguments to abs_set (TypeError); it now uses ensure_cont_acq_exposure for a continuous-acquisition detector and bps.mv otherwise. Both observed failing first in the new tests.

Assisted-by: copilot:claude-opus-5-5
Copilot AI balanced review requested due to automatic review settings October 23, 2026 18:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Hardware-control changes have an unresolved failure-cleanup issue and remain unvalidated on the beamline.

2 open issues
1 resolved since last review

Review effort: Balanced

Comment thread src/hextools/xrd/plans.py Outdated
xrd_count set the Perkin Elmer's exposure before take_radiograph's shutter-closing cleanup was in place, so a setup failure with the shutter already open left the beam on; xrd_calibration did the same before its try. Both now run setup inside a cleanup that closes the photon shutter, and xrd_calibration returns the motor even if the shutter fails to close. Found by Copilot review on NSLS2#110.

Assisted-by: copilot:claude-opus-5-5
Copilot AI balanced review requested due to automatic review settings October 26, 2026 15:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

A shutter-close failure in xrd_scan prevents the requested motor reset.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Ensure motor reset runs when photon shutter closure fails

src/​hextools/​xrd/​plans.py:310

If closing the photon shutter raises (for example, when it is stuck open), cleanup exits before attempting the motor reset, even with reset_position=True. This leaves the motor at the last scan point. Wrap shutter closure in try/finally so the reset is still attempted, as xrd_calibration now does, and add a regression test for this failure path.

2 resolved since last review

Review effort: Balanced

This branch has not been deployed

No deployments
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.

2 participants