countdriv.h
CounterDriver:  iControlMonitor id (default=0)

countdriv.c
CreateCounterDriver: set the default control monitor to channel zero

counter.h
counter.c
Commands to get and set the control monitor
GetCounts return the counts from the current control monitor, ie iControlMonitor
TODO loadCountData, get time from controlling monitor.

scan.c
Set control monitor on counter when setting scan channel

multicounter.c
MMCStart, set slave monitors with a  timer preset of about a year to make sure that they don't stop before the controlling monitor.

r2642 | ffr | 2008-07-10 15:21:21 +1000 (Thu, 10 Jul 2008) | 20 lines
This commit is contained in:
Ferdi Franceschini
2008-07-10 15:21:21 +10:00
committed by Douglas Clowes
parent 0f96e4f82f
commit cff9290272
6 changed files with 81 additions and 34 deletions

View File

@@ -67,19 +67,26 @@ static int MMCCHalt(void *pData){
/*-------------------------------------------------------------------------*/
static int MMCCStart(void *pData, SConnection *pCon)
{
int i, status;
int i, status, controlMonitor;
int oneYear=32000000;
pCounter pCount = NULL;
pMultiCounter self = NULL;
char buffer[128];
pCount = (pCounter)pData;
if(pCount != NULL){
self = (pMultiCounter)pCount->pDriv->pData;
}
assert(self);
controlMonitor = GetControlMonitor((pCounter)pCount);
for(i = 0; i < self->nSlaves; i++){
if (i == controlMonitor) {
self->slaves[i]->SetCountParameters(self->slaveData[i],
pCount->pDriv->fPreset, pCount->pDriv->eMode);
} else {
self->slaves[i]->SetCountParameters(self->slaveData[i],
oneYear, eTimer);
}
status = self->slaves[i]->StartCount(self->slaveData[i],pCon);
if(status != OKOK){
MMCCHalt(pData);
@@ -93,7 +100,8 @@ static int MMCCStart(void *pData, SConnection *pCon)
}
/*-------------------------------------------------------------------------*/
static int MMCCStatus(void *pData, SConnection *pCon){
int status,i;
int status,i, controlMonitor;
pCounter pCountController = NULL;
pCounter pCount = NULL;
pMultiCounter self = NULL;
pDummy pDum = NULL;
@@ -109,7 +117,9 @@ static int MMCCStatus(void *pData, SConnection *pCon){
return HWFault;
}
status = self->slaves[0]->CheckCountStatus(self->slaveData[0],pCon);
controlMonitor = GetControlMonitor((pCounter)pCount);
pCountController = (pCounter)self->slaveData[controlMonitor];
status = self->slaves[controlMonitor]->CheckCountStatus(pCountController,pCon);
if(status == HWIdle || status == HWFault){
/*
stop counting on slaves when finished or when an error
@@ -200,7 +210,8 @@ static void loadCountData(pCounter pCount, const char *data){
pPtr = (char *)data;
pPtr = getNextMMCCNumber(pPtr,pNumber);
pCount->pDriv->fTime = atof(pNumber);
// SICS-195 get time from controlling monitor
// pCount->pDriv->fTime = atof(pNumber);
while(pPtr != NULL && i < MAXCOUNT){
pPtr = getNextMMCCNumber(pPtr,pNumber);
pCount->pDriv->lCounts[i] = atoi(pNumber);
@@ -212,14 +223,18 @@ static int MMCCTransfer(void *pData, SConnection *pCon){
int i, retVal = OKOK, status;
char pBueffel[132];
pCounter pCount = NULL;
pCounter pCountController = NULL;
pMultiCounter self = NULL;
int tclStatus;
int controlMonitor;
pCount = (pCounter)pData;
if(pCount != NULL){
self = (pMultiCounter)pCount->pDriv->pData;
}
assert(self);
controlMonitor = GetControlMonitor(pCount);
pCountController = (pCounter)self->slaveData[controlMonitor];
for(i = 0; i < self->nSlaves; i++){
status = self->slaves[i]->TransferData(self->slaveData[i], pCon);
@@ -230,6 +245,7 @@ static int MMCCTransfer(void *pData, SConnection *pCon){
SCWrite(pCon,pBueffel,eWarning);
}
}
pCount->pDriv->fTime = pCountController->pDriv->fTime;
if(self->transferScript != NULL){
MacroPush(pCon);
tclStatus = Tcl_Eval(InterpGetTcl(pServ->pSics), self->transferScript);
@@ -364,7 +380,31 @@ int MakeMultiCounter(SConnection *pCon, SicsInterp *pSics,
memset(pDriv,0,sizeof(CounterDriver));
pDriv->pData = self;
pDriv->KillPrivate = KillMultiDriver;
pDriv->iNoOfMonitors = MAXCOUNT;
/*
now loop through the remaining arguments, thereby entering them into
the slave list.
*/
for(i = 2, self->nSlaves = 0; i < argc; i++){
pCom = FindCommand(pSics,argv[i]);
if(!pCom){
sprintf(pBueffel,"ERROR: object %s not found in MakeMultiCounter",
argv[i]);
SCWrite(pCon,pBueffel,eError);
continue;
}
pCount = GetCountableInterface(pCom->pData);
if(!pCount){
sprintf(pBueffel,"ERROR: object %s is NOT countable",
argv[i]);
SCWrite(pCon,pBueffel,eError);
continue;
}
self->slaves[self->nSlaves] = pCount;
self->slaveData[self->nSlaves] = pCom->pData;
self->nSlaves++;
}
pDriv->iNoOfMonitors = self->nSlaves;
pNew = CreateCounter(argv[1],pDriv);
if(pNew == NULL){
SCWrite(pCon,"ERROR: out of memory in MakeMultiCounter",eError);
@@ -388,30 +428,6 @@ int MakeMultiCounter(SConnection *pCon, SicsInterp *pSics,
pNew->pCountInt->TransferData = MMCCTransfer;
pNew->pCountInt->SetCountParameters = MMCCParameter;
/*
now loop through the remaining arguments, thereby entering them into
the slave list.
*/
for(i = 2; i < argc; i++){
pCom = FindCommand(pSics,argv[i]);
if(!pCom){
sprintf(pBueffel,"ERROR: object %s not found in MakeMultiCounter",
argv[i]);
SCWrite(pCon,pBueffel,eError);
continue;
}
pCount = GetCountableInterface(pCom->pData);
if(!pCount){
sprintf(pBueffel,"ERROR: object %s is NOT countable",
argv[i]);
SCWrite(pCon,pBueffel,eError);
continue;
}
self->slaves[self->nSlaves] = pCount;
self->slaveData[self->nSlaves] = pCom->pData;
self->nSlaves++;
}
/*
now install our action command and we are done
*/