/* $Id: devMbboMpsLinkNode.c,v 1.4 2009/04/28 19:13:46 dayle Exp $ */ /*============================================================================= Name: devMbboMps.c Abs: Auth: Rev: -----------------------------------------------------------------------------*/ #if 0 #include "copyright_SLAC.h" /* SLAC copyright comments */ #endif /*----------------------------------------------------------------------------- Mod: (see CVS log) =============================================================================*/ #include #include #include #include #include #include /* for S_dev_no_memory */ #include #include #include #include #include #include #include "drvMpsLinkNode.h" typedef struct mbboMps_s { int routine; int module; } mbboMps_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 devMbboMpsFlag = 2; #endif LOCAL long report(int interest); LOCAL long init_mbbo(); LOCAL long write_mbbo(); MBBODSET devMbboMpsLinkNode = { 5, report, 0, init_mbbo, 0, write_mbbo }; epicsExportAddress(dset, devMbboMpsLinkNode); static long report(int interest) { epicsPrintf(" Mpsdevice support for mbbo\n"); return 0; } static long init_mbbo(mbboRecord *pmbbo) { mbboMps_t *pmbbop; /* Allocate the memory for this records private data structure */ pmbbop = (mbboMps_t *) malloc(sizeof(mbboMps_t)); if (pmbbop == NULL) { #ifdef DEBUG_PRINT DEBUGPRINT(DP_ERROR, devMbboMpsFlag, ("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->module)); #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devMbboMpsFlag, ("init_mbbo: %s: has parm: %s\n", pmbbo->name, pmbbo->out.value.instio.string)); DEBUGPRINT(DP_INFO, devMbboMpsFlag, ("init_mbbo: %s's dpvt has routine: %d %d\n", pmbbo->name, pmbbop->routine, pmbbop->module)); #endif break; default: #ifdef DEBUG_PRINT DEBUGPRINT(DP_ERROR, devMbboMpsFlag, ("init_mbbo: %s: unrecognized link type\n", pmbbo->name)); #endif return ERROR; } return OK; } static long write_mbbo(mbboRecord *pmbbo) { mbboMps_t *pmbbop; int rc; /* Set this to facilitate easy access to index field */ if (pmbbo->dpvt == NULL) { #ifdef DEBUG_PRINT DEBUGPRINT(DP_ERROR, devMbboMpsFlag, ("write_mbbo: %s: dpvt is NULL\n", pmbbo->name)); #endif return ERROR; } pmbbop = (mbboMps_t *)pmbbo->dpvt; #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devMbboMpsFlag, ("record %s setting laser source to: %i\n", pmbbo->name, pmbbo->val)); #endif switch (pmbbop->routine) { /* case 0: rc = mpsSetLinkNodeType( pmbbo->val ); break; */ case 1: rc = mpsSetCSR1TriggerSourceSelect( pmbbop->module, pmbbo->val ); break; case 2: rc = mpsSetCSR1DiagnosticModeSelect( pmbbop->module, pmbbo->val ); break; case 3: rc = mpsSetCSR3SyncOutputPulseSourceSelectionMUX( pmbbop->module, pmbbo->val ); break; } pmbbo->rbv = pmbbo->val; return pmbbo->val; }