#ifdef __STRICT_ANSI__ #undef __STRICT_ANSI__ #endif #include "wavBuf.h" #include #include #include #include #include #include #if 0 typedef struct WavBufRec_ { void *data; void *data1; uint16_t type; uint8_t flags; uint8_t res; uint16_t m,n; /* dimension of waveform array */ void *usrData; int (*free)(struct WavBufRec_ *pb); epicsTimeStamp ts; } WavBufRec, *WavBuf; #endif static void wavBufPostTst(int m, int n, int colm, int type) { WavBuf b = wavBufAlloc(); int i,j,c,r; int slot = 0; int kind = 0; union { void *r; int16_t *s; float *f; } p,pi; p.r = pi.r = 0; if ( !b ) return; switch (type) { case 0: type = 0; default: b->type = WavBufInt16; break; case 1: b->type = WavBufFloat; break; case 2: b->type = WavBufCplx; break; } kind = type; b->flags = colm ? WavBufFlagCM : 0; b->m = b->segs.m = m; b->n = b->segs.n = n; b->segs.nsegs = 1; b->segs.data[0] = p.r = calloc(wavBufTypeSize(b->type),m*n); if ( WavBufCplx == b->type ) { b->segs.nsegs++; b->segs.data[1] = pi.r = calloc(wavBufTypeSize(b->type),m*n); } if ( colm ) { c=m; r=1; } else { c=1; r=n; } i=0; for (j=0; jtype ) { case WavBufInt16: p.s[i*r+j*c] = j*(15000/n); break; case WavBufFloat: p.f[i*r+j*c] = j*(15000/n); break; case WavBufCplx: pi.f[i*r+j*c] = j*(15000/n); break; } } if ( m>=2 ) { i=2; for (j=0; jtype ) { case WavBufInt16: p.s[i*r+j*c] = 15000*sinf((float)j*2.*3.141592/(float)n*3.); break; case WavBufFloat: p.f[i*r+j*c] = 15000*sinf((float)j*2.*3.141592/(float)n*3.); break; case WavBufCplx: p.f[i*r+j*c] = 15000*sinf((float)j*2.*3.141592/(float)n*3.); pi.f[i*r+j*c] = 15000*cosf((float)j*2.*3.141592/(float)n*3.); break; } } } wavBufPost(slot, kind, b); } static const struct iocshArg args[] = { { "m", /* iocshArgPersistentString is broken (3.14.8) - * it doesn't check for an empty string before * duplicating :-( */ iocshArgInt }, { "n", iocshArgInt }, { "col_major", iocshArgInt }, { "type", iocshArgInt } }; static const struct iocshArg *bloatp[] = { &args[0], &args[1], &args[2], &args[3], 0 }; struct iocshFuncDef wavBufTstDesc = { "wavBufTst", sizeof(bloatp)/sizeof(bloatp[0])-1, bloatp }; static void wavBufTst(const iocshArgBuf *args) { wavBufPostTst(args[0].ival,args[1].ival,args[2].ival,args[3].ival); } static void wavBufTstRegistrar(void) { extern void bpmCavFilterInit(); wavBufInit(); bpmCavFilterInit(); iocshRegister(&wavBufTstDesc, wavBufTst); } epicsExportRegistrar(wavBufTstRegistrar);