#ifndef DRV_PAD_UDP_COMM_H #define DRV_PAD_UDP_COMM_H #include #include #include #include #include #include /* Max # BPMs supported per IOC */ #define MAX_BPM 25 #ifdef __cplusplus extern "C" { #endif /* socket descriptor for sending requests to PAD */ extern int drvPadUdpCommSd; /* PAD IP and port */ extern char *drvPadUdpCommPeerIp; extern int drvPadUdpCommPort; /* timeout (in ms) when waiting for a reply or streamed data */ extern int drvPadUdpCommTimeout; /* This routine may return 0 if no data is * available (=> READ_ALARM) (this also may * indicate that the slot number is out of range). * * If a non-null item is returned, * the user must free it with * padDataFree(); */ void * padDataGet(unsigned slot, PadDataKind kind); /* padDataGet() obtains an opaque object. * In order to retrieve the 'PadReply' data structure * you must call 'padReplyFind()'... */ PadReply padReplyFind(void *data_p); /* release a waveform object */ void padDataFree(void *item); /* get a new 'transaction ID'; a global counter * is incremented atomically by this routine * (but you may use a different policy for the * transaction id that is passed to 'padRequest'). */ uint32_t drvPadUdpCommGetXid(); /* retrieve the number of samples (global constant * for now) per channel. */ int drvPadUdpCommGetNsamples(/*int channel*/); /* Send a 'start' command to one ('channel'#) or all (channel < 0) * PADs tagging the streamed data with transaction ID 'xid'. * * RETURNS: return code of underlying 'padRequest()' call. */ int drvPadUdpCommSendStartCmd(int nsamples, uint32_t xid, int channel); /* Convenience wrapper using drvPadUdpCommGetNsamples() and * drvpadUdpCommGetXid() and broadcast to all PADs using * timestamp '*ts_p' (may be NULL and zero timestamps are used). * * RETURNS: return code of underlying 'padRequest()' call. */ int drvPadUdpCommSendStartAll(epicsTimeStamp *ts_p); /* All device support modules using drvPadUdpCommGetIointInfo() * must include the struct DrvPadUdpCommDpvtRec_ at the beginning * of their respective DPVT structs. */ typedef struct DrvPadUdpCommDpvtRec_ { unsigned channel; /* BPM / channel this record represents */ } DrvPadUdpCommDpvtRec, *DrvPadUdpCommDpvt; /* Initialize the above struct */ int drvPadUdpCommDpvtInit(DrvPadUdpCommDpvt padUdpCommPart, unsigned channel); /* get_ioint_info routine to put a record on the BPM scanning * list. */ long drvPadUdpCommGetIointInfo(int cmd, struct dbCommon *precord, IOSCANPVT *ppvt); /* read function for ai records. INP *must* be a VMEIO; * 'card #' is the BPM number, slot identifies the detail: * s = 0 -> GRN * s = 1 -> RED * s = 2 -> BLU * s = 3 -> YLO * s = 4..6 -> calibration ratios */ long drvPadUdpComm_read_raw_ai_stripl(aiRecord *pai); /* Write Simulated BPM readings to the PAD */ /* x,y, position (normalized to BPM radius) * q arbitrary scale. The simulator produces a * full scale data for (strip) values of ~200k * * -> to produce full scale at 1/2 of the BPM radius * * RETURNS: 0 on success, nonzero on error (pad # invalid) */ int drvPadUdpCommSimulatePos(unsigned pad, float x, float y, float q, float phi, float psi, float w); /* Request a PAD to start/stop streaming; * RETURNS: 0 on success; nonzero on error (invalid * channel, remote request failure). */ int drvPadUdpCommStrmStartReq(int channel); int drvPadUdpCommStrmStopReq(int channel); #ifdef __cplusplus } #endif #endif