- Enhanced and debugged histogram memory for AMOR

* added PROJECT both in HM and driver code
  * added single detector support.
- Removed several bugs in the AMOR data bit.
- Updated documentation
This commit is contained in:
cvs
2001-08-17 14:33:05 +00:00
parent a538361516
commit db6c355f44
56 changed files with 4060 additions and 426 deletions

View File

@@ -6,6 +6,8 @@
David Maden, Mark Koennecke, April 1997
Updated for TOF support: Mark Koennecke, December 1998
Added Project for AMOR: Mark Koennecke, August 2001
Copyright:
@@ -1098,6 +1100,134 @@ extern int close(int fp);
}
}
/* swap bytes if necessary */
if ((self->iBinWidth > 0) && (Rply_buff.bigend != 0x12345678))
{
switch (self->iBinWidth)
{ /* Byte swapping is necessary */
case 2:
/* Not sure how to do this - this might be wrong! */
p16 = (SQint16 *) pData;
for (i = 0; i < iNoBins; i++)
{
p16[i] = ntohs (p16[i]);
}
break;
case 4:
p32 = (SQint32 *) pData;
for (i = 0; i < iNoBins; i++)
{
p32[i] = ntohl(p32[i]);
}
break;
}
}
/* done */
return 1;
}
/*-----------------------------------------------------------------------*/
int SINQHMProject(pSINQHM self, int code, int xStart, int nx,
int yStart, int ny,
void *pData, int iDataLen)
{
long lBins2Get, lSpace,iNoBins, i;
int status, iRet;
struct req_buff_struct Req_buff;
struct rply_buff_struct Rply_buff;
SQint16 *p16;
SQint32 *p32;
char *pPtr;
char pBuffer[8192];
assert(self);
/* initialize the Request data */
Req_buff.bigend = htonl (0x12345678);
Req_buff.cmnd = htonl (SQHM_PROJECT);
Req_buff.u.project.sub_code = htonl (code);
Req_buff.u.project.x_lo = htonl (xStart);
Req_buff.u.project.nx = htonl (nx);
Req_buff.u.project.y_lo = htonl (yStart);
Req_buff.u.project.ny = htonl (ny);
Req_buff.u.project.nhist = htonl (1);
/* send the message */
status = send (self->iClientSocket, (char *) &Req_buff,
sizeof (Req_buff), 0);
if (status == -1)
{
return SEND_ERROR;
}
if (status != sizeof (Req_buff))
{
return SEND_ERROR;
}
/* wait for an answer */
status = recv (self->iClientSocket, (char *) &Rply_buff,
sizeof (Rply_buff), MSG_WAITALL);
/* check various error conditions */
if (status == -1)
{
return RECEIVE_ERROR;
}
if (status != sizeof (Rply_buff))
{
return INSUFFICIENT_DATA;
}
if(ntohl (Rply_buff.bigend) != 0x12345678)
{
return BYTE_ORDER_CHAOS;
}
iRet = ntohl(Rply_buff.status);
if(iRet != KER__SUCCESS)
{
return HIST_BAD_CODE;
}
/* calculate the size of things to come */
lBins2Get = ntohl(Rply_buff.u.project.n_bins) *
ntohl(Rply_buff.u.project.bytes_per_bin);
/* read data */
pPtr = (char *)pData;
lSpace = iDataLen;
iNoBins = ntohl(Rply_buff.u.project.n_bins);
while (lBins2Get > 0)
{
if(lBins2Get > self->iPacket)
{
i = self->iPacket;
}
else
{
i = lBins2Get;
}
status = recv (self->iClientSocket, pBuffer,
i, 0);
if (status == -1)
{
return SEND_ERROR;
}
lBins2Get -= status;
if((lSpace - status) > 0)
{
memcpy(pPtr,pBuffer,status);
lSpace -= status;
pPtr += status;
}
else
{
if(lSpace > 0)
{
memcpy(pPtr,pBuffer,lSpace);
lSpace = 0;
}
}
}
/* swap bytes if necessary */
if ((self->iBinWidth > 0) && (Rply_buff.bigend != 0x12345678))
{

View File

@@ -1,5 +1,5 @@
#line 346 "sinqhm.w"
#line 363 "sinqhm.w"
/*---------------------------------------------------------------------------
S I N Q H M
@@ -17,7 +17,7 @@
typedef struct __SINQHM *pSINQHM;
/*------------------------------ Error codes -----------------------------*/
#line 324 "sinqhm.w"
#line 341 "sinqhm.w"
#define HMCOMPUTER_NOT_FOUND -2
#define SOCKET_ERROR -3
@@ -39,7 +39,7 @@
#define DAQ_INHIBIT -19
#define DAQ_NOTSTOPPED -20
#line 362 "sinqhm.w"
#line 379 "sinqhm.w"
/*------------------------------ Prototypes ------------------------------*/
@@ -50,7 +50,8 @@
pSINQHM CopySINQHM(pSINQHM self);
void DeleteSINQHM(pSINQHM self);
void SINQHMSetPar(pSINQHM self, int iRank, int iLength, int iBinWidth);
void SINQHMSetPSD(pSINQHM self, int xSize, int xOff, int xFac,
int ySize, int yOff, int yFac);
#line 142 "sinqhm.w"
@@ -89,9 +90,11 @@
long SINQHMSize(pSINQHM self, int iNum, int iStart, int iEnd);
int SINQHMRead(pSINQHM self, int iNum, int iStart, int iEnd,
void *pData, int iDataLen);
int SINQHMProject(pSINQHM self, int code, int xStart, int nx,
int yStart, int ny, void *pData, int iDataLen);
int SINQHMZero(pSINQHM self, int iNum, int iStart, int iEnd);
#line 365 "sinqhm.w"
#line 382 "sinqhm.w"
#line 232 "sinqhm.w"
@@ -99,6 +102,6 @@
int SINQHMDefineBank(pSINQHM self, int iBankNumber, int iStart, int iEnd,
float *iEdges, int iEdgeLength);
#line 366 "sinqhm.w"
#line 383 "sinqhm.w"
#endif

View File

@@ -394,6 +394,8 @@ $\langle$Protos {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ long SINQHMSize(pSINQHM self, int iNum, int iStart, int iEnd);@\\
\mbox{}\verb@ int SINQHMRead(pSINQHM self, int iNum, int iStart, int iEnd, @\\
\mbox{}\verb@ void *pData, int iDataLen); @\\
\mbox{}\verb@ int SINQHMProject(pSINQHM self, int code, int xStart, int nx,@\\
\mbox{}\verb@ int yStart, int ny, void *pData, int iDataLen);@\\
\mbox{}\verb@ int SINQHMZero(pSINQHM self, int iNum, int iStart, int iEnd);@\\
\mbox{}\verb@@$\diamond$
\end{list}
@@ -432,6 +434,21 @@ SINQHMRead reads histograms. The parameters iNum, iStart and iEnd have the
same meaning as with SINQHMWrite. Maximum iDataLen bytes of data are copied
to the memory area pointed to by pData.
SINQHMProject requests a projection of the data from the histogram memory. This
is currently only implemented for AMOR because histograms can get so large
at this instrument that a transfer for processing would take to long. The
parameters are:
\begin{description}
\item[code] The operation code for project. Can be PROJECT__COLL for
collapsing all time channels onto a 2D array and PROJECT__SAMPLE for
summing a rectangular region of the histogram memory in time.
\item[xStart, nx] start value in x and number of detectors to sum in x direction
\item[yStart,ny]start value in y and number of detectors to sum in y direction
\item[pData] a pointer to a data array large enough for holding the projected
data.
\item[iDataLen] The length of pData.
\end{description}
SINQHMZero clears the histogram iNum from iStart to iEnd to 0.
A recommended call prior
to any serious data aquisition.

View File

@@ -272,6 +272,8 @@ cleared by default.
long SINQHMSize(pSINQHM self, int iNum, int iStart, int iEnd);
int SINQHMRead(pSINQHM self, int iNum, int iStart, int iEnd,
void *pData, int iDataLen);
int SINQHMProject(pSINQHM self, int code, int xStart, int nx,
int yStart, int ny, void *pData, int iDataLen);
int SINQHMZero(pSINQHM self, int iNum, int iStart, int iEnd);
@}
@@ -302,6 +304,21 @@ SINQHMRead reads histograms. The parameters iNum, iStart and iEnd have the
same meaning as with SINQHMWrite. Maximum iDataLen bytes of data are copied
to the memory area pointed to by pData.
SINQHMProject requests a projection of the data from the histogram memory. This
is currently only implemented for AMOR because histograms can get so large
at this instrument that a transfer for processing would take to long. The
parameters are:
\begin{description}
\item[code] The operation code for project. Can be PROJECT__COLL for
collapsing all time channels onto a 2D array and PROJECT__SAMPLE for
summing a rectangular region of the histogram memory in time.
\item[xStart, nx] start value in x and number of detectors to sum in x direction
\item[yStart,ny]start value in y and number of detectors to sum in y direction
\item[pData] a pointer to a data array large enough for holding the projected
data.
\item[iDataLen] The length of pData.
\end{description}
SINQHMZero clears the histogram iNum from iStart to iEnd to 0.
A recommended call prior
to any serious data aquisition.

View File

@@ -23,7 +23,7 @@
#define MAX_CLIENTS 8 /* The maximum number of active clients */
#define MAX_TOF_CNTR 1024 /* The maximum number of individual counters ..
** which can be handled in TOF mode */
#define MAX_PSD_CNTR 65536 /* maximum number of PSD elements */
#define MAX_PSD_CNTR 1048576 /* maximum number of PSD elements */
#define MAX_TOF_NBINS 32768 /* The maximum number of bins in a TOF histog */
#define MAX_TOF_EDGE 16 /* The maximum number of TOF edge arrays */
#define VMIO_BASE_ADDR 0x1900 /* VME address of a (possible) VMIO10 module */
@@ -111,6 +111,10 @@
*/
#define PROJECT__ON_Y 0x0001 /* Project onto y-axis */
#define PROJECT__1_DIM 0x0002 /* Make projection of a 1-dim histogram */
#define PROJECT__COLL 0x0003 /* collapse PSD on one time channel */
#define PROJECT__SAMPLE 0x0004 /* sum a rectangular part of the PSD
detector in time
*/
/*
** ----------------------------------------------------------
** Definition of bits in <flag> of TOF edge-array
@@ -213,6 +217,15 @@
#define LWL_TOF_C8 (0x08000000) /* TOF-Mode 8 chan dgrm hdr */
#define LWL_TOF_C9 (0x09000000) /* TOF-Mode 9 chan dgrm hdr */
#define LWL_PSD_TSI 0x0E000000 /* PSD-Mode TSI datagram */
#define LWL_PSD_DATA 0x12000000 /* PSD-mode data datagram */
#define LWL_PSD_PWF 0x20000000 /* PSD-mode Power Fail bit */
#define LWL_PSD_TIME 0x000fffff /* PSD-mode time stamp extraction
mask */
#define LWL_PSD_FLASH_MASK 0x00ff /* mask for flash count */
#define LWL_PSD_XORF 0x2000 /* mask for TDC-XORF bit */
#define LWL_PSD_CONF 0x0100 /* mask for TDC-CONF flag */
#define LWL_SM_NC (0x10000000) /* Strobo-Mode/No-Coinc 0 chan dgrm hdr */
#define LWL_SM_NC_C1 (0x11000000) /* Strobo-Mode/No-Coinc 1 chan dgrm hdr */
#define LWL_SM_NC_C2 (0x12000000) /* Strobo-Mode/No-Coinc 2 chan dgrm hdr */