/* $Id: drvBpm.c,v 1.24 2012/12/13 21:27:49 strauman Exp $ */ #define _ISOC99_SOURCE #undef __STRICT_ANSI__ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef __PPC__ uint32_t totTimeMax = 0; uint32_t totTimeAvg = 0; #endif #define ZERO_PT_5 0.5 int mpsDiagMsg = 0; static int setStatFromErr(dbCommon *prec, int err) { int sevr = NO_ALARM; if ( err > 0 ) { sevr = err & 0xff; recGblSetSevr(prec, ((err>>8) & 0xff), sevr); } else if ( err < 0 ) { recGblSetSevr(prec, READ_ALARM, INVALID_ALARM); sevr = INVALID_ALARM; } return sevr; } /* u,v,correction,x,y,tmit */ #define RES_U 0 #define RES_V 1 #define RES_C 2 #define RES_X 3 #define RES_Y 4 #define RES_T 5 /* * The bpmResultsxx[] and bpmStatus[] etc. variables * are written/computed by drvBpmCalcPos * to be read by record device support. */ #define NUM_RES 6 BpmNumber bpmResults [MAX_BPM][NUM_RES]; float bpmResultsScl[MAX_BPM][NUM_RES]; float bpmResultsOff[MAX_BPM][NUM_RES] = { {0.} }; DrvBpmMpsThresVal drvBpmMpsLolo[MAX_BPM][NUM_MPSTHRES] = { {0.} }; DrvBpmMpsThresVal drvBpmMpsHihi[MAX_BPM][NUM_MPSTHRES] = { {0.} }; int bpmStatus[MAX_BPM] = {0}; TimeStamp bpmTimeStamp[MAX_BPM] = { {0} }; FcomBlob bpmBlobs[MAX_BPM] = { {{0}} }; FcomGroup bpmGroup = 0; volatile uint32_t drvBpmFcomAddGroupFailed = 0; volatile int drvBpmFcomAddGroupError = 0; volatile uint32_t drvBpmFcomPutGroupFailed = 0; volatile int drvBpmFcomPutGroupError = 0; volatile uint32_t drvBpmFcomPurgedGroups = 0; volatile uint32_t drvBpmFcomPostedGroups = 0; /* Status bitmasks for MPS -- the individual words * MPS_X and MPS_Y must be interrupt-locked to keep * them thread-safe. * MPS_BP is the 'bypass mask'. */ /* NOTE: EPICS records rely on MPS_BP .. MPS_FLT * being 0..5, respectively. */ #define MPS_BP 0 /* bypass mask */ #define MPS_LBP 1 /* low-beam current bypasses */ #define MPS_X_F 2 /* latched failed-X */ #define MPS_Y_F 3 /* latched failed-Y */ #define MPS_T_F 4 /* latched failed-TMIT */ #define MPS_FLT 5 /* actual state */ #define MPS_X 6 #define MPS_Y 7 /* code relies on MPS_Y = MPS_X + 1 */ #define MPS_NOB 8 /* got TMIT pulse but below thresh */ #define MPS_B 9 /* got TMIT pulse above thresh */ #define MPS_NUM 10 volatile uint32_t drvBpmMps[MPS_NUM] = {0}; IOSCANPVT drvBpmMpsScan; /* Cached rotation matrix coefficients */ #define ROT_UU 0 #define ROT_UV 1 #define ROT_VU 2 #define ROT_VV 3 BpmNumber bpmRot[MAX_BPM][PADRPLY_STRM_NCHANNELS]; /* Cached inter-axes angle parameter */ BpmNumber bpmCosPsi[MAX_BPM]; BpmNumber bpmSinPsi[MAX_BPM]; /* Cached pincushion adjustment factor */ BpmNumber bpmPincAdj[MAX_BPM]; #if 0 /* Various cached parameters */ float bpmParms[MAX_BPM][NUM_BPM_PARMS] = { {0.} }; #endif #if 0 static BpmRawAmplitudes ampFree = 0; static __inline__ volatile BpmRawAmplitudes ampAlloc(unsigned chnl) { int key; BpmRawAmplitudes rval; key = epicsInterruptLock(); if ( (rval = ampFree) ) ampFree = *(BpmRawAmplitudes*)ampFree; epicsInterruptUnlock(key); return (volatile BpmRawAmplitudes)rval; } static __inline__ void ampFreeNonl(BpmRawAmplitudes a) { *(BpmRawAmplitudes*)a = ampFree; ampFree = a; } /* The cooked (and calibrated) strip signals */ BpmRawAmplitudes bpmRawAmplitudes[MAX_BPM] = { 0 }; static BpmRawAmplitudesRec ampBuffers[MAX_BPM*PADRPLY_STRM_NCHANNELS]; static __inline__ void ampInit() { int i; /* Don't lock - we assume nobody is using this yet */ for ( i=0; i 32 #error "MAX_BPM too big for current bitmask implementation" #endif volatile uint32_t bpmRawAmplitudesPending = 0; /* Operate on the bitmask */ /* Check if new data for 'channel' is pending */ static __inline__ int bpmRawAmplitudePending(unsigned channel) { int rval, key; key = epicsInterruptLock(); rval = (1<status |= BPM_AMPL_SKIPPED; } else { /* mark as old */ oa->status |= BPM_AMPL_OLD; oa = a; } ampFreeNonl(oa); } bpmRawAmplitudesPending |= msk; epicsInterruptUnlock(key); return rval ? 1 : 0; } #else BpmRawAmplitudesRec ampBuffers[MAX_BPM]; static __inline__ void ampInit() { int i; memset(ampBuffers, 0, sizeof(ampBuffers)); for ( i=0; i drvBpm callbacks) we * do NOT bother introducing a lock. * This is OK because we rely on time-interleaving: the fiducial * processing is done 1ms before data arrive and must be finished * by the time the BPM callbacks execute. */ fcomFreeGroup(bpmGroup); bpmFcomGroupMustAlloc("drvBpmPurgeFcomGroup"); drvBpmFcomPurgedGroups++; } static void bpmFcomPost(unsigned channel, epicsTimeStamp *p_ts) { int status, add_post; if ( (add_post = fcomOutStatePost(channel)) ) { bpmBlobs[channel].fc_tsHi = p_ts->secPastEpoch; bpmBlobs[channel].fc_tsLo = p_ts->nsec; status = fcomAddGroup(bpmGroup, &bpmBlobs[channel]); if ( status ) { drvBpmFcomAddGroupFailed++; drvBpmFcomAddGroupError = status; } if ( (FCOS_POST & add_post) ) { status = fcomPutGroup(bpmGroup); if ( status ) { drvBpmFcomPutGroupFailed++; drvBpmFcomPutGroupError = status; } else { drvBpmFcomPostedGroups++; } bpmFcomGroupMustAlloc("bpmFcomPost"); } } } void bpmWatchdog(int channel, int kind, void *closure) { int key; if ( channel < 0 || channel >= MAX_BPM ) return; if ( kind < 0 || kind >= NUM_DATA_KINDS ) return; key = epicsInterruptLock(); if ( PadDataBpm == kind ) ampBuffers[channel].status = BPM_AMPL_TIMEDOUT; epicsInterruptUnlock(key); } volatile DrvPadUdpCommHWTime drvBpmMaxProcessingTime = 0; /* from 'start' command (FIDP) to end of position calc */ volatile DrvPadUdpCommHWTime drvBpmMaxTotalTime = 0; long drvBpmCalcPos( unsigned c, BpmNumber u, BpmNumber v, BpmNumber t, uint32_t raw_status, BpmNumber pinc, TimeStamp *p_ts ) { int ovrErr = 0; int rval = 0; DrvPadUdpCommHWTime totTime, now; BpmNumber uscl,vscl,uoff,voff,xraw,yraw,x,y; BpmNumber xscl, yscl, tscl, xoff, yoff, toff; BpmNumber *prot; int key; int newStatus; if ( c >= MAX_BPM ) { errlogPrintf("drvBpmCalcPos - invalid channel # %i (INPL)\n", c); return -1; } if ( raw_status & BPM_AMPL_RNG_MSK(-1) ) { newStatus = ENC_ST_SVR(READ_ALARM, INVALID_ALARM); bpmBlobs[c].fc_stat = FC_STAT_BPM_INVAL; } else if ( raw_status & (BPM_AMPL_OVR_MSK) ) { newStatus = ENC_ST_SVR(HIHI_ALARM, MAJOR_ALARM ); bpmBlobs[c].fc_stat = FC_STAT_BPM_OVRFL; ovrErr = 1; } else if ( raw_status & (BPM_AMPL_UDR_MSK) ) { newStatus = ENC_ST_SVR(LOLO_ALARM, INVALID_ALARM); bpmBlobs[c].fc_stat = FC_STAT_BPM_REFLO; /* set TMIT for underrange channels */ key = epicsInterruptLock(); bpmResults[c][RES_T] = t*bpmResultsScl[c][RES_T] + bpmResultsOff[c][RES_T]; /* Sonya prefers the old behavior where X/Y just freeze the last * valid beam position... bpmResults[c][RES_X] = bpmResults[c][RES_Y] = NAN; */ drvBpmMps[MPS_NOB] &= ~ (1< drvBpmMpsLolo[c][MPSTHRES_T] ) drvBpmMps[MPS_B] &= ~ (1< drvBpmMpsLolo[c][MPSTHRES_X] ) drvBpmMps[MPS_X] &= ~ (1< drvBpmMpsLolo[c][MPSTHRES_Y] ) drvBpmMps[MPS_Y] &= ~ (1< drvBpmMaxProcessingTime ) { drvBpmMaxProcessingTime = totTime; } totTime = now - fidTimeBaseline; if ( totTime > drvBpmMaxTotalTime ) { drvBpmMaxTotalTime = totTime; } return rval; } /* Check for MPS violations during last cycle and * re-arm this check. This routine is intended to * be executed from the fiducial callback. */ uint32_t drvBpmMpsPoll(void) { uint32_t rval, res_x, res_y, res_nob, res_b, beam_and_not_bypassed; int key; /* Note that we are not protected against modifications of * the bypass-mask by devBusMapped device support (because * that devsup doesn't interrupt-lock) but we assume * that such modifications (changing a 32-bit bitmask) * can never happen in an inconsistent way (flipping a * particular bit does not affect other bits) */ key = epicsInterruptLock(); res_x = drvBpmMps[MPS_X]; res_y = drvBpmMps[MPS_Y]; res_nob = drvBpmMps[MPS_NOB]; res_b = drvBpmMps[MPS_B]; /* Reset */ drvBpmMps[MPS_X] = drvBpmMps[MPS_Y] = drvBpmMps[MPS_NOB] = drvBpmMps[MPS_B] = (uint32_t)-1; epicsInterruptUnlock(key); /* bits in res_b, res_nob are set for BPMs where TMIT was not updated */ /* *negative* logic: * bypassed OR ( received TMIT AND NOT beam AND low-TMIT bypasses ) */ beam_and_not_bypassed = drvBpmMps[MPS_BP] & ( res_nob | drvBpmMps[MPS_LBP] ); /* 'negative' logic: 1 == 'FAILED' */ rval = (res_x | res_y | res_b) & beam_and_not_bypassed; if ( rval ) { /* only latch first fault */ if ( ! (drvBpmMps[MPS_X_F] | drvBpmMps[MPS_Y_F] | drvBpmMps[MPS_T_F]) ) { if ( mpsDiagMsg ) { printf("Setting:\n"); printf("res_x: 0x%08"PRIx32"\n",res_x); printf("res_y: 0x%08"PRIx32"\n",res_y); printf("res_nob: 0x%08"PRIx32"\n",res_nob); printf("res_b: 0x%08"PRIx32"\n",res_b); } drvBpmMps[MPS_X_F] = res_x & beam_and_not_bypassed; drvBpmMps[MPS_Y_F] = res_y & beam_and_not_bypassed; drvBpmMps[MPS_T_F] = res_b & beam_and_not_bypassed; scanIoRequest(drvBpmMpsScan); } } else { if ( (drvBpmMps[MPS_X_F] | drvBpmMps[MPS_Y_F] | drvBpmMps[MPS_T_F]) ) { /* If there is beam in at least one BPM and all * non-bypassed BPMs with beam are good then * we can reset the latched state. */ if ( 0 != ~res_b ) { if ( mpsDiagMsg ) { printf("Clearing:\n"); printf("res_x: 0x%08"PRIx32"\n",res_x); printf("res_y: 0x%08"PRIx32"\n",res_y); printf("res_nob: 0x%08"PRIx32"\n",res_nob); printf("res_b: 0x%08"PRIx32"\n",res_b); } drvBpmMps[MPS_X_F] = drvBpmMps[MPS_Y_F] = drvBpmMps[MPS_T_F] = 0; scanIoRequest(drvBpmMpsScan); } } } drvBpmMps[MPS_FLT] = rval; return rval; } static long generic_cb(aiRecord *pai, TimeStamp *pts, unsigned c, unsigned s) { uint32_t st = 0; uint32_t umsk = 0, omsk = 0; long err = 0; int key; if ( s < NumberOf(ampBuffers[0].vals) ) { /* They want to read stripline signals */ key = epicsInterruptLock(); /* get cached copies */ st = ampBuffers[c].status; pai->val = ampBuffers[c].vals[s]; *pts = ampBuffers[c].timeStamp; epicsInterruptUnlock(key); omsk = BPM_AMPL_OVR(0) << (s % BPM_NUM_VALS); umsk = BPM_AMPL_UDR(0) << (s % BPM_NUM_VALS); err = drvBpm_map_status(st, omsk, umsk); /* NO aslo/aoff scaling on the raw signals */ err |= STAT_NO_CVT; } else if ( (s-=NumberOf(ampBuffers[0].vals)) < NumberOf(bpmResults[0]) ) { BpmNumber newScl = (0. == pai->aslo ? 1.0 : pai->aslo); BpmNumber newOff = pai->aoff; switch ( pai->linr ) { case menuConvertNO_CONVERSION: break; case menuConvertLINEAR: case menuConvertSLOPE: if ( 0. != pai->eslo ) { newScl *= pai->eslo; newOff *= pai->eslo; } newOff += pai->eoff; break; default: assert( 0 == "breakpoint table conversion not implemented"); break; } /* cache possibly new values for ASLO/AOFF */ key = epicsInterruptLock(); bpmResultsScl[c][s] = newScl; bpmResultsOff[c][s] = newOff; pai->val = bpmResults[c][s]; err = bpmStatus[c]; *pts = bpmTimeStamp[c]; epicsInterruptUnlock(key); /* A hack; if we are reading TMIT flagged as underflown * then de-escalate from INVALID_ALARM to MAJOR_ALARM */ if ( RES_T == s && ENC_ST_SVR(LOLO_ALARM, INVALID_ALARM) == err ) { /* If llsv is set then de-escalate to OK so that the database * limits are used. */ if ( pai->llsv ) err = 0; else err = ENC_ST_SVR(LOLO_ALARM, MAJOR_ALARM); } /* PINC was not scaled by low-level code - all others were */ if ( RES_C != s ) err |= STAT_NO_CVT; #ifdef __PPC__ if ( 5 == s ) { uint32_t tbl; __asm__ __volatile__ ("mftb %0":"=r"(tbl)); tbl -= ampBuffers[c].timeStamp.nsec; if ( tbl > totTimeMax ) totTimeMax = tbl; /* to read AVG, divide by 16 */ totTimeAvg += (tbl - (totTimeAvg >> 4)); } #endif } else { return -1; } return err; } long drvBpm_read_raw_ai(aiRecord *pai) { return drvBpm_read_raw_ai_helper(pai, generic_cb); } long drvBpm_read_raw_stat(longinRecord *pli) { unsigned c = pli->inp.value.vmeio.card; /* unsigned s = pli->inp.value.vmeio.signal; */ int key; key = epicsInterruptLock(); pli->val = ampBuffers[c].status; /* get cached copy */ if ( epicsTimeEventDeviceTime == pli->tse ) pli->time = ampBuffers[c].timeStamp; epicsInterruptUnlock(key); if ( pli->time.secPastEpoch == 0 ) { epicsTimeGetCurrent(&pli->time); } return 0; } long drvBpm_init_raw_stat(void *record_p) { longinRecord *li_ps = record_p; if ( VME_IO != li_ps->inp.type ) { errlogPrintf("drvBpm_init_raw_stat(%s): INP must be VMEIO\n", li_ps->name); goto egress; } return 0; egress: li_ps->pact = TRUE; return -1; } long drvBpm_read_raw_ai_helper(aiRecord *pai, DrvBpm_read_raw_ai_cb cb) { unsigned c = pai->inp.value.vmeio.card; unsigned s = pai->inp.value.vmeio.signal; TimeStamp ts; int err = 0; if ( c >= MAX_BPM ) { pai->pact = TRUE; errlogPrintf("drvBpm_read_raw_ai_helper (rec: %s) -- invalid channel # %i\n", pai->name, c); return -1; } ts.secPastEpoch = 0; err = cb(pai, &ts, c, s); /* Should we set the timestamp ? */ if ( epicsTimeEventDeviceTime == pai->tse ) { if ( ts.secPastEpoch ) pai->time = ts; else epicsTimeGetCurrent(&pai->time); } if ( -1 == err ) { pai->pact = TRUE; errlogPrintf("drvBpm_read_raw_ai_helper (rec: %s) -- invalid signal # %i\n", pai->name, s); return -1; } if ( ! (STAT_NO_CVT & err) ) { /* Linear transformation just with ASLO/AOFF */ if ( pai->aslo ) pai->val *= pai->aslo; pai->val += pai->aoff; } pai->udf = isnan(pai->val); if ( INVALID_ALARM == setStatFromErr((dbCommon*)pai, err) ) pai->udf = TRUE; return 2; } /* For now there is no need to make this public */ typedef struct DevAiRawBpmDpvt_ts_ { struct DrvPadUdpCommDpvtRec_ drvPadUdpCommPart; } DevAiRawBpmDpvt_ts, *DevAiRawBpmDpvt_tps; static long init_bpm_results_cb(aiRecord *ai_ps, unsigned c, unsigned s) { int sres = s - NumberOf(ampBuffers[0].vals); if ( c >= MAX_BPM ) { errlogPrintf("drvBpm_init_raw_ai(%s): INP #C must be < %u\n", ai_ps->name, MAX_BPM); return -1; } if ( sres < 0 ) return 0; if ( sres >= NUM_RES ) { errlogPrintf("drvBpm_init_raw_ai(%s): VMEIO INP 'Signal' must be < %u\n", ai_ps->name, NUM_RES + (s-sres) ); return -1; } /* initializei FCOM blob headers */ if ( RES_X == sres ) { /* First make sure we have matching layouts: */ if ( sizeof(bpmResults[c][sres]) != sizeof( ((FcomBlobRef)0)->fcbl_bpm_X ) ) { errlogPrintf("drvBpm_init_raw_ai(%s): FATAL PROGRAMMING ERROR -- internal data size doesn't match chosen FCOM type\n", ai_ps->name); errlogFlush(); abort(); } if ( &((FcomBlobRef)0)->fcbl_bpm_X - &((FcomBlobRef)0)->fc_flt[0] != RES_X - RES_X ) { errlogPrintf("drvBpm_init_raw_ai(%s): FATAL PROGRAMMING ERROR -- internal layout doesn't match chosen FCOM layout (X)\n", ai_ps->name); errlogFlush(); abort(); } if ( &((FcomBlobRef)0)->fcbl_bpm_Y - &((FcomBlobRef)0)->fc_flt[0] != RES_Y - RES_X ) { errlogPrintf("drvBpm_init_raw_ai(%s): FATAL PROGRAMMING ERROR -- internal layout doesn't match chosen FCOM layout (Y)\n", ai_ps->name); errlogFlush(); abort(); } if ( &((FcomBlobRef)0)->fcbl_bpm_T - &((FcomBlobRef)0)->fc_flt[0] != RES_T - RES_X ) { errlogPrintf("drvBpm_init_raw_ai(%s): FATAL PROGRAMMING ERROR -- internal layout doesn't match chosen FCOM layout (TMIT)\n", ai_ps->name); errlogFlush(); abort(); } bpmBlobs[c].fc_vers = FCOM_PROTO_VERSION; bpmBlobs[c].fc_type = FCOM_EL_FLOAT; bpmBlobs[c].fc_nelm = 3; bpmBlobs[c].fc_flt = &bpmResults[c][RES_X]; if ( FCOM_ID_NONE == (bpmBlobs[c].fc_idnt = fcomLCLSPV2FcomID(ai_ps->name)) ) { errlogPrintf("drvBpm_init_raw_ai(%s): CONFIGURATION ERROR -- unable to determine FCOM ID; NOT using FCOM for this channel\n", ai_ps->name); } else { fcomOutStateMask |= (1<aslo ? 1.0 : ai_ps->aslo); bpmResultsOff[c][sres] = ai_ps->aoff; return 0; } long drvBpm_init_raw_ai_helper(aiRecord *ai_ps, DrvBpm_init_raw_ai_cb cb) { unsigned c = ai_ps->inp.value.vmeio.card; unsigned s = ai_ps->inp.value.vmeio.signal; DevAiRawBpmDpvt_tps dpvt_ps; if ( VME_IO != ai_ps->inp.type ) { errlogPrintf("drvBpm_init_raw_ai(%s): INP must be VMEIO\n", ai_ps->name); goto egress; } if ( !(dpvt_ps = calloc(1, sizeof(*dpvt_ps))) ) { epicsPrintf("drvBpm_init_raw_ai(%s): Error -- no memory\n", ai_ps->name); goto egress; } ai_ps->dpvt = dpvt_ps; if ( drvPadUdpCommDpvtInit(&dpvt_ps->drvPadUdpCommPart, ai_ps->inp.value.vmeio.card) ) goto egress; if ( cb && cb(ai_ps, c, s) ) goto egress; return 0; egress: ai_ps->pact = TRUE; return -1; } long drvBpm_init_raw_ai(aiRecord *pai) { return drvBpm_init_raw_ai_helper(pai, init_bpm_results_cb); } long drvBpm_init_raw_ai_generic(void *precord) { return drvBpm_init_raw_ai_helper((aiRecord*)precord, 0); } static long bpmReport(int level) { int N = sizeof(digiHasOvfl)/sizeof(digiHasOvfl[0]); char ovflSup[ N + 1]; int i,j; char ch; epicsPrintf("Generic BPM Support\n"); if ( level > 0 ) { epicsPrintf("Max processing time (ticks) %d\n", (unsigned)drvBpmMaxProcessingTime); epicsPrintf("Max total time (ticks) %d\n", (unsigned)drvBpmMaxTotalTime); i = N; ovflSup[--i] = 0; /* terminating 0 */ for ( j=0; i>=0; j++, i-- ) { if ( DIGI_HAS_OVFL_SUP(j) ) ch = 'Y'; else if ( DIGI_OVFL_NO_SUP == digiHasOvfl[j] ) ch = 'N'; else ch = 'X'; ovflSup[i] = ch; } epicsPrintf("Digitizer hardware overflow detection: %s\n", ovflSup); } return 0; } long bpmInit(void) { int i,j; for ( i=0; ie) #define PSI (psub->f) #define PCADJ (psub->k) long drvBpmBvectSetupSub(subRecord *psub) { int key; unsigned c = psub->l; BpmNumber *prot; BpmNumber cpsi, spsi, ruu, ruv, rvu, rvv; if ( c >= MAX_BPM ) { psub->pact=TRUE; errlogPrintf("drvBpmBvectSetupSub - invalid channel # %i (INPL)\n", c); return -1; } /* Did one of the parameters change */ if ( PHI != psub->le || PSI != psub->lf || PCADJ != psub->lk ) { /* compute new values */ cpsi = cos(PSI*RAD); spsi = sin(PSI*RAD); if ( spsi < ZERO_PT_5 ) { /* Invalid */ recGblSetSevr(psub, CALC_ALARM, INVALID_ALARM); psub->udf = TRUE; return 0; } /* uu */ ruu = sin((PSI-PHI)*RAD)/spsi; ruv = sin(PHI*RAD) /spsi; rvu = -cos((PSI-PHI)*RAD)/spsi; rvv = cos(PHI*RAD) /spsi; prot = bpmRot[c]; /* store a consistent set */ key = epicsInterruptLock(); prot[ROT_UU] = ruu; prot[ROT_UV] = ruv; prot[ROT_VU] = rvu; prot[ROT_VV] = rvv; bpmCosPsi[c] = cpsi; bpmSinPsi[c] = spsi; bpmPincAdj[c]= PCADJ; epicsInterruptUnlock(key); psub->le = PHI; psub->lf = PSI; psub->lk = PCADJ; if ( spsi < 0.5 ) { /* Invalid; PSI too small */ recGblSetSevr(psub, CALC_ALARM, INVALID_ALARM); psub->udf = TRUE; } } return 0; } DrvPadUdpCommHWTime drvBpmMaxProcessingTimeReset(int doit) { DrvPadUdpCommHWTime rval = drvBpmMaxProcessingTime; if ( doit ) drvBpmMaxProcessingTime = 0; return rval; } DrvPadUdpCommHWTime drvBpmMaxTotalTimeReset(int doit) { DrvPadUdpCommHWTime rval = drvBpmMaxTotalTime; if ( doit ) drvBpmMaxTotalTime = 0; return rval; } static const struct iocshArg do_rst_args[] = { { "do_reset_if_nonzero", iocshArgInt, }, }; static const struct iocshArg *do_rst_bloat[] = { &do_rst_args[0], }; static void mptFunc(const iocshArgBuf *args) { epicsPrintf("%d\n", (unsigned)drvBpmMaxProcessingTimeReset(args[0].ival)); } static void mttFunc(const iocshArgBuf *args) { epicsPrintf("%d\n", (unsigned)drvBpmMaxTotalTimeReset(args[0].ival)); } static const iocshFuncDef mptDesc = { "drvBpmMaxProcessingTimeReset", sizeof(do_rst_bloat)/sizeof(do_rst_bloat[0]), do_rst_bloat }; static const iocshFuncDef mttDesc = { "drvBpmMaxTotalTimeReset", sizeof(do_rst_bloat)/sizeof(do_rst_bloat[0]), do_rst_bloat }; static void drvBpmRegistrar(void) { iocshRegister( &mptDesc, mptFunc ); iocshRegister( &mttDesc, mttFunc ); } epicsRegisterFunction(drvBpmBvectSetupSub); epicsExportRegistrar(drvBpmRegistrar);