/* devSkiNIM.c */
/*
* Author: Makoto Tobiyama
* Date: 22/Nov/2017
*/
#include <epicsStdio.h>
#include <devCommonGpib.h>
#include <string.h>
#include <strings.h>
/***********************************************************************
* asynDriver is distributed subject to a Software License Agreement
* found in file LICENSE that is included with this distribution.
***********************************************************************/
| #define | DSET_AI | | devAiSKINIM |
| #define | DSET_AO | | devAoSKINIM |
| #define | DSET_BI | | devBiSKINIM |
| #define | DSET_BO | | devBoSKINIM |
| #define | DSET_LI | | devLiSKINIM |
| #define | DSET_LO | | devLoSKINIM |
| #define | DSET_MBBO | devMbboSKINIM |
| #define | DSET_MBBI | devMbbiSKINIM |
| #define | DSET_MBBOD | devMbbodSKINIM |
| #define | DSET_MBBID | devMbbidSKINIM |
| #define | DSET_SI | | devSiSKINIM |
| #define | DSET_SO | | devSoSKINIM |
#include <devGpib.h> /* must be included after DSET defines */
#define TIMEOUT 0.5 /* I/O must complete within this time */
#define TIMEWINDOW 0.001 /* Wait this long after device timeout */
/*
* Define end-of-string character(s) here to allow
* easier changes when testing the driver.
*/
static char *OnOffList[]={"ON","OFF"};
static struct devGpibNames OnOffState={2, OnOffList,0,1};
static char *(ROnOffState[])={"ON","OFF",0};
static char *(CH01OnOffState[])={"CH01 ON\n","CH01 OFF\n",0};
static char *(CH02OnOffState[])={"CH02 ON\n","CH02 OFF\n",0};
static char *(CH03OnOffState[])={"CH03 ON\n","CH03 OFF\n",0};
static char *(CH04OnOffState[])={"CH04 ON\n","CH04 OFF\n",0};
static char *(SyncMode[])={"SYNCMODE SING\n","SYNCMODE ALLW\n","SYNCMODE DSBL\n", 0};
static char *SyncList[]={"SING","ALLW","DSBL"};
static unsigned long SyncVal[]= {0 , 1 , 2};
static struct devGpibNames SyncState = {3, SyncList, SyncVal, 2};
static char *(SyncmodeE[])={"SING\n","ALLW\n","DSBL\n",0};
#define EOSNL NULL
static struct gpibCmd gpibCmds[] = {
/* Command 0 divide set */
{&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "RATIO %ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL},
/* Command 1 divide read */
{&DSET_LI, GPIBREAD, IB_Q_LOW,"RATIO?\n", "%ld\n", 0, 2047, NULL, 0, 0, NULL ,NULL, EOSNL},
/* Command 2 ch01 delay set */
{&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "CH01:DEL %ld\n",0, 2047, NULL, 0, 0, NULL, NULL, EOSNL},
/* Command 3 ch01 delay read */
{&DSET_LI, GPIBREAD, IB_Q_LOW, "CH01:DEL?\n", "%ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL},
/* Command 4 ch02 delay set */
{&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "CH02:DEL %ld\n",0,2047,NULL, 0, 0, NULL, NULL, EOSNL},
/* Command 5 ch02 delay read */
{&DSET_LI, GPIBREAD, IB_Q_LOW, "CH02:DEL?\n", "%ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL},
/* Command 6 ch03 delay set */
{&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "CH03:DEL %ld\n",0,2047,NULL, 0, 0, NULL, NULL, EOSNL},
/* Command 7 ch03 delay read */
{&DSET_LI, GPIBREAD, IB_Q_LOW, "CH03:DEL?\n", "%ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL},
/* Command 8 ch04 delay set */
{&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "CH04:DEL %ld\n",0,2047,NULL, 0, 0, NULL, NULL, EOSNL},
/* Command 9 ch04 delay read */
{&DSET_LI, GPIBREAD, IB_Q_LOW, "CH04:DEL?\n", "%ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL},
/* Command 10 ch01 width set */
{&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "CH01:WID %ld\n",0,2047,NULL, 0, 0, NULL, NULL, EOSNL},
/* Command 11 ch01 width read */
{&DSET_LI, GPIBREAD, IB_Q_LOW, "CH01:WID?\n", "%ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL},
/* Command 12 ch02 width set */
{&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "CH02:WID %ld\n",0,2047,NULL, 0, 0, NULL, NULL, EOSNL},
/* Command 13 ch02 width read */
{&DSET_LI, GPIBREAD, IB_Q_LOW, "CH02:WID?\n", "%ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL},
/* Command 14 ch03 width set */
{&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "CH03:WID %ld\n",0,2047,NULL, 0, 0, NULL, NULL, EOSNL},
/* Command 15 ch03 width read */
{&DSET_LI, GPIBREAD, IB_Q_LOW, "CH03:WID?\n", "%ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL},
/* Command 16 ch04 width set */
{&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "CH04:WID %ld\n",0,2047,NULL, 0, 0, NULL, NULL, EOSNL},
/* Command 17 ch04 width read */
{&DSET_LI, GPIBREAD, IB_Q_LOW, "CH04:WID?\n", "%ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL},
/* Command 18 EP195 delay set */
{&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "EXTD %ld\n",0,2047,NULL, 0, 0, NULL, NULL, EOSNL},
/* Command 19 EP195 delay read */
{&DSET_LI, GPIBREAD, IB_Q_LOW, "EXTD?\n", "%ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL},
/* Command 20 CH01 On/Off set */
{&DSET_BO,GPIBEFASTO, IB_Q_LOW, NULL, NULL, 0, 2047, NULL, 0, 0, CH01OnOffState, &OnOffState, EOSNL},
/* Command 21 CH01 On/Off read */
{&DSET_BI,GPIBEFASTI, IB_Q_LOW, "CH01?\n", NULL, 0, 2047, NULL, 0, 0, ROnOffState, &OnOffState, EOSNL},
/* Command 22 CH02 On/Off set */
{&DSET_BO,GPIBEFASTO, IB_Q_LOW, NULL, NULL, 0, 2047, NULL, 0, 0, CH02OnOffState, &OnOffState, EOSNL},
/* Command 23 CH02 On/Off read */
{&DSET_BI,GPIBEFASTI, IB_Q_LOW, "CH02?\n", NULL, 0, 2047, NULL, 0, 0, ROnOffState, &OnOffState, EOSNL},
/* Command 24 CH03 On/Off set */
{&DSET_BO,GPIBEFASTO, IB_Q_LOW, NULL, NULL, 0, 2047, NULL, 0, 0, CH03OnOffState, &OnOffState, EOSNL},
/* Command 25 CH03 On/Off read */
{&DSET_BI,GPIBEFASTI, IB_Q_LOW, "CH03?\n", NULL, 0, 2047, NULL, 0, 0, ROnOffState, &OnOffState, EOSNL},
/* Command 26 CH04 On/Off set */
{&DSET_BO,GPIBEFASTO, IB_Q_LOW, NULL, NULL, 0, 2047, NULL, 0, 0, CH04OnOffState, &OnOffState, EOSNL},
/* Command 27 CH04 On/Off read */
{&DSET_BI,GPIBEFASTI, IB_Q_LOW, "CH04?\n", NULL, 0, 2047, NULL, 0, 0, ROnOffState, &OnOffState, EOSNL},
/* Command 28 SYNC mode set */
{&DSET_MBBO, GPIBEFASTO, IB_Q_LOW, NULL, NULL, 0, 2047, NULL, 0, 0,SyncMode,&SyncState, EOSNL},
/* Command 29 SYNC mode read */
{&DSET_MBBI, GPIBEFASTI, IB_Q_LOW, "SYNCMODE?\n", NULL, 0, 2047, NULL, 0,0, SyncmodeE, &SyncState, EOSNL},
/* Command 30 Save */
{&DSET_SI, GPIBREAD, IB_Q_LOW, "SAV\n", "%s\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL}
};
/* The following is the number of elements in the command array above. */
| #define NUMPARAMS | sizeof(gpibCmds)/sizeof(struct gpibCmd) |
/******************************************************************************
*
* Initialization for device support
* This is called one time before any records are initialized with a parm
* value of 0. And then again AFTER all record-level init is complete
* with a param value of 1.
*
******************************************************************************/
static long init_ai(int parm)
{
if(parm==0) {
devSupParms.name = "devSKINIM";
devSupParms.gpibCmds = gpibCmds;
devSupParms.numparams = NUMPARAMS;
devSupParms.timeout = TIMEOUT;
devSupParms.timeWindow = TIMEWINDOW;
devSupParms.respond2Writes = -1.0;
}
return(0);
}