Rev 310 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
308 | f9daq | 1 | #include <userint.h> |
2 | #include "K2231A-ctrl.h" |
||
3 | #include <stdlib.h> |
||
4 | #include <stdio.h> |
||
5 | #include <windows.h> |
||
6 | #include <visa.h> |
||
7 | |||
310 | f9daq | 8 | static int debug = 0; |
308 | f9daq | 9 | static ViStatus istat; |
310 | f9daq | 10 | static ViSession DeviceHandle,RMHandle; |
308 | f9daq | 11 | |
12 | |||
310 | f9daq | 13 | char response[0xFF]= {0}; |
308 | f9daq | 14 | |
312 | f9daq | 15 | int K2231A_SetDebug(int x){ debug = x;return 0;}; |
310 | f9daq | 16 | |
17 | int K2231A_Write(const char *format, ... ) |
||
308 | f9daq | 18 | { |
310 | f9daq | 19 | char cmd[0xFF]; |
20 | va_list aptr; |
||
21 | va_start(aptr, format); |
||
22 | vsprintf(cmd, format, aptr); |
||
23 | va_end(aptr); |
||
24 | |||
25 | char str[0xFF]; |
||
26 | sprintf(str, "%s\r\n",cmd); |
||
27 | int istat = viPrintf (DeviceHandle, str); |
||
28 | if (debug) printf("K2231A_Write %s\n", cmd); |
||
29 | return istat; |
||
30 | } |
||
31 | |||
32 | const char * K2231A_Read(const char *format, ... ) |
||
33 | { |
||
308 | f9daq | 34 | |
310 | f9daq | 35 | char cmd[0xFF]; |
36 | va_list aptr; |
||
37 | va_start(aptr, format); |
||
38 | vsprintf(cmd, format, aptr); |
||
39 | va_end(aptr); |
||
40 | |||
41 | char str[0xFF]; |
||
42 | int istat=0; |
||
43 | |||
44 | sprintf(str, "%s\n",cmd); |
||
45 | istat = viPrintf (DeviceHandle, str); |
||
46 | |||
47 | int nb=0; |
||
48 | istat = viRead (DeviceHandle, response, 0xFF, &nb); |
||
49 | |||
50 | if (nb>0) response[nb-1]=0; |
||
51 | if (debug) printf("K2231A_Read %s : %s\n", cmd, response); |
||
52 | if (istat) return NULL; |
||
53 | |||
54 | return response; |
||
308 | f9daq | 55 | } |
56 | |||
310 | f9daq | 57 | int K2231A_QueryInt(const char *format, ... ) |
58 | { |
||
59 | char cmd[0xFF]; |
||
60 | va_list aptr; |
||
61 | va_start(aptr, format); |
||
62 | vsprintf(cmd, format, aptr); |
||
63 | va_end(aptr); |
||
64 | return atoi(K2231A_Read(cmd )); |
||
65 | } |
||
308 | f9daq | 66 | |
310 | f9daq | 67 | |
68 | |||
69 | double K2231A_QueryDouble(const char *format, ...) { |
||
70 | char cmd[0xFF]; |
||
71 | va_list aptr; |
||
72 | va_start(aptr, format); |
||
73 | vsprintf(cmd, format, aptr); |
||
74 | va_end(aptr); |
||
75 | return atof(K2231A_Read(cmd )); |
||
76 | } |
||
77 | |||
312 | f9daq | 78 | static int K2231A_Port=5; |
79 | int K2231A_SetPort(int x){K2231A_Port=x; return x;}; |
||
80 | |||
310 | f9daq | 81 | int K2231A_Initialize() |
82 | { |
||
83 | |||
84 | istat = viOpenDefaultRM (&RMHandle); |
||
312 | f9daq | 85 | char cport[0xFF]; |
86 | sprintf(cport,"ASRL%d::INSTR", K2231A_Port ); |
||
87 | if (RMHandle) istat = viOpen (RMHandle, cport , VI_NULL, VI_NULL, &DeviceHandle); |
||
310 | f9daq | 88 | if (DeviceHandle) |
89 | { |
||
90 | |||
91 | istat = viSetAttribute (DeviceHandle, VI_ATTR_TERMCHAR, '\n'); |
||
92 | istat = viSetAttribute (DeviceHandle, VI_ATTR_TERMCHAR_EN, VI_TRUE); |
||
93 | istat = viSetAttribute (DeviceHandle, VI_ATTR_TMO_VALUE, 5000); |
||
94 | |||
95 | |||
96 | printf("\n"); |
||
97 | } |
||
98 | else |
||
99 | { |
||
100 | MessagePopup("Error","Cannot open handle"); |
||
101 | } |
||
102 | |||
103 | |||
104 | return 0; |
||
105 | } |
||
106 | |||
107 | |||
108 | |||
109 | |||
308 | f9daq | 110 | int K2231A_Test() |
111 | { |
||
310 | f9daq | 112 | char response[0xFF]= {0}; |
113 | int i; |
||
114 | for ( i=0; i<255; i++) response[i]=0; |
||
115 | |||
116 | K2231A_Read("*IDN?"); |
||
117 | K2231A_Read("SYSTem:VERSion?"); |
||
118 | K2231A_Read("VOLT?"); |
||
119 | K2231A_Read("CURR?"); |
||
120 | K2231A_Read("MEAS:VOLT?"); |
||
121 | K2231A_Read("MEAS:CURR?"); |
||
122 | K2231A_Read("FETC:VOLT?"); |
||
123 | K2231A_Read("FETC:CURR?"); |
||
124 | K2231A_Write("SYSTem:BEEPer"); |
||
308 | f9daq | 125 | return TRUE; |
126 | } |
||
127 | |||
128 | int K2231A_Close() |
||
129 | { |
||
310 | f9daq | 130 | K2231A_Write("syst:loc"); |
308 | f9daq | 131 | return 0; |
132 | } |
||
133 | |||
134 | int K2231A_Open() |
||
135 | { |
||
310 | f9daq | 136 | K2231A_Initialize(); |
137 | K2231A_Write("syst:rem"); |
||
308 | f9daq | 138 | return TRUE; |
310 | f9daq | 139 | } |
308 | f9daq | 140 | |
310 | f9daq | 141 | int K2231A_RecallFromMemory(int preset){ |
142 | return K2231A_Write("*rcl %d",preset); |
||
143 | } |
||
308 | f9daq | 144 | |
310 | f9daq | 145 | double K2231A_GetSetCurrent(){ |
146 | return K2231A_QueryDouble("CURR?"); |
||
147 | } |
||
308 | f9daq | 148 | |
310 | f9daq | 149 | double K2231A_GetSetVoltage(){ |
150 | return K2231A_QueryDouble("VOLT?"); |
||
151 | } |
||
308 | f9daq | 152 | |
310 | f9daq | 153 | double K2231A_SetCurrent(double x){ |
312 | f9daq | 154 | return K2231A_Write("CURR %f", x); |
310 | f9daq | 155 | } |
308 | f9daq | 156 | |
310 | f9daq | 157 | double K2231A_SetVoltage(double x){ |
312 | f9daq | 158 | return K2231A_Write("VOLT %f", x); |
310 | f9daq | 159 | } |
308 | f9daq | 160 | |
310 | f9daq | 161 | double K2231A_GetCurrentMonitor(){ |
162 | return K2231A_QueryDouble("MEAS:CURR?"); |
||
163 | } |
||
308 | f9daq | 164 | |
310 | f9daq | 165 | double K2231A_GetVoltageMonitor(){ |
166 | return K2231A_QueryDouble("MEAS:VOLT?"); |
||
167 | } |
||
168 | |||
169 | |||
170 | int K2231A_SelectChannel(int ch){ |
||
171 | return K2231A_Write( "INST CH%d",ch); |
||
172 | } |
||
173 | |||
174 | |||
175 | int K2231A_GetOperationMode(){ |
||
176 | /* |
||
177 | //cv_cc = K2231A_QueryInt("Stat:ques:inst?"); |
||
178 | sprintf(cmd, "Stat:ques:inst:isum%d?",ch+1); |
||
179 | */ |
||
180 | return K2231A_QueryInt("Stat:ques:inst?"); |
||
181 | } |
||
182 | |||
183 | |||
184 | int K2231A_SetSwitch(int state){ |
||
185 | K2231A_Write("Outp:enab %d",state); |
||
186 | K2231A_Write("Outp %d",state); |
||
187 | return 0; |
||
188 | } |
||
189 | int K2231A_GetSwitch(){ |
||
190 | return K2231A_QueryInt("CHAN:OUTP?"); |
||
191 | } |
||
192 | |||
193 | |||
194 | |||
195 | void K2231A_ReadMonitorValues(double * I , double * V, unsigned char * mode, unsigned char *onoff) |
||
196 | { |
||
197 | int iRet; |
||
198 | char ch=0; |
||
199 | double Voltage; |
||
200 | double Current; |
||
201 | char cv_cc; |
||
202 | |||
203 | for (ch=0; ch<3; ch++) |
||
204 | { |
||
205 | |||
206 | |||
207 | K2231A_SelectChannel(ch+1); |
||
208 | cv_cc = K2231A_GetOperationMode(); |
||
209 | I[ch]= K2231A_GetCurrentMonitor(); |
||
210 | V[ch]= K2231A_GetVoltageMonitor(); |
||
211 | int onoff=K2231A_QueryInt("OUTP?"); |
||
212 | if (debug) printf("[%d] %g V %g A CVCC %d ONOFF %d\t",ch, V[ch], I[ch], cv_cc, onoff ); |
||
213 | |||
214 | |||
215 | |||
216 | } |
||
217 | |||
218 | |||
219 | |||
308 | f9daq | 220 | return; |
221 | |||
310 | f9daq | 222 | |
308 | f9daq | 223 | } |
224 | |||
310 | f9daq | 225 | void K2231A_ReadSetValues(double * I , double * V, unsigned char *onoff) |
226 | { |
||
227 | int iRet; |
||
228 | char ch=0; |
||
229 | double Voltage; |
||
230 | double Current; |
||
231 | char cv_cc; |
||
308 | f9daq | 232 | |
310 | f9daq | 233 | for (ch=0; ch<3; ch++) |
234 | { |
||
308 | f9daq | 235 | |
310 | f9daq | 236 | |
237 | K2231A_SelectChannel(ch+1); |
||
238 | cv_cc = K2231A_GetOperationMode(); |
||
239 | I[ch]= K2231A_GetSetCurrent(); |
||
240 | V[ch]= K2231A_GetSetVoltage(); |
||
241 | int onoff=K2231A_GetSwitch(); |
||
242 | if (debug) printf("[%d] %g V %g A CVCC %d ONOFF %d\t",ch, V[ch], I[ch], cv_cc, onoff ); |
||
243 | |||
244 | } |
||
245 | |||
246 | return; |
||
247 | } |
||
248 | |||
249 | |||
250 | #ifdef MAIN |
||
251 | |||
308 | f9daq | 252 | #include <ansi_c.h> |
253 | #include <utility.h> |
||
254 | |||
255 | |||
256 | #define RSTREG(a,x) (a&=(~(x))) |
||
257 | #define SETREG(a,x) (a|=x) |
||
258 | |||
259 | int gLogToFile; |
||
310 | f9daq | 260 | int vmon[3]= {P1_VMON_1,P1_VMON_2,P1_VMON_3 }; |
261 | int imon[3]= {P1_IMON_1,P1_IMON_2,P1_IMON_3 }; |
||
262 | int vset[3]= {P1_U_1,P1_U_2,P1_U_3 }; |
||
263 | int iset[3]= {P1_I_1,P1_I_2,P1_I_3 }; |
||
264 | int radiob[3]= {P1_BOX_1,P1_BOX_2,P1_BOX_3 }; |
||
308 | f9daq | 265 | |
310 | f9daq | 266 | int cvcc[3]= {P1_CVCC_1,P1_CVCC_2,P1_CVCC_3 }; |
267 | |||
308 | f9daq | 268 | int gMask=0xF; |
269 | |||
270 | int pnl; |
||
271 | FILE *gFp; |
||
272 | int main (int argc, char *argv[]) |
||
273 | { |
||
310 | f9daq | 274 | int DeviceId=0; |
275 | unsigned char MainOutput=0, preset=0; |
||
276 | double Voltage=0, Current=0, tinterval=1; |
||
277 | char str[0xFF]; |
||
278 | int i=0; |
||
279 | char response[0xFF]; |
||
308 | f9daq | 280 | if (InitCVIRTE (0, argv, 0) == 0) |
281 | return -1; /* out of memory */ |
||
310 | f9daq | 282 | SetStdioPort (CVI_STDIO_WINDOW); |
283 | SetStdioWindowOptions (1000, 1, 0); |
||
284 | SetStdioWindowSize (150, 600); |
||
285 | SetStdioWindowPosition (825, 20); |
||
308 | f9daq | 286 | |
310 | f9daq | 287 | |
308 | f9daq | 288 | if ((pnl = LoadPanel (0, "K2231A-ctrl.uir", P1)) < 0) return -1; |
289 | |||
310 | f9daq | 290 | if (K2231A_Open()== 0) MessagePopup("Error","Cannot open USB device"); |
291 | |||
292 | if (K2231A_Test() == 0 )MessagePopup("DLL error","Dll Error"); |
||
293 | |||
294 | |||
295 | |||
296 | SetCtrlVal(pnl, P1_ONOFF, MainOutput); |
||
297 | GetCtrlVal(pnl, P1_TINTERVAL, &tinterval); |
||
298 | SetCtrlAttribute (pnl, P1_TIMER, ATTR_INTERVAL, tinterval); |
||
299 | |||
300 | SetCtrlVal(pnl, P1_PRESET, preset); |
||
301 | SetTraceAttributeEx (pnl, P1_GRAPH_IMON, 1, ATTR_TRACE_LG_TEXT, "CH 30V"); |
||
308 | f9daq | 302 | SetTraceAttributeEx (pnl, P1_GRAPH_IMON, 2, ATTR_TRACE_LG_TEXT, "CH 30V"); |
303 | SetTraceAttributeEx (pnl, P1_GRAPH_IMON, 3, ATTR_TRACE_LG_TEXT, "CH 5V"); |
||
310 | f9daq | 304 | |
305 | SetTraceAttributeEx (pnl, P1_GRAPH_VMON, 1, ATTR_TRACE_LG_TEXT, "CH 30V"); |
||
308 | f9daq | 306 | SetTraceAttributeEx (pnl, P1_GRAPH_VMON, 2, ATTR_TRACE_LG_TEXT, "CH 30V"); |
307 | SetTraceAttributeEx (pnl, P1_GRAPH_VMON, 3, ATTR_TRACE_LG_TEXT, "CH 5V"); |
||
310 | f9daq | 308 | int ison; |
309 | for (unsigned char ch=0; ch<3; ch++) |
||
310 | { |
||
311 | |||
312 | K2231A_SelectChannel(ch+1); |
||
313 | |||
314 | Voltage =K2231A_GetSetVoltage(); |
||
315 | Current =K2231A_GetSetCurrent(); |
||
316 | ison =K2231A_GetSwitch(); |
||
317 | |||
318 | |||
319 | |||
320 | SetCtrlVal(pnl, vset[ch], Voltage); |
||
321 | SetCtrlVal(pnl, iset[ch], Current); |
||
322 | SetCtrlVal(pnl, radiob[ch], ison); |
||
323 | if (ison) SETREG(gMask,(1<<ch)); |
||
324 | else RSTREG(gMask,(1<<ch)); |
||
325 | } |
||
326 | |||
327 | DisplayPanel (pnl); |
||
308 | f9daq | 328 | RunUserInterface (); |
329 | DiscardPanel (pnl); |
||
310 | f9daq | 330 | K2231A_Close(); |
308 | f9daq | 331 | |
310 | f9daq | 332 | if (gFp) fclose(gFp); |
308 | f9daq | 333 | return 0; |
334 | } |
||
335 | |||
336 | |||
337 | |||
338 | |||
339 | int CVICALLBACK SwitchOnOffCB (int panel, int control, int event, |
||
310 | f9daq | 340 | void *callbackData, int eventData1, int eventData2) |
308 | f9daq | 341 | { |
310 | f9daq | 342 | unsigned char state; |
343 | switch (event) |
||
344 | { |
||
345 | case EVENT_COMMIT: |
||
346 | GetCtrlVal(panel, control, &state); |
||
347 | |||
348 | |||
349 | K2231A_SetSwitch(state); |
||
350 | |||
351 | break; |
||
352 | } |
||
353 | return 0; |
||
308 | f9daq | 354 | } |
355 | |||
356 | int CVICALLBACK SetCB (int panel, int control, int event, |
||
310 | f9daq | 357 | void *callbackData, int eventData1, int eventData2) |
308 | f9daq | 358 | { |
310 | f9daq | 359 | |
360 | |||
361 | switch (event) |
||
362 | { |
||
363 | case EVENT_COMMIT: |
||
364 | { |
||
365 | unsigned char preset=0; |
||
366 | |||
367 | SetCtrlVal(pnl, P1_PRESET, preset); |
||
368 | for (unsigned char ch = 0; ch<3; ch++) |
||
369 | { |
||
370 | //printf("ch %d %x\n", ch, gMask); |
||
371 | if (gMask & (1<<ch)) |
||
372 | { |
||
373 | double Voltage; |
||
374 | double Current; |
||
375 | |||
376 | GetCtrlVal(panel, vset[ch], &Voltage); |
||
377 | GetCtrlVal(panel, iset[ch], &Current); |
||
308 | f9daq | 378 | |
310 | f9daq | 379 | |
380 | char cmd[0xFF]; |
||
381 | |||
382 | K2231A_SelectChannel(ch+1); |
||
383 | |||
384 | Voltage =K2231A_GetVoltageMonitor(); |
||
385 | Current =K2231A_GetCurrentMonitor(); |
||
386 | |||
387 | |||
388 | printf("<-ch %d VSet %g Iset %g\n", ch, Voltage, Current); |
||
389 | |||
390 | } |
||
391 | } |
||
308 | f9daq | 392 | } |
310 | f9daq | 393 | break; |
394 | } |
||
395 | return 0; |
||
308 | f9daq | 396 | } |
397 | |||
398 | int CVICALLBACK ReadCB (int panel, int control, int event, |
||
310 | f9daq | 399 | void *callbackData, int eventData1, int eventData2) |
308 | f9daq | 400 | { |
310 | f9daq | 401 | |
402 | int iRet; |
||
403 | char ch=0; |
||
404 | double Voltage=0; |
||
405 | double Current=0; |
||
406 | char cv_cc=0; |
||
407 | switch (event) |
||
408 | { |
||
409 | case EVENT_COMMIT: |
||
410 | |||
411 | for (ch = 0; ch<3; ch++) |
||
412 | { |
||
413 | if (gMask & (1<<ch)) |
||
414 | { |
||
415 | K2231A_SelectChannel(ch+1); |
||
416 | |||
417 | Voltage =K2231A_GetVoltageMonitor(); |
||
418 | Current =K2231A_GetCurrentMonitor(); |
||
419 | |||
420 | cv_cc = K2231A_GetOperationMode(); |
||
421 | |||
422 | printf("ch %d VSet %g Iset %g\n", ch, Voltage, Current); |
||
423 | SetCtrlVal(panel, vmon[ch], Voltage); |
||
424 | SetCtrlVal(panel, imon[ch], Current); |
||
425 | SetCtrlVal(panel, cvcc[ch], cv_cc); |
||
426 | } |
||
427 | } |
||
428 | break; |
||
429 | } |
||
430 | return 0; |
||
308 | f9daq | 431 | } |
432 | |||
433 | int CVICALLBACK SetIntervalCB (int panel, int control, int event, |
||
310 | f9daq | 434 | void *callbackData, int eventData1, int eventData2) |
435 | { |
||
436 | double tinterval; |
||
437 | switch (event) |
||
438 | { |
||
439 | case EVENT_COMMIT: |
||
440 | GetCtrlVal(panel, control, &tinterval); |
||
441 | SetCtrlAttribute (panel, P1_TIMER, ATTR_INTERVAL, tinterval); |
||
442 | break; |
||
443 | } |
||
444 | return 0; |
||
308 | f9daq | 445 | } |
446 | |||
447 | int CVICALLBACK TimerOnOffCB (int panel, int control, int event, |
||
310 | f9daq | 448 | void *callbackData, int eventData1, int eventData2) |
308 | f9daq | 449 | { |
310 | f9daq | 450 | int state; |
451 | switch (event) |
||
452 | { |
||
453 | case EVENT_COMMIT: |
||
454 | GetCtrlVal(panel, control, &state); |
||
455 | if (state) |
||
456 | { |
||
457 | SetCtrlAttribute (panel, P1_TIMER, ATTR_ENABLED, 1); |
||
458 | ResumeTimerCallbacks(); |
||
459 | } |
||
460 | else |
||
461 | { |
||
462 | SuspendTimerCallbacks (); |
||
463 | printf ("Disabling timer....\n"); |
||
464 | } |
||
465 | break; |
||
466 | } |
||
467 | return 0; |
||
308 | f9daq | 468 | } |
469 | |||
470 | int CVICALLBACK ExitCB (int panel, int control, int event, |
||
310 | f9daq | 471 | void *callbackData, int eventData1, int eventData2) |
308 | f9daq | 472 | { |
310 | f9daq | 473 | switch (event) |
474 | { |
||
475 | case EVENT_COMMIT: |
||
476 | QuitUserInterface(0); |
||
477 | break; |
||
478 | } |
||
479 | return 0; |
||
308 | f9daq | 480 | } |
481 | |||
482 | int CVICALLBACK SetMaskCB (int panel, int control, int event, |
||
310 | f9daq | 483 | void *callbackData, int eventData1, int eventData2) |
484 | { |
||
485 | int ison; |
||
486 | switch (event) |
||
487 | { |
||
488 | int i=0; |
||
489 | case EVENT_COMMIT: |
||
490 | GetCtrlVal(panel, control, &ison); |
||
491 | for (i=0; i<3; i++) if (control == radiob[i]) break; |
||
492 | if (ison) SETREG(gMask,(1<<i)); |
||
493 | else RSTREG(gMask,(1<<i)); |
||
494 | break; |
||
495 | } |
||
496 | return 0; |
||
308 | f9daq | 497 | } |
498 | |||
499 | int CVICALLBACK LogToFileCB (int panel, int control, int event, |
||
310 | f9daq | 500 | void *callbackData, int eventData1, int eventData2) |
308 | f9daq | 501 | { |
310 | f9daq | 502 | |
503 | switch (event) |
||
504 | { |
||
505 | case EVENT_COMMIT: |
||
506 | GetCtrlVal(panel, control, &gLogToFile); |
||
507 | |||
508 | break; |
||
509 | } |
||
510 | return 0; |
||
308 | f9daq | 511 | } |
512 | |||
513 | int CVICALLBACK TimerCB (int panel, int control, int event, |
||
310 | f9daq | 514 | void *callbackData, int eventData1, int eventData2) |
308 | f9daq | 515 | { |
310 | f9daq | 516 | switch (event) |
517 | { |
||
518 | |||
519 | unsigned char ch; |
||
520 | double current[3]= {0,0,0}; |
||
521 | double voltage[3]= {0,0,0}; |
||
522 | char cv_cc=0; |
||
523 | case EVENT_TIMER_TICK: |
||
524 | for (ch = 0; ch<3; ch++) |
||
525 | { |
||
526 | if (gMask & (1<<ch)) |
||
527 | { |
||
528 | |||
529 | K2231A_SelectChannel(ch+1); |
||
530 | |||
531 | voltage[ch] =K2231A_GetVoltageMonitor(); |
||
532 | current[ch] =K2231A_GetCurrentMonitor(); |
||
533 | cv_cc = K2231A_GetOperationMode(); |
||
534 | int onoff=K2231A_GetSwitch(); |
||
535 | |||
536 | |||
537 | |||
538 | SetCtrlVal(panel, vmon[ch], voltage[ch]); |
||
539 | SetCtrlVal(panel, imon[ch], current[ch]); |
||
540 | SetCtrlVal(panel, cvcc[ch], cv_cc); |
||
541 | SetCtrlVal(panel, P1_ONOFFLED, onoff); |
||
542 | if (gLogToFile) |
||
543 | { |
||
544 | if (!gFp) |
||
545 | { |
||
546 | gFp= fopen("pw18-1.8aq.log","w"); |
||
547 | fprintf(gFp,"#time\tch\tU\tI\tCV_CC\n"); |
||
548 | } |
||
549 | fprintf(gFp,"%ul\t%d\t%g\t%g\t%d\n", time(NULL), ch+1, voltage[ch], current[ch], cv_cc); |
||
550 | } |
||
551 | } |
||
552 | } |
||
553 | PlotStripChart (panel, P1_GRAPH_IMON, current, 3, 0, 0, VAL_DOUBLE); |
||
554 | PlotStripChart (panel, P1_GRAPH_VMON, voltage, 3, 0, 0, VAL_DOUBLE); |
||
555 | break; |
||
556 | } |
||
557 | return 0; |
||
308 | f9daq | 558 | } |
559 | |||
560 | int CVICALLBACK SetPresetCB (int panel, int control, int event, |
||
310 | f9daq | 561 | void *callbackData, int eventData1, int eventData2) |
562 | { |
||
563 | char cmd[0xFF]; |
||
564 | switch (event) |
||
565 | { |
||
566 | case EVENT_COMMIT: |
||
567 | { |
||
308 | f9daq | 568 | unsigned char preset; |
569 | double Voltage, Current; |
||
310 | f9daq | 570 | GetCtrlVal(panel, control, &preset); |
308 | f9daq | 571 | |
310 | f9daq | 572 | K2231A_RecallFromMemory(preset); |
573 | for (unsigned char ch=0; ch<3; ch++) |
||
574 | { |
||
575 | int ison; |
||
576 | K2231A_SelectChannel(ch+1); |
||
577 | Voltage =K2231A_GetSetVoltage(); |
||
578 | Current =K2231A_GetSetCurrent(); |
||
579 | ison =K2231A_GetSwitch(); |
||
580 | |||
581 | SetCtrlVal(pnl, vset[ch], Voltage); |
||
582 | SetCtrlVal(pnl, iset[ch], Current); |
||
583 | GetCtrlVal(pnl, radiob[ch], &ison); |
||
584 | if (ison) SETREG(gMask,(1<<ch)); |
||
585 | else RSTREG(gMask,(1<<ch)); |
||
586 | } |
||
308 | f9daq | 587 | break; |
588 | } |
||
589 | } |
||
590 | return 0; |
||
591 | } |
||
592 | |||
310 | f9daq | 593 | int CVICALLBACK DebugCB (int panel, int control, int event, |
594 | void *callbackData, int eventData1, int eventData2) |
||
595 | { |
||
596 | switch (event) |
||
597 | { |
||
598 | case EVENT_COMMIT: |
||
599 | GetCtrlVal(panel, control, &debug); |
||
600 | break; |
||
601 | } |
||
602 | return 0; |
||
603 | } |
||
308 | f9daq | 604 | |
605 | |||
310 | f9daq | 606 | #endif MAIN |
607 |