- 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:
506
histmem.c
506
histmem.c
@ -62,6 +62,7 @@
|
||||
#include "dynstring.h"
|
||||
#include "event.h"
|
||||
#include "status.h"
|
||||
#include "tdchm.h"
|
||||
/*
|
||||
#define LOADDEBUG 1
|
||||
*/
|
||||
@ -106,12 +107,13 @@
|
||||
fprintf(fd,"%s preset %f\n",name,fVal);
|
||||
|
||||
/* time binning if TOF */
|
||||
if(self->pDriv->eHistMode == eHTOF)
|
||||
if(isInTOFMode(self->pDriv->data))
|
||||
{
|
||||
fprintf(fd,"%s genbin %f %f %d\n",
|
||||
name, self->pDriv->fTime[0],
|
||||
self->pDriv->fTime[1] - self->pDriv->fTime[0],
|
||||
self->pDriv->iTimeChan);
|
||||
name, self->pDriv->data->timeBinning[0],
|
||||
self->pDriv->data->timeBinning[1] -
|
||||
self->pDriv->data->timeBinning[0],
|
||||
self->pDriv->data->nTimeChan);
|
||||
fprintf(fd,"%s init\n",name);
|
||||
}
|
||||
|
||||
@ -167,9 +169,7 @@
|
||||
iRet = self->pDriv->Start(self->pDriv, pCon);
|
||||
if(iRet == OKOK)
|
||||
{
|
||||
self->pDriv->iUpdate = 1;
|
||||
self->iLocalUpdate = 1;
|
||||
self->tLocal = time(NULL) + self->iUpdateIntervall;
|
||||
updateHMData(self->pDriv->data);
|
||||
return iRet;
|
||||
}
|
||||
else
|
||||
@ -214,7 +214,7 @@
|
||||
iRet = self->pDriv->Pause(self->pDriv, pCon);
|
||||
if(iRet == OKOK)
|
||||
{
|
||||
self->pDriv->iUpdate = 1;
|
||||
updateHMData(self->pDriv->data);
|
||||
return iRet;
|
||||
}
|
||||
else
|
||||
@ -259,7 +259,7 @@
|
||||
iRet = self->pDriv->Continue(self->pDriv, pCon);
|
||||
if(iRet == OKOK)
|
||||
{
|
||||
self->pDriv->iUpdate = 1;
|
||||
updateHMData(self->pDriv->data);
|
||||
return iRet;
|
||||
}
|
||||
else
|
||||
@ -312,20 +312,19 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
self->iLocalUpdate = 1;
|
||||
updateHMData(self->pDriv->data);
|
||||
return HWBusy;
|
||||
}
|
||||
}
|
||||
if(eCt == HWBusy)
|
||||
self->iLocalUpdate = 1;
|
||||
updateHMData(self->pDriv->data);
|
||||
|
||||
if(eCt == HWIdle)
|
||||
{
|
||||
/* force an update of local histogram data with next
|
||||
GetHistogram
|
||||
*/
|
||||
self->iLocalUpdate = 1;
|
||||
self->tLocal = 0;
|
||||
updateHMData(self->pDriv->data);
|
||||
}
|
||||
|
||||
return eCt;
|
||||
@ -426,11 +425,6 @@
|
||||
pNew->pCountInt->Halt = HistHalt;
|
||||
pNew->pCountInt->Pause = HistPause;
|
||||
pNew->pCountInt->Continue = HistContinue;
|
||||
pNew->iLocalData = NULL;
|
||||
pNew->iLocalLength = 0;
|
||||
pNew->iUpdateIntervall = 0;
|
||||
pNew->iLocalUpdate = 1;
|
||||
pNew->tLocal = 0;
|
||||
|
||||
/* initialise options dictionary */
|
||||
pNew->pOption = CreateStringDict();
|
||||
@ -451,6 +445,10 @@
|
||||
{
|
||||
pNew->pDriv = CreateSINQDriver(pNew->pOption);
|
||||
}
|
||||
else if(strcmp(driver,"tdc") == 0)
|
||||
{
|
||||
pNew->pDriv = MakeTDCHM(pNew->pOption);
|
||||
}
|
||||
else /* no driver found */
|
||||
{
|
||||
DeleteDescriptor(pNew->pDes);
|
||||
@ -494,10 +492,6 @@
|
||||
{
|
||||
DeleteStringDict(self->pOption);
|
||||
}
|
||||
if(self->iLocalData)
|
||||
{
|
||||
free(self->iLocalData);
|
||||
}
|
||||
free(self);
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
@ -568,22 +562,6 @@
|
||||
assert(self);
|
||||
assert(pCon);
|
||||
|
||||
/* handle update intervall */
|
||||
iRet = StringDictGet(self->pOption,"update",pValue,79);
|
||||
assert(iRet); /* this is a programming error, we added it
|
||||
when creating the histogram memory object
|
||||
*/
|
||||
iRet = Tcl_GetInt(pSics->pTcl,pValue,&iVal);
|
||||
if(iRet != TCL_OK)
|
||||
{
|
||||
SCWrite(pCon,"WARNING: invalid value for update ignored",
|
||||
eWarning);
|
||||
}
|
||||
else
|
||||
{
|
||||
self->iUpdateIntervall = iVal;
|
||||
}
|
||||
|
||||
iRet = HistDriverConfig(self->pDriv,self->pOption,pCon);
|
||||
if(!iRet)
|
||||
{
|
||||
@ -596,8 +574,6 @@
|
||||
SCWrite(pCon,"ERROR: failed to configure histogram memory",eError);
|
||||
return 0;
|
||||
}
|
||||
self->iLocalUpdate = 1;
|
||||
self->tLocal = 0;
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@ -642,124 +618,23 @@
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int GetHistDim(pHistMem self, int iDim[MAXDIM], int *nDim)
|
||||
{
|
||||
int i, myDim;
|
||||
|
||||
assert(self);
|
||||
|
||||
for(i = 0, myDim = 0; i < self->pDriv->nDim; i++)
|
||||
getHMDataDim(self->pDriv->data,iDim,nDim);
|
||||
if(isInTOFMode(self->pDriv->data))
|
||||
{
|
||||
if(self->pDriv->iDims[i] > 0)
|
||||
{
|
||||
iDim[i] = self->pDriv->iDims[i];
|
||||
myDim++;
|
||||
}
|
||||
iDim[*nDim] = getNoOfTimebins(self->pDriv->data);
|
||||
*nDim ++;
|
||||
}
|
||||
if(self->pDriv->eHistMode == eHTOF
|
||||
|| self->pDriv->eHistMode == ePSD
|
||||
|| self->pDriv->eHistMode == eSANSTOF)
|
||||
{
|
||||
iDim[myDim] = self->pDriv->iTimeChan;
|
||||
myDim++;
|
||||
}
|
||||
*nDim = myDim;
|
||||
return 1;
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
static long SumRow(int *iData, int iDataLength, int iStart, int iEnd)
|
||||
{
|
||||
int i;
|
||||
long lSum;
|
||||
|
||||
if(iEnd > iDataLength)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
lSum = 0;
|
||||
for(i = iStart; i < iEnd; i++)
|
||||
{
|
||||
lSum += iData[i];
|
||||
}
|
||||
return lSum;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
long HistSum(pHistMem self, SConnection *pCon,
|
||||
int iStart[MAXDIM], int iEnd[MAXDIM])
|
||||
{
|
||||
int i, iDataDim[MAXDIM], nDim, iIndex;
|
||||
long lSum;
|
||||
char pBueffel[132];
|
||||
HistInt *iData = NULL;
|
||||
int iHistLength, iRet;
|
||||
|
||||
assert(self);
|
||||
|
||||
/* do some serious error checking */
|
||||
GetHistDim(self,iDataDim,&nDim);
|
||||
if(nDim <= 0)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: Now data dimensions specified, cannot sum",eError);
|
||||
return -1;
|
||||
}
|
||||
for(i = 0; i < nDim; i++)
|
||||
{
|
||||
if( (iStart[i] < 0) || (iStart[i] > iDataDim[i]) )
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: %d is out of data dimension range",
|
||||
iStart[i]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return -1;
|
||||
}
|
||||
if( (iEnd[i] < 0) || (iEnd[i] > iDataDim[i]) )
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: %d is out of data dimension range",
|
||||
iEnd[i]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* get histogram data */
|
||||
iHistLength = GetHistLength(self);
|
||||
iData = (HistInt *)malloc(iHistLength*sizeof(HistInt));
|
||||
if(!iData)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: Failed to allocate data in sum", eError);
|
||||
return -1;
|
||||
}
|
||||
iRet = GetHistogram(self,pCon,0,0,iHistLength,iData,
|
||||
iHistLength*sizeof(HistInt));
|
||||
if(!iRet)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: could not get hold of data to sum",eError);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* actually sum */
|
||||
switch(nDim)
|
||||
{
|
||||
case 1:
|
||||
lSum = SumRow(iData, iHistLength, iStart[0], iEnd[0]);
|
||||
break;
|
||||
case 2:
|
||||
lSum = 0;
|
||||
for(i = iStart[0]; i < iEnd[0]; i++)
|
||||
{
|
||||
iIndex = i*iDataDim[1];
|
||||
lSum += SumRow(iData,iHistLength,
|
||||
iIndex+iStart[1], iIndex+iEnd[1]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
sprintf(pBueffel,
|
||||
"ERROR: summing in %d dimensions not yet implemented",
|
||||
nDim);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
lSum = -1;
|
||||
break;
|
||||
}
|
||||
free(iData);
|
||||
return lSum;
|
||||
return sumHMDataRectangle(self,pCon,iStart,iEnd);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
CounterMode GetHistCountMode(pHistMem self)
|
||||
@ -806,15 +681,15 @@
|
||||
const float *GetHistTimeBin(pHistMem self, int *iLength)
|
||||
{
|
||||
assert(self);
|
||||
*iLength = self->pDriv->iTimeChan;
|
||||
return self->pDriv->fTime;
|
||||
*iLength = getNoOfTimebins(self->pDriv->data);
|
||||
return getTimeBinning(self->pDriv->data);
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
int GetHistLength(pHistMem self)
|
||||
{
|
||||
assert(self);
|
||||
|
||||
return self->pDriv->iRank*self->pDriv->iLength;
|
||||
return getHMDataLength(self->pDriv->data);
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
float GetHistCountTime(pHistMem self, SConnection *pCon)
|
||||
@ -898,9 +773,7 @@
|
||||
i,iStart,iEnd,lData);
|
||||
if(iRet == OKOK)
|
||||
{
|
||||
self->iLocalUpdate = 1;
|
||||
self->tLocal = 0;
|
||||
self->pDriv->iUpdate = 0;
|
||||
updateHMData(self->pDriv->data);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@ -921,87 +794,20 @@
|
||||
int GetHistogram(pHistMem self, SConnection *pCon,
|
||||
int i, int iStart, int iEnd, HistInt *lData, int iDataLen)
|
||||
{
|
||||
int ii, iErr, iRet, iCopy;
|
||||
char pBueffel[512], pError[80];
|
||||
HistInt *lHist = NULL;
|
||||
|
||||
assert(self);
|
||||
|
||||
if(!self->iInit)
|
||||
{
|
||||
if(!self->iInit)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: histogram memory not initialised",eError);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* get the full histogram if an update is needed */
|
||||
if( (self->iLocalUpdate) && (time(NULL) > self->tLocal) )
|
||||
{
|
||||
#ifdef LOADDEBUG
|
||||
fprintf(stdout,"Getting new histogram from HM\n");
|
||||
#endif
|
||||
/* check data allocation */
|
||||
if(self->iLocalLength != self->pDriv->iLength)
|
||||
{
|
||||
if(self->iLocalData)
|
||||
{
|
||||
free(self->iLocalData);
|
||||
self->iLocalData = NULL;
|
||||
}
|
||||
self->iLocalData = (HistInt *)malloc(
|
||||
self->pDriv->iLength*sizeof(HistInt));
|
||||
if(!self->iLocalData)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: failed to allocate data in GetHistogram",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
self->iLocalLength = self->pDriv->iLength;
|
||||
memset(self->iLocalData,0,self->iLocalLength*sizeof(HistInt));
|
||||
}
|
||||
/* try at least three times */
|
||||
for(ii = 0; ii < 3; ii++)
|
||||
{
|
||||
iRet = self->pDriv->GetHistogram(self->pDriv,pCon,
|
||||
i,0,self->iLocalLength,
|
||||
self->iLocalData);
|
||||
if(iRet == OKOK)
|
||||
{
|
||||
self->iLocalUpdate = 0;
|
||||
self->tLocal = time(NULL) + self->iUpdateIntervall;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
iRet = self->pDriv->GetError(self->pDriv,&iErr,pError,79);
|
||||
sprintf(pBueffel,"ERROR: %s ",pError);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
iRet = self->pDriv->TryAndFixIt(self->pDriv,iErr);
|
||||
if(iRet == COTERM)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* copy from buffer if there and updated */
|
||||
if(self->iLocalData)
|
||||
{
|
||||
#ifdef LOADDEBUG
|
||||
fprintf(stdout,"Copying histogram data from memory\n");
|
||||
#endif
|
||||
lHist = self->iLocalData + iStart;
|
||||
if(iEnd*sizeof(HistInt) < iDataLen)
|
||||
{
|
||||
iCopy = iEnd;
|
||||
}
|
||||
else
|
||||
{
|
||||
iCopy = iDataLen/sizeof(HistInt);
|
||||
}
|
||||
memcpy(lData,lHist,iCopy*sizeof(HistInt));
|
||||
}
|
||||
return 1;
|
||||
if(iEnd > iDataLen/sizeof(HistInt))
|
||||
{
|
||||
SCWrite(pCon,"WARNING: truncating request to fit data space",eWarning);
|
||||
iEnd = (iDataLen/sizeof(HistInt)) - 1;
|
||||
}
|
||||
return getHMDataHistogram(self,pCon,i,iStart,iEnd,lData);
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
int GetHistogramDirect(pHistMem self, SConnection *pCon,
|
||||
@ -1048,10 +854,6 @@
|
||||
/*-----------------------------------------------------------------------*/
|
||||
HistInt *GetHistogramPointer(pHistMem self, SConnection *pCon)
|
||||
{
|
||||
int ii, iErr, iRet, iCopy;
|
||||
char pBueffel[512], pError[80];
|
||||
HistInt *lHist = NULL;
|
||||
|
||||
assert(self);
|
||||
|
||||
if(!self->iInit)
|
||||
@ -1060,67 +862,7 @@
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(self->iLocalData == NULL)
|
||||
{
|
||||
self->iLocalUpdate = 1;
|
||||
self->tLocal = 0;
|
||||
}
|
||||
|
||||
/* get the full histogram if an update is needed */
|
||||
if( (self->iLocalUpdate) && (time(NULL) > self->tLocal) )
|
||||
{
|
||||
#ifdef LOADDEBUG
|
||||
fprintf(stdout,"Getting new histogram from HM\n");
|
||||
#endif
|
||||
/* check data allocation */
|
||||
if(self->iLocalLength != self->pDriv->iLength)
|
||||
{
|
||||
if(self->iLocalData)
|
||||
{
|
||||
free(self->iLocalData);
|
||||
self->iLocalData = NULL;
|
||||
}
|
||||
self->iLocalData = (HistInt *)malloc(
|
||||
self->pDriv->iLength*sizeof(HistInt));
|
||||
if(!self->iLocalData)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: failed to allocate data in GetHistogram",
|
||||
eError);
|
||||
return NULL;
|
||||
}
|
||||
self->iLocalLength = self->pDriv->iLength;
|
||||
memset(self->iLocalData,0,self->iLocalLength*sizeof(HistInt));
|
||||
}
|
||||
/* try at least three times */
|
||||
for(ii = 0; ii < 3; ii++)
|
||||
{
|
||||
iRet = self->pDriv->GetHistogram(self->pDriv,pCon,
|
||||
0,0,self->iLocalLength,
|
||||
self->iLocalData);
|
||||
if(iRet == OKOK)
|
||||
{
|
||||
self->iLocalUpdate = 0;
|
||||
self->tLocal = time(NULL) + self->iUpdateIntervall;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
iRet = self->pDriv->GetError(self->pDriv,&iErr,pError,79);
|
||||
sprintf(pBueffel,"ERROR: %s ",pError);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
iRet = self->pDriv->TryAndFixIt(self->pDriv,iErr);
|
||||
if(iRet == COTERM)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef LOADDEBUG
|
||||
fprintf(stdout,"Copying histogram data from memory\n");
|
||||
#endif
|
||||
return self->iLocalData;
|
||||
return getHMDataBufferPointer(self,pCon);
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int PresetHistogram(pHistMem self, SConnection *pCon, HistInt lVal)
|
||||
@ -1142,9 +884,7 @@
|
||||
iRet = self->pDriv->Preset(self->pDriv,pCon,lVal);
|
||||
if(iRet == OKOK)
|
||||
{
|
||||
self->pDriv->iUpdate = 0;
|
||||
self->iLocalUpdate = 1;
|
||||
self->tLocal = 0;
|
||||
updateHMData(self->pDriv->data);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@ -1161,6 +901,7 @@
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*-----------------------------------------------------------------------*/
|
||||
static int HMCountInterest(int iEvent, void *pEvent, void *pUser)
|
||||
{
|
||||
@ -1183,6 +924,22 @@
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static int checkHMEnd(pHistMem self, char *text){
|
||||
int iTest, iEnd;
|
||||
|
||||
iEnd = getHMDataLength(self->pDriv->data);
|
||||
if(text == NULL){
|
||||
return iEnd;
|
||||
} else {
|
||||
iTest = atoi(text);
|
||||
if(iTest > iEnd){
|
||||
return iEnd;
|
||||
} else {
|
||||
return iTest;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int HistAction(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[])
|
||||
@ -1276,7 +1033,8 @@
|
||||
/* authorise */
|
||||
if(!SCMatchRights(pCon,usMugger))
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: you need to be manager in order to configure %s",
|
||||
sprintf(pBueffel,
|
||||
"ERROR: you need to be manager in order to configure %s",
|
||||
argv[0]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
@ -1304,7 +1062,6 @@
|
||||
fVal = atof(argv[2]);
|
||||
if(!SCMatchRights(pCon,self->iAccess))
|
||||
{
|
||||
SCWrite(pCon,"ERROR: you are not priviledged for attempted operation",eError);
|
||||
return 0;
|
||||
}
|
||||
iRet = SetHistPreset(self,fVal);
|
||||
@ -1324,7 +1081,6 @@
|
||||
{
|
||||
if(!SCMatchRights(pCon,self->iAccess))
|
||||
{
|
||||
SCWrite(pCon,"ERROR: you are not priviledged for attempted operation",eError);
|
||||
return 0;
|
||||
}
|
||||
self->iExponent = atoi(argv[2]);
|
||||
@ -1346,7 +1102,6 @@
|
||||
strtolower(argv[2]);
|
||||
if(!SCMatchRights(pCon,self->iAccess))
|
||||
{
|
||||
SCWrite(pCon,"ERROR: you are not priviledged for attempted operation",eError);
|
||||
return 0;
|
||||
}
|
||||
if(strcmp(argv[2],"timer") == 0)
|
||||
@ -1386,8 +1141,6 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
SCWrite(pCon,
|
||||
"ERROR: you are not privileged for attempted operation",eError);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1410,8 +1163,6 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
SCWrite(pCon,
|
||||
"ERROR: you are not privileged for attempted operation",eError);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1429,8 +1180,6 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
SCWrite(pCon,
|
||||
"ERROR: you are not privileged for attempted operation",eError);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1448,8 +1197,6 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
SCWrite(pCon,
|
||||
"ERROR: you are not privileged for attempted operation",eError);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1458,8 +1205,6 @@
|
||||
/* check user rights */
|
||||
if(!SCMatchRights(pCon,self->iAccess))
|
||||
{
|
||||
SCWrite(pCon,
|
||||
"ERROR: you are not priviledged for attempted operation",eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1491,15 +1236,6 @@
|
||||
}
|
||||
iNum = atoi(argv[2]);
|
||||
|
||||
/* check iNum */
|
||||
if( (iNum < 0) || (iNum > self->pDriv->iRank))
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: requested histogram no %d out of range",
|
||||
iNum);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* optional iStart, default 0 */
|
||||
iStart = 0;
|
||||
if(argc > 3 )
|
||||
@ -1513,21 +1249,12 @@
|
||||
SCWrite(pCon,"WARNING: Invalid start position defaulted to 0",eWarning);
|
||||
iStart = 0;
|
||||
}
|
||||
|
||||
/* optional iEnd, default to maximum */
|
||||
iEnd = self->pDriv->iLength;
|
||||
if(argc > 4)
|
||||
{
|
||||
iEnd = atoi(argv[4]);
|
||||
}
|
||||
|
||||
/* check iEnd */
|
||||
if(iEnd > self->pDriv->iLength)
|
||||
{
|
||||
iEnd = self->pDriv->iLength;
|
||||
SCWrite(pCon,
|
||||
"WARNING: invalid end parameter reset to max ",eWarning);
|
||||
}
|
||||
|
||||
if(argc > 4){
|
||||
iEnd = checkHMEnd(self,argv[4]);
|
||||
} else {
|
||||
iEnd = checkHMEnd(self,NULL);
|
||||
}
|
||||
|
||||
/* allocate data storage and get it */
|
||||
lData = (HistInt *)malloc(iEnd*sizeof(HistInt));
|
||||
@ -1577,15 +1304,6 @@
|
||||
}
|
||||
iNum = atoi(argv[2]);
|
||||
|
||||
/* check iNum */
|
||||
if( (iNum < 0) || (iNum > self->pDriv->iRank))
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: requested histogram no %d out of range",
|
||||
iNum);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* optional iStart, default 0 */
|
||||
iStart = 0;
|
||||
if(argc > 3 )
|
||||
@ -1599,22 +1317,13 @@
|
||||
SCWrite(pCon,"WARNING: Invalid start position defaulted to 0",eWarning);
|
||||
iStart = 0;
|
||||
}
|
||||
|
||||
/* optional iEnd, default to maximum */
|
||||
iEnd = self->pDriv->iLength;
|
||||
if(argc > 4)
|
||||
{
|
||||
iEnd = atoi(argv[4]);
|
||||
}
|
||||
|
||||
/* check iEnd */
|
||||
if(iEnd > self->pDriv->iLength)
|
||||
{
|
||||
iEnd = self->pDriv->iLength;
|
||||
SCWrite(pCon,
|
||||
"WARNING: invalid end parameter reset to max ",eWarning);
|
||||
}
|
||||
|
||||
|
||||
if(argc > 4){
|
||||
iEnd = checkHMEnd(self,argv[4]);
|
||||
} else {
|
||||
iEnd = checkHMEnd(self,NULL);
|
||||
}
|
||||
|
||||
/* allocate data storage and get it */
|
||||
lData = (HistInt *)malloc((iEnd+1)*sizeof(HistInt));
|
||||
if(!lData)
|
||||
@ -1659,15 +1368,6 @@
|
||||
}
|
||||
iNum = atoi(argv[2]);
|
||||
|
||||
/* check iNum */
|
||||
if( (iNum < 0) || (iNum > self->pDriv->iRank))
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: requested histogram no %d out of range",
|
||||
iNum);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* optional iStart, default 0 */
|
||||
iStart = 0;
|
||||
if(argc > 3 )
|
||||
@ -1678,25 +1378,17 @@
|
||||
/* check iStart */
|
||||
if(iStart < 0)
|
||||
{
|
||||
SCWrite(pCon,"WARNING: Invalid start position defaulted to 0",eWarning);
|
||||
SCWrite(pCon,"WARNING: Invalid start position defaulted to 0",
|
||||
eWarning);
|
||||
iStart = 0;
|
||||
}
|
||||
|
||||
/* optional iEnd, default to maximum */
|
||||
iEnd = self->pDriv->iLength;
|
||||
if(argc > 4)
|
||||
{
|
||||
iEnd = atoi(argv[4]);
|
||||
}
|
||||
|
||||
/* check iEnd */
|
||||
if(iEnd > self->pDriv->iLength)
|
||||
{
|
||||
iEnd = self->pDriv->iLength;
|
||||
SCWrite(pCon,
|
||||
"WARNING: invalid end parameter reset to max ",eWarning);
|
||||
}
|
||||
|
||||
if(argc > 4){
|
||||
iEnd = checkHMEnd(self,argv[4]);
|
||||
} else {
|
||||
iEnd = checkHMEnd(self,NULL);
|
||||
}
|
||||
|
||||
/* allocate data storage and get it */
|
||||
lData = (HistInt *)malloc((iEnd+1)*sizeof(HistInt));
|
||||
if(!lData)
|
||||
@ -1731,7 +1423,8 @@
|
||||
else if(strcmp(argv[1],"notimebin") == 0)
|
||||
{
|
||||
sprintf(pBueffel,
|
||||
"%s.notimebin = %d",argv[0], self->pDriv->iTimeChan);
|
||||
"%s.notimebin = %d",argv[0],
|
||||
getNoOfTimebins(self->pDriv->data));
|
||||
SCWrite(pCon,pBueffel,eValue);
|
||||
return 1;
|
||||
}
|
||||
@ -1740,9 +1433,9 @@
|
||||
{
|
||||
Tcl_DStringInit(&tResult);
|
||||
Tcl_DStringAppend(&tResult,"histogram.timebins = ",-1);
|
||||
for(i = 0; i < self->pDriv->iTimeChan; i++)
|
||||
for(i = 0; i < self->pDriv->data->nTimeChan; i++)
|
||||
{
|
||||
sprintf(pBueffel," %8.2f", self->pDriv->fTime[i]);
|
||||
sprintf(pBueffel," %8.2f", self->pDriv->data->timeBinning[i]);
|
||||
Tcl_DStringAppend(&tResult,pBueffel,-1);
|
||||
}
|
||||
/* Write it */
|
||||
@ -1757,7 +1450,6 @@
|
||||
{
|
||||
if(!SCMatchRights(pCon,usMugger))
|
||||
{
|
||||
SCWrite(pCon,"ERROR: you are not authorised for this operation",eError);
|
||||
return 0;
|
||||
}
|
||||
if(GetStatus() == eCounting)
|
||||
@ -1795,22 +1487,13 @@
|
||||
/* do it */
|
||||
if(iNum >= MAXCHAN)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: number of requested time bins exceeds maximum permissible number",
|
||||
SCWrite(pCon,
|
||||
"ERROR: number of requested time bins exceeds maximum permissible number",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
for(i = 0; i < iNum; i++)
|
||||
{
|
||||
self->pDriv->fTime[i] = dStart + i* dStep;
|
||||
}
|
||||
self->pDriv->iTimeChan = iNum;
|
||||
self->iInit = 0;
|
||||
self->pDriv->iLength = 1;
|
||||
for(i = 0; i < self->pDriv->iRank; i++)
|
||||
{
|
||||
self->pDriv->iLength *= self->pDriv->iDims[i];
|
||||
}
|
||||
self->pDriv->iLength *= self->pDriv->iTimeChan;
|
||||
genTimeBinning(self->pDriv->data,
|
||||
(float)dStart,(float)dStep,iNum);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
@ -1819,7 +1502,6 @@
|
||||
{
|
||||
if(!SCMatchRights(pCon,usMugger))
|
||||
{
|
||||
SCWrite(pCon,"ERROR: yoy are not authorised for this operation",eError);
|
||||
return 0;
|
||||
}
|
||||
if(argc < 4)
|
||||
@ -1843,20 +1525,11 @@
|
||||
}
|
||||
if( (iNum < 0) || (iNum > MAXCHAN) )
|
||||
{
|
||||
SCWrite(pCon,"ERROR: requested time bin out or permissible range",eError);
|
||||
SCWrite(pCon,"ERROR: requested time bin out or permissible range",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
self->pDriv->fTime[iNum] = dStep;
|
||||
if(iNum > self->pDriv->iTimeChan)
|
||||
{
|
||||
self->pDriv->iTimeChan = iNum;
|
||||
self->pDriv->iLength = 1;
|
||||
for(i = 0; i < self->pDriv->iRank; i++)
|
||||
{
|
||||
self->pDriv->iLength *= self->pDriv->iDims[i];
|
||||
}
|
||||
self->pDriv->iLength *= self->pDriv->iTimeChan;
|
||||
}
|
||||
setTimeBin(self->pDriv->data,iNum, (float)dStep);
|
||||
self->iInit = 0;
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
@ -1864,8 +1537,7 @@
|
||||
/* clear time bin info */
|
||||
else if(strcmp(argv[1],"clearbin") == 0)
|
||||
{
|
||||
self->pDriv->iTimeChan = 0;
|
||||
self->iInit = 1;
|
||||
clearTimeBinning(self->pDriv->data);
|
||||
SCSendOK(pCon);
|
||||
}
|
||||
/*-------- sum */
|
||||
@ -1924,5 +1596,3 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user