/* @(#)GNC Version 1.4: : R3172 */
/******************************************************************************
*
* The following define statements are used to declare the names to be used
* for the dset tables.
*
* NOTE: The dsets are referenced by the entries in the command table.
*
******************************************************************************/

#defineDSET_AI devAiR3172Gpib
#defineDSET_AO devAoR3172Gpib
#defineDSET_BI devBiR3172Gpib
#defineDSET_BO devBoR3172Gpib
#defineDSET_SI devSiR3172Gpib
#defineDSET_SO devSoR3172Gpib
#defineDSET_LI devLiR3172Gpib
#defineDSET_LO devLoR3172Gpib
#defineDSET_MBBI devMbbiR3172Gpib
#defineDSET_MBBO devMbboR3172Gpib
#defineDSET_WF devWfR3172Gpib
#include <devGpib.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <devCommonGpib.h>
#include <errlog.h>
#include <menuFtype.h>
#include <epicsStdio.h>


#define STATIC static


# line 2 "devR3172Gpib.gt"

static float get_onedata(char wa1[]);
static int rd_data(char wav[], float temp[]);
static int rd_datab(unsigned char wav[], short temp[]);
static int rd_wf_data(struct gpibDpvt *pdpvt, int p1, int p2, char **p3);


staticstruct devGpibParmBlock devSupParms;
/******************************************************************************
*
* Define all the dset's.
*
* Note that the dset names are provided via the #define lines at the top of
* this file.
*
* Other than for the debugging flag(s), these DSETs are the only items that
* will appear in the global name space within the IOC.
*
* The last 3 items in the DSET structure are used to point to the parm
* structure, the work functions used for each record type, and the srq
* handler for each record type.
*
******************************************************************************/


/******************************************************************************
*
* Debugging flags that can be accessed from the shell.
*
******************************************************************************/
int R3172Debug = 0;

/******************************************************************************
*
* Use the TIME_WINDOW defn to indicate how long commands should be ignored
* for a given device after it times out. The ignored commands will be
* returned as errors to device support.
*
* Use the DMA_TIME to define how long you wish to wait for an I/O operation
* to complete once started.
*
* These are to be declared in 60ths of a second.
*
******************************************************************************/
#define TIMEWINDOW600/* 10 seconds */
#define TIMEOUT5
/****************************************************************************** *
* Strings used by the init routines to fill in the znam, onam, ...
* fields in BI and BO record types.
*
******************************************************************************/

static unsigned long GDL_BinaryNameVal[] = { 0 ,1 };

static char *TrNameList[] = { "501", "1001" };
static struct devGpibNames TrName = { 2, TrNameList, GDL_BinaryNameVal, 1 };

static char *HsNameList[] = { "OFF", "ON" };
static struct devGpibNames HsName = { 2, HsNameList, GDL_BinaryNameVal, 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.
*
******************************************************************************/

static char *XdbnList[] = { "10dB/" ,"5dB/" ,"2dB/" ,"1dB/" };
static unsigned long XdbnVal[] = { 0 ,1 ,2 ,3 };
static struct devGpibNames Xdbn = { 4, XdbnList, XdbnVal, 2 };


/******************************************************************************
*
* String arrays for EFAST operations. Note that the last entry must be
* NULL.
*
* On input operations, only as many bytes as are found in the string array
* elements are compared. If there are more bytes than that in the input
* message, they are ignored. The first matching string found (starting
* from the 0'th element) will be used as a match.
*
* NOTE: For the input operations, the strings are compared literally! This
* can cause problems if the instrument is returning things like \r and \n
* characters. You must take care when defining input strings so you include
* them as well.
*
******************************************************************************/

static char *(Xdbe[])={"0","1","2","3",NULL};
static char *(TrMode[])={"0","1",NULL};
static char *(HsMode[])={"0","1",NULL};

/******************************************************************************
*
* Array of structures that define all GPIB messages
* supported for this type of instrument.
*
******************************************************************************/
#define EOSLN NULL


static struct gpibCmd gpibCmds[] = {

/* CMMAND 0 set_center_freq */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; CF%lfHZ\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 1 get_center_freq */
{&DSET_AI, GPIBREAD, IB_Q_LOW, "DL0; CF?\r\n", "%lf\r\n", 0, 1024, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 2 set_start_freq */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; FA%lfHZ\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 3 get_start_freq */
{&DSET_AI, GPIBREAD, IB_Q_LOW, "DL0; FA?\r\n", "%lf\r\n", 0, 1024, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 4 set_stop_freq */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; FB%lfHZ\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 5 get_stop_freq */
{&DSET_AI, GPIBREAD, IB_Q_LOW, "DL0; FB?\r\n", "%lf\r\n", 0, 1024, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 6 set_center_freq_step */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; CS %lfHZ\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 7 set_center_freq_auto */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; CA\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 8 get_center_freq_step */
{&DSET_AI, GPIBREAD, IB_Q_LOW, "DL0; CS?\r\n", "%lf\r\n", 0, 1024, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 9 set_span */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; SP%lfHZ\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 10 get_span */
{&DSET_AI, GPIBREAD, IB_Q_LOW, "DL0; SP?\r\n", "%lf\r\n", 0, 1024, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 11 set_rbw */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; RB%lfHZ\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 12 set_rbw_auto */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; BA\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 13 get_rbw */
{&DSET_AI, GPIBREAD, IB_Q_LOW, "DL0; RB?\r\n", "%lf\r\n", 0, 1024, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 14 set_vbw */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; VB%lfHZ\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 15 set_vbw_auto */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; VA\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 16 get_vbw */
{&DSET_AI, GPIBREAD, IB_Q_LOW, "DL0; VB?\r\n", "%lf\r\n", 0, 1024, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 17 set_sweep */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; SW%lfSC\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 18 set_sweep_auto */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; AS\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 19 get_sweep */
{&DSET_AI, GPIBREAD, IB_Q_LOW, "DL0; SW?\r\n", "%lf\r\n", 0, 1024, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 20 set_attenuation */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; AT%lfDB\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 21 set_attenuation_auto */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; AA\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 22 get_attenuation */
{&DSET_AI, GPIBREAD, IB_Q_LOW, "DL0; AT?\r\n", "%lf\r\n", 0, 1024, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 23 set_couple_all_auto */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; AL\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 24 set_log_scale */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; DD%lfDB\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 25 get_log_scale */
{&DSET_MBBI, GPIBEFASTI, IB_Q_LOW, "DL0; DD?\r\n", NULL, 0, 32, NULL, 0, 0, Xdbe, &Xdbn, EOSLN },

/* CMMAND 26 set_reference_level */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; RL%lfDB\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 27 get_reference_level */
{&DSET_AI, GPIBREAD, IB_Q_LOW, "DL0; RL?\r\n", "%lf\r\n", 0, 1024, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 28 set_tgpwr */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; TGL%lfDB\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 29 set_tgpwr_on */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; TG\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 30 set_tgpwr_off */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; TGF\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 31 get_tgpwr */
{&DSET_AI, GPIBREAD, IB_Q_LOW, "DL0; TGL?\r\n", "%lf\r\n", 0, 1024, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 32 set_srccal */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; TGA\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 33 set_title */
{&DSET_SO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; LON/%s/\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 34 set_title_off */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; LOF\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 35 get_trace_a */
{&DSET_WF, GPIBREADW, IB_Q_LOW, "DL0; SI; *SRE128; OPR 8; S0; SR; DL2 TBA?", NULL, 0, 819100, rd_wf_data, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 36 get_trace_b */
{&DSET_WF, GPIBREAD, IB_Q_LOW, "DL2 TBB?", NULL, 0, 819100, rd_wf_data, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 37 set_trigger_single */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; SI\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 38 set_trigger_start */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; SR\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 39 set_trigegr_cont */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; CONTS\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 40 set_trace_a_clrw */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; AB\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 41 set_trace_b_clrw */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; BB\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 42 set_marker_peak */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; PS\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 43 set_marker_on */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; MN 1\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 44 set_market_off */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; MO\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 45 set_marker_delta */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; MKD 1\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 46 set_marker_normal */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; MN 1\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 47 get_marker_freq */
{&DSET_AI, GPIBREAD, IB_Q_LOW, "DL0; MF?\r\n", "%lf\r\n", 0, 1024, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 48 get_marker_amp */
{&DSET_AI, GPIBREAD, IB_Q_LOW, "DL0; ML?\r\n", "%lf\r\n", 0, 1024, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 49 set_sa_init */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; IP\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 50 set_trace_writeA */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; AW\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 51 set_trace_writeB */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; BW\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 52 set_trace_viewA */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; AV\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 53 set_trace_viewB */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; BV\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 54 set_trace_maxholdA */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; AMAX ON\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 55 set_trace_maxholdB */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; BMAX ON\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 56 set_trace_vavgA */
{&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; AG%d\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 57 set_trace_vavgA_start */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; AGR\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 58 set_trace_vavgA_stop */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; AGS\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 59 set_header_off */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; S2\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 60 set_trace_vavgB */
{&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; BG%d\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 61 set_trace_vavgB_start */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; BGR\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 62 set_trace_vavgB_stop */
{&DSET_AO, GPIBWRITE, IB_Q_LOW, NULL, "DL0; BGS\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 63 set_srccal_man */
{&DSET_LO, GPIBWRITE, IB_Q_LOW, NULL, "TGM %d\r\n", 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 64 set_srq_on */
{&DSET_SO, GPIBCMD, IB_Q_LOW, "DL0; *SRE128; OPR 8; S0\r\n", NULL, 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 65 set_srq_off */
{&DSET_SO, GPIBCMD, IB_Q_LOW, "DL0; S1\r\n", NULL, 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 66 UNSolicited_SRQ */
{&DSET_LI, GPIBSRQHANDLER, IB_Q_LOW, "DL0; S2\r\n", NULL, 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 67 set_trace_501 */
{&DSET_SO, GPIBCMD, IB_Q_LOW, "DL0; TPS\r\n", NULL, 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 68 set_trace_1001 */
{&DSET_SO, GPIBCMD, IB_Q_LOW, "DL0; TPL\r\n", NULL, 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 69 get_trace_num */
{&DSET_MBBI, GPIBEFASTI, IB_Q_LOW, "DL0; TP?\r\n", NULL, 0, 32, NULL, 0, 0, TrMode, &TrName, EOSLN },

/* CMMAND 70 set_hisense_on */
{&DSET_SO, GPIBCMD, IB_Q_LOW, "DL0;HS\r\n", NULL, 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 71 set_hisense_off */
{&DSET_SO, GPIBCMD, IB_Q_LOW, "DL0;HS OFF\r\n", NULL, 0, 32, NULL, 0, 0, NULL, NULL, EOSLN },

/* CMMAND 72 get_hisense */
{&DSET_MBBI, GPIBEFASTI, IB_Q_LOW, "DL0;HS?\r\n", NULL, 0, 32, NULL, 0, 0, HsMode, &HsName, EOSLN }
};
/* The following is the number of elements in the command array above. */
#define NUMPARAMSsizeof(gpibCmds)/sizeof(struct gpibCmd)
/******************************************************************************
*
* Structure containing the user's functions and operating parameters needed
* by the gpib library functions.
*
* The magic SRQ parm is the parm number that, if specified on a passive
* record, will cause the record to be processed automatically when an
* unsolicited SRQ interrupt is detected from the device.
*
* If the parm is specified on a non-passive record, it will NOT be processed
* when an unsolicited SRQ is detected.
*
* In the future, the magic SRQ parm records will be processed as "I/O event
* scanned"... not passive.
*
******************************************************************************/

static long init_ai(int parm)
{
if(parm==0) {
devSupParms.name = "devR3172Gpib";
devSupParms.gpibCmds = gpibCmds;
devSupParms.numparams = NUMPARAMS;
devSupParms.timeout = TIMEOUT;
devSupParms.timeWindow = TIMEWINDOW;
devSupParms.respond2Writes = -1.0;
}
return(0);
}


/******************************************************************************
*
* 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.
*
******************************************************************************/

/******************************************************************************
*
* Print a report of operating statistics for all devices supported by this
* module.
*
* This function will no longer be required after epics 3.3 is released
*
******************************************************************************/

/******************************************************************************
*
* c code
*
*****************************************************************************/
# line 121 "devR3172Gpib.gt"

#defineR3172_GOODBITS0x3f
#define R3172_UNCAL0x1
#define R3172_ENDCAL0x2
#define R3172_ENDSW 0x4
#define R3172_ENDAV0x8
#define R3172_ERR0x20


static float get_onedata(char wa1[])
{
return atof(wa1);
}

static int rd_data(char wav[], float data[])

{
int i;
char wa1[8191];

strcpy(wa1,strtok(wav,"\r\n"));
data[0]=get_onedata(wa1);
for (i=1; i<1001; i++)
{

strcpy(wa1,strtok(NULL,"\r\n"));
/*printf("wa1=%s\n",wa1); */
data[i] = get_onedata(wa1); }
return 0;
}

static int rd_datab(unsigned char wav[], short data[])
{
int i;

for (i=0; i<1001; i++)
{
data[i]= wav[i*2]*256+wav[i*2+1];
}
return 0;
}

STATIC int rd_wf_data(struct gpibDpvt *pdpvt, int p1, int p2, char **p3)
{
struct waveformRecord *pwf = (struct waveformRecord *) (pdpvt->precord);
unsigned char*craw;
short *temparray; short temp[81910],*ptemp;
intok_flag;
unsigned longnumElem;
temparray = (unsigned short *) pwf->bptr;
craw = pdpvt->msg;

/*logMsg("craw = %s\n",craw);
printf("craw -- end\n");*/
/* craw = strtok(craw,"\r\n");
if (craw == NULL)
{
devGpibLib_setPvSevr(pwf, READ_ALARM, INVALID_ALARM);
logMsg("null data in R3172\n");
return(ERROR);
}
*/

ok_flag = rd_datab(craw,temp);
/* logMsg("1,2,3,4 %d %d %d %d\n",temp[0],temp[1],temp[2],temp[3]); */
if (ok_flag != 0)
{
/* devGpibLib_setPvSevr(pwf,READ_ALARM, INVALID_ALARM);
logMsg("Not OK R3172\n"); */
return(-1); }

numElem = 1001;
if (numElem > pwf->nelm) numElem = pwf->nelm;
pwf->nord = numElem;
ptemp=temp;
while (numElem--) {
/* logMsg( "\n%d-th data: %f",numElem, *ptemp); */
*temparray++ = (short) *ptemp++; }
/* logMsg( "\nread_wf end normally\n"); */
return(0);
}



# line 237 "devR3172Gpib.gt"