- Fixed SICS up to run with up to three TRICS detectors.

- added 150 detectors the default for FOCUS middle bank.
- added documentation for el734_test
This commit is contained in:
cvs
2001-02-09 16:04:46 +00:00
parent 96e2fc44c0
commit 5be8359212
24 changed files with 1842 additions and 224 deletions

View File

@@ -315,6 +315,143 @@ extern int close(int fp);
}
return 1; /* success, finally */
}
/*------------------------------------------------------------------------*/
int SINQHMConfigurePSD(pSINQHM self, int iMode,
int xSize, int xOff, int xFac,
int ySize, int yOff, int yFac,
int iBinWidth,
float *iEdges, int iEdgeLength)
{
int status, iRet;
struct req_buff_struct Req_buff;
struct rply_buff_struct Rply_buff;
int iLength, i, iDelay;
unsigned int iExtra;
char *pBuffer = NULL, *pPtr;
struct tof_edge_arr tea;
int iTeaLength;
struct tof_bank toba;
assert(self);
/* set up detector bank information. This code supports only
one detector bank as of now. Which is appropriate for the
detector at hand.
*/
self->iBinWidth = iBinWidth;
SINQHMDefineBank(self,0,0,xSize*ySize,
iEdges,iEdgeLength);
/* figure out how long we are going to be*/
iLength = 36 + self->iBanks*sizeof(struct tof_bank);
for(i = 0; i < self->iBanks; i++)
{
iLength += 8 + self->pBank[i].iEdgeLength*sizeof(SQint32);
}
if(iLength < 64)
iLength = 64;
/* allocate send buffer */
pBuffer = (char *)malloc(iLength*sizeof(char));
if(!pBuffer)
{
return HIST_BAD_ALLOC;
}
memset(pBuffer,0,iLength);
/* do the message header */
iExtra = iLength - sizeof(Req_buff);
if(iExtra < 0)
iExtra = 0;
iDelay = self->pBank[0].iEdges[0];
Req_buff.bigend = htonl (0x12345678);
Req_buff.cmnd = htonl (SQHM_CONFIG);
Req_buff.u.cnfg.mode = htonl (iMode);
Req_buff.u.cnfg.u.psd.n_extra_bytes = htonl (iExtra);
Req_buff.u.cnfg.u.psd.n_edges = htons (1);
Req_buff.u.cnfg.u.psd.n_banks = htons (1);
Req_buff.u.cnfg.u.psd.xOffset = htons (xOff);
Req_buff.u.cnfg.u.psd.yOffset = htons (yOff);
Req_buff.u.cnfg.u.psd.xFactor = htons (xFac);
Req_buff.u.cnfg.u.psd.yFactor = htons (yFac);
Req_buff.u.cnfg.u.psd.xSize = htons (xSize);
Req_buff.u.cnfg.u.psd.ySize = htons (ySize);
Req_buff.u.cnfg.u.psd.preset_delay = htonl((int)iEdges[0]);
memcpy(pBuffer,&Req_buff,36);
pPtr = pBuffer + 36;
/* do the edge thingies */
for(i = 0; i < self->iBanks; i++)
{
tea.n_bins = htonl(self->pBank[i].iEdgeLength-1);
if(self->pBank[i].iEdgeLength == 2)
{
tea.flag = htonl(0);
}
else
{
tea.flag = htonl(1);
}
tea.edges = self->pBank[i].iEdges;
memcpy(pPtr,&tea,8);
pPtr += 8;
iTeaLength = self->pBank[i].iEdgeLength*4;
memcpy(pPtr,self->pBank[i].iEdges,iTeaLength);
pPtr += iTeaLength;
}
/* do the swiss bank structures */
for(i = 0; i < self->iBanks; i++)
{
toba.first = htons(self->pBank[i].iStart);
toba.n_cntrs = htons(self->pBank[i].iEnd);
toba.edge_indx = htons(i);
toba.bytes_per_bin = htons(self->iBinWidth);
memcpy(pPtr,&toba,sizeof(struct tof_bank));
pPtr += sizeof(struct tof_bank);
}
/* all packed up neat and nicely, send it */
/* try, get a connection to master server */
status = OpenMasterConnection(self);
if(status < 0)
{
if(pBuffer)
free(pBuffer);
return status;
}
/* send request */
status = send(self->iMasterSocket,pBuffer,iLength ,0);
if(pBuffer)
{
free(pBuffer);
}
if(status == -1)
{
return SEND_ERROR;
}
/* get a reply */
iRet = GetMasterReply(self,&Rply_buff,sizeof(Rply_buff));
if(iRet < 0)
{
/* try close the socket */
close(self->iMasterSocket);
self->iMasterSocket = 0;
return iRet;
}
else
{
/* close the socket */
status = close(self->iMasterSocket);
self->iMasterSocket = 0;
if((status != 0) && (errno != ECONNRESET))
{
return CLOSE_ERROR;
}
}
return 1; /* success, finally */
}
/*------------------------------------------------------------------------*/
int SINQHMDeconfigure(pSINQHM self, int iHarsh)
{
@@ -1272,26 +1409,39 @@ extern int close(int fp);
free(pWork->iEdges);
pWork->iEdges = NULL;
}
iDelay = (int)iEdges[0];
pWork->iStart = iStart;
pWork->iEnd = iEnd;
pWork->iEdgeLength = iEdgeLength;
if(iEdgeLength == 2)
{
{ /*
fixed binwidth: two values required: start stop in
edge[0], edge[1]
*/
pWork->iFlag = 0;
pWork->iDelay = iDelay;
pWork->iEdges = (unsigned int *)malloc(2*sizeof(unsigned int));
if(!pWork->iEdges)
{
return HIST_BAD_ALLOC;
}
pWork->iEdges[0] = htonl((unsigned int)iEdges[0]);
pWork->iEdges[1] = htonl((unsigned int)(iEdges[1] - iDelay));
return 1;
}
else
{
pWork->iFlag = 1;
pWork->iEdgeLength++;
iEdgeLength++;
}
/*
normal case: create the bin boundaries
*/
pWork->iFlag = 1;
pWork->iEdgeLength++;
iEdgeLength++;
pWork->iEdges = (unsigned int *)malloc(iEdgeLength *
sizeof(unsigned int));
if(!pWork->iEdges)
{
return HIST_BAD_ALLOC;
}
iDelay = iEdges[0];
pWork->iDelay = iDelay;
for(i = 0; i < iEdgeLength-1; i++)
{
@@ -1361,14 +1511,6 @@ extern int close(int fp);
tofi.preset_delay = htonl(self->pBank[0].iDelay);
memcpy(pPtr,&tofi,12);
pPtr += 12;
/*
Req_buff.u.cnfg.u.tof.n_extra_bytes = htonl(iExtra);
Req_buff.u.cnfg.u.tof.n_edges = htons((short int)self->iBanks);
Req_buff.u.cnfg.u.tof.n_banks = htons((short int)self->iBanks);
Req_buff.u.cnfg.u.tof.preset_delay = htonl(self->pBank[0].iDelay);
memcpy(pBuffer,&Req_buff,24);
pPtr = pBuffer + 24;
*/
/* do the edge thingies */
for(i = 0; i < self->iBanks; i++)