Repository navigation
Conversation
Adds sequence, getdata(camera), getdata(camera, n), live and getlastframe to the SDK3 driver, replacing the four methods that threw, and decodes the Mono12Packed pixel encoding. Tested against the recording fake of atcore; no test loads an Andor library. - sequence sets a fixed cycle and, with the internal trigger and a writable FrameRate, the new frame_rate keyword (default nothing: the camera's maximum), read back into frame_rate_actual. It queues a ring of min(N, max(8, ceil(frame_rate_actual / 2))) buffers and queues each one again as it is read, so frames arrive in order and each is delivered once. - getdata(camera, n) is a second method of the existing getdata: the next n frames, the sequence still running. getdata(camera) returns the rest and stops; a stop that fails after the frames were read throws. Each frame gets its own deadline. An overflow of the camera's memory stops the acquisition and throws, saying how many frames were read. - live uses the software trigger: each getlastframe queues a buffer, sends SoftwareTrigger and returns that frame. It refuses before any library call on a camera without a SoftwareTrigger command. During a sequence getlastframe returns the newest unread-by-getdata frame and takes nothing from getdata; it returns nothing when abort replaces its acquisition. - capture, sequence and live share one start; one read path takes frames from the ring for all of them. - export_state adds frame_rate_requested and frame_rate_actual. - The fake delivers frames per software trigger, packs Mono12Packed, stamps each frame with its index and can overflow after k frames. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The driver counted holders of the library (cameras, and list_cameras while it ran) and finalized it when the last gave it back, so a listing followed by initialize, or shutdown followed by initialize, called AT_InitialiseLibrary a second time in one process. On the real library (SDK3 3.15.30175, USB 3 Zyla, Linux) the second call never returns: it waits inside the USB transport for a control transfer to the camera. The manual initializes and finalizes once per application. The driver now calls AT_InitialiseLibrary at most once per binding per process, at the first use, and never finalizes the library while the process runs. The real binding registers an atexit hook that finalizes it once if it was initialized; a fake registers none. The holder count, LibraryUse, the camera's library_held field and the release paths in shutdown, initialize and list_cameras are removed. The fake records an AT_InitialiseLibrary after an AT_FinaliseLibrary as a violation, since a test cannot hang. New tests: a listing, initialize, capture, shutdown and initialize again on one fake make exactly one initialisation and no finalise; the exit hook finalizes once and does nothing when the library was never initialized. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sured
Found with a USB 3 Zyla, SDK3 3.15.30175: with TriggerMode "External
Exposure" the camera reports ExposureTime not writable, and
AT_SetFloat("ExposureTime") answers 5 (AT_ERR_NOTWRITABLE); the pulse sets the
exposure. The driver sent the exposure, then the region, then the trigger
mode, at initialize and at every capture start, so with trigger_mode
EXTERNAL_EXPOSURE the second start, and an initialize of a camera already in
that mode, threw.
The trigger mode is now sent before the exposure, and no ExposureTime is sent
when the mode being sent is EXTERNAL_EXPOSURE; exposure_time_actual is still
read back. setexposuretime! in that mode throws and says the exposure comes
from the trigger pulse, with no library call.
The stand-in's Zyla profile answers as the real camera did: ExposureTime is
not writable in External Exposure; AcquisitionStop on an idle camera answers 5;
after a fixed cycle ends by itself CameraAcquiring stays true and
AcquisitionStart answers 5 until AcquisitionStop. The simulated-camera profile
keeps the old answers, and the knobs (idle_stop_code, needs_stop) remain.
Comments record the other facts from the same camera: a second AT_Close of a
closed handle answers 12, a second AT_Open of a held index succeeds with a new
handle (the driver never does it), and ImageSizeBytes equals AOIStride times
AOIHeight at full frame.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in the library fix: AT_InitialiseLibrary once per process and AT_FinaliseLibrary only at exit, the trigger mode sent before the exposure with no ExposureTime in External Exposure, setexposuretime! refused in that mode, and the stand-in's Zyla profile answering as the real camera did. Conflicts resolved so both changes hold: capture's start is this branch's shared start_acquisition!, which now sends the trigger mode first (live's "Software" included), then the exposure (none in External Exposure), then the region; the sequence call-order test asserts that order. The camera struct keeps this branch's acquisition fields and loses library_held. The Zyla profile's idle_stop_code = 5 and needs_stop = true apply to every sequence and live test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ished after it The exit hook called AT_FinaliseLibrary whenever the library was up, so a process that exited with a camera open finalized the library under that camera, and a later exit hook (an application's, registered before the library's first use, which Julia runs after the driver's) then reached a finalized library: its shutdown failed, and its list_cameras initialized the library again, which never returned on the real library. - The hook finalizes only when the process holds no camera in the library. With one open it leaves the library up, so a later hook's shutdown works. - The library state is :down, :up or :finalized. After the finalize, every use throws, saying the library was finalized at exit and cannot be initialized again in this process, with no library call. A failed first AT_InitialiseLibrary stays :down and is tried again. - initialize initializes the library inside find_camera!'s hold of the registry lock, so the hook cannot finalize between that and the open. - Whether a binding's library is finalized at exit is a method, registers_exit_hook (true for AtCore). The fake can stand for the real library (exit_hook), so a test sees the hook registered in Base.atexit_hooks once, at the first successful initialization, never for a fake or after a failed first one, and runs it. A child process checks the exit order with an application hook registered before the first use. - The comment on the library cites the manual for what it says (a second initialization is allowed, M3 p.27) and says what the real library did: an initialization after a finalize never returned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…alize reads it once setexposuretime! refused by the trigger_mode field, which is a request: with the field set back from EXTERNAL_EXPOSURE by hand, or after a settriggermode! the camera refused, the camera was still in External Exposure and the setter sent ExposureTime, which the camera refuses in that mode. - setexposuretime! still refuses with no library call when trigger_mode is EXTERNAL_EXPOSURE. Otherwise it reads the camera's TriggerMode first and, in External Exposure, throws, saying settriggermode! or the next start sends trigger_mode and changes it. - initialize reads trigger_mode once and passes it to the trigger and the exposure senders, as capture does, so a field edited between the two cannot send an exposure the camera refuses, or skip one it needs. - Tests: both ways into the stale mode; the field edited during the trigger mode's read-back, in both directions; and in External Exposure the exposure the camera reports changes between captures, so a readback reused from the first start fails. These tests deliver the frame at the first poll, so they never compare the clock with a deadline. - The struct and export_state docstrings say no exposure is sent in External Exposure, and that exposure_time_actual is then the value the camera reports, not the width of the trigger pulse. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… profile tests - The simulated camera's profile is checked by the raw calls: a start, its one frame delivered, and a second start with no stop between. capture sends a stop between its starts, so the old check passed with a simulated camera that refused the second start. - The profile testset delivers the frame at the first poll, so its captures never compare the clock with a deadline. - The stop subtest that modeled a library neither profile is (a finished cycle that reads idle and refuses the stop) is gone. The rule it also guarded, that capture flushes after a failed AcquisitionStop and then lets the buffer go, is now asserted in the walk of a code at every call of capture, on the Zyla profile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…for it The Andor SDK3 driver has never been released, so its two Fixed entries are folded into its Added entry, which now says: - every start sends every setting, the trigger mode first, except the exposure in EXTERNAL_EXPOSURE, where setexposuretime! throws while the field asks for that mode or the camera is still in it, and exposure_time_actual is the value the camera gives, not the pulse width; - the library is initialized once per process and not finalized while it runs; the exit hook finalizes it only with no camera open, and after that, initialize and list_cameras throw with no library call; - the library lifecycle and what is sent in External Exposure follow how a real Zyla answered, in place of the claim that no Andor library or camera was used. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The comment said the driver never makes a second AT_InitialiseLibrary with no finalize between. It does, to retry a first one that failed; whether that hangs on the real library was not tried. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Every buffer queued to the library is held by one process-wide root (LIBRARY_BUFFERS, under its own lock) from its queuing until an AT_Flush or AT_Close of its handle succeeds, so a camera dropped while a sequence runs never leaves the library writing into freed memory. leak_buffers! and LEAKED_BUFFERS are gone. - getdata allocates its stack inside the scope whose failure stops the acquisition, so a failed allocation stops it and is thrown. - A frame's deadline is exact: each sleep ends at the deadline, and a poll that returns after it throws, whether or not a frame came. - getdata is planned once (plan_read) and read from that plan (run_read): in a live view it reads the live view it was called on. - A sequence stops when the driver takes its last frame, by whichever call; the frames not yet delivered stay readable with getdata until the next start, abort or shutdown. A stop that fails there throws from that call. - Mono12Packed needs AOIStride: without it a start throws before anything is queued. - One stop rule: AcquisitionStop answering AT_ERR_NOTWRITABLE, then CameraAcquiring reading false, counts as stopped; any other failure throws. abort no longer reads CameraAcquiring first. - Every stop changes acquisition_id, so a read waiting between polls makes no further library call once another read's failure stopped the camera. - Live software triggers are numbered: a reader sends the next trigger only when none is outstanding, takes only its trigger's frame, and returns nothing when another reader took it. - frame_rate_actual is read in refresh_actuals!, at initialize and every start and setting. - Each frame is decoded once, straight into the stack slice or the returned matrix: CameraInterface.rowmajor_to_yx! (the in-place form of rowmajor_to_yx) for the 16-bit encodings, and a packed decode that writes [y, x] directly over blocks of rows. - live takes no frame count. getlastframe in a sequence still reads at most one ring's worth per call, now documented and tested. - Text: the overflow message says frames were not read or not transferred fast enough; the claim that a sequence that fits the ring cannot overflow is gone; getlastframe's live-view throws are in the interface docstring and mc-acquire; phase and is_running are the driver's state; the window's memory cost is in start_sequence's docstring; the changelog no longer says an out-of-range rate sends nothing. - The test stand-in models the camera's own memory (a first-in, first-out store of memory_frames frames, written into a buffer the moment one is queued; an overflow when it is full) and what an overflow leaves behind (overflow_leaves_armed), and can return a known address twice (duplicate_after). overflow_after is gone. Every sequence and live test runs on the Zyla profile; tests added for each fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…state, trigger mode read by the camera) Conflicts resolved so both branches hold: - shutdown docstring: the exit hook finalizes the library if no camera is open then, and a finished sequence's undelivered frames are dropped. - AndorSDK3Camera docstring: the trigger-mode and External Exposure text, with frame_rate_actual among the reported values and the frame_rate paragraph kept. - CHANGELOG: the driver entry as the library fix now describes it, followed by the sequences, streaming and live view entry. - test: the stop testset keeps the library fix's version, without the case that set needs_stop = false on a Zyla; its title now says the abort on the idle camera does not throw, since abort always sends the stop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…from initialization through open The failure walk injects an error by call number, and its fake delivered on the second poll against a real deadline: a descheduled runner could end the wait first and move the injection from AcquisitionStop to AT_Flush. The trace run and each injected run now use a fake whose clock stands still, with both polls still covered. A new test runs a competing task, as the exit hook of another thread would, just as use_library! returns for the fake. It takes the registry lock if it is free; with use_library! outside find_camera!'s hold the camera is finalized before it is opened. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…each capture; formatting Each capture sends the trigger mode, the exposure (none in External Exposure), the region and the one-frame cycle; features are sent only at initialize. The CHANGELOG no longer says the rule to finalize at exit only with no camera open follows the camera: review set it. Overlong lines in the Andor entry and an unevenly rewrapped docstring are wrapped to the file's width. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…vers the whole span; text The capture failure walk runs on a clock that advances 1 ms per read and asserts that no more than two polls follow each other, so a driver that swallows an injected failure and waits for a frame never queued fails the test at once instead of polling until the deadline. Two reworked testsets that captured on the default fake use first-poll delivery, so no reworked test reads the wall clock. The lock test now counts its probe's runs and asserts it ran, probes both initialize and list_cameras, and builds the camera before installing the shared callback so a failed construction cannot leave it set. The existing registry-lock test also records the lock at the DeviceCount read between the library's initialization and the opens. Text: the frame timeout is checked and bounds the driver's own polling; it is not sent to the camera (CHANGELOG and the capture docstring). The capture docstring is rewrapped, a code span is no longer split across lines, and the comment on the probe says what point it guards. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Conflicts resolved: the initialize, shutdown and capture docstrings keep this branch's additions (SoftwareTrigger read, frames dropped at shutdown, the stop rule, frame_rate_actual, late frames refused) in the library fix's wording (settings sent again at each capture; features only at initialize). The CHANGELOG's driver entry takes the library fix's text with this branch's stop rule, process-wide buffer root and Mono12Packed decoding. The idle-abort test keeps this branch's name and the library fix's first-poll fake. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second of the Andor driver pull requests: sequences, streaming reads and live view for
AndorSDK3Camera, replacingthe four methods that threw (
sequence,getdata,live,getlastframe), and decoding of theMono12Packedpixelencoding.
Until pull request #101 merges, this diff includes it. This branch carries #101's commits through merges. Once #101
is on
main,mainis merged in here and the diff is this change alone.What it adds
sequencesets a fixed cycle ofsequence_lengthframes and, with the internal trigger and a camera that saysFrameRateis writable, the newframe_ratekeyword (defaultnothing: the fastest rate the camera reports; arequest outside its range throws
ArgumentErrorbefore the rate is sent). The driver queues a ring ofmin(N, max(8, ceil(frame_rate_actual / 2)))buffers and queues each again as it is read, so a sequence of anylength arrives in order from a ring of fixed size, every frame once.
getdata(camera, n), a second method of the existinggetdata(no new interface function), returns the nextnframes and leaves the sequence running, so a scan can read a long sequence in bundles.getdata(camera)returnsevery frame not yet delivered. When the driver takes a sequence's last frame, by whichever call, it stops the
acquisition; frames not yet delivered stay readable with
getdatauntil the next start,abortorshutdown.not accepted. If frames are not read or not transferred fast enough, the camera overflows its own memory; the driver
stops the acquisition and throws, saying how many frames it had read.
liveuses the software trigger. Eachgetlastframethat finds no trigger outstanding queues a buffer and sendsthe next numbered trigger; a reader that finds another reader's trigger outstanding waits for that frame and returns
nothingif the other reader takes it. A stalled reader cannot overflow the camera, every frame is new, and notrigger is sent twice.
livethrows before any library call on a camera with noSoftwareTriggercommand.getlastframeduring a sequence reads at most one ring's worth of finished frames per call and returns a copy ofthe newest that
getdatahas not delivered, taking nothing fromgetdata.close of its handle succeeds, so the library never writes into freed memory, even when the camera object is dropped
mid-sequence.
AT_ERR_NOTWRITABLE(5), after whichCameraAcquiringreadsfalse, counts as stopped; any other failure throws. Every stop ends the acquisition for every read waiting on it.
CameraInterface.rowmajor_to_yx!(the in-place form ofrowmajor_to_yx).Mono12Packed(two pixels in threebytes) decodes to
(height, width)and needs the camera'sAOIStride; a start in that encoding without it throws.export_stategainsframe_rate_requestedandframe_rate_actual;frame_rate_actualis read at every start andsetting.
Like the rest of the driver, it checks every library return code, cleans up with ordinary
try/finally, and enforcesno safety of its own.
Tests
Against the recording fake of
atcore(test/andor_sdk3_fake.jl); no test loads an Andor library. The fake nowdelivers frames per software trigger, packs
Mono12Packed, and models the camera's own memory: frames exposed with nobuffer queued wait there, and the camera overflows when it is full, leaving the acquisition either armed or stopped, since what a real camera
does then is not yet known. Each
rule added in review was removed in a scratch copy and its test failed.
@test_brokenintest/gui.jl), 0 fail.Not covered here
queue after a fixed cycle, a software-triggered start with no buffer queued, buffer queue capacity, and the reader's
speed at full frame.
frame rate against the interface's transfer rate; a cap on the ring.
Version stays
0.2.7-DEV: nothing breaks for existing callers.🤖 Generated with Claude Code