#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 "longinRecord.h" /* for longinRecord structure */ #include "epicsExport.h"/* for epicsExportAddress */ #include /* for DEBUGPRINT */ #include "drvMpsLinkNode.h" /* for mpsGet* routines */ typedef struct liMps_s { int routine; int pic; int channel; int type; } liMps_t; typedef struct { long number; DEVSUPFUN report; DEVSUPFUN init; DEVSUPFUN init_record; DEVSUPFUN get_ioint_info; DEVSUPFUN read_write; } LONGDSET; #ifdef DEBUG_PRINT int devLonginMpsFlag = 4; #endif LOCAL long init_longin(); LOCAL long longin_ioinfo(); LOCAL long read_longin(); LONGDSET devLonginMpsLinkNode = {5, NULL, NULL, init_longin, longin_ioinfo, read_longin}; epicsExportAddress(dset, devLonginMpsLinkNode); LOCAL long init_longin(struct longinRecord *plongin) { liMps_t *plip; int debounceenum; switch(plongin->inp.type) { case(INST_IO): /* Allocate the memory for this records private data structure */ plip = (liMps_t *) malloc(sizeof(liMps_t)); if (plip == NULL) { return S_dev_noMemory; } /* Tell the record about its private data structure */ plongin->dpvt = plip; #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devLonginMpsFlag, ("init_longin: %s: has parm: %s\n", plongin->name, plongin->inp.value.instio.string)); #endif sscanf(plongin->inp.value.instio.string, "%d %d %d %d", &(plip->routine), &(plip->pic), &(plip->channel), &(plip->type)); #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devLonginMpsFlag, ("init_longin: %s's dpvt has routine: %d, pic: %d, ch: %d, type:%d\n", plongin->name, plip->routine, plip->pic, plip->channel, plip->type)); #endif /* Do some work so that GUIs show correct values after iocInit. For the read-only variables, set up the global structure to match what is in the register */ switch (plip->routine) { case 0: /* this shouldnt be necess. the parsing does this call. why does GUI look wrong? 9/26/8 */ debounceenum = mpsGetDebounceEnum(plip->channel); mpsSetDebounceEnum(plip->channel, debounceenum); break; #ifdef GOING case 4: plongin->val = mpsSetLatched(plip->channel); break; #endif case 5: plongin->val = mpsSetState(plip->channel); /* state = !filtered */ break; } break; default: DEBUGPRINT(DP_ERROR, devLonginMpsFlag, ("init_longin: %s: illegal INP field: %d", plongin->name, (int) plongin->inp.type)); break; } return 0; } LOCAL long longin_ioinfo( int cmd, struct longinRecord *plongin, IOSCANPVT *ppvt ) { return 0; } LOCAL long read_longin(struct longinRecord *plongin) { liMps_t *plip; DEBUGPRINT(DP_INFO, devLonginMpsFlag, ("read_longin for %s\n", plongin->name)); /* Set this to facilitate easy access to index field */ plip = (liMps_t *)plongin->dpvt; DEBUGPRINT(DP_INFO, devLonginMpsFlag, ("read_longin routine %d\n", plip->routine)); switch(plip->routine) { case 0: plongin->val = mpsGetDebounceTime(plip->channel); break; case 1: plongin->val = (long) mpsGetAutobootTime(); break; case 2: plongin->val = mpsGetDeadMan(plip->channel); break; case 3: plongin->val = mpsGetAutoRecoverable(plip->channel); break; case 4: plongin->val = mpsGetLatched(plip->channel); break; case 5: plongin->val = mpsGetState(plip->channel); break; case 6: plongin->val = mpsGetLinkNodeType(); break; case 7: plongin->val = mpsGetPICThreshold(plip->pic, plip->channel, plip->type); break; case 8: plongin->val = mpsGetLinkNodeID(); break; case 9: plongin->val = mpsReadLinkNodeIDRotary(); break; case 10: /* Display this in hexadecimal */ plongin->val = mpsGetFPGAVersion(); break; case 11: /* Display this in hexadecimal */ plongin->val = mpsGetQADCFault(plip->channel, plip->type); break; case 12: plongin->val = mpsGetRackLocked(); break; case 13: /* Display this in hexadecimal */ plongin->val = mpsGetQADCCSR(plip->type); break; case 14: plongin->val = mpsGetCSR2TestAcquisitionDelayControl(); break; case 15: plongin->val = mpsGetTriggerDelay(); #ifdef DEBUG_PRINT DEBUGPRINT(DP_DEBUG, devLonginMpsFlag, ("%s got %d\n", plongin->name, plongin->val)); #endif break; case 16: plongin->val = mpsGetTriggerErrorCounter(); break; case 17: plongin->val = mpsGetTestPulseGeneratorDelay(); break; case 18: plongin->val = mpsGetTestPulseGeneratorWidth(); break; case 19: plongin->val = mpsGetGateGeneratorDelay(); break; case 20: plongin->val = mpsGetGateGeneratorWidth(); break; case 21: plongin->val = mpsGetSyncOutDelay(); break; case 22: plongin->val = mpsGetSyncOutWidth(); break; case 23: plongin->val = mpsGetGeneralPurposeIOControl(); break; case 24: plongin->val = mpsGetGateADCDelay(); break; case 25: plongin->val = mpsGetBeamToTestAcqDelay(); break; case 26: plongin->val = mpsGetTestToBaseAcqDelay(); break; case 27: plongin->val = mpsGetExtendedGateGeneratorDelay(); break; case 28: plongin->val = mpsGetExtendedGateGeneratorWidthLow(); break; case 29: plongin->val = mpsGetExtendedGateGeneratorWidthHigh(); break; case 30: plongin->val = mpsGetExtendedGateGeneratorWidth(); break; case 31: plongin->val = mpsGetFiducialDelay(); break; case 32: plongin->val = mpsGetFiducialWidth(); break; case 33: plongin->val = mpsGetFiducialDCMPhase(); break; default: plongin->udf = 1; return ERROR; } #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devLonginMpsFlag, ("%s's val is %d\n", plongin->name, plongin->val)); #endif return OK; }