/*
* R+K 5757 AMP device support
*/
#include <epicsStdio.h>
#include <devCommonGpib.h>
#include <string.h>
#include <strings.h>
/******************************************************************************
*
* The following define statements are used to declare the names to be used
* for the dset tables.
*
* A DSET_AI entry must be declared here and referenced in an application
* database description file even if the device provides no AI records.
*
******************************************************************************/
#define DSET_AI devAiRK5757
#define DSET_AO devAoRK5757
#define DSET_BI devBiRK5757
#define DSET_BO devBoRK5757
#define DSET_EV devEvRK5757
#define DSET_LI devLiRK5757
#define DSET_LO devLoRK5757
#define DSET_MBBI devMbbiRK5757
#define DSET_MBBID devMbbidRK5757
#define DSET_MBBO devMbboRK5757
#define DSET_MBBOD devMbbodRK5757
#define DSET_SI devSiRK5757
#define DSET_SO devSoRK5757
#define DSET_WF devWfRK5757
#include <devGpib.h> /* must be included after DSET defines */
#define TIMEOUT 1.0 /* I/O must complete within this time */
#define TIMEWINDOW 2.0 /* Wait this long after device timeout */
/*static int rd_efast_data(struct gpibDpvt *pdpvt, int p1, int p2, char **p3);
*/
/******************************************************************************
* Strings used by the init routines to fill in the znam,onam,...
* fields in BI and BO record types.
******************************************************************************/
static char *POnOffList[] = { "POWER OFF", "POWER ON" };
static struct devGpibNames POnOffState = { 2, POnOffList, 0, 1 };
static char *ROnOffList[] = {"RF OFF", "RF ON"};
static struct devGpibNames ROnOffState = { 2, ROnOffList, 0, 1 };
/******************************************************************************
* Structures used by the init routines to fill in the onst,twst,... and the
* onvl,twvl,... fields in MBBI and MBBO record types.
*
* Note that the intExtSsBm and intExtSsBmStop structures use the same
* intExtSsBmStopList and intExtSsBmStopVal lists but have a different number
* of elements in them that they use... The intExtSsBm structure only represents
* 4 elements,while the intExtSsBmStop structure represents 5.
******************************************************************************/
/******************************************************************************
* String arrays for EFAST operations. The last entry must be 0.
*
* On input operations,only as many bytes as are found in the string array
* elements are compared. Additional bytes are ignored.
* The first matching string will be used as a match.
*
* For the input operations,the strings are compared literally! This
* can cause problems if the instrument is returning things like \r and \n
* characters. When defining input strings so you include them as well.
******************************************************************************/
static char *(POnOffState1[])={"M0\r\n","M1\r\n",0};
static char *(ROnOffState1[])={"P0\r\n","P1\r\n",0};
/******************************************************************************
* Array of structures that define all GPIB messages
* supported for this type of instrument.
******************************************************************************/
static struct gpibCmd gpibCmds[] = {
/* CMMAND 0 power ON/OFF ON=1 */
{&DSET_BO, GPIBEFASTO, IB_Q_LOW, NULL, NULL, 0, 127, NULL, 0, 0, POnOffState1, &POnOffState, NULL },
/* CMMAND 1 RF on/off on=1 */
{&DSET_BO, GPIBEFASTO, IB_Q_LOW, NULL, NULL, 0, 127, NULL, 0, 0, ROnOffState1, &ROnOffState, NULL },
/* CMMAND 2 Pon/off read */
{&DSET_BI, GPIBREAD, IB_Q_LOW, "M?\r\n", NULL, 0, 127, NULL, 0, 0, NULL, &POnOffState, NULL },
/* CMMAND 3 RFon/off read */
{&DSET_BI, GPIBREAD, IB_Q_LOW, "P?\r\n", NULL, 0, 127, NULL, 0, 0, NULL, &ROnOffState, NULL },
/* CMMAND 4 Foward power */
{&DSET_AI, GPIBREAD, IB_Q_LOW, "FMON\r\n", "%lf\r\n", 0, 2047, NULL, 0, 0, NULL, NULL, NULL },
/* CMMAND 5 Reflection power */
{&DSET_AI, GPIBREAD, IB_Q_LOW, "RMON\r\n", "%lf\r\n", 0, 2047, NULL, 0, 0, NULL, NULL, NULL },
/* CMMAND 6 ALARM */
{&DSET_LI, GPIBREAD, IB_Q_LOW, "ALM?\r\n", "%ld\r\n", 0, 2047, NULL, 0, 0, NULL, NULL, NULL },
/* CMMAND 7 reset */
{&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "R\r\n", 0, 127, NULL, 0, 0, NULL, NULL, NULL }
};
/* The following is the number of elements in the command array above. */
#define NUMPARAMS sizeof(gpibCmds)/sizeof(struct gpibCmd)
/******************************************************************************
* Initialize device support parameters
*
*****************************************************************************/
static long init_ai(int parm)
{
if(parm==0) {
devSupParms.name = "devRK5757";
devSupParms.gpibCmds = gpibCmds;
devSupParms.numparams = NUMPARAMS;
devSupParms.timeout = TIMEOUT;
devSupParms.timeWindow = TIMEWINDOW;
devSupParms.respond2Writes = -1;
}
return(0);
}
/******************************************************************************
*
* c code
*
*****************************************************************************/
mailto: makoto.tobiyama@kek.jp
Last update: 12/Jul/2010