Skip to content

getNumFrames sets Frame number from 0 to 1 before first frame finishes #60

@newville

Description

@newville

@TomQD-94

XSpress3::getNumFramesRead()

int Xspress3::getNumFramesRead()

sets the FrameCountParam from 0 to 1 well before the first frame is done.

Setting up to acquire 10 frames of 5 seconds each, and monitoring the ArrayCounter_RBV gives this:

~> camonitor 13QX7:det1:ArrayCounter_RBV 13QX7:det1:Acquire 13QX7:det1:ERASE
13QX7:det1:ArrayCounter_RBV    2025-06-17 10:56:31.140269 0
13QX7:det1:Acquire             2025-06-17 10:55:42.676662 Done
13QX7:det1:ERASE               2025-06-17 10:56:31.140407 Erase
13QX7:det1:Acquire             2025-06-17 10:56:58.307833 Acquire
13QX7:det1:ArrayCounter_RBV    2025-06-17 10:56:58.307956 1
13QX7:det1:ArrayCounter_RBV    2025-06-17 10:57:08.307801 2
13QX7:det1:ArrayCounter_RBV    2025-06-17 10:57:13.307802 3
13QX7:det1:ArrayCounter_RBV    2025-06-17 10:57:18.307891 4
13QX7:det1:ArrayCounter_RBV    2025-06-17 10:57:23.308066 5
13QX7:det1:ArrayCounter_RBV    2025-06-17 10:57:28.308073 6
13QX7:det1:ArrayCounter_RBV    2025-06-17 10:57:33.308064 7
13QX7:det1:ArrayCounter_RBV    2025-06-17 10:57:38.308080 8
13QX7:det1:ArrayCounter_RBV    2025-06-17 10:57:43.308110 9
13QX7:det1:ArrayCounter_RBV    2025-06-17 10:57:48.308194 10
13QX7:det1:Acquire             2025-06-17 10:57:48.308416 Done

Note that the counter goes to 1 as soon as Acquire starts, and is advanced to 2 after 10 seconds.

This comes from xsp3->scaler_check_progress. It appears that it returns 1 on the first call, but that subsequent calls before the first frame ends do return 0.

A possible workaround is to add a short delay before calling this in xsp3DataTaskC at

while (acquire && (frameNumber < numFrames)) {

to be something like (yes, it looks like it needs to be 30,000 microsceconds in my tests):

      while (acquire && (frameNumber < numFrames)) {
            if (acquired == 0) { 
                 usleep(30000);   \\ from unistd.h
            }
            acquired = pXspAD->getNumFramesRead();
            if (frameNumber < acquired) {

That seems kludgy. Any better ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions