Skip to content

Continuous acquisition trigger mixin with circular buffer #1240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

thomashopkins32
Copy link
Collaborator

@thomashopkins32 thomashopkins32 commented Apr 4, 2025

Overview

Adds a continuous acquisition trigger mixin class that allows for easy integration with area detectors cameras.

Motivation

Area detectors typically can be run in a few modes: single, multiple, or continuous acquisition. In single acquisition mode, detectors capture a single image. In multiple mode, detectors capture multiple images. Acquisition stops once the desired number of images is reached. This behavior is covered in Ophyd by TriggerBase (and relevant subclasses). Continuous acquisition mode captures images continuously, never terminating the underlying control system's acquisition thread.

There are a few benefits to running the camera in continuous acquisition mode:

  • Camera temperature remains stable
  • Added flexibility for software-based triggers
  • Avoids noise in the first few captured frame in some cameras
  • Reduces noise in between frame timestamps introduced by acquisition start/stop
  • The camera captures frames asynchronously from downstream tasks (like computing statistics, writing images to disk, etc.)

How it works

This class utilizes a subset of the functionality provided by the NDPluginCircularBuff EPICS area detector plugin to buffer frames for a software trigger. The size of the buffer, the "pre-count", is set to 0 in our implementation to ensure that the most recent frame is the one that is always captured. Triggering the plugin releases from the buffer a number of frames specified by the "post count".

The NDCircularBuffTriggerStatus tracks the "post-count quantity" and compares it to the target "post-count".

How it was tested

This was tested using ADSim. I set up the plugins as:

DET -> CB -> HDF5

so that we can test file writing from triggering the circular buffer.

  • Unit tests added (see comment below about current ADSim image not working)

Notes

I think there may be a bug with the NDPluginCircularBuff plugin implementation when setting the "pre-count" > 0. When used in tandem with the HDF5 plugin, it was always writing one more frame than desired which was strange to me.

Other changes

Refactors the ADTriggerStatus to utilize a base class TriggerStatus as to not duplicate code.

@thomashopkins32
Copy link
Collaborator Author

thomashopkins32 commented Apr 11, 2025

The ADSim tests will fail until a new image is released that has the NDCircularBuff plugin configured correctly. This depends on epics-containers/ioc-adsimdetector having their ibek-support bumped to epics-containers/ibek-support@5fc52f9 and a new container image built and uploaded to their container registry.

@thomashopkins32 thomashopkins32 marked this pull request as ready for review April 11, 2025 20:32
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