Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 25 additions & 22 deletions eigerApp/src/eigerDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1011,26 +1011,25 @@ void eigerDetector::controlTask (void)
getIntegerParam(ADStatus, &adStatus);
}
}
else // TMExternalSeries or TMExternalEnable

// Wait for detector to stop acquiring.
// Essential for TMExternalSeries or TMExternalEnable,
// which have to wait for external action.
FLOW("waiting for detector state");
string state;
for(;;)
{
// The Eiger does not indicate when acquisition is complete.
// Wait either until the NumImagesCounter is the expected value or
// until there is a manual stop event.
int expectedImages = numImages * numTriggers;
int numImagesCounter;
for(;;)
{
getIntegerParam(ADNumImagesCounter, &numImagesCounter);
if (numImagesCounter >= expectedImages) break;
if (mStopEvent.tryWait()) break;
unlock();
epicsThreadSleep(0.1);
lock();
}
mState->fetch(state);
callParamCallbacks();
// We must exit this loop without the lock
unlock();
if (state != "configure" && state != "ready" && state != "acquire") break;
if (mStopEvent.wait(0.1)) break;
// If we haven't exited yet, grab the lock so we can update the param library
lock();
}

// All triggers issued, disarm the detector
unlock();
status = mApi.disarm();
lock();

Expand All @@ -1045,11 +1044,17 @@ void eigerDetector::controlTask (void)
{
// Wait FileWriter to go out of the "acquire" state
FLOW("waiting for FileWriter");
string fwAcquire;
do

for(;;)
{
mFWState->get(fwAcquire);
}while(fwAcquire == "acquire");
string fwAcquire;
lock();
mFWState->fetch(fwAcquire);
callParamCallbacks();
unlock();
if (fwAcquire != "acquire") break;
epicsThreadSleep(0.1);
}
epicsThreadSleep(0.5);

// Request polling task to stop
Expand Down Expand Up @@ -1195,8 +1200,6 @@ void eigerDetector::downloadTask (void)

FLOW_ARGS("file=%s", file->name);

file->refCount = file->parse + file->save;

// Download the file
if(mApi.getFile(file->name, &file->data, &file->len))
{
Expand Down
7 changes: 6 additions & 1 deletion eigerApp/src/eigerDetector.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef EIGER_DETECTOR_H
#define EIGER_DETECTOR_H

#include <atomic>
#include <map>
#include <vector>

Expand Down Expand Up @@ -269,7 +270,11 @@ class eigerDetector : public ADDriver
mPollDoneEvent, mRestartEvent, mInitializeEvent;
epicsMessageQueue mPollQueue, mDownloadQueue, mParseQueue, mSaveQueue,
mReapQueue;
bool mPollStop, mPollComplete, mStreamComplete;
std::atomic<bool> mPollStop;
// Access to this variable is synchronized by mPollQueue and mPollDoneEvent
bool mPollComplete;
// Access to this variable is synchronized by mStreamEvent and mStreamDoneEvent
bool mStreamComplete;
unsigned int mFrameNumber;
uid_t mFsUid, mFsGid;
EigerParamSet mParams;
Expand Down