/*============================================================================= Name: devLongoutPad.c Abs: Device support for LCLS Beam Charge 4 channel ADC module (Arcturus Coldfire 5282 processor with LTC2208 ADC) longout records. Derived from $EPICS/base/src/rec/longoutRecord.c Auth: 16-nov-2005, Dayle Kotturi (dayle): Initial version for LLRF PAD -----------------------------------------------------------------------------*/ #include "copyright_SLAC.h" /* SLAC copyright comments */ /*----------------------------------------------------------------------------- Mod: (newest to oldest) xx-xxx-2007, Dayle Kotturi: xxxxxxxxxxxxxxxxxxx =============================================================================*/ #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 "longoutRecord.h" /* for longoutRecord structure */ #include "epicsExport.h"/* for epicsExportAddress */ #include /* for DEBUGPRINT */ #include "drvPad.h" /* for pad* */ typedef struct loPad_s { int routine; /* O=sample offset, 1=sample size */ int type; /* 0=raw interlaced, 1=raw non-interlaced */ int channel; int sample; } loPad_t; typedef struct { long number; DEVSUPFUN report; DEVSUPFUN init; DEVSUPFUN init_record; DEVSUPFUN get_ioint_info; DEVSUPFUN write_write; } LONGDSET; #ifdef DEBUG_PRINT int devLongoutPadFlag = 4; #endif LOCAL long init_longout(); LOCAL long longout_ioinfo(); LOCAL long write_longout(); LONGDSET devLongoutPad = {5, NULL, NULL, init_longout, longout_ioinfo, write_longout}; epicsExportAddress(dset, devLongoutPad); LOCAL long init_longout(struct longoutRecord *plongout) { loPad_t *plop; /* Allocate the memory for this records private data structure */ plop = (loPad_t *) malloc(sizeof(loPad_t)); if (plop == NULL) { #ifdef DEBUG_PRINT DEBUGPRINT(DP_ERROR, devLongoutPadFlag, ("init_longout: %s: out of memory\n", plongout->name)); #endif return S_dev_noMemory; } /* Read the DBLINK "out" field to get the routine */ DEBUGPRINT(DP_INFO, devLongoutPadFlag, ("init_longout: %s: has parm: %s\n", plongout->name, plongout->out.value.instio.string)); sscanf(plongout->out.value.instio.string, "%d %d %d %d", &(plop->routine), &(plop->type), &(plop->channel), &(plop->sample)); DEBUGPRINT(DP_INFO, devLongoutPadFlag, ("init_longout: %s's dpvt has routine: %d, type: %d, channel %d and sample: %d\n", plongout->name, plop->routine, plop->type, plop->channel, plop->sample)); /* Tell the record about its private data structure */ plongout->dpvt = plop; return 0; } LOCAL long longout_ioinfo( int cmd, struct longoutRecord *plongout, IOSCANPVT *ppvt ) { return 0; } LOCAL long write_longout(struct longoutRecord *plongout) { int rc; loPad_t *plop; /* Set this to facilitate easy access to index field */ if (plongout->dpvt == NULL) { DEBUGPRINT(DP_ERROR, devLongoutPadFlag, ("write_longout: %s: dpvt is NULL\n", plongout->name)); return ERROR; } plop = (loPad_t *)plongout->dpvt; switch (plop->routine) { case 0: rc = padSetSampleOffset(plop->channel, plop->sample, (int)plongout->val); if (rc == ERROR) { DEBUGPRINT(DP_ERROR, devLongoutPadFlag, ("write_longout: %s: unable to set sample offset to: %d", plongout->name, (int) plongout->val)); /*plongout->sevr = INVALID; or something */ } break; case 1: rc = padSetSampleSize(plop->type, plop->channel, plop->sample, (int)plongout->val); if (rc == ERROR) { DEBUGPRINT(DP_ERROR, devLongoutPadFlag, ("write_longout: %s: unable to set sample size to: %d", plongout->name, (int) plongout->val)); /* plongout->sevr = INVALID; or something */ } break; default: rc = ERROR; DEBUGPRINT(DP_ERROR, devLongoutPadFlag, ("write_longout: %s: unrecognized value in routine: %d", plongout->name, (int) plop->routine)); /* plongout->sevr = INVALID; or something */ } return rc; }