/* $Id: devMbboLlrfPad.c,v 1.0 2013/11/21 16:47:02 scondam Exp $ */ /*============================================================================= Name: devMbboLlrfPad.c Abs: LLRF6 Device support for mbbo records Auth: Shantha Condamoor (scondam) Rev: Nov 21 2013 - Initial Release -----------------------------------------------------------------------------*/ #if 0 #include "copyright_SLAC.h" /* SLAC copyright comments */ #endif /*----------------------------------------------------------------------------- Mod: (see CVS log) =============================================================================*/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define MBBODPADSET "devMbboLlrfPad" typedef struct SetLlrfPadDpvtRec_ { int routine,station; LlrfOutNumber input_source; } SetLlrfPadDpvtRec, *SetLlrfPadDpvt; static long report_mbbo_lsr(int interest) { errlogPrintf(MBBODPADSET": Window Parameters device support for mbbo out\n"); return 0; } static long window_init_mbbo(mbboRecord *mbbo_p) { LlrfStation sta_p; SetLlrfPadDpvt dpvt; if ( mbbo_p->out.type != INST_IO ) { errlogPrintf("%s: invalid INP field -- must be INST_IO\n", mbbo_p->name); mbbo_p->pact = TRUE; return S_dev_badInpType; } dpvt = mallocMustSucceed( sizeof(*dpvt), "devMbboLlrfPad -- no memory for DPVT" ); sscanf(mbbo_p->out.value.instio.string, "%d %d", &(dpvt->routine), &(dpvt->station)); if ( ! (sta_p = llrfGetStation( dpvt->station ) ) ) { errlogPrintf("%s: invalid INP field -- bad 'card' value: %i\n", mbbo_p->name, dpvt->station); mbbo_p->pact = TRUE; return S_dev_badCard; } mbbo_p->dpvt = dpvt; epicsMutexMustLock( sta_p->mutex ); switch (dpvt->routine) { case SOURCE: { sta_p->input_source = dpvt->input_source = mbbo_p->rbv = (LlrfOutNumber) mbbo_p->val; lsrDiagSetInputSource(sta_p->index, (LlrfOutNumber) mbbo_p->val); break; } default: errlogPrintf("%s: invalid routine: %i\n", mbbo_p->name, dpvt->routine); } epicsMutexUnlock( sta_p->mutex ); return 0; } static long window_write_mbbo(mbboRecord *mbbo_p) { SetLlrfPadDpvt dpvt = mbbo_p->dpvt; LlrfStation sta_p; if ( ! (sta_p = llrfGetStation( dpvt->station ) ) ) { errlogPrintf("%s: invalid INP field -- bad 'card' value: %i\n", mbbo_p->name, dpvt->station); mbbo_p->pact = TRUE; return S_dev_badCard; } epicsMutexMustLock( sta_p->mutex ); switch (dpvt->routine) { case SOURCE: { sta_p->input_source = dpvt->input_source = mbbo_p->rbv = (LlrfOutNumber) mbbo_p->val; lsrDiagSetInputSource(sta_p->index, (LlrfOutNumber) mbbo_p->val); break; } default: errlogPrintf("%s: invalid routine: %i\n", mbbo_p->name, dpvt->routine); } epicsMutexUnlock( sta_p->mutex ); /* Nothing to do. They access the original waveform data */ return 0; } struct { long number; DEVSUPFUN report; DEVSUPFUN init; DEVSUPFUN init_record; DEVSUPFUN get_ioint_info; DEVSUPFUN write_mbbo; DEVSUPFUN special_linconv; }devMbboLlrfPad={ 6, report_mbbo_lsr, 0, window_init_mbbo, 0, window_write_mbbo, 0}; epicsExportAddress(dset,devMbboLlrfPad);