- Refactored histogram memory code a little
- motor driver for ECB now fully working - Fixed an anticollider bug - Untested version of a driver for the Risoe TDC histogram memory
This commit is contained in:
208
histdriv.c
208
histdriv.c
@ -63,18 +63,16 @@
|
||||
return NULL;
|
||||
}
|
||||
memset(pNew,0,sizeof(HistDriver));
|
||||
|
||||
pNew->data = makeHMData();
|
||||
if(!pNew->data)
|
||||
{
|
||||
free(pNew);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* initialise defaults */
|
||||
pNew->eHistMode = eHNormal;
|
||||
StringDictAddPair(pOption,"histmode","normal");
|
||||
pNew->eFlow = eOCeil;
|
||||
StringDictAddPair(pOption,"overflowmode","ceil");
|
||||
pNew->iRank = 1;
|
||||
StringDictAddPair(pOption,"rank","1");
|
||||
pNew->iLength = 412;
|
||||
StringDictAddPair(pOption,"length","412");
|
||||
pNew->iBinWidth = 16;
|
||||
StringDictAddPair(pOption,"binwidth","16");
|
||||
for(i = 0; i < MAXDIM; i++)
|
||||
{
|
||||
sprintf(pDim,"dim%1.1d",i);
|
||||
@ -84,8 +82,6 @@
|
||||
pNew->eCount = eTimer;
|
||||
pNew->iReconfig = 1;
|
||||
pNew->iUpdate = 0;
|
||||
pNew->iTimeChan = 1;
|
||||
|
||||
|
||||
return pNew;
|
||||
}
|
||||
@ -98,59 +94,12 @@
|
||||
{
|
||||
self->FreePrivate(self);
|
||||
}
|
||||
if(self->data)
|
||||
{
|
||||
killHMData(self->data);
|
||||
}
|
||||
free(self);
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
static char *pHistMode[] = {
|
||||
"transparent",
|
||||
"normal",
|
||||
"tof",
|
||||
"strobo",
|
||||
"hrpt",
|
||||
"psd",
|
||||
"sanstof",
|
||||
NULL
|
||||
};
|
||||
|
||||
static HistMode Text2Mode(char *text)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
while(pHistMode[i] != NULL)
|
||||
{
|
||||
if(strcmp(pHistMode[i],text) == 0)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
/* not found */
|
||||
return -1;
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
static char *pFlowMode[] = {
|
||||
"ignore",
|
||||
"ceil",
|
||||
"count",
|
||||
"reflect",
|
||||
NULL
|
||||
};
|
||||
|
||||
static OverFlowMode Text2Flow(char *text)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
while(pFlowMode[i] != NULL)
|
||||
{
|
||||
if(strcmp(pFlowMode[i],text) == 0)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
/* not found */
|
||||
return -1;
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
int HistDriverConfig(pHistDriver self, pStringDict pOpt, SConnection *pCon)
|
||||
{
|
||||
@ -166,138 +115,5 @@
|
||||
assert(pOpt);
|
||||
assert(pCon);
|
||||
|
||||
/* enter histmode */
|
||||
iRet = StringDictGet(pOpt,"histmode",pValue,79);
|
||||
if(!iRet)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: internal Value not found!",eError);
|
||||
return 0;
|
||||
}
|
||||
strtolower(pValue);
|
||||
iRet = Text2Mode(pValue);
|
||||
if(iRet < 0)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: Invalid parameter %s to HistMode",pValue);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
self->eHistMode = iRet;
|
||||
|
||||
/* handle overflowmode */
|
||||
iRet = StringDictGet(pOpt,"overflowmode",pValue,79);
|
||||
if(!iRet)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: internal Value not found!",eError);
|
||||
return 0;
|
||||
}
|
||||
strtolower(pValue);
|
||||
iRet = Text2Flow(pValue);
|
||||
if(iRet < 0)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: Invalid parameter %s to OverflowMode",pValue);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
self->eFlow = iRet;
|
||||
|
||||
/* no of hist */
|
||||
iRet = StringDictGetAsNumber(pOpt,"rank",&fVal);
|
||||
if(!iRet)
|
||||
{
|
||||
iRet = StringDictGet(pOpt,"rank",pValue,79);
|
||||
if(iRet)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: %s not valid for Rank ",pValue);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
SCWrite(pCon,"ERROR: internal Value not found!",eError);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if(fVal < 0)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: %f is invalid for rank",fVal);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
self->iRank = (int)fVal;
|
||||
|
||||
/* length */
|
||||
iRet = StringDictGetAsNumber(pOpt,"length",&fVal);
|
||||
if(!iRet)
|
||||
{
|
||||
iRet = StringDictGet(pOpt,"length",pValue,79);
|
||||
if(iRet)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: %s not valid for Length ",pValue);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
SCWrite(pCon,"ERROR: internal Value not found!",eError);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if(fVal < 1)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: %f is invalid for Length",fVal);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
self->iLength = (int)fVal;
|
||||
|
||||
/* BinWidth */
|
||||
iRet = StringDictGetAsNumber(pOpt,"binwidth",&fVal);
|
||||
if(!iRet)
|
||||
{
|
||||
iRet = StringDictGet(pOpt,"binwidth",pValue,79);
|
||||
if(iRet)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: %s not valid for BinWidth ",pValue);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
SCWrite(pCon,"ERROR: internal Value not found!",eError);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if(fVal < 1)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: %f is invalid for BinWidth",fVal);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
self->iBinWidth = (int)fVal;
|
||||
|
||||
/* dimensions */
|
||||
self->nDim = 0;
|
||||
for(i = 0; i < MAXDIM; i++)
|
||||
{
|
||||
sprintf(pValue,"dim%1.1d",i);
|
||||
iRet = StringDictGetAsNumber(pOpt,pValue,&fVal);
|
||||
if(!iRet)
|
||||
{
|
||||
if(i < self->iRank)
|
||||
{
|
||||
sprintf(pBueffel,"WARNING: dimension %s NOT found",pValue);
|
||||
SCWrite(pCon,pBueffel,eWarning);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(fVal > 0.)
|
||||
{
|
||||
self->nDim++;
|
||||
self->iDims[i] = (int)fVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
return configureHMdata(self->data,pOpt,pCon);
|
||||
}
|
||||
|
Reference in New Issue
Block a user