Changed HM-configuration at FOCUS
This commit is contained in:
242
faverage.c
242
faverage.c
@@ -22,6 +22,7 @@
|
||||
#include <time.h>
|
||||
#include "fortify.h"
|
||||
#include "sics.h"
|
||||
#include "sicsvar.h"
|
||||
#include "counter.h"
|
||||
#include "HistMem.h"
|
||||
#include "fomerge.h"
|
||||
@@ -33,10 +34,16 @@
|
||||
/*-------------------------------------------------------------------------*/
|
||||
typedef struct __FocusAverager {
|
||||
pObjectDescriptor pDes;
|
||||
pHistMem pHist;
|
||||
pHistMem pHistogram1;
|
||||
pHistMem pHistogram2;
|
||||
pHistMem pHistogram3;
|
||||
} FocusAverager, *pFocusAverager;
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
HistInt *CheckBank(pFocusAverager self, SConnection *pCon,
|
||||
int iLength, int iBank);
|
||||
|
||||
static void KillFA(void *pData)
|
||||
{
|
||||
pFocusAverager self = NULL;
|
||||
@@ -61,7 +68,11 @@
|
||||
char pBueffel[256];
|
||||
HistInt *hiData = NULL, *hiPtr;
|
||||
time_t tStart, tEnd;
|
||||
int iBank = MIDDLE;
|
||||
int iBank = MIDDLE;
|
||||
pSicsVariable var1 = NULL;
|
||||
pSicsVariable var2 = NULL;
|
||||
pSicsVariable var3 = NULL;
|
||||
int lbank, mbank, ubank;
|
||||
|
||||
self = (pFocusAverager)pData;
|
||||
assert(self);
|
||||
@@ -129,7 +140,36 @@
|
||||
#endif
|
||||
|
||||
/* do work! first retrieve time binning data */
|
||||
fTimeBin = GetHistTimeBin(self->pHist,&iLength);
|
||||
|
||||
var2 = FindVariable(pServ->pSics,"mbank");
|
||||
if(var2)
|
||||
{
|
||||
VarGetInt(var2,&mbank);
|
||||
} else {
|
||||
SCWrite(pCon,"ERROR: mbank value not found!",eError);
|
||||
}
|
||||
if(var2)
|
||||
{
|
||||
fTimeBin = GetHistTimeBin(self->pHistogram2,&iLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
var1 = FindVariable(pServ->pSics,"lbank");
|
||||
if(var1)
|
||||
{
|
||||
VarGetInt(var1,&lbank);
|
||||
} else {
|
||||
SCWrite(pCon,"ERROR: lbank value not found!",eError);
|
||||
}
|
||||
if(var1)
|
||||
{
|
||||
fTimeBin = GetHistTimeBin(self->pHistogram1,&iLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
fTimeBin = GetHistTimeBin(self->pHistogram3,&iLength);
|
||||
}
|
||||
}
|
||||
assert(fTimeBin);
|
||||
if(iLength <= 0)
|
||||
{
|
||||
@@ -157,23 +197,19 @@
|
||||
printf("Getting histogram....\n");
|
||||
fflush(stdout);
|
||||
#endif
|
||||
hiData = GetHistogramPointer(self->pHist,pCon);
|
||||
if(hiData == NULL)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: failed to read histogram memory data",eError);
|
||||
free(iData);
|
||||
return 0;
|
||||
}
|
||||
setFMDataPointer(hiData, iLength);
|
||||
hiData = getFMBankPointer(iBank);
|
||||
|
||||
hiData = CheckBank(self,pCon,iLength,iBank);
|
||||
|
||||
#ifdef DEB
|
||||
tEnd = time(NULL);
|
||||
printf("Histogram received in %d seconds\n", tStart - tEnd);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
if(hiData == NULL)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: BAD Configuration",eError);
|
||||
free(iData);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -228,6 +264,10 @@
|
||||
const float *timeBin;
|
||||
HistInt *hiData = NULL, *hiPtr;
|
||||
int iBank = MIDDLE;
|
||||
pSicsVariable var1 = NULL;
|
||||
pSicsVariable var2 = NULL;
|
||||
pSicsVariable var3 = NULL;
|
||||
int lbank, mbank, ubank;
|
||||
|
||||
self = (pFocusAverager)pData;
|
||||
assert(self);
|
||||
@@ -250,23 +290,38 @@
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
timeBin = GetHistTimeBin(self->pHist,&iLength);
|
||||
assert(timeBin);
|
||||
hiData = GetHistogramPointer(self->pHist,pCon);
|
||||
if(hiData == NULL)
|
||||
var2 = FindVariable(pServ->pSics,"mbank");
|
||||
if(var2)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: failed to read histogram memory data",eError);
|
||||
return 0;
|
||||
}
|
||||
setFMDataPointer(hiData, iLength);
|
||||
hiData = getFMBankPointer(iBank);
|
||||
if(hiData == NULL)
|
||||
VarGetInt(var2,&mbank);
|
||||
} else {
|
||||
SCWrite(pCon,"ERROR: mbank value not found!",eError);
|
||||
}
|
||||
if(var2)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: BAD Configuration",eError);
|
||||
return 0;
|
||||
timeBin = GetHistTimeBin(self->pHistogram2,&iLength);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
var1 = FindVariable(pServ->pSics,"lbank");
|
||||
if(var1)
|
||||
{
|
||||
VarGetInt(var1,&lbank);
|
||||
} else {
|
||||
SCWrite(pCon,"ERROR: lbank value not found!",eError);
|
||||
}
|
||||
if(var1)
|
||||
{
|
||||
timeBin = GetHistTimeBin(self->pHistogram1,&iLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
timeBin = GetHistTimeBin(self->pHistogram3,&iLength);
|
||||
}
|
||||
}
|
||||
assert(timeBin);
|
||||
hiData = CheckBank(self, pCon, iLength, iBank);
|
||||
|
||||
/* get histogram length */
|
||||
iLength = getFMdim(iBank);
|
||||
noTimebin = getFMdim(TIMEBIN);
|
||||
@@ -305,7 +360,11 @@
|
||||
pDummy pDum = NULL;
|
||||
char pBueffel[256];
|
||||
int iRet;
|
||||
|
||||
pSicsVariable var1 = NULL;
|
||||
pSicsVariable var2 = NULL;
|
||||
pSicsVariable var3 = NULL;
|
||||
int lbank, mbank, ubank;
|
||||
|
||||
assert(pCon);
|
||||
assert(pSics);
|
||||
|
||||
@@ -334,9 +393,9 @@
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
if(strcmp(pDum->pDescriptor->name,"HistMem") != 0)
|
||||
if(strcmp(pDum->pDescriptor->name,"HMcontrol") != 0)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: %s is NO histogram memory object!", argv[2]);
|
||||
sprintf(pBueffel,"ERROR: %s is NO histogram control object!", argv[2]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
@@ -356,8 +415,45 @@
|
||||
SCWrite(pCon,"ERROR: out of memory in MakeFA",eError);
|
||||
return 0;
|
||||
}
|
||||
pNew->pHist = (pHistMem)pDum;
|
||||
|
||||
var2 = FindVariable(pServ->pSics,"mbank");
|
||||
if(var2)
|
||||
{
|
||||
VarGetInt(var2,&mbank);
|
||||
} else {
|
||||
SCWrite(pCon,"ERROR: mbank value not found!",eError);
|
||||
}
|
||||
if(mbank==1)
|
||||
{
|
||||
pCom = FindCommand(pSics,"hm2");
|
||||
pDum = (pDummy)pCom->pData;
|
||||
pNew->pHistogram2 = (pHistMem)pDum;
|
||||
}
|
||||
var1 = FindVariable(pServ->pSics,"lbank");
|
||||
if(var1)
|
||||
{
|
||||
VarGetInt(var1,&lbank);
|
||||
} else {
|
||||
SCWrite(pCon,"ERROR: lbank value not found!",eError);
|
||||
}
|
||||
if(lbank==1)
|
||||
{
|
||||
pCom = FindCommand(pSics,"hm1");
|
||||
pDum = (pDummy)pCom->pData;
|
||||
pNew->pHistogram1 = (pHistMem)pDum;
|
||||
}
|
||||
var3 = FindVariable(pServ->pSics,"ubank");
|
||||
if(var3)
|
||||
{
|
||||
VarGetInt(var3,&ubank);
|
||||
} else {
|
||||
SCWrite(pCon,"ERROR: ubank value not found!",eError);
|
||||
}
|
||||
if(ubank==1)
|
||||
{
|
||||
pCom = FindCommand(pSics,"hm3");
|
||||
pDum = (pDummy)pCom->pData;
|
||||
pNew->pHistogram3 = (pHistMem)pDum;
|
||||
}
|
||||
iRet = AddCommand(pSics,argv[1],FocusAverageDo, KillFA, pNew);
|
||||
if(!iRet)
|
||||
{
|
||||
@@ -375,3 +471,87 @@
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
HistInt *CheckBank(pFocusAverager self, SConnection *pCon,
|
||||
int iLength, int iBank)
|
||||
{
|
||||
|
||||
pSicsVariable var1 = NULL;
|
||||
pSicsVariable var2 = NULL;
|
||||
pSicsVariable var3 = NULL;
|
||||
HistInt *lData = NULL;
|
||||
HistInt *mData = NULL;
|
||||
HistInt *uData = NULL;
|
||||
HistInt *mergData = NULL;
|
||||
int lbank, mbank, ubank;
|
||||
|
||||
if (iBank==2)
|
||||
{
|
||||
var2 = FindVariable(pServ->pSics,"mbank");
|
||||
if(var2)
|
||||
{
|
||||
VarGetInt(var2,&mbank);
|
||||
} else {
|
||||
SCWrite(pCon,"ERROR: mbank value not found!",eError);
|
||||
}
|
||||
if(mbank==1)
|
||||
{
|
||||
mData = GetHistogramPointer(self->pHistogram2,pCon);
|
||||
if(mData == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
setFMDataPointer(mData, iLength,1);
|
||||
mData = getFMBankPointer(1);
|
||||
return mData;
|
||||
}
|
||||
}
|
||||
if (iBank==3)
|
||||
{
|
||||
var1 = FindVariable(pServ->pSics,"lbank");
|
||||
if(var1)
|
||||
{
|
||||
VarGetInt(var1,&lbank);
|
||||
} else {
|
||||
SCWrite(pCon,"ERROR: lbank value not found!",eError);
|
||||
}
|
||||
if(lbank==1)
|
||||
{
|
||||
lData = GetHistogramPointer(self->pHistogram1,pCon);
|
||||
if(lData == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
setFMDataPointer(lData, iLength, 3);
|
||||
lData = getFMBankPointer(3);
|
||||
return lData;
|
||||
}
|
||||
}
|
||||
if (iBank==1)
|
||||
{
|
||||
var3 = FindVariable(pServ->pSics,"ubank");
|
||||
if(var3)
|
||||
{
|
||||
VarGetInt(var3,&ubank);
|
||||
} else {
|
||||
SCWrite(pCon,"ERROR: ubank value not found!",eError);
|
||||
}
|
||||
if(ubank==1)
|
||||
{
|
||||
uData = GetHistogramPointer(self->pHistogram3,pCon);
|
||||
if(uData == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
setFMDataPointer(uData, iLength, 2);
|
||||
uData = getFMBankPointer(2);
|
||||
return uData;
|
||||
}
|
||||
}
|
||||
if (iBank==4)
|
||||
{
|
||||
setFMDataPointer(mergData, iLength,4);
|
||||
mergData = getFMBankPointer(4);
|
||||
return mergData;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user