/* devSkiLOSS.c */
/*
 *      Author: Makoto Tobiyama
 *      Date:   22/Dec/2020
 */
#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.
***********************************************************************/
#defineDSET_AIdevAiSKILOSS
#defineDSET_AOdevAoSKILOSS
#defineDSET_BIdevBiSKILOSS
#defineDSET_BOdevBoSKILOSS
#defineDSET_LIdevLiSKILOSS
#defineDSET_LOdevLoSKILOSS
#defineDSET_MBBOdevMbboSKILOSS
#defineDSET_MBBIdevMbbiSKILOSS
#defineDSET_MBBODdevMbbodSKILOSS
#defineDSET_MBBIDdevMbbidSKILOSS
#defineDSET_SIdevSiSKILOSS
#defineDSET_SOdevSoSKILOSS
#include <devGpib.h> /* must be included after DSET defines */ #define TIMEOUT 0.01 /* 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 *(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 *(CH05OnOffState[])={"CH05:ON\n","CH05:OFF\n",0}; static char *(CH06OnOffState[])={"CH06:ON\n","CH06:OFF\n",0}; static char *(CH07OnOffState[])={"CH07:ON\n","CH07:OFF\n",0}; static char *(CH08OnOffState[])={"CH08:ON\n","CH08:OFF\n",0}; static char *(ROnOffState[])={"ON","OFF",0}; #define EOSNL NULL static struct gpibCmd gpibCmds[] = { /* Command 0 ch1 delay set */ {&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "CH01:DEL %ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL}, /* Command 1 ch1 delay read */ {&DSET_LI, GPIBREAD, IB_Q_LOW, "CH01:DEL?\n","%ld\n", 0, 2047, NULL, 0, 0, NULL,NULL, EOSNL}, /* Command 2 ch1 width set */ {&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "CH01:WID %ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL}, /* Command 3 ch1 width read */ {&DSET_LI, GPIBREAD, IB_Q_LOW, "CH01:WID?\n","%ld\n", 0, 2047, NULL, 0, 0, NULL,NULL, EOSNL}, /* Command 4 ch1 enable/disable set */ {&DSET_BO, GPIBEFASTO, IB_Q_LOW, NULL, NULL, 0, 2047, NULL, 0, 0,CH01OnOffState, &OnOffState, EOSNL}, /* Command 5 ch1 on/off read */ {&DSET_BI, GPIBEFASTI, IB_Q_LOW,"CH01?\n",NULL, 0, 2047, NULL, 0, 0, ROnOffState, &OnOffState, EOSNL}, /* Command 6 ch2 delay set */ {&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "CH02:DEL %ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL}, /* Command 7 ch2 delay read */ {&DSET_LI, GPIBREAD, IB_Q_LOW, "CH02:DEL?\n","%ld\n", 0, 2047, NULL, 0, 0, NULL,NULL, EOSNL}, /* Command 8 ch2 width set */ {&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "CH02:WID %ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL}, /* Command 9 ch2 width read */ {&DSET_LI, GPIBREAD, IB_Q_LOW, "CH02:WID?\n","%ld\n", 0, 2047, NULL, 0, 0, NULL,NULL, EOSNL}, /* Command 10 ch2 enable/disable set */ {&DSET_BO, GPIBEFASTO, IB_Q_LOW, NULL, NULL, 0, 2047, NULL, 0, 0,CH02OnOffState, &OnOffState, EOSNL}, /* Command 11 ch2 on/off read */ {&DSET_BI, GPIBEFASTI, IB_Q_LOW,"CH02?\n",NULL, 0, 2047, NULL, 0, 0, ROnOffState, &OnOffState, EOSNL}, /* Command 12 ch3 delay set */ {&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "CH03:DEL %ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL}, /* Command 13 ch3 delay read */ {&DSET_LI, GPIBREAD, IB_Q_LOW, "CH03:DEL?\n","%ld\n", 0, 2047, NULL, 0, 0, NULL,NULL, EOSNL}, /* Command 14 ch3 width set */ {&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "CH03:WID %ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL}, /* Command 15 ch3 width read */ {&DSET_LI, GPIBREAD, IB_Q_LOW, "CH03:WID?\n","%ld\n", 0, 2047, NULL, 0, 0, NULL,NULL, EOSNL}, /* Command 16 ch3 enable/disable set */ {&DSET_BO, GPIBEFASTO, IB_Q_LOW, NULL, NULL, 0, 2047, NULL, 0, 0,CH03OnOffState, &OnOffState, EOSNL}, /* Command 17 ch3 on/off read */ {&DSET_BI, GPIBEFASTI, IB_Q_LOW,"CH03?\n",NULL, 0, 2047, NULL, 0, 0, ROnOffState, &OnOffState, EOSNL}, /* Command 18 ch4 delay set */ {&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "CH04:DEL %ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL}, /* Command 19 ch4 delay read */ {&DSET_LI, GPIBREAD, IB_Q_LOW, "CH04:DEL?\n","%ld\n", 0, 2047, NULL, 0, 0, NULL,NULL, EOSNL}, /* Command 20 ch4 width set */ {&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "CH04:WID %ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL}, /* Command 21 ch4 width read */ {&DSET_LI, GPIBREAD, IB_Q_LOW, "CH04:WID?\n","%ld\n", 0, 2047, NULL, 0, 0, NULL,NULL, EOSNL}, /* Command 22 ch4 enable/disable set */ {&DSET_BO, GPIBEFASTO, IB_Q_LOW, NULL, NULL, 0, 2047, NULL, 0, 0,CH04OnOffState, &OnOffState, EOSNL}, /* Command 23 ch4 on/off read */ {&DSET_BI, GPIBEFASTI, IB_Q_LOW,"CH04?\n",NULL, 0, 2047, NULL, 0, 0, ROnOffState, &OnOffState, EOSNL}, /* Command 24 ch5 delay set */ {&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "CH05:DEL %ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL}, /* Command 25 ch5 delay read */ {&DSET_LI, GPIBREAD, IB_Q_LOW, "CH05:DEL?\n","%ld\n", 0, 2047, NULL, 0, 0, NULL,NULL, EOSNL}, /* Command 26 ch5 width set */ {&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "CH05:WID %ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL}, /* Command 27 ch5 width read */ {&DSET_LI, GPIBREAD, IB_Q_LOW, "CH05:WID?\n","%ld\n", 0, 2047, NULL, 0, 0, NULL,NULL, EOSNL}, /* Command 28 ch5 enable/disable set */ {&DSET_BO, GPIBEFASTO, IB_Q_LOW, NULL, NULL, 0, 2047, NULL, 0, 0,CH05OnOffState, &OnOffState, EOSNL}, /* Command 29 ch5 on/off read */ {&DSET_BI, GPIBEFASTI, IB_Q_LOW,"CH05?\n",NULL, 0, 2047, NULL, 0, 0, ROnOffState, &OnOffState, EOSNL}, /* Command 30 ch6 delay set */ {&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "CH06:DEL %ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL}, /* Command 31 ch6 delay read */ {&DSET_LI, GPIBREAD, IB_Q_LOW, "CH06:DEL?\n","%ld\n", 0, 2047, NULL, 0, 0, NULL,NULL, EOSNL}, /* Command 32 ch6 width set */ {&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "CH06:WID %ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL}, /* Command 33 ch6 width read */ {&DSET_LI, GPIBREAD, IB_Q_LOW, "CH06:WID?\n","%ld\n", 0, 2047, NULL, 0, 0, NULL,NULL, EOSNL}, /* Command 34 ch6 enable/disable set */ {&DSET_BO, GPIBEFASTO, IB_Q_LOW, NULL, NULL, 0, 2047, NULL, 0, 0,CH06OnOffState, &OnOffState, EOSNL}, /* Command 35 ch6 on/off read */ {&DSET_BI, GPIBEFASTI, IB_Q_LOW,"CH06?\n",NULL, 0, 2047, NULL, 0, 0, ROnOffState, &OnOffState, EOSNL}, /* Command 36 CH07 delay set */ {&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "CH07:DEL %ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL}, /* Command 37 CH07 delay read */ {&DSET_LI, GPIBREAD, IB_Q_LOW, "CH07:DEL?\n","%ld\n", 0, 2047, NULL, 0, 0, NULL,NULL, EOSNL}, /* Command 38 CH07 width set */ {&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "CH07:WID %ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL}, /* Command 39 CH07 width read */ {&DSET_LI, GPIBREAD, IB_Q_LOW, "CH07:WID?\n","%ld\n", 0, 2047, NULL, 0, 0, NULL,NULL, EOSNL}, /* Command 40 CH07 enable/disable set */ {&DSET_BO, GPIBEFASTO, IB_Q_LOW, NULL, NULL, 0, 2047, NULL, 0, 0,CH07OnOffState, &OnOffState, EOSNL}, /* Command 41 CH07 on/off read */ {&DSET_BI, GPIBEFASTI, IB_Q_LOW,"CH07?\n",NULL, 0, 2047, NULL, 0, 0, ROnOffState, &OnOffState, EOSNL}, /* Command 42 CH08 delay set */ {&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "CH08:DEL %ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL}, /* Command 43 CH08 delay read */ {&DSET_LI, GPIBREAD, IB_Q_LOW, "CH08:DEL?\n","%ld\n", 0, 2047, NULL, 0, 0, NULL,NULL, EOSNL}, /* Command 44 CH08 width set */ {&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "CH08:WID %ld\n", 0, 2047, NULL, 0, 0, NULL, NULL, EOSNL}, /* Command 45 CH08 width read */ {&DSET_LI, GPIBREAD, IB_Q_LOW, "CH08:WID?\n","%ld\n", 0, 2047, NULL, 0, 0, NULL,NULL, EOSNL}, /* Command 46 CH08 enable/disable set */ {&DSET_BO, GPIBEFASTO, IB_Q_LOW, NULL, NULL, 0, 2047, NULL, 0, 0,CH08OnOffState, &OnOffState, EOSNL}, /* Command 47 CH08 on/off read */ {&DSET_BI, GPIBEFASTI, IB_Q_LOW,"CH08?\n",NULL, 0, 2047, NULL, 0, 0, ROnOffState, &OnOffState, EOSNL}, /* Command 48 save */ {&DSET_LO,GPIBWRITE,IB_Q_LOW,NULL,"SAV\n",0,2047,NULL, 0, 0, NULL, NULL, EOSNL} }; /* The following is the number of elements in the command array above. */
#define NUMPARAMSsizeof(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 = "devSKILOSS"; devSupParms.gpibCmds = gpibCmds; devSupParms.numparams = NUMPARAMS; devSupParms.timeout = TIMEOUT; devSupParms.timeWindow = TIMEWINDOW; devSupParms.respond2Writes = -1.0; } return(0); }