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