183,6 → 183,17 |
return; |
} |
|
int _VI_FUNC K6517_EventStatus () |
{ |
K6517_send (":STATUS:MEAS:EVEN?",0); |
char cres[100]; |
cres[0]= 0; |
int len = K6517_receive (cres, 50); |
if (len>0) |
return atoi(cres); |
else |
return -1; |
} |
double _VI_FUNC K6517_get (char *prefix, int *loc) |
{ |
|
457,6 → 468,7 |
sprintf(tempBuf,"localhost"); |
switch (event) { |
case EVENT_COMMIT: |
if (g_connected) return 0; |
if (ConnectToTCPServer (&g_hconversation, portNum, tempBuf, ClientTCPCB, NULL, 5000) < 0) |
MessagePopup("TCP Client", "Connection to server failed !"); |
else |
506,7 → 518,7 |
sscanf(receiveBuf, "%d%f%f%f%f", &t0,&humidity,&temp, &tdiff, &dt); |
SetCtrlVal(pn2,P2_TMON, temp); |
SetCtrlVal(pn2,P2_HUMIDITY, humidity); |
if (fabs(tdiff)<0.5 && fabs(dt) < 0.2) SetCtrlVal(pn2,P2_LED, 1); |
if (fabs(tdiff)<0.2 && fabs(dt) < 0.05) SetCtrlVal(pn2,P2_LED, 1); |
else SetCtrlVal(pn2,P2_LED, 0); |
} |
break; |
544,20 → 556,30 |
int n=0; |
int led; |
GetNumTableRows (pn2, P2_TABLE, &n ); |
stop = 0; |
for(int i=0; i<n; i++) { |
if (stop) break; |
GetTableCellVal (pn2, P2_TABLE, MakePoint (1,i+1), &temp); |
if (temp>100) break; |
char transmitBuf[512]= {0}; |
sprintf(transmitBuf, "1 %f\n", temp); |
SetCtrlVal(pn2,P2_LED, 0); |
if (g_hconversation) |
if ( ClientTCPWrite (g_hconversation, transmitBuf, strlen (transmitBuf), 1000) < 0) printf("Transmit Error\n"); |
|
|
|
if (g_connected) |
if ( ClientTCPWrite (g_hconversation, transmitBuf, strlen (transmitBuf), 1000) < 0) printf("Transmit Error\n"); else printf("%s\n", transmitBuf); |
SetCtrlVal(pn2,P2_LED, 0); |
do { |
time_t t0 = time(NULL); |
SetCtrlVal(pn2,P2_TIME, ctime(&t0)); |
Delay(1); |
GetCtrlVal(pn2,P2_LED, &led); |
if (led) { |
for (int k=0;k<10;k++){ |
Delay(1); |
if (stop) break; |
} |
GetCtrlVal(pn2,P2_LED, &led); |
} |
if (stop) break; |
} while (!led); |
if (stop) break; |
973,8 → 995,20 |
Delay(t2); |
// voltage =K6517_vsource_get(); |
current =K6517_get(cres,&k); |
int status = K6517_EventStatus(); |
SetCtrlVal(pn2,P2_STATUS, status); |
SetCtrlVal(pn2,P2_OVERFLOW, status & 0x1); |
// if (current > range) printf("Overflow +\n"); |
// if (current < -range) printf("Overflow -\n"); |
if (status & 0x1){ |
if (range>0) range*=10; |
K6517_current_mode (range); |
Delay(1); |
current =K6517_get(cres,&k); |
status = K6517_EventStatus(); |
SetCtrlVal(pn2,P2_STATUS, status); |
SetCtrlVal(pn2,P2_OVERFLOW, status & 0x1); |
} |
voltage = u; |
xpoints[tockaK]= voltage; |
ypoints[tockaK]= current; |
984,7 → 1018,7 |
double humidity=0; |
GetCtrlVal(pn2, P2_TMON, &temperature); |
GetCtrlVal(pn2, P2_HUMIDITY, &humidity); |
if (fp) fprintf(fp, "%d %g %g %g %g %g\n",tockaK, u, voltage,current, humidity, temperature); |
if (fp) fprintf(fp, "%d %g %g %g %g %g %d\n",tockaK, u, voltage,current, humidity, temperature, status); |
if (debugCode) printf("n=%d u=%g voltage=%g current=%g\n",tockaK, u, voltage,current); |
if (plivhandle) DeleteGraphPlot (pn2, P2_GRAPHIV, plivhandle, VAL_IMMEDIATE_DRAW); |
plivhandle = PlotXY (pn2, P2_GRAPHIV, xpoints, ypoints, tockaK+1, VAL_DOUBLE, VAL_DOUBLE, VAL_CONNECTED_POINTS, VAL_BOLD_X, VAL_SOLID, 1, VAL_RED); |