Merge branch 'ICSHWI-9971_addMutex' into 'dev'
ICSHWI-9971: Add mutex See merge request epics-modules/adhama!2
This commit is contained in:
+13
-25
@@ -52,20 +52,13 @@ Hama::Hama(const char* portName, int cameraId, int maxBuffers, size_t maxMemory,
|
||||
stopThread = 0;
|
||||
|
||||
/* Create the epicsEvents for signaling to task when acquisition starts and stops */
|
||||
startAcquireEventId_ = epicsEventCreate(epicsEventEmpty);
|
||||
if (!startAcquireEventId_) {
|
||||
startEvent_ = epicsEventCreate(epicsEventEmpty);
|
||||
if (!startEvent_) {
|
||||
printf("%s:%s epicsEventCreate failure for acquire start event\n",
|
||||
driverName, functionName);
|
||||
return;
|
||||
}
|
||||
|
||||
stopAcquireEventId_ = epicsEventCreate(epicsEventEmpty);
|
||||
if (!stopAcquireEventId_) {
|
||||
printf("%s:%s epicsEventCreate failure for acquire stop event\n",
|
||||
driverName, functionName);
|
||||
return;
|
||||
}
|
||||
|
||||
//General
|
||||
|
||||
createParam( HamaName, asynParamOctet, &hHamaName);
|
||||
@@ -496,12 +489,17 @@ epicsTimeStamp imageStamp;
|
||||
|
||||
//static const char *functionName = "imageTask";
|
||||
|
||||
lock();
|
||||
|
||||
while(1) {
|
||||
getIntegerParam(ADAcquire, &acquire);
|
||||
if(!acquire) {
|
||||
puts("Waitng start");
|
||||
status = epicsEventWait(startAcquireEventId_);
|
||||
puts("Waiting start");
|
||||
|
||||
unlock();
|
||||
status = epicsEventWait(startEvent_);
|
||||
puts("Starting request received");
|
||||
lock();
|
||||
|
||||
/* We are acquiring. */
|
||||
//acquireStatusError = 0;
|
||||
@@ -510,7 +508,6 @@ epicsTimeStamp imageStamp;
|
||||
status = startAcquire();
|
||||
printf("Status: %d\n", status);
|
||||
if (status != asynSuccess) {
|
||||
epicsEventSignal(this->stopAcquireEventId_);
|
||||
acquireStatusError = 1;
|
||||
epicsThreadSleep(.1);
|
||||
}
|
||||
@@ -522,21 +519,13 @@ epicsTimeStamp imageStamp;
|
||||
}
|
||||
}
|
||||
|
||||
eventStatus = epicsEventWaitWithTimeout(this->stopAcquireEventId_, 0);
|
||||
/* Stop event detected */
|
||||
if (eventStatus == epicsEventWaitOK) {
|
||||
setShutter(0);
|
||||
setIntegerParam(ADAcquire, 0);
|
||||
acquire=0;
|
||||
callParamCallbacks();
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Added this delay for the thread not to hog the processor. No need to run on full speed. */
|
||||
epicsThreadSleep(0.001);
|
||||
|
||||
// get image transfer status.
|
||||
unlock();
|
||||
imageTransferStatus(m_hdcam, captransferinfo);
|
||||
lock();
|
||||
|
||||
if (prevAcquisitionCount < captransferinfo.nFrameCount) {
|
||||
//printf("nFrameCount: %d, nNewestFrameIndex: %d\n", captransferinfo.nFrameCount, captransferinfo.nNewestFrameIndex);
|
||||
@@ -653,12 +642,11 @@ asynStatus Hama::writeInt32(asynUser *pasynUser, epicsInt32 value){
|
||||
if (value) {
|
||||
/* Send an event to wake up the acq task.*/
|
||||
puts("Requested acquire start event. Sending acquire start event signal to thread");
|
||||
epicsEventSignal(this->startAcquireEventId_);
|
||||
epicsEventSignal(this->startEvent_);
|
||||
}
|
||||
else if (!value && (adstatus == ADStatusAcquire || adstatus == ADStatusError)) {
|
||||
/* This was a command to stop acquisition */
|
||||
puts("Requested acquire stop event. Sending acquire stop event signal to thread");
|
||||
epicsEventSignal(this->stopAcquireEventId_);
|
||||
setShutter(0);
|
||||
stopAcquire();
|
||||
}
|
||||
|
||||
|
||||
@@ -264,8 +264,7 @@ private:
|
||||
int m_id;
|
||||
int stopThread;
|
||||
|
||||
epicsEventId startAcquireEventId_;
|
||||
epicsEventId stopAcquireEventId_;
|
||||
epicsEventId startEvent_;
|
||||
|
||||
asynStatus startAcquire(void);
|
||||
asynStatus stopAcquire(void);
|
||||
|
||||
Reference in New Issue
Block a user