/*============================================================================= -----------------------------------------------------------------------------*/ #include "copyright_SLAC.h" /* SLAC copyright comments */ /*----------------------------------------------------------------------------- Mod: (newest to oldest) xx-xxx-2007, Robert Steele xx-xxx-2007, Dayle Kotturi: xxxxxxxxxxxxxxxxxxx =============================================================================*/ #include #include #include #include "alarm.h" #include "cvtTable.h" #include "dbDefs.h" #include "devLib.h" #include "dbAccess.h" #include "recSup.h" #include "callback.h" #include "devSup.h" #include "dbScan.h" /* for SCAN_IO_EVENT */ #include "link.h" #include "mbbiRecord.h" #include "epicsExport.h"/* for epicsExportAddress */ #include /* for DEBUGPRINT */ #include "drvPll.h" #include "pllChannel.hxx" #ifdef DEBUG_PRINT int devMbbiFlag = DP_ERROR; #endif typedef struct mbbiPll_s { int routine; } mbbiPll_t; typedef struct { long number; DEVSUPFUN report; DEVSUPFUN init; DEVSUPFUN init_record; DEVSUPFUN get_ioint_info; DEVSUPFUN read_write; } MBBIDSET; LOCAL long init_mbbi(struct mbbiRecord *pmbbi); LOCAL long mbbi_ioinfo( int cmd, struct mbbiRecord *pmbbi, IOSCANPVT *ppvt ); LOCAL long read_mbbi(struct mbbiRecord *pmbbi); MBBIDSET devMbbiPll = {5, NULL, NULL, (DEVSUPFUN) init_mbbi, (DEVSUPFUN) mbbi_ioinfo, (DEVSUPFUN) read_mbbi }; epicsExportAddress(dset, devMbbiPll); LOCAL long init_mbbi(struct mbbiRecord *pmbbi) { /* Tell the record about its private data structure */ mbbiPll_t *pmbbip; /* Allocate the memory for this records private data structure */ pmbbip = (mbbiPll_t *) malloc(sizeof(mbbiPll_t)); if (pmbbip == NULL) { DEBUGPRINT(DP_ERROR, devMbbiFlag, ("init_mbbi: %s: out of memory\n", pmbbi->name)); return S_dev_noMemory; } /* Read the DBLINK "out" field to get the routine */ sscanf(pmbbi->inp.value.instio.string, "%d", &(pmbbip->routine)); DEBUGPRINT(DP_INFO, devMbbiFlag, ("init_mbbi: %s: has parm: %s\n", pmbbi->name, pmbbi->inp.value.instio.string)); DEBUGPRINT(DP_INFO, devMbbiFlag, ("init_mbbi: %s's dpvt has routine: %d\n", pmbbi->name, pmbbip->routine)); /* Tell the record about its private data structure */ pmbbi->dpvt = pmbbip; return 0; } LOCAL long mbbi_ioinfo( int cmd, struct mbbiRecord *pmbbi, IOSCANPVT *ppvt ) { return 0; } LOCAL long read_mbbi(struct mbbiRecord *pmbbi) { int rc = 0; mbbiPll_t *pmbbip; /* Set this to facilitate easy access to index field */ if (pmbbi->dpvt == NULL) { DEBUGPRINT(DP_ERROR, devMbbiFlag, ("write_mbbi: %s: dpvt is NULL\n", pmbbi->name)); return ERROR; } /* point to private data */ pmbbip = (mbbiPll_t *) pmbbi->dpvt; switch (pmbbip->routine) { case 0: pmbbi->rval = getTrackingMode(); break; case 1: pmbbi->rval = getAutotrackState(); break; default: return ERROR; } DEBUGPRINT(DP_INFO, devMbbiFlag, ("read_mbbi: %s: %d: %d\n", pmbbi->name, pmbbip->routine, (int) pmbbi->rval )); return rc; }