#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 module; 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 = 2; #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 %d", &(pbip->routine), &(pbip->module), &(pbip->channel), &(pbip->type)); #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devBiMpsFlag, ("init_bi: %s's dpvt has routine: %d module: %d channel: %d type: %d\n", pbi->name, pbip->routine, pbip->module, 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(pbip->module); break; case 2: pbi->val = mpsGetCSR1DataReady(pbip->module); break; case 3: pbi->val = mpsGetCSR1GateGeneratorSelect(pbip->module); break; case 4: pbi->val = mpsGetCSR1GatePolarity(pbip->module); break; case 5: pbi->val = mpsGetCSR1GateEnable(pbip->module); break; case 6: pbi->val = mpsGetCSR2D2LStatus(pbip->module); break; case 7: pbi->val = mpsGetCSR2D4LStatus(pbip->module); break; case 8: pbi->val = mpsGetCSR2TestPulseEnable(pbip->module); break; case 9: pbi->val = mpsGetCSR2TestPulsePolarity(pbip->module); break; case 10: pbi->val = mpsGetCSR2TestPulseTriggerSelect(pbip->module); break; case 11: pbi->val = mpsGetCSR3SyncOutputEnable(pbip->module); break; case 12: pbi->val = mpsGetCSR3SyncPulsePolarity(pbip->module); break; case 13: pbi->val = mpsGetCSR3SyncOutputMode(pbip->module); break; case 14: pbi->val = mpsGetCSR3ADCRangeControl(pbip->module); break; case 15: pbi->val = mpsGetCSR3FBC(pbip->module); break; case 16: pbi->val = mpsGetCSR3PICMode(pbip->module); break; /* BYKIK Faults 4/7/9 */ case 17: pbi->val = mpsGetBYKOverThresholdFault(); #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devBiMpsFlag, ("read_bi: %s: mpsGetBYKOverThresholdFault returns %d\n", pbi->name, pbi->val)); #endif break; case 18: pbi->val = mpsGetBYKUnderThresholdFault(); #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devBiMpsFlag, ("read_bi: %s: mpsGetBYKUndeThresholdFault returns %d\n", pbi->name, pbi->val)); #endif break; case 19: pbi->val = mpsGetBXKickLatch(); #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devBiMpsFlag, ("read_bi: %s: mpsGetBXKickLatch returns %d\n", pbi->name, pbi->val)); #endif break; case 20: pbi->val = mpsGet30HzStdbyTriggerMissed(); #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devBiMpsFlag, ("read_bi: %s: mpsGet30HzStdbyTriggerMissed returns %d\n", pbi->name, pbi->val)); #endif break; case 21: pbi->val = mpsGet30HzAbortTriggerMissed(); #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devBiMpsFlag, ("read_bi: %s: mpsGet30HzAbortTriggerMissed returns %d\n", pbi->name, pbi->val)); #endif break; case 22: pbi->val = mpsGet120HzStdbyTriggerMissed(); #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devBiMpsFlag, ("read_bi: %s: mpsGet120HzStdbyTriggerMissed returns %d\n", pbi->name, pbi->val)); #endif break; case 23: pbi->val = mpsGet120HzAbortTriggerMissed(); #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devBiMpsFlag, ("read_bi: %s: mpsGet120HzAbortTriggerMissed returns %d\n", pbi->name, pbi->val)); #endif break; case 24: pbi->val = mpsGetPICHighVoltageStatus(); #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devBiMpsFlag, ("read_bi: %s: mpsGetPICHighVoltageStatus. returns %d\n", pbi->name, pbi->val)); #endif break; case 25: pbi->val = mpsGetPIC29HighVoltageStatus(); #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devBiMpsFlag, ("read_bi: %s: mpsGetPIC29HighVoltageStatus. returns %d\n", pbi->name, pbi->val)); #endif break; case 26: pbi->val = mpsGetBYKAbortTimingFault(); break; case 27: pbi->val = mpsGetBYKStandbyTimingFault(); break; case 28: pbi->val = mpsGetBYKBeamLossTimingFault(); break; default: pbi->udf = 1; #ifdef DEBUG_PRINT DEBUGPRINT(DP_ERROR, devBiMpsFlag, ("%s: unrecognized routine: %d\n", pbi->name, pbip->routine)); #endif return pbi->val; } #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devBiMpsFlag, ("%s's val is %d\n", pbi->name, pbi->val)); #endif pbi->udf = 0; /* without this, if val is 1, record has UDF = 1, which is not desired */ return pbi->val; }