/* $Id: devMbboLlrf.c,v 1.1.1.1.2.1 2014/03/06 18:33:18 khkim Exp $ */ /*============================================================================= Name: devMbboLlrf.c Abs: Auth: Rev: -----------------------------------------------------------------------------*/ #if 0 #include "copyright_SLAC.h" /* SLAC copyright comments */ #endif /*----------------------------------------------------------------------------- Mod: (see CVS log) =============================================================================*/ #include #include #include #include #include #include #include /* for S_dev_no_memory */ #include #include #include #include #include #include #include "llrfMacros.h" #include "drvLlrf.h" typedef struct mbboLlrf_s { int routine; int station; } mbboLlrf_t; typedef struct { long number; DEVSUPFUN report; DEVSUPFUN init; DEVSUPFUN init_record; DEVSUPFUN get_ioint_info; DEVSUPFUN write; } MBBODSET; /* 11/21/8 Writing errors (level 2) has become too invasive to the processor w.r.t. processing the incoming data streams. Set this to 0 */ #ifdef DEBUG_PRINT int devMbboLlrfFlag = 0; #endif LOCAL long report(int interest); LOCAL long init_mbbo(); LOCAL long write_mbbo(); MBBODSET devMbboLlrf = { 5, report, 0, init_mbbo, 0, write_mbbo }; epicsExportAddress(dset, devMbboLlrf); static long report(int interest) { epicsPrintf(" Llrfdevice support for mbbo\n"); return 0; } static long init_mbbo(mbboRecord *pmbbo) { mbboLlrf_t *pmbbop; /* Allocate the memory for this records private data structure */ pmbbop = (mbboLlrf_t *) malloc(sizeof(mbboLlrf_t)); if (pmbbop == NULL) { #ifdef DEBUG_PRINT DEBUGPRINT(DP_ERROR, devMbboLlrfFlag, ("init_mbbo: %s: out of memory\n", pmbbo->name)); #endif return S_dev_noMemory; } /* Tell the record about its private data structure */ pmbbo->dpvt = pmbbop; switch(pmbbo->out.type) { case(INST_IO): sscanf(pmbbo->out.value.instio.string, "%d %d", &(pmbbop->routine), &(pmbbop->station)); #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devMbboLlrfFlag, ("init_mbbo: %s: has parm: %s\n", pmbbo->name, pmbbo->out.value.instio.string)); DEBUGPRINT(DP_INFO, devMbboLlrfFlag, ("init_mbbo: %s's dpvt has routine: %d\n", pmbbo->name, pmbbop->routine)); DEBUGPRINT(DP_INFO, devMbboLlrfFlag, ("init_mbbo: %s's dpvt has station: %d\n", pmbbo->name, pmbbop->station)); #endif break; default: #ifdef DEBUG_PRINT DEBUGPRINT(DP_ERROR, devMbboLlrfFlag, ("init_mbbo: %s: unrecognized link type\n", pmbbo->name)); #endif return ERROR; } return OK; } static long write_mbbo(mbboRecord *pmbbo) { mbboLlrf_t *pmbbop; int rc; /* Set this to facilitate easy access to index field */ if (pmbbo->dpvt == NULL) { #ifdef DEBUG_PRINT DEBUGPRINT(DP_ERROR, devMbboLlrfFlag, ("write_mbbo: %s: dpvt is NULL\n", pmbbo->name)); #endif return ERROR; } pmbbop = (mbboLlrf_t *)pmbbo->dpvt; #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devMbboLlrfFlag, ("record %s setting laser source to: %i\n", pmbbo->name, pmbbo->val)); #endif rc = llrfSetInputSource( pmbbop->station, pmbbo->val ); pmbbo->rbv = pmbbo->val; return pmbbo->val; }