abandon use of GenMalloc and GenFree
This commit is contained in:
@@ -31,11 +31,11 @@
|
||||
* causes problems on Sun4; other minor fixes
|
||||
* .04 04-04-92 rac add arCFChanWrite_args; handle flags for begin
|
||||
* and end of snapshot
|
||||
* .05 09-14-92 rac remove use of special malloc and free routines
|
||||
*
|
||||
* make options
|
||||
* -DNDEBUG don't compile assert() checking
|
||||
* -DDEBUG compile various debug code, including checks on
|
||||
* malloc'd memory
|
||||
* -DDEBUG compile various debug code
|
||||
*/
|
||||
/*+/mod***********************************************************************
|
||||
* TITLE arAccessLib.c - AR access library for AR data set files
|
||||
@@ -133,7 +133,7 @@ arCF_mallocCHAN_DESC()
|
||||
#ifdef DEBUG
|
||||
return (AR_CHAN_DESC *)arMalloc(sizeof(AR_CHAN_DESC), "AR_CHAN_DESC");
|
||||
#else
|
||||
return (AR_CHAN_DESC *)GenMalloc(sizeof(AR_CHAN_DESC));
|
||||
return (AR_CHAN_DESC *)malloc(sizeof(AR_CHAN_DESC));
|
||||
#endif
|
||||
}
|
||||
void
|
||||
@@ -143,7 +143,7 @@ AR_CHAN_DESC *ptr;
|
||||
#ifdef DEBUG
|
||||
arFree(ptr, sizeof(AR_CHAN_DESC), "AR_CHAN_DESC");
|
||||
#else
|
||||
GenFree(ptr);
|
||||
free(ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ arCF_mallocCF_DESC()
|
||||
#ifdef DEBUG
|
||||
return (AR_CF_DESC *)arMalloc(sizeof(AR_CF_DESC), "AR_CF_DESC");
|
||||
#else
|
||||
return (AR_CF_DESC *)GenMalloc(sizeof(AR_CF_DESC));
|
||||
return (AR_CF_DESC *)malloc(sizeof(AR_CF_DESC));
|
||||
#endif
|
||||
}
|
||||
void
|
||||
@@ -163,7 +163,7 @@ AR_CF_DESC *ptr;
|
||||
#ifdef DEBUG
|
||||
arFree(ptr, sizeof(AR_CF_DESC), "AR_CF_DESC");
|
||||
#else
|
||||
GenFree(ptr);
|
||||
free(ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2785,7 +2785,6 @@ AR_CF_DESC *pArCfDesc; /* I ptr to channel file descriptor */
|
||||
pArCfDesc->pMIFree = pMIBuf;
|
||||
pArCfDesc->MIFree_hdrNum = ArB0MIFree_hdrNum(pArCfDesc);
|
||||
}
|
||||
GenBufCheck(pMIBuf);
|
||||
blockNum = pMIBuf->bfInfo.flink; /* next MI block */
|
||||
}
|
||||
return OK;
|
||||
|
||||
+17
-17
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* Experimental Physics and Industrial Control System (EPICS)
|
||||
*
|
||||
* Copyright 1991, the Regents of the University of California,
|
||||
* Copyright 1991-92, the Regents of the University of California,
|
||||
* and the University of Chicago Board of Governors.
|
||||
*
|
||||
* This software was produced under U.S. Government contracts:
|
||||
@@ -25,16 +25,16 @@
|
||||
*
|
||||
* Modification Log:
|
||||
* -----------------
|
||||
* .01 03-09-90 rac initial version
|
||||
* .02 07-31-91 rac installed in SCCS
|
||||
* .03 09-19-91 rac add a new assert check; fix bug in writing
|
||||
* index blocks
|
||||
* .01 03-09-90 rac initial version
|
||||
* .02 07-31-91 rac installed in SCCS
|
||||
* .03 09-19-91 rac add a new assert check; fix bug in writing
|
||||
* index blocks
|
||||
* .04 09-14-92 rac remove use of special malloc and free routines
|
||||
*
|
||||
* make options
|
||||
* -DvxWorks makes a version for VxWorks
|
||||
* -DNDEBUG don't compile assert() checking
|
||||
* -DDEBUG compile various debug code, including checks on
|
||||
* malloc'd memory
|
||||
* -DDEBUG compile various debug code
|
||||
*/
|
||||
/*+/mod***********************************************************************
|
||||
* TITLE arChanIO.c - AR channel data file routines
|
||||
@@ -132,7 +132,7 @@ void *pMem;
|
||||
int size;
|
||||
char *text;
|
||||
{
|
||||
GenFree((char *)pMem);
|
||||
free((char *)pMem);
|
||||
glArNFree++;
|
||||
glArNbytesFree += size;
|
||||
glArNetNbytesMalloc -= size;
|
||||
@@ -148,7 +148,7 @@ int size;
|
||||
char *text;
|
||||
{
|
||||
void *pMem;
|
||||
pMem = (void *)GenMalloc(size);
|
||||
pMem = (void *)malloc(size);
|
||||
if (pMem != NULL) {
|
||||
glArNMalloc++;
|
||||
glArNbytesMalloc += size;
|
||||
@@ -182,7 +182,7 @@ arCF_mallocMI_BUF()
|
||||
#ifdef DEBUG
|
||||
return (AR_MI_BUF *)arMalloc(sizeof(AR_MI_BUF), "AR_MI_BUF");
|
||||
#else
|
||||
return (AR_MI_BUF *)GenMalloc(sizeof(AR_MI_BUF));
|
||||
return (AR_MI_BUF *)malloc(sizeof(AR_MI_BUF));
|
||||
#endif
|
||||
}
|
||||
void
|
||||
@@ -192,7 +192,7 @@ AR_MI_BUF *ptr;
|
||||
#ifdef DEBUG
|
||||
arFree(ptr, sizeof(AR_MI_BUF), "AR_MI_BUF");
|
||||
#else
|
||||
GenFree(ptr);
|
||||
free(ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ arCF_mallocINDEX_BUF()
|
||||
#ifdef DEBUG
|
||||
return (AR_INDEX_BUF *)arMalloc(sizeof(AR_INDEX_BUF), "AR_INDEX_BUF");
|
||||
#else
|
||||
return (AR_INDEX_BUF *)GenMalloc(sizeof(AR_INDEX_BUF));
|
||||
return (AR_INDEX_BUF *)malloc(sizeof(AR_INDEX_BUF));
|
||||
#endif
|
||||
}
|
||||
void
|
||||
@@ -212,7 +212,7 @@ AR_INDEX_BUF *ptr;
|
||||
#ifdef DEBUG
|
||||
arFree(ptr, sizeof(AR_INDEX_BUF), "AR_INDEX_BUF");
|
||||
#else
|
||||
GenFree(ptr);
|
||||
free(ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ arCF_mallocDATA_BUF()
|
||||
#ifdef DEBUG
|
||||
return (AR_DATA_BUF *)arMalloc(sizeof(AR_DATA_BUF), "AR_DATA_BUF");
|
||||
#else
|
||||
return (AR_DATA_BUF *)GenMalloc(sizeof(AR_DATA_BUF));
|
||||
return (AR_DATA_BUF *)malloc(sizeof(AR_DATA_BUF));
|
||||
#endif
|
||||
}
|
||||
void
|
||||
@@ -232,7 +232,7 @@ AR_DATA_BUF *ptr;
|
||||
#ifdef DEBUG
|
||||
arFree(ptr, sizeof(AR_DATA_BUF), "AR_DATA_BUF");
|
||||
#else
|
||||
GenFree(ptr);
|
||||
free(ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ arCF_mallocGR_BUF()
|
||||
#ifdef DEBUG
|
||||
return (AR_GR_BUF *)arMalloc(sizeof(AR_GR_BUF), "AR_GR_BUF");
|
||||
#else
|
||||
return (AR_GR_BUF *)GenMalloc(sizeof(AR_GR_BUF));
|
||||
return (AR_GR_BUF *)malloc(sizeof(AR_GR_BUF));
|
||||
#endif
|
||||
}
|
||||
void
|
||||
@@ -252,7 +252,7 @@ AR_GR_BUF *ptr;
|
||||
#ifdef DEBUG
|
||||
arFree(ptr, sizeof(AR_GR_BUF), "AR_GR_BUF");
|
||||
#else
|
||||
GenFree(ptr);
|
||||
free(ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
+26
-32
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* Experimental Physics and Industrial Control System (EPICS)
|
||||
*
|
||||
* Copyright 1991, the Regents of the University of California,
|
||||
* Copyright 1991-92, the Regents of the University of California,
|
||||
* and the University of Chicago Board of Governors.
|
||||
*
|
||||
* This software was produced under U.S. Government contracts:
|
||||
@@ -25,14 +25,14 @@
|
||||
*
|
||||
* Modification Log:
|
||||
* -----------------
|
||||
* .01 03-05-90 rac initial version
|
||||
* .02 07-30-91 rac installed in SCCS
|
||||
* .01 03-05-90 rac initial version
|
||||
* .02 07-30-91 rac installed in SCCS
|
||||
* .03 09-14-92 rac discontinue using special malloc routines
|
||||
*
|
||||
* make options
|
||||
* -DvxWorks makes a version for VxWorks
|
||||
* -DNDEBUG don't compile assert() checking
|
||||
* -DDEBUG compile various debug code, including checks on
|
||||
* malloc'd memory
|
||||
* -DDEBUG compile various debug code
|
||||
*/
|
||||
/*+/mod***********************************************************************
|
||||
* TITLE bfSubr.c - 'block file' subroutines
|
||||
@@ -173,22 +173,16 @@
|
||||
#endif
|
||||
|
||||
BF_DESC *bfMallocDesc()
|
||||
{ return (BF_DESC *)GenMalloc(sizeof(BF_DESC)); }
|
||||
void bfBufCheckDesc(ptr)
|
||||
BF_DESC *ptr;
|
||||
{ GenBufCheck(ptr); }
|
||||
{ return (BF_DESC *)malloc(sizeof(BF_DESC)); }
|
||||
void bfFreeDesc(ptr)
|
||||
BF_DESC *ptr;
|
||||
{ GenFree(ptr); }
|
||||
{ free(ptr); }
|
||||
|
||||
BF_BLOCK0 *bfMallocBlock0()
|
||||
{ return (BF_BLOCK0 *)GenMalloc(sizeof(BF_BLOCK0)); }
|
||||
void bfBufCheckBlock0(ptr)
|
||||
BF_BLOCK0 *ptr;
|
||||
{ GenBufCheck(ptr); }
|
||||
{ return (BF_BLOCK0 *)malloc(sizeof(BF_BLOCK0)); }
|
||||
void bfFreeBlock0(ptr)
|
||||
BF_BLOCK0 *ptr;
|
||||
{ GenFree(ptr); }
|
||||
{ free(ptr); }
|
||||
|
||||
|
||||
/*+/subr**********************************************************************
|
||||
@@ -290,7 +284,7 @@ BF_DESC *pDesc; /* IO block file descriptor for ring file */
|
||||
if (pDesc->readBlock > 0) {
|
||||
if (pDesc->pReadBuf == NULL) {
|
||||
if ((pDesc->pReadBuf =
|
||||
(BF_BLOCK *)GenMalloc((unsigned)BfB0BlockSize(pDesc))) ==
|
||||
(BF_BLOCK *)malloc((unsigned)BfB0BlockSize(pDesc))) ==
|
||||
NULL) {
|
||||
(void)fprintf(stderr,
|
||||
"bfRingFillRbufAndGetc: can't get memory\n");
|
||||
@@ -435,7 +429,7 @@ BF_DESC *pDesc; /* IO pointer to ring file descriptor */
|
||||
BF_BLKNUM flink; /* link to next write block */
|
||||
BF_BLOCK *pBuf; /* next write block */
|
||||
|
||||
if ((pBuf = (BF_BLOCK *)GenMalloc((unsigned)BfB0BlockSize(pDesc))) == NULL) {
|
||||
if ((pBuf = (BF_BLOCK *)malloc((unsigned)BfB0BlockSize(pDesc))) == NULL) {
|
||||
(void)fprintf(stderr, "bfRingFlushWbufAndPutc: can't get memory\n");
|
||||
return EOF;
|
||||
}
|
||||
@@ -451,7 +445,7 @@ BF_DESC *pDesc; /* IO pointer to ring file descriptor */
|
||||
if ((flink = BfB0RingTail(pDesc)) > 0) {
|
||||
stat = bfRead(pDesc, pBuf, flink);
|
||||
if (stat != OK) {
|
||||
(void)GenFree((char *)pBuf);
|
||||
(void)free((char *)pBuf);
|
||||
return EOF;
|
||||
}
|
||||
if (pBuf->lastByte >= BfB0BlockSize(pDesc)-1) {
|
||||
@@ -462,7 +456,7 @@ BF_DESC *pDesc; /* IO pointer to ring file descriptor */
|
||||
else {
|
||||
flink = bfAcquire(pDesc, pBuf);
|
||||
if (flink == ERROR) {
|
||||
(void)GenFree((char *)pBuf);
|
||||
(void)free((char *)pBuf);
|
||||
return EOF;
|
||||
}
|
||||
}
|
||||
@@ -491,7 +485,7 @@ BF_DESC *pDesc; /* IO pointer to ring file descriptor */
|
||||
if ((flink = BfB0RingHead(pDesc)) > 0)
|
||||
readFlag = 1;
|
||||
else {
|
||||
GenFree((char *)pBuf);
|
||||
free((char *)pBuf);
|
||||
return EOF; /* no new block available */
|
||||
}
|
||||
}
|
||||
@@ -499,7 +493,7 @@ BF_DESC *pDesc; /* IO pointer to ring file descriptor */
|
||||
if (readFlag) { /* only have flink; get the actual block */
|
||||
stat = bfRead(pDesc, pBuf, flink);
|
||||
if (stat != OK) {
|
||||
GenFree((char *)pBuf);
|
||||
free((char *)pBuf);
|
||||
return EOF;
|
||||
}
|
||||
pBuf->firstByte = 0;
|
||||
@@ -536,10 +530,10 @@ BF_DESC *pDesc; /* IO pointer to ring file descriptor */
|
||||
|
||||
stat = bfWrite(pDesc, pDesc->pWriteBuf, pDesc->writeBlock);
|
||||
if (stat != OK) {
|
||||
GenFree((char *)pBuf);
|
||||
free((char *)pBuf);
|
||||
return EOF;
|
||||
}
|
||||
GenFree((char *)pDesc->pWriteBuf);
|
||||
free((char *)pDesc->pWriteBuf);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
@@ -611,7 +605,7 @@ BF_DESC *pDesc; /* IO pointer to ring file descriptor */
|
||||
* BF_BLKNUM blockNum; block number of acquired block
|
||||
*
|
||||
* pDesc = bfOpen("myFile", O_RDWR, BF_TYPE_UNDEF);
|
||||
* pBuf = (BF_BLOCK *)GenMalloc(BfB0BlockSize(pDesc));
|
||||
* pBuf = (BF_BLOCK *)malloc(BfB0BlockSize(pDesc));
|
||||
* blockNum = bfAcquire(pDesc, pBuf);
|
||||
* pBuf->firstByte = pBuf->lastByte + 1;
|
||||
* for (i=0; i<nBytes; i++)
|
||||
@@ -744,9 +738,9 @@ BF_DESC **ppDesc; /* IO pointer to pointer to descriptor */
|
||||
}
|
||||
}
|
||||
if (pDesc->pWriteBuf != NULL)
|
||||
GenFree((char *)pDesc->pWriteBuf);
|
||||
free((char *)pDesc->pWriteBuf);
|
||||
if (pDesc->pReadBuf != NULL)
|
||||
GenFree((char *)pDesc->pReadBuf);
|
||||
free((char *)pDesc->pReadBuf);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* next, position file at beginning and write block0
|
||||
@@ -901,7 +895,7 @@ BF_BLKNUM maxBlocks; /* I size limit in blocks; must be <= BF_MAX_BLOCKS */
|
||||
if (retStat == OK && nBlocks > 1) {
|
||||
BF_BLOCK *pBuf;
|
||||
|
||||
pBuf = (BF_BLOCK *)GenMalloc(blockSize);
|
||||
pBuf = (BF_BLOCK *)malloc(blockSize);
|
||||
if (pBuf == NULL) {
|
||||
retStat = ERROR;
|
||||
(void)fprintf(stderr,
|
||||
@@ -918,7 +912,7 @@ BF_BLKNUM maxBlocks; /* I size limit in blocks; must be <= BF_MAX_BLOCKS */
|
||||
perror("bfCreate: error writing free block list");
|
||||
break;
|
||||
}
|
||||
GenFree((char *)pBuf);
|
||||
free((char *)pBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -954,7 +948,7 @@ BF_BLKNUM blockNum; /* I block number */
|
||||
int retStat=OK; /* return status to caller */
|
||||
char *pBuf; /* buffer pointer */
|
||||
|
||||
if ((pBuf = (char *)GenMalloc((unsigned)BfB0BlockSize(pBfDesc))) == NULL) {
|
||||
if ((pBuf = (char *)malloc((unsigned)BfB0BlockSize(pBfDesc))) == NULL) {
|
||||
(void)printf("bfDumpHex: can't malloc buffer\n");
|
||||
retStat = ERROR;
|
||||
}
|
||||
@@ -987,7 +981,7 @@ BF_BLKNUM blockNum; /* I block number */
|
||||
}
|
||||
}
|
||||
if (pBuf != NULL)
|
||||
(void)GenFree(pBuf);
|
||||
(void)free(pBuf);
|
||||
|
||||
return retStat;
|
||||
}
|
||||
@@ -1016,7 +1010,7 @@ BF_BLKNUM blockNum; /* I block number */
|
||||
int retStat=OK; /* return status to caller */
|
||||
char *pBuf; /* buffer pointer */
|
||||
|
||||
if ((pBuf = (char *)GenMalloc((unsigned)BfB0BlockSize(pBfDesc))) == NULL) {
|
||||
if ((pBuf = (char *)malloc((unsigned)BfB0BlockSize(pBfDesc))) == NULL) {
|
||||
(void)printf("bfDumpHex: can't malloc buffer\n");
|
||||
retStat = ERROR;
|
||||
}
|
||||
@@ -1051,7 +1045,7 @@ BF_BLKNUM blockNum; /* I block number */
|
||||
}
|
||||
}
|
||||
if (pBuf != NULL)
|
||||
(void)GenFree(pBuf);
|
||||
(void)free(pBuf);
|
||||
|
||||
return retStat;
|
||||
}
|
||||
|
||||
+162
-88
@@ -62,12 +62,17 @@
|
||||
* restrict range of interest to a subset of the samples;
|
||||
* put a blank line in export file following snapshot;
|
||||
* for .RVAL channels, set prec=0, EGU="counts"
|
||||
* .15 08-25-92 rac fix bugs in exporting for restricted time range;
|
||||
* fix sydSamplePrint to put a separator in front of
|
||||
* the no data message; add better handling for SSF
|
||||
* files with missing data; added a routine to prepare
|
||||
* a channel for a new retrieval; discontinue use of
|
||||
* special malloc routines
|
||||
*
|
||||
* make options
|
||||
* -DvxWorks makes a version for VxWorks
|
||||
* -DNDEBUG don't compile assert checking
|
||||
* -DDEBUG compile various debug code, including checks on
|
||||
* malloc'd memory
|
||||
* -DDEBUG compile various debug code
|
||||
*/
|
||||
#if 0 /* allow comments within the module heading */
|
||||
/*+/mod***********************************************************************
|
||||
@@ -106,6 +111,7 @@
|
||||
* SYD_CHAN *sydChanFind( pSspec, chanName )
|
||||
* long sydChanOpen( pSspec, >ppSChan, chanName, sync, pArg, trig)
|
||||
* sync = SYD_SY_{NONF,FILLED}
|
||||
* long sydChanPrep( pSspec, pSChan )
|
||||
* long sydClose( pSspec )
|
||||
* void sydCopyGr( >pDest, pSrc, srcDbrType )
|
||||
* void sydCopyVal( >pDest, pSrc, count, srcDbrType )
|
||||
@@ -147,10 +153,12 @@
|
||||
* long sydTest( pSspec )
|
||||
* long sydTestAddFromText( pSspec, text )
|
||||
* long sydTestClose( pSspec )
|
||||
* double sydValAsDbl( pSChan, sampNum )
|
||||
* int sydValAsDbl( pSChan, sampNum, pDbl )
|
||||
*
|
||||
* BUGS
|
||||
* o error detection and handling isn't "leakproof"
|
||||
* o for retrieving from sample set files, if all the channels in the
|
||||
* set are missing for two snapshots in a row, EOF is reported
|
||||
*
|
||||
* DESCRIPTION, continued
|
||||
*
|
||||
@@ -511,17 +519,17 @@ SYD_CHAN *pSChan; /* I pointer to synchronous channel descriptor */
|
||||
(void)(pSspec->pFunc)(pSspec, pSChan, SYD_FC_CLOSE, NULL);
|
||||
for (i=0; i<pSChan->nInBufs; i++) {
|
||||
if (pSChan->pInBuf[i] != NULL)
|
||||
GenFree((char *)pSChan->pInBuf[i]);
|
||||
free((char *)pSChan->pInBuf[i]);
|
||||
}
|
||||
sydChanFreeArrays(pSChan);
|
||||
|
||||
pSspec->chanCount--;
|
||||
DoubleListRemove(pSChan, pSspec->pChanHead, pSspec->pChanTail);
|
||||
if (pSChan->testChan) {
|
||||
GenFree((char *)pSspec->pAccept);
|
||||
free((char *)pSspec->pAccept);
|
||||
pSspec->pAccept = NULL;
|
||||
}
|
||||
GenFree((char *)pSChan);
|
||||
free((char *)pSChan);
|
||||
|
||||
return S_syd_OK;
|
||||
}
|
||||
@@ -534,31 +542,31 @@ sydChanFreeArrays(pSChan)
|
||||
SYD_CHAN *pSChan;
|
||||
{
|
||||
if (pSChan->pData != NULL) {
|
||||
GenFree((char *)pSChan->pData);
|
||||
free((char *)pSChan->pData);
|
||||
pSChan->pData = NULL;
|
||||
}
|
||||
if (pSChan->pDataAlStat != NULL) {
|
||||
GenFree((char *)pSChan->pDataAlStat);
|
||||
free((char *)pSChan->pDataAlStat);
|
||||
pSChan->pDataAlStat = NULL;
|
||||
}
|
||||
if (pSChan->pDataAlSev != NULL) {
|
||||
GenFree((char *)pSChan->pDataAlSev);
|
||||
free((char *)pSChan->pDataAlSev);
|
||||
pSChan->pDataAlSev = NULL;
|
||||
}
|
||||
if (pSChan->pDataCodeL != NULL) {
|
||||
GenFree((char *)pSChan->pDataCodeL);
|
||||
free((char *)pSChan->pDataCodeL);
|
||||
pSChan->pDataCodeL = NULL;
|
||||
}
|
||||
if (pSChan->pDataCodeR != NULL) {
|
||||
GenFree((char *)pSChan->pDataCodeR);
|
||||
free((char *)pSChan->pDataCodeR);
|
||||
pSChan->pDataCodeR = NULL;
|
||||
}
|
||||
if (pSChan->pFlags != NULL) {
|
||||
GenFree((char *)pSChan->pFlags);
|
||||
free((char *)pSChan->pFlags);
|
||||
pSChan->pFlags = NULL;
|
||||
}
|
||||
if (pSChan->pStats != NULL) {
|
||||
GenFree((char *)pSChan->pStats);
|
||||
free((char *)pSChan->pStats);
|
||||
pSChan->pStats = NULL;
|
||||
}
|
||||
}
|
||||
@@ -711,7 +719,7 @@ int test; /* I 0,1 if this is data,test channel */
|
||||
new = 0;
|
||||
}
|
||||
if (new) {
|
||||
pSChan = (SYD_CHAN *)GenMalloc(sizeof(SYD_CHAN));
|
||||
pSChan = (SYD_CHAN *)malloc(sizeof(SYD_CHAN));
|
||||
if (pSChan == NULL)
|
||||
return S_syd_noMem;
|
||||
DoubleListAppend(pSChan, pSspec->pChanHead, pSspec->pChanTail);
|
||||
@@ -726,6 +734,7 @@ int test; /* I 0,1 if this is data,test channel */
|
||||
}
|
||||
pSChan->firstInBuf = pSChan->lastInBuf = pSChan->sampInBuf = -1;
|
||||
pSChan->minDataVal = pSChan->maxDataVal = 0.;
|
||||
pSChan->minMaxNeedInit = 1;
|
||||
pSChan->restrictMinDataVal = pSChan->restrictMaxDataVal = 0.;
|
||||
strcpy(pSChan->name, chanName);
|
||||
strcpy(pSChan->label, chanName);
|
||||
@@ -801,7 +810,7 @@ SYD_CHAN *pSChan; /* I sync channel pointer */
|
||||
* set either SMOOTH or STEP for the channel
|
||||
*----------------------------------------------------------------------------*/
|
||||
for (i=0; i<pSChan->nInBufs; i++) {
|
||||
pSChan->pInBuf[i] = (union db_access_val *)GenMalloc(
|
||||
pSChan->pInBuf[i] = (union db_access_val *)malloc(
|
||||
dbr_size_n(pSChan->dbrType, pSChan->elCount));
|
||||
if (pSChan->pInBuf[i] == NULL) {
|
||||
(void)sydChanClose(pSspec, pSChan);
|
||||
@@ -878,6 +887,35 @@ SYD_CHAN *pSChan; /* I sync channel pointer */
|
||||
}
|
||||
|
||||
/*+/subr**********************************************************************
|
||||
* NAME sydChanPrep - prepare a channel for a new retrieval
|
||||
*
|
||||
* DESCRIPTION
|
||||
* This routine initializes a channel structure in preparation for
|
||||
* a new retrieval.
|
||||
*
|
||||
* RETURNS
|
||||
* S_syd_OK
|
||||
*
|
||||
* SEE ALSO
|
||||
* sydSampleSetGet, sydInputGet, sydInputStoreInSet
|
||||
*
|
||||
*-*/
|
||||
long
|
||||
sydChanPrep(pSspec, pSChan)
|
||||
SYD_SPEC *pSspec; /* I pointer to synchronous set spec */
|
||||
SYD_CHAN *pSChan; /* I pointer to synchronous channel descriptor */
|
||||
{
|
||||
int i;
|
||||
|
||||
assert(pSspec != NULL);
|
||||
assert(pSChan != NULL);
|
||||
|
||||
pSChan->minDataVal = pSChan->maxDataVal = 0.;
|
||||
pSChan->minMaxNeedInit = 1;
|
||||
pSChan->restrictMinDataVal = pSChan->restrictMaxDataVal = 0.;
|
||||
}
|
||||
|
||||
/*+/subr**********************************************************************
|
||||
* NAME sydClose - close a synchronous set spec
|
||||
*
|
||||
* DESCRIPTION
|
||||
@@ -890,10 +928,10 @@ SYD_CHAN *pSChan; /* I sync channel pointer */
|
||||
* other status codes if an error occurs
|
||||
*
|
||||
* BUGS
|
||||
* o the `wrapup' call should do the GenFree, since the GenFree must
|
||||
* match the GenMalloc--if this routine is compiled with DEBUG and
|
||||
* the routine which did the GenMalloc (e.g., sydSubrCA) is compiled
|
||||
* without it, then the GenFree here will complain.
|
||||
* o the `wrapup' call should do the free, since the free must
|
||||
* match the malloc--if this routine is compiled with DEBUG and
|
||||
* the routine which did the malloc (e.g., sydSubrCA) is compiled
|
||||
* without it, then the free here will complain.
|
||||
*
|
||||
* SEE ALSO
|
||||
* sydOpen
|
||||
@@ -921,7 +959,7 @@ SYD_SPEC *pSspec; /* I pointer to synchronous set spec */
|
||||
if (stat != S_syd_OK)
|
||||
retStat = stat;
|
||||
|
||||
GenFree((char *)pSspec);
|
||||
free((char *)pSspec);
|
||||
return retStat;
|
||||
}
|
||||
|
||||
@@ -941,20 +979,30 @@ void *pSrc; /* I pointer to buffer holding graphics info */
|
||||
chtype srcDbrType; /* I DBR_xxx type of the source buffer */
|
||||
{
|
||||
#define U_DB union db_access_val *
|
||||
if (srcDbrType == DBR_GR_FLOAT)
|
||||
if (srcDbrType == DBR_GR_FLOAT) {
|
||||
((U_DB)pDest)->gfltval = ((U_DB)pSrc)->gfltval;
|
||||
else if (srcDbrType == DBR_GR_SHORT)
|
||||
((U_DB)pDest)->gfltval.units[7] = '\0';
|
||||
}
|
||||
else if (srcDbrType == DBR_GR_SHORT) {
|
||||
((U_DB)pDest)->gshrtval = ((U_DB)pSrc)->gshrtval;
|
||||
else if (srcDbrType == DBR_GR_DOUBLE)
|
||||
((U_DB)pDest)->gshrtval.units[7] = '\0';
|
||||
}
|
||||
else if (srcDbrType == DBR_GR_DOUBLE) {
|
||||
((U_DB)pDest)->gdblval = ((U_DB)pSrc)->gdblval;
|
||||
else if (srcDbrType == DBR_GR_LONG)
|
||||
((U_DB)pDest)->gdblval.units[7] = '\0';
|
||||
}
|
||||
else if (srcDbrType == DBR_GR_LONG) {
|
||||
((U_DB)pDest)->glngval = ((U_DB)pSrc)->glngval;
|
||||
((U_DB)pDest)->glngval.units[7] = '\0';
|
||||
}
|
||||
else if (srcDbrType == DBR_GR_STRING)
|
||||
((U_DB)pDest)->gstrval = ((U_DB)pSrc)->gstrval;
|
||||
else if (srcDbrType == DBR_GR_ENUM)
|
||||
((U_DB)pDest)->genmval = ((U_DB)pSrc)->genmval;
|
||||
else if (srcDbrType == DBR_GR_CHAR)
|
||||
else if (srcDbrType == DBR_GR_CHAR) {
|
||||
((U_DB)pDest)->gchrval = ((U_DB)pSrc)->gchrval;
|
||||
((U_DB)pDest)->gchrval.units[7] = '\0';
|
||||
}
|
||||
else
|
||||
assertAlways(0);
|
||||
}
|
||||
@@ -1545,6 +1593,8 @@ skipSecondRead:
|
||||
if (i >= 0 && BUFiTS.secPastEpoch == 0)
|
||||
BUFiTS.secPastEpoch = 86401;
|
||||
}
|
||||
if (pSspec->type == SYD_TY_SSF)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1834,8 +1884,10 @@ int ignorePartial; /* I 0,1 to store,ignore partial samples */
|
||||
float *pSrc, *pDest;
|
||||
pSrc = &pSChan->pInBuf[i]->tfltval.value;
|
||||
pDest = ((float *)pSChan->pData) + sub * pSChan->elCount;
|
||||
if (useVal && pSspec->sampleCount == 0)
|
||||
if (useVal && pSChan->minMaxNeedInit) {
|
||||
pSChan->maxDataVal = pSChan->minDataVal = (double)*pSrc;
|
||||
pSChan->minMaxNeedInit = 0;
|
||||
}
|
||||
for (el=0; el<pSChan->elCount; el++) {
|
||||
if (useVal) {
|
||||
if ((double)*pSrc > pSChan->maxDataVal)
|
||||
@@ -1851,12 +1903,13 @@ int ignorePartial; /* I 0,1 to store,ignore partial samples */
|
||||
double dbl;
|
||||
pSrc = &pSChan->pInBuf[i]->tshrtval.value;
|
||||
pDest = ((short *)pSChan->pData) + sub * pSChan->elCount;
|
||||
if (useVal && pSspec->sampleCount == 0) {
|
||||
if (useVal && pSChan->minMaxNeedInit) {
|
||||
if (pSChan->isRVAL)
|
||||
dbl = (double)(*(unsigned short *)pSrc);
|
||||
else
|
||||
dbl = (double)(*pSrc);
|
||||
pSChan->maxDataVal = pSChan->minDataVal = dbl;
|
||||
pSChan->minMaxNeedInit = 0;
|
||||
}
|
||||
for (el=0; el<pSChan->elCount; el++) {
|
||||
if (useVal) {
|
||||
@@ -1876,8 +1929,10 @@ int ignorePartial; /* I 0,1 to store,ignore partial samples */
|
||||
double *pSrc, *pDest;
|
||||
pSrc = &pSChan->pInBuf[i]->tdblval.value;
|
||||
pDest = ((double *)pSChan->pData) + sub * pSChan->elCount;
|
||||
if (useVal && pSspec->sampleCount == 0)
|
||||
if (useVal && pSChan->minMaxNeedInit) {
|
||||
pSChan->maxDataVal = pSChan->minDataVal = *pSrc;
|
||||
pSChan->minMaxNeedInit = 0;
|
||||
}
|
||||
for (el=0; el<pSChan->elCount; el++) {
|
||||
if (useVal) {
|
||||
if (*pSrc > pSChan->maxDataVal)
|
||||
@@ -1893,12 +1948,14 @@ int ignorePartial; /* I 0,1 to store,ignore partial samples */
|
||||
double dbl;
|
||||
pSrc = &pSChan->pInBuf[i]->tlngval.value;
|
||||
pDest = ((long *)pSChan->pData) + sub * pSChan->elCount;
|
||||
if (useVal && pSspec->sampleCount == 0)
|
||||
if (useVal && pSChan->minMaxNeedInit) {
|
||||
if (pSChan->isRVAL)
|
||||
dbl = (double)(*(unsigned long *)pSrc);
|
||||
else
|
||||
dbl = (double)(*pSrc);
|
||||
pSChan->maxDataVal = pSChan->minDataVal = (double)*pSrc;
|
||||
pSChan->minMaxNeedInit = 0;
|
||||
}
|
||||
for (el=0; el<pSChan->elCount; el++) {
|
||||
if (useVal) {
|
||||
if (pSChan->isRVAL)
|
||||
@@ -1929,8 +1986,10 @@ int ignorePartial; /* I 0,1 to store,ignore partial samples */
|
||||
pSrc = &pSChan->pInBuf[i]->tchrval.value;
|
||||
pDest = ((unsigned char *)pSChan->pData) +
|
||||
sub * pSChan->elCount;
|
||||
if (useVal && pSspec->sampleCount == 0)
|
||||
if (useVal && pSChan->minMaxNeedInit) {
|
||||
pSChan->maxDataVal = pSChan->minDataVal = (double)*pSrc;
|
||||
pSChan->minMaxNeedInit = 0;
|
||||
}
|
||||
for (el=0; el<pSChan->elCount; el++) {
|
||||
if (useVal) {
|
||||
if ((double)*pSrc > pSChan->maxDataVal)
|
||||
@@ -1945,8 +2004,10 @@ int ignorePartial; /* I 0,1 to store,ignore partial samples */
|
||||
short *pSrc, *pDest;
|
||||
pSrc = &pSChan->pInBuf[i]->tenmval.value;
|
||||
pDest = ((short *)pSChan->pData) + sub * pSChan->elCount;
|
||||
if (useVal && pSspec->sampleCount == 0)
|
||||
if (useVal && pSChan->minMaxNeedInit) {
|
||||
pSChan->maxDataVal = pSChan->minDataVal = (double)*pSrc;
|
||||
pSChan->minMaxNeedInit = 0;
|
||||
}
|
||||
for (el=0; el<pSChan->elCount; el++) {
|
||||
if (useVal) {
|
||||
if ((double)*pSrc > pSChan->maxDataVal)
|
||||
@@ -2222,7 +2283,7 @@ int samp; /* I sample number in synchronous set */
|
||||
*----------------------------------------------------------------------------*/
|
||||
if (samp == pSspec->restrictFirstData) {
|
||||
(void)fprintf(out, "\"%s\"\n\"date\"\t\"time\"", tsStampToText(
|
||||
&pSspec->refTs, TS_TEXT_MMDDYY, stampText));
|
||||
&pSspec->restrictRefTs, TS_TEXT_MMDDYY, stampText));
|
||||
for (pSChan=pSspec->pChanHead; pSChan!=NULL; pSChan = pSChan->pNext) {
|
||||
if (pSChan->dataChan) {
|
||||
if (option == 2 || option == 4)
|
||||
@@ -2299,7 +2360,7 @@ int snap; /* I snapshot number in synchronous set */
|
||||
*----------------------------------------------------------------------------*/
|
||||
if (snap == 0) {
|
||||
(void)fprintf(out, "\"%s\"\n\"date\"\t\"time\"\t\"sample\"",
|
||||
tsStampToText( &pSspec->refTs, TS_TEXT_MMDDYY, stampText));
|
||||
tsStampToText(&pSspec->restrictRefTs,TS_TEXT_MMDDYY,stampText));
|
||||
for (pSChan=pSspec->pChanHead; pSChan!=NULL; pSChan = pSChan->pNext) {
|
||||
if (pSChan->dataChan)
|
||||
(void)fprintf(out,"\t\"%s\"\t\"%s\"",pSChan->name,pSChan->EGU);
|
||||
@@ -2315,7 +2376,7 @@ int snap; /* I snapshot number in synchronous set */
|
||||
/*-----------------------------------------------------------------------------
|
||||
* print the statistics for each channel for this snapshot.
|
||||
*----------------------------------------------------------------------------*/
|
||||
tsStampToText(&pSspec->pTimeStamp[snap], TS_TEXT_MMDDYY, stampText);
|
||||
tsStampToText(&pSspec->pStatTimeStamp[snap], TS_TEXT_MMDDYY, stampText);
|
||||
(void)fprintf(out, "\"%s\"\t%.3f\t%d", stampText,
|
||||
pSspec->pStatDeltaSec[snap] - pSspec->restrictDeltaSecSubtract,
|
||||
pSspec->pStatPopCount[snap]);
|
||||
@@ -2602,7 +2663,8 @@ int sampNum; /* I sample number in sync set */
|
||||
}
|
||||
else {
|
||||
if (flags&SHOW_AR)
|
||||
(void)fprintf(out, "1");
|
||||
(void)fprintf(out, "1%c", sep);
|
||||
(void)fputc(sep, out);
|
||||
if (flags&USE_QUO) {
|
||||
if (flags&ENF_WID)
|
||||
(void)fprintf(out, "\"%*.*s\"", colWidth, colWidth, special);
|
||||
@@ -2903,9 +2965,12 @@ int samp; /* I sample number in synchronous set */
|
||||
|
||||
for (pSChan=pSspec->pChanHead; pSChan!=NULL; pSChan=pSChan->pNext) {
|
||||
if (pSChan->dataChan) {
|
||||
(void)fprintf(pFile, "%s %s %d %d", SydChanName(pSChan),
|
||||
dbf_type_to_text(SydChanDbfType(pSChan)),
|
||||
pSChan->pDataAlSev[samp], pSChan->pDataAlStat[samp]);
|
||||
(void)fprintf(pFile, "%s %s", SydChanName(pSChan),
|
||||
dbf_type_to_text(SydChanDbfType(pSChan)));
|
||||
(void)fprintf(pFile, " %d",
|
||||
pSChan->pDataAlSev != NULL ? pSChan->pDataAlSev[samp] : 0);
|
||||
(void)fprintf(pFile, " %d",
|
||||
pSChan->pDataAlStat != NULL ? pSChan->pDataAlStat[samp] : 0);
|
||||
sydSamplePrint1(pSChan, pFile, ' ', SHOW_AR, 0, samp);
|
||||
(void)fprintf(pFile, "\n");
|
||||
}
|
||||
@@ -2957,13 +3022,13 @@ int reqCount; /* I number of samples in the set */
|
||||
if (reqCount > pSspec->dataDim)
|
||||
sydSampleSetFree(pSspec);
|
||||
if (pSspec->dataDim <= 0) {
|
||||
pSspec->pDeltaSec = (double *)GenMalloc(reqCount * sizeof(double));
|
||||
pSspec->pDeltaSec = (double *)malloc(reqCount * sizeof(double));
|
||||
if (pSspec->pDeltaSec == NULL)
|
||||
goto sampleMallocErr;
|
||||
pSspec->pTimeStamp = (TS_STAMP *)GenMalloc(reqCount * sizeof(TS_STAMP));
|
||||
pSspec->pTimeStamp = (TS_STAMP *)malloc(reqCount * sizeof(TS_STAMP));
|
||||
if (pSspec->pTimeStamp == NULL)
|
||||
goto sampleMallocErr;
|
||||
pSspec->pPartial = (char *)GenMalloc(reqCount * sizeof(char));
|
||||
pSspec->pPartial = (char *)malloc(reqCount * sizeof(char));
|
||||
if (pSspec->pPartial == NULL)
|
||||
goto sampleMallocErr;
|
||||
pSspec->dataDim = reqCount;
|
||||
@@ -2973,28 +3038,28 @@ int reqCount; /* I number of samples in the set */
|
||||
if (pSChan->conn == 0)
|
||||
; /* no action if never been connected */
|
||||
else if (pSChan->pData == NULL) {
|
||||
pSChan->pData = (void *)GenMalloc(reqCount *
|
||||
pSChan->pData = (void *)malloc(reqCount *
|
||||
dbr_value_size[pSChan->dbrType] * pSChan->elCount);
|
||||
if (pSChan->pData == NULL)
|
||||
goto sampleMallocErr;
|
||||
|
||||
pSChan->pDataAlStat = (void *)GenMalloc(reqCount *
|
||||
pSChan->pDataAlStat = (void *)malloc(reqCount *
|
||||
sizeof(*pSChan->pDataAlStat));
|
||||
if (pSChan->pDataAlStat == NULL)
|
||||
goto sampleMallocErr;
|
||||
pSChan->pDataAlSev = (void *)GenMalloc(reqCount *
|
||||
pSChan->pDataAlSev = (void *)malloc(reqCount *
|
||||
sizeof(*pSChan->pDataAlSev));
|
||||
if (pSChan->pDataAlSev == NULL)
|
||||
goto sampleMallocErr;
|
||||
pSChan->pDataCodeL = (void *)GenMalloc(reqCount *
|
||||
pSChan->pDataCodeL = (void *)malloc(reqCount *
|
||||
sizeof(*pSChan->pDataCodeL));
|
||||
if (pSChan->pDataCodeL == NULL)
|
||||
goto sampleMallocErr;
|
||||
pSChan->pDataCodeR = (void *)GenMalloc(reqCount *
|
||||
pSChan->pDataCodeR = (void *)malloc(reqCount *
|
||||
sizeof(*pSChan->pDataCodeR));
|
||||
if (pSChan->pDataCodeR == NULL)
|
||||
goto sampleMallocErr;
|
||||
pSChan->pFlags = (void *)GenMalloc(reqCount *
|
||||
pSChan->pFlags = (void *)malloc(reqCount *
|
||||
sizeof(*pSChan->pFlags));
|
||||
if (pSChan->pFlags == NULL)
|
||||
goto sampleMallocErr;
|
||||
@@ -3088,27 +3153,27 @@ SYD_SPEC *pSspec;
|
||||
assert(pSspec != NULL);
|
||||
|
||||
if (pSspec->pDeltaSec != NULL) {
|
||||
GenFree((char *)pSspec->pDeltaSec);
|
||||
free((char *)pSspec->pDeltaSec);
|
||||
pSspec->pDeltaSec = NULL;
|
||||
}
|
||||
if (pSspec->pTimeStamp != NULL) {
|
||||
GenFree((char *)pSspec->pTimeStamp);
|
||||
free((char *)pSspec->pTimeStamp);
|
||||
pSspec->pTimeStamp = NULL;
|
||||
}
|
||||
if (pSspec->pPartial != NULL) {
|
||||
GenFree((char *)pSspec->pPartial);
|
||||
free((char *)pSspec->pPartial);
|
||||
pSspec->pPartial = NULL;
|
||||
}
|
||||
if (pSspec->pStatTimeStamp != NULL) {
|
||||
GenFree((char *)pSspec->pStatTimeStamp);
|
||||
free((char *)pSspec->pStatTimeStamp);
|
||||
pSspec->pStatTimeStamp = NULL;
|
||||
}
|
||||
if (pSspec->pStatDeltaSec != NULL) {
|
||||
GenFree((char *)pSspec->pStatDeltaSec);
|
||||
free((char *)pSspec->pStatDeltaSec);
|
||||
pSspec->pStatDeltaSec = NULL;
|
||||
}
|
||||
if (pSspec->pStatPopCount != NULL) {
|
||||
GenFree((char *)pSspec->pStatPopCount);
|
||||
free((char *)pSspec->pStatPopCount);
|
||||
pSspec->pStatPopCount = NULL;
|
||||
}
|
||||
pSspec->dataDim = 0;
|
||||
@@ -3154,6 +3219,7 @@ SYD_SPEC *pSspec;
|
||||
for (pSChan=pSspec->pChanHead; pSChan!=NULL; pSChan=pSChan->pNext) {
|
||||
if (pSChan->discon == 0)
|
||||
n++;
|
||||
sydChanPrep(pSspec, pSChan);
|
||||
}
|
||||
|
||||
pSspec->firstData = pSspec->lastData = -1;
|
||||
@@ -3263,7 +3329,7 @@ TS_STAMP *pTsEnd; /* I pointer to stamp to end, or NULL */
|
||||
{
|
||||
SYD_CHAN *pSChan;
|
||||
TS_STAMP tsBegin, tsEnd;
|
||||
int i, beg=-1, end=-1;
|
||||
int i, beg=-1, end=-1, first;
|
||||
int statCount=0, sampCount;
|
||||
double val;
|
||||
|
||||
@@ -3317,12 +3383,15 @@ TS_STAMP *pTsEnd; /* I pointer to stamp to end, or NULL */
|
||||
&pSspec->restrictRefTs, &pSspec->refTs);
|
||||
for (pSChan=pSspec->pChanHead; pSChan!=NULL; pSChan=pSChan->pNext) {
|
||||
i = beg;
|
||||
first = 1;
|
||||
while (1) {
|
||||
val=sydValAsDbl(pSChan, i);
|
||||
if (pSChan->restrictMinDataVal > val || i == beg)
|
||||
pSChan->restrictMinDataVal = val;
|
||||
if (pSChan->restrictMaxDataVal < val || i == beg)
|
||||
pSChan->restrictMaxDataVal = val;
|
||||
if (sydValAsDbl(pSChan, i, &val)) {
|
||||
if (pSChan->restrictMinDataVal > val || first)
|
||||
pSChan->restrictMinDataVal = val;
|
||||
if (pSChan->restrictMaxDataVal < val || first)
|
||||
pSChan->restrictMaxDataVal = val;
|
||||
first = 0;
|
||||
}
|
||||
if (i == end)
|
||||
break;
|
||||
if (++i >= pSspec->dataDim)
|
||||
@@ -3369,21 +3438,21 @@ SYD_SPEC *pSspec; /* I pointer to synchronous set spec */
|
||||
if (!pSChan->dataChan)
|
||||
continue;
|
||||
if (pSspec->statDim > 0) {
|
||||
GenFree((char *)pSChan->pStats);
|
||||
GenFree((char *)pSspec->pStatTimeStamp);
|
||||
GenFree((char *)pSspec->pStatDeltaSec);
|
||||
GenFree((char *)pSspec->pStatPopCount);
|
||||
free((char *)pSChan->pStats);
|
||||
free((char *)pSspec->pStatTimeStamp);
|
||||
free((char *)pSspec->pStatDeltaSec);
|
||||
free((char *)pSspec->pStatPopCount);
|
||||
}
|
||||
pSChan->pStats=(SYD_STATS *)GenMalloc(statCount*sizeof(SYD_STATS));
|
||||
pSChan->pStats=(SYD_STATS *)malloc(statCount*sizeof(SYD_STATS));
|
||||
assertAlways(pSChan->pStats != NULL);
|
||||
pSspec->pStatDeltaSec =
|
||||
(double *)GenMalloc(statCount*sizeof(double));
|
||||
(double *)malloc(statCount*sizeof(double));
|
||||
assertAlways(pSspec->pStatDeltaSec != NULL);
|
||||
pSspec->pStatTimeStamp =
|
||||
(TS_STAMP *)GenMalloc(statCount*sizeof(TS_STAMP));
|
||||
(TS_STAMP *)malloc(statCount*sizeof(TS_STAMP));
|
||||
assertAlways(pSspec->pStatTimeStamp != NULL);
|
||||
pSspec->pStatPopCount =
|
||||
(short *)GenMalloc(statCount*sizeof(short));
|
||||
(long *)malloc(statCount*sizeof(long));
|
||||
assertAlways(pSspec->pStatPopCount != NULL);
|
||||
}
|
||||
pSspec->statDim = statCount;
|
||||
@@ -3431,7 +3500,7 @@ SYD_SPEC *pSspec;
|
||||
int statNum, sampBeg, sampEnd, sampCount;
|
||||
{
|
||||
SYD_CHAN *pSChan;
|
||||
double mean, stdDev, diff;
|
||||
double mean, stdDev, diff, val;
|
||||
int i;
|
||||
|
||||
pSspec->pStatDeltaSec[statNum] = pSspec->pDeltaSec[sampBeg];
|
||||
@@ -3443,7 +3512,8 @@ int statNum, sampBeg, sampEnd, sampCount;
|
||||
mean = stdDev = 0.;
|
||||
i = sampBeg;
|
||||
while (1) {
|
||||
mean += sydValAsDbl(pSChan, i);
|
||||
if (sydValAsDbl(pSChan, i, &val))
|
||||
mean += val;
|
||||
if (i == sampEnd) break;
|
||||
if (++i >= pSspec->dataDim) i = 0;
|
||||
}
|
||||
@@ -3451,8 +3521,10 @@ int statNum, sampBeg, sampEnd, sampCount;
|
||||
mean /= sampCount;
|
||||
i = sampBeg;
|
||||
while (1) {
|
||||
diff = sydValAsDbl(pSChan, i) - mean;
|
||||
stdDev += diff * diff;
|
||||
if (sydValAsDbl(pSChan, i, &val)) {
|
||||
diff = val - mean;
|
||||
stdDev += diff * diff;
|
||||
}
|
||||
if (i == sampEnd) break;
|
||||
if (++i >= pSspec->dataDim) i = 0;
|
||||
}
|
||||
@@ -3704,7 +3776,7 @@ char *text; /* I pointer to string with test specification */
|
||||
}
|
||||
pText = myText;
|
||||
strcpy(myText, text);
|
||||
if ((pTest = (SYD_TEST *)GenMalloc(sizeof(SYD_TEST))) == NULL) {
|
||||
if ((pTest = (SYD_TEST *)malloc(sizeof(SYD_TEST))) == NULL) {
|
||||
(void)printf("sydTestAddFromText: couldn't malloc for test struct\n");
|
||||
free(myText);
|
||||
return S_syd_noMem;
|
||||
@@ -3813,14 +3885,14 @@ SYD_SPEC *pSspec; /* I pointer to synchronous set spec */
|
||||
if ((pTest = pSspec->pAccept) == NULL)
|
||||
return S_syd_OK;
|
||||
if (pTest->pSChan == NULL) {
|
||||
GenFree((char *)pTest);
|
||||
free((char *)pTest);
|
||||
pSspec->pAccept = NULL;
|
||||
}
|
||||
else if (pTest->pSChan->dataChan == 0)
|
||||
sydChanClose(pSspec, pTest->pSChan);
|
||||
else {
|
||||
pTest->pSChan->testChan = 0;
|
||||
GenFree((char *)pTest);
|
||||
free((char *)pTest);
|
||||
pSspec->pAccept = NULL;
|
||||
}
|
||||
|
||||
@@ -3851,36 +3923,38 @@ int roundNsec;
|
||||
* NAME sydValAsDbl - fetch value from channel as a double
|
||||
*
|
||||
* RETURNS
|
||||
* value (as a double) of channel for the specified sample number, or
|
||||
* 0., if the value is missing or EOF, or if the type is invalid
|
||||
* 1, or
|
||||
* 0 if the value is missing or EOF, or if the type is invalid
|
||||
*
|
||||
*
|
||||
*-*/
|
||||
double
|
||||
sydValAsDbl(pSChan, sampNum)
|
||||
int
|
||||
sydValAsDbl(pSChan, sampNum, pDbl)
|
||||
SYD_CHAN *pSChan; /* I sync channel pointer */
|
||||
int sampNum; /* I sample number */
|
||||
double *pDbl; /* O value */
|
||||
{
|
||||
if (pSChan->pFlags[sampNum].missing || pSChan->pFlags[sampNum].eof)
|
||||
return 0.;
|
||||
return 0;
|
||||
if (pSChan->dbfType == DBF_FLOAT)
|
||||
return (double)(((float *)pSChan->pData)[sampNum]);
|
||||
*pDbl = (double)(((float *)pSChan->pData)[sampNum]);
|
||||
else if (pSChan->dbfType == DBF_DOUBLE)
|
||||
return (double)(((double *)pSChan->pData)[sampNum]);
|
||||
*pDbl = ((double *)pSChan->pData)[sampNum];
|
||||
else if (pSChan->dbfType == DBF_SHORT) {
|
||||
if (pSChan->isRVAL)
|
||||
return (double)(((unsigned short *)pSChan->pData)[sampNum]);
|
||||
*pDbl = (double)(((unsigned short *)pSChan->pData)[sampNum]);
|
||||
else
|
||||
return (double)(((short *)pSChan->pData)[sampNum]);
|
||||
*pDbl = (double)(((short *)pSChan->pData)[sampNum]);
|
||||
}
|
||||
else if (pSChan->dbfType == DBF_LONG) {
|
||||
if (pSChan->isRVAL)
|
||||
return (double)(((unsigned long *)pSChan->pData)[sampNum]);
|
||||
*pDbl = (double)(((unsigned long *)pSChan->pData)[sampNum]);
|
||||
else
|
||||
return (double)(((long *)pSChan->pData)[sampNum]);
|
||||
*pDbl = (double)(((long *)pSChan->pData)[sampNum]);
|
||||
}
|
||||
else if (pSChan->dbfType == DBF_CHAR)
|
||||
return (double)(((char *)pSChan->pData)[sampNum]);
|
||||
*pDbl = (double)(((char *)pSChan->pData)[sampNum]);
|
||||
else
|
||||
return 0.;
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Id$
|
||||
/* @(#)sydSubrCA.c 1.8 8/24/92
|
||||
* Author: Roger A. Cole
|
||||
* Date: 06-12-91
|
||||
*
|
||||
@@ -39,12 +39,12 @@
|
||||
* after ca_search; handle disconCount and needGrCount
|
||||
* in sampleSetSpec; move copyGr and copyVal into
|
||||
* sydSubr.c
|
||||
* .08 09-14-92 rac discontinue use of special malloc routines
|
||||
*
|
||||
* make options
|
||||
* -DvxWorks makes a version for VxWorks
|
||||
* -DNDEBUG don't compile assert() checking
|
||||
* -DDEBUG compile various debug code, including checks on
|
||||
* malloc'd memory
|
||||
* -DDEBUG compile various debug code
|
||||
*/
|
||||
/*+/mod***********************************************************************
|
||||
* TITLE sydSubrCA.c - acquire synchronous samples from Channel Access
|
||||
@@ -86,12 +86,12 @@ void *pHandle; /* I NULL; someday might implement a callback
|
||||
|
||||
assert(ppSspec != NULL);
|
||||
|
||||
if ((*ppSspec = (SYD_SPEC *)GenMalloc(sizeof(SYD_SPEC))) == NULL)
|
||||
if ((*ppSspec = (SYD_SPEC *)malloc(sizeof(SYD_SPEC))) == NULL)
|
||||
return S_syd_noMem;
|
||||
(*ppSspec)->pFunc = sydCAFunc;
|
||||
(*ppSspec)->type = SYD_TY_CA;
|
||||
if ((stat = sydCAFunc(*ppSspec, NULL, SYD_FC_INIT, pHandle)) != S_syd_OK){
|
||||
GenFree((char *)*ppSspec);
|
||||
free((char *)*ppSspec);
|
||||
return stat;
|
||||
}
|
||||
(*ppSspec)->nInBufs = SYD_CHAN_MAX_IN;
|
||||
@@ -163,9 +163,9 @@ void *pArg; /* I pointer to arg, as required by funcCode */
|
||||
* If searches are to be asynchronous, the connection handler is allowed
|
||||
* to do the required connection processing.
|
||||
*----------------------------------------------------------------------------*/
|
||||
pSChan->dbrType = TYPENOTCONN;
|
||||
pSChan->dbfType = pSChan->dbrType = TYPENOTCONN;
|
||||
pSspec->disconCount++;
|
||||
pSChan->elCount = 0;
|
||||
pSChan->elCount = 1;
|
||||
pSChan->evid = NULL;
|
||||
pSChan->gotGr = 0;
|
||||
pSspec->needGrCount++;
|
||||
|
||||
+10
-10
@@ -25,18 +25,18 @@
|
||||
*
|
||||
* Modification Log:
|
||||
* -----------------
|
||||
* .00 12-04-90 rac initial version
|
||||
* .01 06-18-91 rac installed in SCCS
|
||||
* .02 06-19-91 rac replace <fields.h> with <alarm.h>
|
||||
* .03 08-06-91 rac allow specifying file name
|
||||
* .04 09-11-91 rac finish allowing user specified name
|
||||
* .05 02-27-92 rac do ts rounding here instead of sydSubr.c
|
||||
* .00 12-04-90 rac initial version
|
||||
* .01 06-18-91 rac installed in SCCS
|
||||
* .02 06-19-91 rac replace <fields.h> with <alarm.h>
|
||||
* .03 08-06-91 rac allow specifying file name
|
||||
* .04 09-11-91 rac finish allowing user specified name
|
||||
* .05 02-27-92 rac do ts rounding here instead of sydSubr.c
|
||||
* .06 09-14-92 rac discontinue use of special malloc routines
|
||||
*
|
||||
* make options
|
||||
* -DvxWorks makes a version for VxWorks
|
||||
* -DNDEBUG don't compile assert() checking
|
||||
* -DDEBUG compile various debug code, including checks on
|
||||
* malloc'd memory
|
||||
* -DDEBUG compile various debug code
|
||||
*/
|
||||
/*+/mod***********************************************************************
|
||||
* TITLE sydSubrCF.c - acquire synchronous samples from `by channel' AR file
|
||||
@@ -101,12 +101,12 @@ char *filePath; /* I path name for `by channel' archive file */
|
||||
|
||||
assert(ppSspec != NULL);
|
||||
|
||||
if ((*ppSspec = (SYD_SPEC *)GenMalloc(sizeof(SYD_SPEC))) == NULL)
|
||||
if ((*ppSspec = (SYD_SPEC *)malloc(sizeof(SYD_SPEC))) == NULL)
|
||||
return S_syd_noMem;
|
||||
(*ppSspec)->pFunc = sydCFFunc;
|
||||
(*ppSspec)->type = SYD_TY_CF;
|
||||
if ((stat = sydCFFunc(*ppSspec, NULL, SYD_FC_INIT, filePath)) != S_syd_OK){
|
||||
GenFree((char *)*ppSspec);
|
||||
free((char *)*ppSspec);
|
||||
*ppSspec = NULL;
|
||||
return stat;
|
||||
}
|
||||
|
||||
+232
-90
@@ -28,18 +28,21 @@
|
||||
* .00 12-04-90 rac initial version
|
||||
* .01 06-18-91 rac installed in SCCS
|
||||
* .02 06-19-91 rac replace <fields.h> with <alarm.h>
|
||||
* .03 08-14-91 rac jjj
|
||||
* .03 08-14-91 rac
|
||||
* .04 02-27-92 rac do ts rounding here instead of sydSubr.c
|
||||
* .05 08-18-92 rac add SYD_FC_STOP function code
|
||||
* .06 09-09-92 rac allow reading text values such as `no data'; look at
|
||||
* the _end_ of the file to do name searches; handle
|
||||
* channels which are missing and/or disconnected;
|
||||
* discontinue use of special malloc routines
|
||||
*
|
||||
* make options
|
||||
* -DvxWorks makes a version for VxWorks
|
||||
* -DNDEBUG don't compile assert() checking
|
||||
* -DDEBUG compile various debug code, including checks on
|
||||
* malloc'd memory
|
||||
* -DDEBUG compile various debug code
|
||||
*/
|
||||
/*+/mod***********************************************************************
|
||||
* TITLE sydSubr.c - acquire synchronous samples from AR `sample set' files
|
||||
* TITLE sydSubrSSF.c - acquire synchronous samples from AR `sample set' files
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
@@ -107,6 +110,10 @@ static long posKeyFwd();
|
||||
static long posKeyRev();
|
||||
static long posPos();
|
||||
|
||||
/*+/internal******************************************************************
|
||||
* NAME posBOF - position file at the beginning
|
||||
*
|
||||
*-*/
|
||||
static long
|
||||
posBOF(pStream)
|
||||
FILE *pStream;
|
||||
@@ -117,7 +124,10 @@ FILE *pStream;
|
||||
}
|
||||
return ftell(pStream);
|
||||
}
|
||||
|
||||
/*+/internal******************************************************************
|
||||
* NAME posEOF - position file at the end
|
||||
*
|
||||
*-*/
|
||||
static long
|
||||
posEOF(pStream)
|
||||
FILE *pStream;
|
||||
@@ -128,7 +138,14 @@ FILE *pStream;
|
||||
}
|
||||
return ftell(pStream);
|
||||
}
|
||||
|
||||
/*+/internal******************************************************************
|
||||
* NAME posKeyFwd - search forward for a string
|
||||
*
|
||||
* RETURNS
|
||||
* position of key (its first character), or
|
||||
* -1 if search fails
|
||||
*
|
||||
*-*/
|
||||
static long
|
||||
posKeyFwd(key, pStream)
|
||||
char *key;
|
||||
@@ -186,13 +203,19 @@ FILE *pStream;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
/*+/internal******************************************************************
|
||||
* NAME posKeyRev - search backward for a string
|
||||
*
|
||||
* RETURNS
|
||||
* position of key (its first character), or
|
||||
* -1 if search fails
|
||||
*
|
||||
*-*/
|
||||
static long
|
||||
posKeyRev(key, pStream, lastPos)
|
||||
char *key;
|
||||
FILE *pStream;
|
||||
long lastPos; /* I position to start search if reverse; -1
|
||||
says to start at EOF */
|
||||
long lastPos; /* I position to start search; -1 for EOF */
|
||||
{
|
||||
int i, lastChar;
|
||||
int c;
|
||||
@@ -241,7 +264,10 @@ long lastPos; /* I position to start search if reverse; -1
|
||||
perror("posKeyRev: ftell error");
|
||||
return pos;
|
||||
}
|
||||
|
||||
/*+/internal******************************************************************
|
||||
* NAME posPos - set file to desired position
|
||||
*
|
||||
*-*/
|
||||
static long
|
||||
posPos(pStream, pos)
|
||||
FILE *pStream;
|
||||
@@ -254,6 +280,10 @@ long pos;
|
||||
return ftell(pStream);
|
||||
}
|
||||
|
||||
/*+/subr**********************************************************************
|
||||
* NAME sydOpenSSF
|
||||
*
|
||||
*-*/
|
||||
long
|
||||
sydOpenSSF(ppSspec, filePath)
|
||||
SYD_SPEC **ppSspec; /* O pointer to synchronous set spec pointer */
|
||||
@@ -263,12 +293,12 @@ char *filePath; /* I path name for `sample set' archive file */
|
||||
|
||||
assert(ppSspec != NULL);
|
||||
|
||||
if ((*ppSspec = (SYD_SPEC *)GenMalloc(sizeof(SYD_SPEC))) == NULL)
|
||||
if ((*ppSspec = (SYD_SPEC *)malloc(sizeof(SYD_SPEC))) == NULL)
|
||||
return S_syd_noMem;
|
||||
(*ppSspec)->pFunc = sydSSFFunc;
|
||||
(*ppSspec)->type = SYD_TY_SSF;
|
||||
if ((stat = sydSSFFunc(*ppSspec, NULL,SYD_FC_INIT,filePath)) != S_syd_OK){
|
||||
GenFree((char *)*ppSspec);
|
||||
free((char *)*ppSspec);
|
||||
*ppSspec = NULL;
|
||||
return stat;
|
||||
}
|
||||
@@ -298,6 +328,8 @@ char *filePath; /* I path name for `sample set' archive file */
|
||||
* o doesn't do anything (or even detect) overwriting un-sampled
|
||||
* buffers (for SYD_FC_READ)
|
||||
* o needs a "get graphics information" function and function code
|
||||
* o if a channel wasn't connected when the last snapshot in the file
|
||||
* was written, its elCount is assumed to be 1
|
||||
*
|
||||
* SEE ALSO
|
||||
*
|
||||
@@ -339,16 +371,15 @@ void *pArg; /* I pointer to arg, as required by funcCode */
|
||||
pSspec->pHandle = (void *)ssFile;
|
||||
}
|
||||
else if (funcCode == SYD_FC_OPEN) {
|
||||
(void)posBOF(ssFile);
|
||||
if ((pos = posKeyFwd("%endData%", ssFile)) < 0) {
|
||||
(void)printf("couldn't find %%endData%%\n");
|
||||
if ((pos = posKeyRev("%endHeader%", ssFile, -1L)) < 0) {
|
||||
(void)printf("couldn't find %%endHeader%%\n");
|
||||
(void)posBOF(ssFile);
|
||||
return S_syd_chanNotFound;
|
||||
}
|
||||
strcpy(chanName, "\n");
|
||||
strcat(chanName, pSChan->name);
|
||||
strcat(chanName, " ");
|
||||
if ((pos = posKeyRev(chanName, ssFile, pos)) < 0)
|
||||
if ((pos = posKeyFwd(chanName, ssFile)) < 0)
|
||||
return S_syd_chanNotFound;
|
||||
assert(sizeof(record) == 120);
|
||||
fgetc(ssFile); /* skip over the \n */
|
||||
@@ -364,21 +395,29 @@ void *pArg; /* I pointer to arg, as required by funcCode */
|
||||
if (nextAlphField(&pRecord, &pField, &delim) <= 1)
|
||||
assertAlways(0);
|
||||
dbf_text_to_type(pField, type);
|
||||
assert(type >= 0);
|
||||
pSChan->dbfType = type;
|
||||
pSChan->dbrType = dbf_type_to_DBR_TIME(type);
|
||||
pSChan->dbrGrType = dbf_type_to_DBR_GR(type);
|
||||
stat = sscanf(pRecord, "%*d %*d %d", &elCount);
|
||||
assert(stat == 1);
|
||||
pSChan->elCount = elCount;
|
||||
pSChan->sync = SYD_SY_NONF; /* force channel to be sync */
|
||||
if (type >= 0) {
|
||||
pSChan->dbfType = type;
|
||||
pSChan->dbrType = dbf_type_to_DBR_TIME(type);
|
||||
pSChan->dbrGrType = dbf_type_to_DBR_GR(type);
|
||||
stat = sscanf(pRecord, "%*d %*d %d", &elCount);
|
||||
assert(stat == 1);
|
||||
pSChan->elCount = elCount;
|
||||
}
|
||||
else {
|
||||
pSChan->dbfType = TYPENOTCONN;
|
||||
pSChan->dbrType = TYPENOTCONN;
|
||||
pSChan->dbrGrType = TYPENOTCONN;
|
||||
pSChan->elCount = 1;
|
||||
}
|
||||
sydSSFFuncGetGR(pSspec, pSChan);
|
||||
pSChan->sync = SYD_SY_NONF; /* force channel to be sync */
|
||||
(void)posBOF(ssFile);
|
||||
}
|
||||
else if (funcCode == SYD_FC_READ) {
|
||||
TS_STAMP timeStamp;
|
||||
enum sydBStatus bufStat;
|
||||
int bufNum, oldBufNum;
|
||||
enum sydBStatus bufStat, newStat;
|
||||
int bufNum, oldBufNum, first=1;
|
||||
char typeText[80];
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* find the next line with SAMPLE: and get the time stamp. When done:
|
||||
@@ -386,12 +425,15 @@ void *pArg; /* I pointer to arg, as required by funcCode */
|
||||
* SYD_B_RESTART this sample starts a new "run" of data
|
||||
* SYD_B_FULL this is an ordinary sample
|
||||
* SYD_B_EOF end of file
|
||||
* SYD_B_MISSING no value for this channel i nthis sample
|
||||
* o the file will be positioned following the %endHeader% line
|
||||
* o if time stamp rounding has been requested, it will be done
|
||||
*----------------------------------------------------------------------------*/
|
||||
bufStat = sydSSFFuncSeekSample(ssFile, &timeStamp);
|
||||
if (pSspec->roundNsec > 0)
|
||||
sydTsRound(&timeStamp, pSspec->roundNsec);
|
||||
while (1) {
|
||||
newStat = SYD_B_EMPTY;
|
||||
bufStat = sydSSFFuncSeekSample(ssFile, &timeStamp);
|
||||
if (pSspec->roundNsec > 0)
|
||||
sydTsRound(&timeStamp, pSspec->roundNsec);
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* now, read the actual data. This is done by processing all the data
|
||||
@@ -403,36 +445,53 @@ void *pArg; /* I pointer to arg, as required by funcCode */
|
||||
* o all channels with data will have the data in the buffer
|
||||
* o all channels will have .lastInBuf updated
|
||||
*----------------------------------------------------------------------------*/
|
||||
pSChan = pSspec->pChanHead;
|
||||
oldBufNum = pSChan->lastInBuf;
|
||||
bufNum = NEXT_INBUF(pSChan, oldBufNum);
|
||||
while (pSChan != NULL) {
|
||||
if (bufStat != SYD_B_EOF)
|
||||
pSChan->inStatus[bufNum] = SYD_B_MISSING;
|
||||
else
|
||||
pSChan->inStatus[bufNum] = bufStat;
|
||||
pSChan->pInBuf[bufNum]->tfltval.stamp = timeStamp;
|
||||
pSChan->lastInBuf = bufNum;
|
||||
if (pSChan->firstInBuf < 0)
|
||||
pSChan->firstInBuf = bufNum;
|
||||
pSChan = pSChan->pNext;
|
||||
}
|
||||
if (bufStat == SYD_B_EOF)
|
||||
return S_syd_EOF;
|
||||
while (1) {
|
||||
stat = fscanf(ssFile, "%s", chanName);
|
||||
assert(stat == 1);
|
||||
if ((pSChan = sydChanFind(pSspec, chanName)) != NULL) {
|
||||
(void)fscanf(ssFile, "%*s"); /* skip DBF_xxx */
|
||||
stat = sydSSFFuncReadData(pSChan, ssFile,
|
||||
bufStat, bufNum, oldBufNum);
|
||||
pSChan = pSspec->pChanHead;
|
||||
if (first) {
|
||||
oldBufNum = pSChan->lastInBuf;
|
||||
bufNum = NEXT_INBUF(pSChan, oldBufNum);
|
||||
first = 0;
|
||||
}
|
||||
else if (strcmp(chanName, "%endData%") == 0)
|
||||
while (pSChan != NULL) {
|
||||
if (bufStat != SYD_B_EOF)
|
||||
pSChan->inStatus[bufNum] = SYD_B_MISSING;
|
||||
else
|
||||
pSChan->inStatus[bufNum] = bufStat;
|
||||
pSChan->pInBuf[bufNum]->tfltval.stamp = timeStamp;
|
||||
pSChan->lastInBuf = bufNum;
|
||||
if (pSChan->firstInBuf < 0)
|
||||
pSChan->firstInBuf = bufNum;
|
||||
pSChan = pSChan->pNext;
|
||||
}
|
||||
if (bufStat == SYD_B_EOF)
|
||||
return S_syd_EOF;
|
||||
while (1) {
|
||||
stat = fscanf(ssFile, "%s", chanName);
|
||||
assert(stat == 1);
|
||||
if ((pSChan = sydChanFind(pSspec, chanName)) != NULL) {
|
||||
(void)fscanf(ssFile, "%s", typeText);
|
||||
dbf_text_to_type(typeText, type);
|
||||
if (pSChan->dbfType == TYPENOTCONN && type >= 0) {
|
||||
pSChan->dbfType = type;
|
||||
pSChan->dbrType = dbf_type_to_DBR_TIME(type);
|
||||
pSChan->dbrGrType = dbf_type_to_DBR_GR(type);
|
||||
sydSSFFuncGetGR(pSspec, pSChan);
|
||||
}
|
||||
stat = sydSSFFuncReadData(pSChan, ssFile,
|
||||
bufStat, bufNum, oldBufNum, type);
|
||||
if (pSChan->inStatus[bufNum] != SYD_B_MISSING &&
|
||||
newStat == SYD_B_EMPTY) {
|
||||
newStat = pSChan->inStatus[bufNum];
|
||||
}
|
||||
}
|
||||
else if (strcmp(chanName, "%endData%") == 0)
|
||||
break;
|
||||
else {
|
||||
while ((delim = fgetc(ssFile)) != EOF && delim != '\n')
|
||||
; /* keep skipping until end of line */
|
||||
}
|
||||
}
|
||||
if (newStat != SYD_B_EMPTY)
|
||||
break;
|
||||
else {
|
||||
while ((delim = fgetc(ssFile)) != EOF && delim != '\n')
|
||||
; /* keep skipping until end of line */
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (funcCode == SYD_FC_STOP) {
|
||||
@@ -547,11 +606,7 @@ void *pArg; /* I pointer to arg, as required by funcCode */
|
||||
(void)fprintf((FILE *)pArg, "data from %s through %s\n",
|
||||
tsStampToText(&oldestStamp, TS_TEXT_MMDDYY, oldestStampText),
|
||||
tsStampToText(&newestStamp, TS_TEXT_MMDDYY, newestStampText) );
|
||||
if (posBOF(ssFile) < 0) {
|
||||
(void)fprintf((FILE *)pArg, "error positioning file\n");
|
||||
return S_syd_ERROR;
|
||||
}
|
||||
if (posKeyFwd("%endHeader%", ssFile) < 0) {
|
||||
if (posKeyRev("%endHeader%", ssFile, -1L) < 0) {
|
||||
(void)fprintf((FILE *)pArg,
|
||||
"error locating %%endHeader%% in file\n");
|
||||
return S_syd_ERROR;
|
||||
@@ -606,11 +661,25 @@ void *pArg; /* I pointer to arg, as required by funcCode */
|
||||
return retStat;
|
||||
}
|
||||
|
||||
long
|
||||
sydSSFFuncReadData(pSChan, ssFile, bufStat, bufNum, oldBufNum)
|
||||
/*+/internal******************************************************************
|
||||
* NAME sydSSFFuncReadData
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Read data from the file into the sync set. An entire snapshot is
|
||||
* read. For each channel in the snapshot, the data is stored in the
|
||||
* sync set only if the channel is in the set.
|
||||
*
|
||||
* BUGS
|
||||
* o if a channel has a smaller elCount in the file than in the sync set,
|
||||
* then the `extra' values in the sync set will be garbage
|
||||
*
|
||||
*-*/
|
||||
static long
|
||||
sydSSFFuncReadData(pSChan, ssFile, bufStat, bufNum, oldBufNum, type)
|
||||
SYD_CHAN *pSChan; /* pointer to syncSet channel descriptor */
|
||||
FILE *ssFile;
|
||||
int bufStat, bufNum, oldBufNum;
|
||||
chtype type;
|
||||
{
|
||||
long stat;
|
||||
int alStat, alSev, elCount;
|
||||
@@ -628,57 +697,92 @@ int bufStat, bufNum, oldBufNum;
|
||||
/*-----------------------------------------------------------------------------
|
||||
* now get the actual data
|
||||
*----------------------------------------------------------------------------*/
|
||||
if (pSChan->dbrType == DBR_TIME_FLOAT) {
|
||||
float *pFl;
|
||||
if (pSChan->dbrType == TYPENOTCONN || type == TYPENOTCONN) {
|
||||
stat = fscanf(ssFile, "%*s");
|
||||
bufStat = SYD_B_MISSING;
|
||||
}
|
||||
else if (pSChan->dbrType == DBR_TIME_FLOAT) {
|
||||
float *pFl, val;
|
||||
pFl = &pSChan->pInBuf[bufNum]->tfltval.value;
|
||||
for (i=0; i<elCount; i++) {
|
||||
stat = fscanf(ssFile, "%f", pFl++);
|
||||
assert(stat == 1);
|
||||
stat = fscanf(ssFile, "%f", &val);
|
||||
if (stat != 1) {
|
||||
bufStat = SYD_B_MISSING;
|
||||
break;
|
||||
}
|
||||
else if (i < pSChan->elCount)
|
||||
*pFl++ = val;
|
||||
}
|
||||
}
|
||||
else if (pSChan->dbrType == DBR_TIME_SHORT) {
|
||||
short *pSh;
|
||||
short *pSh, val;
|
||||
pSh = &pSChan->pInBuf[bufNum]->tshrtval.value;
|
||||
for (i=0; i<elCount; i++) {
|
||||
stat = fscanf(ssFile, "%hd", pSh++);
|
||||
assert(stat == 1);
|
||||
stat = fscanf(ssFile, "%hd", &val);
|
||||
if (stat != 1) {
|
||||
bufStat = SYD_B_MISSING;
|
||||
break;
|
||||
}
|
||||
else if (i < pSChan->elCount)
|
||||
*pSh++ = val;
|
||||
}
|
||||
}
|
||||
else if (pSChan->dbrType == DBR_TIME_DOUBLE) {
|
||||
double *pDbl;
|
||||
double *pDbl, val;
|
||||
pDbl = &pSChan->pInBuf[bufNum]->tdblval.value;
|
||||
for (i=0; i<elCount; i++) {
|
||||
stat = fscanf(ssFile, "%lf", pDbl++);
|
||||
assert(stat == 1);
|
||||
stat = fscanf(ssFile, "%lf", &val);
|
||||
if (stat != 1) {
|
||||
bufStat = SYD_B_MISSING;
|
||||
break;
|
||||
}
|
||||
else if (i < pSChan->elCount)
|
||||
*pDbl++ = val;
|
||||
}
|
||||
}
|
||||
else if (pSChan->dbrType == DBR_TIME_LONG) {
|
||||
long *pL;
|
||||
long *pL, val;
|
||||
pL = &pSChan->pInBuf[bufNum]->tlngval.value;
|
||||
for (i=0; i<elCount; i++) {
|
||||
stat = fscanf(ssFile, "%ld", pL++);
|
||||
assert(stat == 1);
|
||||
stat = fscanf(ssFile, "%ld", &val);
|
||||
if (stat != 1) {
|
||||
bufStat = SYD_B_MISSING;
|
||||
break;
|
||||
}
|
||||
else if (i < pSChan->elCount)
|
||||
*pL++ = val;
|
||||
}
|
||||
}
|
||||
else if (pSChan->dbrType == DBR_TIME_STRING) {
|
||||
char *pC;
|
||||
char *pC, val[db_strval_dim];
|
||||
int nChar;
|
||||
pC = pSChan->pInBuf[bufNum]->tstrval.value;
|
||||
for (i=0; i<elCount; i++) {
|
||||
stat = fscanf(ssFile, "%d", &nChar);
|
||||
assert(stat == 1);
|
||||
if (stat != 1) {
|
||||
bufStat = SYD_B_MISSING;
|
||||
break;
|
||||
}
|
||||
assert(nChar > 0 && nChar < db_strval_dim);
|
||||
if (fgets(pC, nChar, ssFile) == NULL)
|
||||
if (fgets(val, nChar, ssFile) == NULL)
|
||||
assertAlways(0);
|
||||
pC += db_strval_dim;
|
||||
if (i < pSChan->elCount) {
|
||||
strcpy(pC, val);
|
||||
pC += db_strval_dim;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (pSChan->dbrType == DBR_TIME_CHAR) {
|
||||
unsigned char *pC;
|
||||
unsigned char *pC, val;
|
||||
pC = &pSChan->pInBuf[bufNum]->tchrval.value;
|
||||
for (i=0; i<elCount; i++) {
|
||||
stat = fscanf(ssFile, "%c", pC++);
|
||||
assert(stat == 1);
|
||||
stat = fscanf(ssFile, "%c", &val);
|
||||
if (stat != 1) {
|
||||
bufStat = SYD_B_MISSING;
|
||||
break;
|
||||
}
|
||||
else if (i < pSChan->elCount)
|
||||
*pC++ = val;
|
||||
}
|
||||
}
|
||||
else if (pSChan->dbrType == DBR_TIME_ENUM) {
|
||||
@@ -688,7 +792,10 @@ int bufStat, bufNum, oldBufNum;
|
||||
pSh = &pSChan->pInBuf[bufNum]->tenmval.value;
|
||||
for (i=0; i<elCount; i++) {
|
||||
stat = fscanf(ssFile, "%s", state);
|
||||
assert(stat == 1);
|
||||
if (stat != 1) {
|
||||
bufStat = SYD_B_MISSING;
|
||||
break;
|
||||
}
|
||||
assert(strlen(state) < db_state_text_dim);
|
||||
iState = 0;
|
||||
while (1) {
|
||||
@@ -702,15 +809,19 @@ int bufStat, bufNum, oldBufNum;
|
||||
iState++;
|
||||
assert(iState < db_state_dim);
|
||||
}
|
||||
*pSh++ = iState;
|
||||
if (i < pSChan->elCount)
|
||||
*pSh++ = iState;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------
|
||||
* set the buffer status. If the previous record had a status of MISSING,
|
||||
* then the buffer status will be SYD_B_RESTART; otherwise, the caller's
|
||||
* status will be used.
|
||||
* status will be used. (Unless, of course, this routine discovered that
|
||||
* the status needs to be something else.)
|
||||
*----------------------------------------------------------------------------*/
|
||||
if (oldBufNum >= 0 && pSChan->inStatus[oldBufNum] == SYD_B_MISSING)
|
||||
if (bufStat == SYD_B_MISSING)
|
||||
pSChan->inStatus[bufNum] = bufStat;
|
||||
else if (oldBufNum >= 0 && pSChan->inStatus[oldBufNum] == SYD_B_MISSING)
|
||||
pSChan->inStatus[bufNum] = SYD_B_RESTART;
|
||||
else
|
||||
pSChan->inStatus[bufNum] = bufStat;
|
||||
@@ -718,6 +829,10 @@ int bufStat, bufNum, oldBufNum;
|
||||
return S_syd_OK;
|
||||
}
|
||||
|
||||
/*+/internal******************************************************************
|
||||
* NAME sydSSFFuncGetGR - simulate getting graphics information
|
||||
*
|
||||
*-*/
|
||||
static long
|
||||
sydSSFFuncGetGR(pSspec, pSChan)
|
||||
SYD_SPEC *pSspec; /* pointer to syncSet specification */
|
||||
@@ -863,7 +978,21 @@ SYD_CHAN *pSChan; /* pointer to syncSet channel descriptor */
|
||||
return S_syd_OK;
|
||||
}
|
||||
|
||||
long
|
||||
/*+/internal******************************************************************
|
||||
* NAME sydSSFFuncSeekStamp - find a `SAMPLE: at' line
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Find a `SAMPLE: at' line and get the time stamp from it.
|
||||
*
|
||||
* If the search is forward, the file is left positioned following
|
||||
* the stamp. If backward, the position is at the beginning of the
|
||||
* line.
|
||||
*
|
||||
* RETURNS
|
||||
* position of the line
|
||||
*
|
||||
*-*/
|
||||
static long
|
||||
sydSSFFuncSeekStamp(ssFile, pStamp, revFlag, pos)
|
||||
FILE *ssFile;
|
||||
TS_STAMP *pStamp;
|
||||
@@ -905,7 +1034,20 @@ long pos; /* I position to start search if reverse; -1
|
||||
return pos;
|
||||
}
|
||||
|
||||
long
|
||||
/*+/internal******************************************************************
|
||||
* NAME sydSSFFuncSeekSample - find the next sample
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Finds the next `SAMPLE: at' line, gets the time stamp for the
|
||||
* sample, and gets the `status' for the snapshot. The file is
|
||||
* positioned following the %endHeader%, ready for reading the data.
|
||||
*
|
||||
* RETURNS
|
||||
* SYD_B_RESTART if `initial' was specified on the `SAMPLE: at' line, or
|
||||
* SYD_B_FULL
|
||||
*
|
||||
*-*/
|
||||
static long
|
||||
sydSSFFuncSeekSample(ssFile, pStamp)
|
||||
FILE *ssFile;
|
||||
TS_STAMP *pStamp;
|
||||
|
||||
Reference in New Issue
Block a user