#include #include #include #include #include #include #include #include #include #include #include #include /* for SCAN_IO_EVENT */ #include #include /* for biRecord structure */ #include /* for epicsExportAddress */ #include /* for DEBUGPRINT */ #include "drvMpsLinkNode.h" /* for mpsGet* routines */ typedef struct biMps_s { int routine; int channel; int type; } biMps_t; typedef struct { long number; DEVSUPFUN report; DEVSUPFUN init; DEVSUPFUN init_record; DEVSUPFUN get_ioint_info; DEVSUPFUN read_bi; } BIDSET; #ifdef DEBUG_PRINT int devBiMpsFlag = 0; #endif LOCAL long init_bi(); LOCAL long bi_ioinfo(); LOCAL long read_bi(); BIDSET devBiMpsLinkNode = { 5, NULL, NULL, init_bi, bi_ioinfo, read_bi }; epicsExportAddress(dset, devBiMpsLinkNode); LOCAL long init_bi(struct biRecord *pbi) { biMps_t *pbip; switch(pbi->inp.type) { case(INST_IO): /* Allocate the memory for this records private data structure */ pbip = (biMps_t *) malloc(sizeof(biMps_t)); if (pbip == NULL) { return S_dev_noMemory; } /* Tell the record about its private data structure */ pbi->dpvt = pbip; #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devBiMpsFlag, ("init_bi: %s: has parm: %s\n", pbi->name, pbi->inp.value.instio.string)); #endif sscanf(pbi->inp.value.instio.string, "%d %d %d", &(pbip->routine), &(pbip->channel), &(pbip->type)); #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devBiMpsFlag, ("init_bi: %s's dpvt has routine: %d, channel: %d type: %d\n", pbi->name, pbip->routine, pbip->channel, pbip->type)); #endif break; default: #ifdef DEBUG_PRINT DEBUGPRINT(DP_ERROR, devBiMpsFlag, ("init_bi: %s: illegal INP field: %d", pbi->name, (int) pbi->inp.type)); #endif return ERROR; break; } return OK; } LOCAL long bi_ioinfo( int cmd, struct biRecord *pbi, IOSCANPVT *ppvt ) { return OK; } LOCAL long read_bi(struct biRecord *pbi) { biMps_t *pbip; #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devBiMpsFlag, ("read_bi for %s\n", pbi->name)); #endif /* Set this to facilitate easy access to index field */ pbip = (biMps_t *)pbi->dpvt; switch(pbip->routine) { case 0: pbi->val = mpsGetRackLocked(); break; case 1: pbi->val = mpsGetCSR1MissedTriggerStatus(); break; case 2: pbi->val = mpsGetCSR1DataReady(); break; case 3: pbi->val = mpsGetCSR1GateGeneratorSelect(); break; case 4: pbi->val = mpsGetCSR1GatePolarity(); break; case 5: pbi->val = mpsGetCSR1GateEnable(); break; case 6: pbi->val = mpsGetCSR2D2LStatus(); break; case 7: pbi->val = mpsGetCSR2D4LStatus(); break; case 8: pbi->val = mpsGetCSR2TestPulseEnable(); break; case 9: pbi->val = mpsGetCSR2TestPulsePolarity(); break; case 10: pbi->val = mpsGetCSR2TestPulseTriggerSelect(); break; case 11: pbi->val = mpsGetCSR3SyncOutputEnable(); break; case 12: pbi->val = mpsGetCSR3SyncPulsePolarity(); break; case 13: pbi->val = mpsGetCSR3SyncOutputMode(); break; case 14: pbi->val = mpsGetCSR3ADCRangeControl(); break; case 15: pbi->val = mpsGetCSR3FBC(); break; case 16: pbi->val = mpsGetCSR3PICMode(); break; default: pbi->udf = 1; return ERROR; } #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devBiMpsFlag, ("%s's val is %d\n", pbi->name, pbi->val)); #endif return OK; }