#include #include #include #include "mbbiRecord.h" /* for mbbiRecord structure */ #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 /* for epicsExportAddress */ #include /* for DEBUGPRINT */ #include "MachineRatesBuffer.h" #if 0 #pragma mark - #pragma mark MBBI Setup #endif /********************************************************************* * MBBI Setup ********************************************************************/ struct privateDataStruct { unsigned int type; unsigned int index; }; typedef struct privateDataStruct privateData; struct mbbiDsetStruct { long number; DEVSUPFUN report; DEVSUPFUN init; DEVSUPFUN init_record; DEVSUPFUN get_ioint_info; DEVSUPFUN read_mbbi; }; typedef struct mbbiDsetStruct mbbiDset; static long init_mbbi(); static long get_ioint_info(); static long read_mbbi(); mbbiDset devMbbiMpsLinkProcessor = { 5, /* number */ NULL, /* report */ NULL, /* init */ init_mbbi, /* init_record */ get_ioint_info, /* get_ioint_info */ read_mbbi}; /* read_mbbi */ epicsExportAddress(dset, devMbbiMpsLinkProcessor); #if 0 #pragma mark - #pragma mark MBBI Implementation #endif /********************************************************************* * MBBI Implementation ********************************************************************/ static long init_mbbi (struct mbbiRecord *pmbbi) { privateData *pdpvt; char *inpString; char *remainingInpString; if (pmbbi->inp.type != INST_IO) { errlogPrintf("init_mbbi: %s has incorrect INP field type: %d", pmbbi->name, (int) pmbbi->inp.type); return S_db_badField; } /* Allocate the memory for the private data structure */ pdpvt = (privateData *) malloc(sizeof(privateData)); if (pdpvt == NULL) { return S_dev_noMemory; } inpString = pmbbi->inp.value.instio.string; pdpvt->type = strtoul(inpString, &remainingInpString, 0); switch (pdpvt->type) { case 1: break; case 2: pdpvt->index = strtoul(remainingInpString, NULL, 0); break; default: errlogPrintf("init_mbbi: %s has unknown type: %u", pmbbi->name, pdpvt->type); return 0; } pmbbi->dpvt = pdpvt; return 0; } static long get_ioint_info ( int cmd, struct mbbiRecord *pmbbi, IOSCANPVT *ppvt) { return 0; } static long read_mbbi (struct mbbiRecord *pmbbi) { privateData *pdpvt; MPSBeamRate rate; pdpvt = (privateData *) pmbbi->dpvt; switch(pdpvt->type) { case 1: /* Mutex not locked -- value returned is below 255 and should not cause problems */ pmbbi->rval = getBeamDestination(); break; case 2: /* Mutex not locked -- value returned is below 255 and should not cause problems */ getRateAfterDevice(&rate, pdpvt->index); pmbbi->rval = rate; break; default: pmbbi->udf = 1; /* return a value that is not 0 or 2 to show there is an error */ return 1; } return 0; }