#include #include #include #include #include #include unsigned fidDiff=0; unsigned minFidDiff = -1; unsigned maxFidDiff = 0; unsigned maxSame=0; unsigned nSame=0; unsigned doFidSend=1; int fidProcessHasBeam = 0; static long bpmEvrFidProcess(subRecord *precord) { epicsTimeStamp ts; epicsTimeStamp *ts_p; static unsigned lts=0; #ifdef __PPC__ static unsigned ltb =0; static unsigned ltb1=0; unsigned tb; #endif ts_p = evrTimeGet(&ts, 0) ? 0 : &ts; /* Tag stream with latest timestamp and * make sure all PADs are started */ if ( ts_p ) { if ( lts == ts_p->nsec ) { nSame ++; if ( nSame > maxSame ) maxSame = nSame; } else { nSame = 0; /* cache value in integer variable */ fidProcessHasBeam = (int) precord->a; if ( doFidSend ) drvPadUdpCommSendStartAll(ts_p); } lts = ts_p->nsec; } #ifdef __PPC__ asm volatile("mftb %0":"=r"(tb)); fidDiff = tb - ltb; ltb = tb; if ( fidDiff < minFidDiff ) minFidDiff = fidDiff; if ( !nSame ) { fidDiff = tb - ltb1; ltb1 = tb; if ( fidDiff > maxFidDiff ) maxFidDiff = fidDiff; } #endif return 0; } epicsRegisterFunction(bpmEvrFidProcess);