#include #include #include #include #include #include #include #include #include #include #include #include #include static long report_aao(int level) { errlogPrintf("AAO device support for setting BLM weight-function waveforms\n"); return 0; } typedef struct AaoDpvtRec_ { BlmStation sta_p; int channel; } AaoDpvtRec, *AaoDpvt; static long init_rec_aao(aaoRecord *aao_p) { BlmStation sta_p; AaoDpvt dpvt; if ( aao_p->out.type != VME_IO ) { errlogPrintf("%s: invalid INP field -- must be VME_IO\n", aao_p->name); aao_p->pact = TRUE; return S_dev_badInpType; } if ( ! (sta_p = blmGetStation( aao_p->out.value.vmeio.card ) ) ) { errlogPrintf("%s: invalid INP field -- bad 'card' value: %i\n", aao_p->name, aao_p->out.value.vmeio.card); aao_p->pact = TRUE; return S_dev_badCard; } if ( aao_p->out.value.vmeio.signal < 0 || aao_p->out.value.vmeio.signal >= sizeof( sta_p->chnls ) / sizeof( sta_p->chnls[0] ) ) { errlogPrintf("%s: invalid INP field -- bad 'signal' value: %i\n", aao_p->name, aao_p->out.value.vmeio.signal); aao_p->pact = TRUE; return S_dev_badSignal; } dpvt = mallocMustSucceed( sizeof(*dpvt), "devAaoBlmWght -- no memory for DPVT" ); dpvt->sta_p = sta_p; dpvt->channel = aao_p->out.value.vmeio.signal; aao_p->nelm = sizeof(sta_p->chnls[0].vec) / sizeof(sta_p->chnls[0].vec[0]); aao_p->ftvl = DRVBLM_INP_FTVL; aao_p->bptr = 0; /* let record support allocate a buffer */ aao_p->dpvt = dpvt; return 0; } static long write_aao(aaoRecord *aao_p) { AaoDpvt dpvt = aao_p->dpvt; BlmStation sta_p = dpvt->sta_p; void *ptr; int n,r; ptr = sta_p->chnls[dpvt->channel].vec; n = dbValueSize( aao_p->ftvl ) * aao_p->nord; r = dbValueSize( aao_p->ftvl ) * aao_p->nelm - n; epicsMutexMustLock( sta_p->mutex ); memcpy( ptr, aao_p->bptr, n ); memset( ptr + n, 0, r ); epicsMutexUnlock( sta_p->mutex ); /* Nothing to do. They access the original waveform data */ return 0; } static struct { long number; DEVSUPFUN report; DEVSUPFUN init; DEVSUPFUN init_record; DEVSUPFUN get_ioint_info; DEVSUPFUN read_aao; } devAaoBlmWght = { 5, report_aao, 0, init_rec_aao, 0, write_aao }; epicsExportAddress(dset, devAaoBlmWght);