From e8df6158eac10c1fc15c0f62aecc8820fdb52359 Mon Sep 17 00:00:00 2001 From: Koennecke Mark Date: Mon, 27 Apr 2015 14:46:39 +0200 Subject: [PATCH] - Fixed a bug relating to the control variable in countserse.c It was used to control the counter and internally to maintain count progress. This has now been fixed. - Due to improper state handling multi counter failed when called both from the count task and the sttus testing. This is now resolved. --- countersec.c | 23 ++++++++++++++++++----- multicounter.c | 21 ++++++++++++++++----- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/countersec.c b/countersec.c index 5eb78ad5..e393786b 100644 --- a/countersec.c +++ b/countersec.c @@ -176,11 +176,24 @@ static int SecCtrCheckStatus(void *pData, SConnection *pCon) } ReleaseHdbValue(&v); - - node = GetHipadabaNode(self->pDes->parNode,"control"); - assert(node != NULL); - GetHipadabaPar(node,&v,pCon); - fControl = v.v.doubleValue; + + if(self->getMode(self) == eTimer){ + node = GetHipadabaNode(self->pDes->parNode,"time"); + assert(node != NULL); + GetHipadabaPar(node,&v,pCon); + fControl = v.v.doubleValue; + } else { + node = GetHipadabaNode(self->pDes->parNode,"values"); + assert(node != NULL); + /* + The 1 below is only correct for PSI where only the first + monitor can be the control monitor. Elsewhere this must be the + control monitor channel + */ + fControl = v.v.intArray[1]; + } + + node = GetHipadabaNode(self->pDes->parNode,"preset"); assert(node != NULL); GetHipadabaPar(node,&v,pCon); diff --git a/multicounter.c b/multicounter.c index a5c0647a..63fb285d 100644 --- a/multicounter.c +++ b/multicounter.c @@ -31,6 +31,14 @@ #define MAXSLAVE 16 #define NOCOUNTERS -2727 + +/* + checkSlaves codes +*/ +#define WAITMASTER 100 +#define WAITSLAVE 200 +#define FINISHED 300 + /*=============== code for the driver ======================================*/ typedef struct { void *slaveData[MAXSLAVE]; @@ -107,7 +115,7 @@ static int MMCCStart(void *pData, SConnection * pCon) pCount->isUpToDate = 0; pCount->tStart = time(NULL); InvokeCallBack(pCount->pCall, COUNTSTART, pCon); - self->checkSlaves = 0; + self->checkSlaves = WAITMASTER; return OKOK; } @@ -132,7 +140,7 @@ static int MMCCStatus(void *pData, SConnection * pCon) return HWFault; } - if(self->checkSlaves == 0) { + if(self->checkSlaves == WAITMASTER) { status = self->slaves[0]->CheckCountStatus(self->slaveData[0], pCon); if (status == HWIdle || status == HWFault) { /* @@ -141,11 +149,11 @@ static int MMCCStatus(void *pData, SConnection * pCon) */ MMCCHalt(pData); ReleaseCountLock(pCount->pCountInt); - self->checkSlaves = 1; + self->checkSlaves = WAITSLAVE; status = HWBusy; } pCount->pDriv->fLastCurrent = GetControlValue(self->slaveData[0]); - } else { + } else if(self->checkSlaves == WAITSLAVE) { /* * wait for the detectors to report finish too. Otherwise, with the second * generation HM data may not be fully transferred. @@ -172,7 +180,9 @@ static int MMCCStatus(void *pData, SConnection * pCon) } status = HWIdle; InvokeCallBack(pCount->pCall, COUNTEND, pCon); - self->checkSlaves = 0; + self->checkSlaves = FINISHED; + } else if(self->checkSlaves == FINISHED){ + status = HWIdle; } return status; } @@ -530,6 +540,7 @@ int MakeMultiCounter(SConnection * pCon, SicsInterp * pSics, self->slaveData[self->nSlaves] = pCom->pData; self->nSlaves++; } + self->checkSlaves = FINISHED; /* now install our action command and we are done