/* $Id: devCalcoutStripSim.c,v 1.4 2008/11/25 05:12:07 strauman Exp $ */ /* To fill in this template search for * Calcout (record type) * StripSim (device type) */ /*============================================================================= Name: devCalcoutStripSim.c Abs: StripSim Device support for Calcout. Auth: 10-oct-2006, Till Straumann (TSS) Rev: -----------------------------------------------------------------------------*/ #if 0 #include "copyright_SLAC.h" /* SLAC copyright comments */ #endif /*----------------------------------------------------------------------------- Mod: (see CVS log) =============================================================================*/ #include #include #include #include #include #include #include #include #include #include #define DEVSUPNAM "devCalcoutStripSim" typedef struct StripSimDpvt_ts_ { IOSCANPVT *scan_p; } StripSimDpvt_ts, *StripSimDpvt_tps; static long report(int interest) { epicsPrintf(DEVSUPNAM": StripSim device support for Calcout\n"); return 0; } static long init_record(void *record_p) { calcoutRecord *calcout_ps = record_p; StripSimDpvt_tps dpvt_ps; if ( !(dpvt_ps = calcout_ps->dpvt = malloc(sizeof(*dpvt_ps))) ) { epicsPrintf(DEVSUPNAM": No memory to allocate DPVT\n"); calcout_ps->pact = 1; return -1; } return 0; } static long write_calcout(void *record_p) { calcoutRecord *calcout_ps = record_p; unsigned long pad; char *endp; float parms[1]; /* calcout only seems to support constant and PV links :-( */ if ( calcout_ps->out.type != CONSTANT ) { errlogPrintf(DEVSUPNAM": invalid OUT type; must be CONSTANT"); goto egress; } pad = strtoul( calcout_ps->out.value.constantStr, &endp, 0); if ( endp == calcout_ps->out.value.constantStr ) { errlogPrintf(DEVSUPNAM": invalid OUT value; must be number"); goto egress; } parms[0] = calcout_ps->g; if ( drvPadUdpCommSimulatePos( pad, (int)calcout_ps->l, calcout_ps->b / calcout_ps->a, calcout_ps->c / calcout_ps->a, calcout_ps->d, calcout_ps->e, calcout_ps->f, parms) ) { errlogPrintf(DEVSUPNAM": invalid OUT value %li, must be < %i\n", pad, MAX_BPM); goto egress; } return 0; egress: calcout_ps->pact = TRUE; return -1; } struct { long number; DEVSUPFUN report; DEVSUPFUN init; DEVSUPFUN init_record; DEVSUPFUN get_ioint_info; DEVSUPFUN write; DEVSUPFUN special_linconv; } devCalcoutStripSim = { 6, report, 0, init_record, 0, write_calcout, 0 }; epicsExportAddress(dset, devCalcoutStripSim);