/* To fill in this template search for * longin (record type) * Pad (device type) */ /*============================================================================= Name: devlonginPad.c Abs: Pad Device support for longin. Modelled after T.Straumann's BPM Application Code. Auth: Shantha Condamoor (scondam) Rev: May 23 2011 - Initial Release -----------------------------------------------------------------------------*/ #if 0 #include "copyright_SLAC.h" /* SLAC copyright comments */ #endif /*----------------------------------------------------------------------------- Mod: (see CVS log) =============================================================================*/ #include #include #include #include #include #include #include #include #define DEVSUPNAM "devLonginPad" static IOSCANPVT scanlist; typedef struct PadDpvt_ts_ { IOSCANPVT *scan_p; void (*readTrigRate)(void); void (*readIntrCount)(void); } PadDpvt_ts, *PadDpvt_tps; static long report(int interest) { errlogPrintf(DEVSUPNAM": Pad device support for longin\n"); return 0; } static long init(int after) { if ( !after ) { scanIoInit(&scanlist); } return 0; } static long init_record(void *record_p) { longinRecord *longin_ps = record_p; PadDpvt_tps dpvt_ps; if ( !(dpvt_ps = longin_ps->dpvt = malloc(sizeof(*dpvt_ps))) ) { errlogPrintf(DEVSUPNAM": No memory to allocate DPVT\n"); longin_ps->pact = 1; return -1; } dpvt_ps->scan_p = &scanlist; const char *x = longin_ps->inp.value.vmeio.parm; if ( x && strstr(x, "TrigRate") ) /* function that returns the current PAD trigger rate in Hz */ dpvt_ps->readTrigRate = padGetTriggerRate; if ( x && strstr(x, "IntrCount") ) /* function that returns the number of interrupts that occurred since boot */ dpvt_ps->readIntrCount = padGetCurrentIntrCount; return 0; } static long get_ioint_info(int cmd, struct dbCommon *record_ps, IOSCANPVT *pvt_ps) { PadDpvt_tps dpvt_ps = record_ps->dpvt; *pvt_ps = *dpvt_ps->scan_p; return 0; } static long read_longin(void *record_p) { longinRecord *longin_ps = record_p; const char *x = longin_ps->inp.value.vmeio.parm; PadDpvt_tps dpvt_ps = longin_ps->dpvt; if ( x && strstr(x, "TrigRate") ) /* function that returns the current PAD trigger rate in Hz */ longin_ps->val = padGetTriggerRate(); if ( x && strstr(x, "IntrCount") ) /* function that returns the number of interrupts that occurred since boot */ longin_ps->val = padGetCurrentIntrCount(); return 0; } struct { long number; DEVSUPFUN report; DEVSUPFUN init; DEVSUPFUN init_record; DEVSUPFUN get_ioint_info; DEVSUPFUN read; } devLonginPad = { 5, report, init, init_record, get_ioint_info, read_longin }; epicsExportAddress(dset, devLonginPad);