/*============================================================================= Name: devLonginBcc.c Abs: Device support for LCLS Beam Charge 4 channel ADC module (Arcturus Coldfire 5282 processor with LTC2208 ADC) longin records. Derived from $EPICS/base/src/rec/longinRecord.c Auth: 16-nov-2005, Dayle Kotturi (dayle): Initial version for LLRF PAD -----------------------------------------------------------------------------*/ #include "copyright_SLAC.h" /* SLAC copyright comments */ /*----------------------------------------------------------------------------- Mod: (newest to oldest) 18-jan-2007, Dayle Kotturi: Adapted for BeamChargeCFApp =============================================================================*/ #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 "drvBeamChargeCF.h" /* for bcc* */ typedef struct liBcc_s { int routine; int channel; } liBcc_t; typedef struct { long number; DEVSUPFUN report; DEVSUPFUN init; DEVSUPFUN init_record; DEVSUPFUN get_ioint_info; DEVSUPFUN read_write; } LONGDSET; #ifdef DEBUG_PRINT int devLonginBccFlag = 4; #endif LOCAL long init_longin(); LOCAL long longin_ioinfo(); LOCAL long read_longin(); LONGDSET devLonginBeamChargeCF = {5, NULL, NULL, init_longin, longin_ioinfo, read_longin}; epicsExportAddress(dset, devLonginBeamChargeCF); LOCAL long init_longin(struct longinRecord *plongin) { liBcc_t *plip; /* Allocate the memory for this records private data structure */ plip = (liBcc_t *) malloc(sizeof(liBcc_t)); if (plip == NULL) { DEBUGPRINT(DP_ERROR, devLonginBccFlag, ("init_longin: %s: out of memory\n", plongin->name)); return S_dev_noMemory; } /* Tell the record about its private data structure */ plongin->dpvt = plip; switch(plongin->inp.type) { case(INST_IO): DEBUGPRINT(DP_INFO, devLonginBccFlag, ("init_longin: %s: has parm: %s\n", plongin->name, plongin->inp.value.instio.string)); sscanf(plongin->inp.value.instio.string, "%d %d", &(plip->routine), &(plip->channel)); DEBUGPRINT(DP_INFO, devLonginBccFlag, ("init_longin: %s's dpvt has routine: %d and channel: %d\n", plongin->name, plip->routine, plip->channel)); break; default: DEBUGPRINT(DP_ERROR, devLonginBccFlag, ("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) { liBcc_t *plip; /* Set this to facilitate easy access to routine field */ plip = (liBcc_t *)plongin->dpvt; switch(plip->routine) { case 6: plongin->val = bccGetIntrCount(); break; case 7: plongin->val = bccGetScanIOCount(); break; case 8: plongin->val = bccGetNumShortsRead(plip->channel); break; case 9: plongin->val = bccGetSampleSize(plip->channel); break; case 10: plongin->val = bccGetSampleOffset(plip->channel); break; case 11: plongin->val = bccGetOverflowCount(); break; default: plongin->udf = 1; #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devLonginBccFlag, ("read_longin: %s: val is: %d", plongin->name, (int) plongin->val)); #endif return ERROR; } #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devLonginBccFlag, ("read_longin: %s: val is: %d", plongin->name, (int) plongin->val)); #endif /* If SCAN is "I/O Intr", use timestamp from Recv task; otherwise leave alone if (plongin->scan == SCAN_IO_EVENT && plongin->tse == -2) { bccOverwriting = TRUE; plongin->time = pnetGetRmsgTime(0); }*/ return OK; }