#include #include #include #include #include #include #include static long subPadDetect(subRecord *psub) { DBADDR *paddr = dbGetPdbAddrFromLink(&psub->inpa); short *pdata = paddr->pfield; int i; unsigned long long val = 0; if ( !paddr ) return -1; /* RAW record must be in ROW major order */ pdata += ((int)psub->b)*(paddr->no_elements/4); #ifdef DEBUG printf("Data pointer 0x%08x\n",pdata); #endif for ( i=(int)psub->c; i < (int)psub->d; i ++ ) { val += pdata[i]*pdata[i]; } psub->val = val; return 0; } epicsRegisterFunction(subPadDetect);