Device(MH3000)
TimeOut 600;
%{
STATIC float get_onetemp(char wa1[]);
STATIC int rd_temp(char wav[], float temp[]);
static int rd_wf_temp(struct gpibDpvt *pdpvt, int p1, int p2, char **p3);
}%
ParamTable{
read_temp01 {rec=wf, command="11,01,\r\n",
leng=1023, conv=rd_wf_temp}
read_temp02 {rec=wf, command="11,02,\r\n",
leng=1023, conv=rd_wf_temp}
read_temp03 {rec=wf, command="11,03,\r\n",
leng=1023, conv=rd_wf_temp}
read_temp11 {rec=wf, command="11,11,\r\n",
leng=1023, conv=rd_wf_temp}
read_temp12 {rec=wf, command="11,12,\r\n",
leng=1023, conv=rd_wf_temp}
read_temp13 {rec=wf, command="11,13,\r\n",
leng=1023, conv=rd_wf_temp}
read_temp21 {rec=wf, command="11,21,\r\n",
leng=1023, conv=rd_wf_temp}
read_temp22 {rec=wf, command="11,22,\r\n",
leng=1023, conv=rd_wf_temp}
read_temp23 {rec=wf, command="11,23,\r\n",
leng=1023, conv=rd_wf_temp}}
read_temp31 {rec=wf, command="11,31,\r\n",
leng=1023, conv=rd_wf_temp}
read_temp32 {rec=wf, command="11,32,\r\n",
leng=1023, conv=rd_wf_temp}
read_temp33 {rec=wf, command="11,33,\r\n",
leng=1023, conv=rd_wf_temp}
read_temp41 {rec=wf, command="11,41,\r\n",
leng=1023, conv=rd_wf_temp}
read_temp42 {rec=wf, command="11,42,\r\n",
leng=1023, conv=rd_wf_temp}
read_temp43 {rec=wf, command="11,43,\r\n",
leng=1023, conv=rd_wf_temp}
read_temp51 {rec=wf, command="11,51,\r\n",
leng=1023, conv=rd_wf_temp}
read_temp52 {rec=wf, command="11,52,\r\n",
leng=1023, conv=rd_wf_temp}
read_temp53 {rec=wf, command="11,53,\r\n",
leng=1023, conv=rd_wf_temp}
read_temp61 {rec=wf, command="11,61,\r\n",
leng=1023, conv=rd_wf_temp}
read_temp62 {rec=wf, command="11,62,\r\n",
leng=1023, conv=rd_wf_temp}
read_temp63 {rec=wf, command="11,63,\r\n",
leng=1023, conv=rd_wf_temp}%{
#define MH2000_ADend 1 /* end of A/D conversion */
#define MH2000_Gerr 2 /* grammer error */
#define MH2000_ICerr 4 /* IC card error */
#define MH2000_Unope 8 /* operation unavailable */
#define MH2000_Chartend 16 /* chart end */
#define MH2000_busy 32 /* scan busy */
#define MH2000_int 64 /* interrupt */
#define MH2000_init 128 /* initializeing */
/*STATIC float get_onetemp(char wa1[], int *s)*/
STATIC float get_onetemp(char wa1[])
{
#define E_TEMP -100.0
int s;
s = (wa1[4]-'0');
if (s != 0) {
/* printf("error on conversion =%x\n",s); */
return E_TEMP;
}
else return atof(wa1+5);
}
/*STATIC int rd_temp(char wav[], float temp[], int s[])*/
static int rd_temp(char wav[], float temp[])
{
int i;
char wa1[511];
#define NAK 0x15
if (wav[0]!=NAK)
{
strtok(wav,",");
strtok(NULL,",");
for (i=0; i<10; i++)
{
strcpy(wa1,strtok(NULL,","));
temp[i] = get_onetemp(wa1);
}
return 0;
}
else
{
/* s[0] = atoi(wav+1);*/
return 1;
}
}
STATIC int rd_wf_temp(struct gpibDpvt *pdpvt, int p1, int p2, char **p3)
{
struct waveformRecord *pwf = (struct waveformRecord *) (pdpvt->precord);
char *craw;
float *temparray;
float temp[511],*ptemp;
int s[511],ok_flag;
unsigned long numElem;
temparray = (float *) pwf->bptr;
craw = pdpvt->msg;
/* printf("input org: %s",&craw); */
craw = strtok(craw,"\n\r");
/* printf("input data: %s\n",craw); */
if (craw == NULL) /* fairly unlikely ... */
{
devGpibLib_setPvSevr(pwf, READ_ALARM, INVALID_ALARM);
printf("null data in MH2000\n");
return(ERROR);
}
ok_flag = rd_temp(craw,temp);
if (ok_flag != 0)
{
devGpibLib_setPvSevr(pwf,READ_ALARM, INVALID_ALARM);
printf("Not OK MH2000\n");
return(ERROR);
}
numElem = 10;
if (numElem > pwf->nelm) numElem = pwf->nelm;
pwf->nord = numElem;
ptemp=temp;
while (numElem--)
{
/* printf( "\n%d-th data: %f",numElem, *ptemp); */
*temparray++ = (float) *ptemp++;
}
/* printf( "\nread_wf end normally\n"); */
return(OK);
}
}%