/* $Id: devAoBpmParms.c,v 1.1 2013/03/12 14:44:01 strauman Exp $ */ #include #include #include #include #include #include #include #define NumberOfEls(arr) (sizeof(arr)/sizeof(arr[0])) BpmNumber drvBpmParms[NUM_BPM_PARMS][MAX_BPM]; static long report(int level) { epicsPrintf("devAoBpmParms: write parameters from VAL to memory cache\n"); return 0; } static long init_record(struct aoRecord *pao) { int c,s; if ( VME_IO != pao->out.type ) { epicsPrintf("devAoBpmParms: ERROR - OUT link is not of type VME_IO\n"); goto bail; } c = pao->out.value.vmeio.card; s = pao->out.value.vmeio.signal; if ( 0 > c || NumberOfEls(drvBpmParms[0]) <= c ) { epicsPrintf("devAoBpmParms: ERROR - OUT link 'card' # (%i) out of range\n", c); goto bail; } if ( 0 > s || NumberOfEls(drvBpmParms) <= s ) { epicsPrintf("devAoBpmParms: ERROR - OUT link 'signal' # (%i) out of range\n", s); goto bail; } /* A paranoia check */ if ( sizeof(BpmNumber) != sizeof(drvBpmParms[0][0]) ) { epicsPrintf("devAoBpmParms: FATAL ERROR - SIZE MISMATCH\n"); errlogFlush(); abort(); } pao->dpvt = &drvBpmParms[s][c]; pao->udf = FALSE; return 2; /* No convert */ bail: pao->pact = TRUE; return -1; } static long write_ao(struct aoRecord *pao) { /* ASSUME: writes to 'double' (and reads) are ATOMIC * so that we don't need to bother with synchronization. * This should only be an issue if memory is misaligned * or the CPU operates with soft-float. * We assume neither of these apply and the access happens * with a single instruction. */ *(BpmNumber*)pao->dpvt = pao->val; return 0; } static struct { long number; DEVSUPFUN report; DEVSUPFUN init; DEVSUPFUN init_record; DEVSUPFUN get_ioint_info; DEVSUPFUN write; DEVSUPFUN special_linconv; } devAoBpmParms = { 6, (DEVSUPFUN) report, 0, (DEVSUPFUN) init_record, 0, (DEVSUPFUN) write_ao, 0 }; epicsExportAddress(dset,devAoBpmParms);