diff --git a/tdchm.c b/tdchm.c index 8b13599..d15f722 100644 --- a/tdchm.c +++ b/tdchm.c @@ -48,6 +48,13 @@ typedef struct { pECB tdc; } Tdc, *pTdc; +/*---------------------- Monitor event data structure (from counter.c) */ +typedef struct { + float fPreset; + float fCurrent; + char *pName; +} MonEvent, *pMonEvent; + /*=======================================================================*/ static int downloadConfiguration(pTdc self) { @@ -235,6 +242,7 @@ static int TDCStart(pHistDriver self, SConnection * pCon) if (tdc->counter != NULL) { tdc->counter->pDriv->fPreset = self->fCountPreset; tdc->counter->pDriv->eMode = self->eCount; + InvokeCallBack(tdc->counter->pCall,COUNTSTART,NULL); return tdc->counter->pDriv->Start(tdc->counter->pDriv); } return 1; @@ -279,15 +287,23 @@ static int TDCCountStatus(pHistDriver self, SConnection * pCon) { pTdc tdc = NULL; int tdcstatus, status; - float fControl; + float fControl, fOldControl; + MonEvent sMon; assert(self); tdc = (pTdc) self->pPriv; assert(tdc); if (tdc->counter != NULL) { + fOldControl = tdc->counter->pDriv->fLastCurrent; status = tdc->counter->pDriv->GetStatus(tdc->counter->pDriv, &fControl); + if(fOldControl != fControl) { + sMon.fCurrent = fControl; + sMon.fPreset = tdc->counter->pDriv->fPreset; + sMon.pName = tdc->counter->name; + InvokeCallBack(tdc->counter->pCall, MONITOR, &sMon); + } } /* The TDC does not seem to have a means to figure if it is counting or not @@ -303,6 +319,7 @@ static int TDCCountStatus(pHistDriver self, SConnection * pCon) leave it for now. */ if (status == HWIdle || status == HWFault) { + InvokeCallBack(tdc->counter->pCall,COUNTEND,NULL); tdcstatus = disableTdc(tdc); if (tdcstatus != 1) { tdc->errorCode = COMMERROR;