Rev 256 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 185 | f9daq | 1 | #include <ansi_c.h> |
| 2 | #include <utility.h> |
||
| 3 | #include <gpib.h> |
||
| 256 | f9daq | 4 | #include "prologix.h" |
| 185 | f9daq | 5 | #include "K617.h" |
| 6 | |||
| 7 | K617STATUS K617Stat; |
||
| 256 | f9daq | 8 | static int K617_Interface,K617_Port,K617_Gdev; |
| 9 | static int iret; |
||
| 185 | f9daq | 10 | |
| 11 | void GpibError(char *msg) { |
||
| 12 | |||
| 13 | printf ("%s\n", msg); |
||
| 14 | |||
| 15 | printf ("ibsta = &H%x <", ibsta); |
||
| 16 | if (ibsta & ERR ) printf (" ERR"); |
||
| 17 | if (ibsta & TIMO) printf (" TIMO"); |
||
| 18 | if (ibsta & END ) printf (" END"); |
||
| 19 | if (ibsta & SRQI) printf (" SRQI"); |
||
| 20 | if (ibsta & RQS ) printf (" RQS"); |
||
| 21 | if (ibsta & CMPL) printf (" CMPL"); |
||
| 22 | if (ibsta & LOK ) printf (" LOK"); |
||
| 23 | if (ibsta & REM ) printf (" REM"); |
||
| 24 | if (ibsta & CIC ) printf (" CIC"); |
||
| 25 | if (ibsta & ATN ) printf (" ATN"); |
||
| 26 | if (ibsta & TACS) printf (" TACS"); |
||
| 27 | if (ibsta & LACS) printf (" LACS"); |
||
| 28 | if (ibsta & DTAS) printf (" DTAS"); |
||
| 29 | if (ibsta & DCAS) printf (" DCAS"); |
||
| 30 | printf (" >\n"); |
||
| 31 | |||
| 32 | printf ("iberr = %d", iberr); |
||
| 33 | if (iberr == EDVR) printf (" EDVR <DOS Error>\n"); |
||
| 34 | if (iberr == ECIC) printf (" ECIC <Not Controller-In-Charge>\n"); |
||
| 35 | if (iberr == ENOL) printf (" ENOL <No Listener>\n"); |
||
| 36 | if (iberr == EADR) printf (" EADR <Address error>\n"); |
||
| 37 | if (iberr == EARG) printf (" EARG <Invalid argument>\n"); |
||
| 38 | if (iberr == ESAC) printf (" ESAC <Not System Controller>\n"); |
||
| 39 | if (iberr == EABO) printf (" EABO <Operation aborted>\n"); |
||
| 40 | if (iberr == ENEB) printf (" ENEB <No GPIB board>\n"); |
||
| 41 | if (iberr == EOIP) printf (" EOIP <Async I/O in progress>\n"); |
||
| 42 | if (iberr == ECAP) printf (" ECAP <No capability>\n"); |
||
| 43 | if (iberr == EFSO) printf (" EFSO <File system error>\n"); |
||
| 44 | if (iberr == EBUS) printf (" EBUS <Command error>\n"); |
||
| 45 | if (iberr == ESTB) printf (" ESTB <Status byte lost>\n"); |
||
| 46 | if (iberr == ESRQ) printf (" ESRQ <SRQ stuck on>\n"); |
||
| 47 | if (iberr == ETAB) printf (" ETAB <Table Overflow>\n"); |
||
| 48 | |||
| 49 | printf ("ibcntl = %ld\n", ibcntl); |
||
| 50 | printf ("\n"); |
||
| 51 | |||
| 52 | /* Call ibonl to take the device and interface offline */ |
||
| 256 | f9daq | 53 | ibonl (K617_Gdev,0); |
| 185 | f9daq | 54 | |
| 55 | exit(1); |
||
| 56 | } |
||
| 57 | |||
| 256 | f9daq | 58 | void _VI_FUNC K617_open (int interface, int port, int primary_addr, |
| 59 | int secondary_addr, int timeout) |
||
| 185 | f9daq | 60 | { |
| 256 | f9daq | 61 | char cmd[100]; |
| 185 | f9daq | 62 | /* |
| 256 | f9daq | 63 | K617_Gdev = OpenDev ("GPIB0", ""); |
| 185 | f9daq | 64 | if (ibsta & ERR) GpibError("OpenDev Error"); |
| 256 | f9daq | 65 | iret = ibpad (K617_Gdev, 0); |
| 185 | f9daq | 66 | if (ibsta & ERR) GpibError("OpenDev Error"); |
| 256 | f9daq | 67 | iret = ibsad (K617_Gdev, NO_SAD); |
| 68 | iret = ibtmo (K617_Gdev, T10s); |
||
| 69 | iret = ibeot (K617_Gdev, 1); |
||
| 70 | iret = ibeos (K617_Gdev, 0); |
||
| 185 | f9daq | 71 | */ |
| 256 | f9daq | 72 | K617_Interface=interface; |
| 73 | K617_Port=port; |
||
| 74 | switch (K617_Interface){ |
||
| 75 | case 1: |
||
| 76 | PROLOGIX_Open (K617_Port); |
||
| 77 | sprintf(cmd,"++addr %0d",primary_addr); |
||
| 78 | PROLOGIX_Send (cmd); |
||
| 79 | PROLOGIX_Send ("++auto 0"); |
||
| 80 | PROLOGIX_Send ("++eoi 1"); |
||
| 81 | PROLOGIX_Send ("++eot_enable 0"); |
||
| 82 | PROLOGIX_Send ("++read_tmo_ms 1000"); |
||
| 83 | break; |
||
| 84 | default: |
||
| 85 | K617_Gdev = ibdev(K617_Port,primary_addr,secondary_addr,timeout,1,0); |
||
| 86 | if (ibsta & ERR) GpibError("OpenDev Error"); |
||
| 87 | } |
||
| 185 | f9daq | 88 | Delay(GDELAY); |
| 89 | return; |
||
| 90 | } |
||
| 91 | |||
| 92 | void _VI_FUNC K617_clear (void) |
||
| 93 | { |
||
| 256 | f9daq | 94 | switch (K617_Interface){ |
| 95 | case 1: |
||
| 96 | PROLOGIX_Send("++clr"); |
||
| 97 | break; |
||
| 98 | default: |
||
| 99 | iret = ibclr (K617_Gdev); // Clear the device |
||
| 100 | if (ibsta & ERR) GpibError("OpenDev Error"); |
||
| 101 | } |
||
| 102 | // Delay(GDELAY); |
||
| 103 | Delay(2.); |
||
| 185 | f9daq | 104 | return; |
| 105 | } |
||
| 106 | |||
| 107 | void _VI_FUNC K617_send (char *cmd, int len) |
||
| 108 | { |
||
| 256 | f9daq | 109 | switch (K617_Interface){ |
| 110 | case 1: |
||
| 111 | PROLOGIX_Send(cmd); |
||
| 112 | break; |
||
| 113 | default: |
||
| 114 | iret = ibwrt (K617_Gdev, cmd, len); |
||
| 115 | if (ibsta & ERR) GpibError("OpenDev Error"); |
||
| 116 | } |
||
| 185 | f9daq | 117 | Delay(GDELAY); |
| 118 | return; |
||
| 119 | } |
||
| 120 | |||
| 121 | int _VI_FUNC K617_receive (char *response, int maxbyt) |
||
| 122 | { |
||
| 256 | f9daq | 123 | switch (K617_Interface){ |
| 124 | case 1: |
||
| 125 | PROLOGIX_Send("++read eoi"); |
||
| 126 | return PROLOGIX_Receive (response,maxbyt); |
||
| 127 | break; |
||
| 128 | default: |
||
| 129 | iret = ibrd (K617_Gdev, response, maxbyt); |
||
| 130 | if (ibsta & ERR) GpibError("OpenDev Error"); |
||
| 131 | response[ibcntl]=0; |
||
| 132 | return ibcntl; |
||
| 133 | } |
||
| 185 | f9daq | 134 | } |
| 135 | |||
| 136 | void _VI_FUNC K617_status (void) |
||
| 137 | { |
||
| 138 | int len; |
||
| 139 | char cres[100]; |
||
| 140 | |||
| 141 | K617_send ("U0X", 3); |
||
| 142 | len = K617_receive (cres, 90); |
||
| 143 | sscanf(cres," 617%1d%2d%1d%1d%1d%1d%1d%1d%1d%1d%1d%2d%1d%2c", |
||
| 144 | &K617Stat.function,&K617Stat.range,&K617Stat.zero_check, |
||
| 145 | &K617Stat.zero_correct,&K617Stat.suppress,&K617Stat.trigger, |
||
| 146 | &K617Stat.vsource_operate,&K617Stat.read_mode, |
||
| 147 | &K617Stat.data_prefix,&K617Stat.display, |
||
| 148 | &K617Stat.data_store,&K617Stat.srq,&K617Stat.eoi,K617Stat.terminator); |
||
| 256 | f9daq | 149 | // printf("617FRRCZNTOBGDQMMKYY\n"); |
| 150 | // printf("%s\n",cres); |
||
| 151 | // K617_send ("X", 1); |
||
| 185 | f9daq | 152 | return; |
| 153 | } |
||
| 154 | |||
| 155 | void _VI_FUNC K617_data_format (int mode) |
||
| 156 | { |
||
| 157 | int len; |
||
| 158 | char cmd[100]; |
||
| 159 | |||
| 160 | len=sprintf(cmd,"G%0dX",mode); |
||
| 161 | K617_send (cmd, len); |
||
| 162 | return; |
||
| 163 | } |
||
| 164 | |||
| 165 | double _VI_FUNC K617_get (char *prefix, int *loc) |
||
| 166 | { |
||
| 167 | int len; |
||
| 168 | double value; |
||
| 169 | char cres[100]; |
||
| 170 | |||
| 171 | K617_send ("X", 1); |
||
| 172 | len = K617_receive (cres, 50); |
||
| 173 | if (loc) { |
||
| 174 | *loc=-1; |
||
| 175 | sscanf(cres,"%4c%lg,%d",prefix, &value, loc); |
||
| 176 | prefix[4]=0; |
||
| 177 | } else { |
||
| 178 | sscanf(cres,"%*4c%lg,%*d",&value); |
||
| 179 | } |
||
| 180 | return value; |
||
| 181 | } |
||
| 182 | |||
| 183 | void _VI_FUNC K617_current_mode (int range) |
||
| 184 | { |
||
| 185 | int len; |
||
| 186 | char cmd[100]; |
||
| 187 | |||
| 188 | len=sprintf(cmd,"F1R%0dX",range); |
||
| 189 | // printf("%d, %s\n",len,cmd); |
||
| 190 | K617_send (cmd, len); |
||
| 191 | Delay(1); |
||
| 192 | return; |
||
| 193 | } |
||
| 194 | |||
| 195 | void _VI_FUNC K617_zero_correct (int zcorrect) |
||
| 196 | { |
||
| 197 | K617_send ("C0X", 3); |
||
| 198 | K617_send ("Z0X", 3); |
||
| 199 | if (zcorrect) { |
||
| 200 | K617_send ("C1X", 3); |
||
| 201 | Delay(2); |
||
| 202 | K617_send ("Z1X", 3); |
||
| 203 | K617_send ("C0X", 3); |
||
| 204 | } |
||
| 205 | return; |
||
| 206 | } |
||
| 207 | |||
| 208 | void _VI_FUNC K617_trigger_mode (int mode) |
||
| 209 | { |
||
| 210 | int len; |
||
| 211 | char cmd[100]; |
||
| 212 | |||
| 213 | len=sprintf(cmd,"T%0dX",mode); |
||
| 214 | K617_send (cmd, len); |
||
| 215 | return; |
||
| 216 | } |
||
| 217 | |||
| 218 | void _VI_FUNC K617_reading_mode (int mode) |
||
| 219 | { |
||
| 220 | int len; |
||
| 221 | char cmd[100]; |
||
| 222 | |||
| 223 | len=sprintf(cmd,"B%0dX",mode); |
||
| 224 | K617_send (cmd, len); |
||
| 225 | return; |
||
| 226 | } |
||
| 227 | |||
| 228 | void _VI_FUNC K617_vsource_set (float value) |
||
| 229 | { |
||
| 230 | int len; |
||
| 231 | char cmd[100]; |
||
| 232 | |||
| 233 | value=0.05*floor((value+0.025)/0.05); |
||
| 234 | len=sprintf(cmd,"V%+0.2fX",value); |
||
| 235 | // printf("%d, %s\n",len,cmd); |
||
| 236 | K617_send (cmd, len); |
||
| 237 | return; |
||
| 238 | } |
||
| 239 | |||
| 240 | double _VI_FUNC K617_vsource_get (void) |
||
| 241 | { |
||
| 242 | double value; |
||
| 243 | |||
| 244 | K617_reading_mode (4); |
||
| 245 | value = K617_get (NULL, NULL); |
||
| 246 | K617_reading_mode (0); |
||
| 247 | return value; |
||
| 248 | } |
||
| 249 | |||
| 250 | void _VI_FUNC K617_vsource_operate (int operate) |
||
| 251 | { |
||
| 252 | |||
| 253 | if (operate) |
||
| 254 | K617_send ("O1X", 3); |
||
| 255 | else |
||
| 256 | K617_send ("O0X", 3); |
||
| 257 | |||
| 258 | return; |
||
| 259 | } |
||
| 260 | |||
| 261 | void _VI_FUNC K617_close (void) |
||
| 262 | { |
||
| 256 | f9daq | 263 | // iret = CloseDev (K617_Gdev); |
| 264 | switch (K617_Interface){ |
||
| 265 | case 1: |
||
| 266 | PROLOGIX_Close(); |
||
| 267 | break; |
||
| 268 | default: |
||
| 269 | iret = ibonl(K617_Gdev, 0);// Take the device offline |
||
| 270 | if (ibsta & ERR) GpibError("OpenDev Error"); |
||
| 271 | } |
||
| 185 | f9daq | 272 | return; |
| 273 | } |
||
| 274 | |||
| 279 | f9daq | 275 | void _VI_FUNC K617_test (void) |
| 185 | f9daq | 276 | { |
| 279 | f9daq | 277 | int i; |
| 185 | f9daq | 278 | double value; |
| 279 | char cres[100]; |
||
| 280 | |||
| 281 | K617_clear (); |
||
| 282 | K617_current_mode (4); |
||
| 283 | K617_zero_correct (1); |
||
| 284 | K617_data_format (0); |
||
| 256 | f9daq | 285 | K617_trigger_mode (1); |
| 185 | f9daq | 286 | K617_vsource_set (-100.); |
| 287 | K617_vsource_operate (1); |
||
| 288 | |||
| 256 | f9daq | 289 | K617_status(); |
| 290 | |||
| 291 | value=K617_get(cres,&i); |
||
| 185 | f9daq | 292 | printf("%s, %lg, %d\n",cres,value,i); |
| 293 | value=K617_vsource_get(); |
||
| 256 | f9daq | 294 | printf("%lg\n",value); |
| 295 | value=K617_get(cres,&i); |
||
| 185 | f9daq | 296 | printf("%s, %lg, %d\n",cres,value,i); |
| 256 | f9daq | 297 | value=K617_get(cres,&i); |
| 185 | f9daq | 298 | printf("%s, %lg, %d\n",cres,value,i); |
| 256 | f9daq | 299 | value=K617_get(cres,&i); |
| 300 | printf("%s, %lg, %d\n",cres,value,i); |
||
| 301 | value=K617_get(cres,&i); |
||
| 302 | printf("%s, %lg, %d\n",cres,value,i); |
||
| 185 | f9daq | 303 | Delay(5); |
| 256 | f9daq | 304 | K617_vsource_operate (0); |
| 185 | f9daq | 305 | |
| 306 | |||
| 279 | f9daq | 307 | } |
| 308 | |||
| 309 | #ifdef K617_MAIN |
||
| 310 | |||
| 311 | #include <cvirte.h> |
||
| 312 | #include <userint.h> |
||
| 313 | #include "K617-ctrl.h" |
||
| 314 | int pnl; int gLogToFile; |
||
| 315 | int vmon[4]={P1_VMON_1}; |
||
| 316 | int imon[4]={P1_IMON_1 }; |
||
| 317 | int vset[4]={P1_U_1 }; |
||
| 318 | int iset[4]={P1_I_1 }; |
||
| 319 | int radiob[4]={P1_BOX_1 }; |
||
| 320 | |||
| 321 | int cvcc[4]={P1_CVCC_1 }; |
||
| 322 | const unsigned char Pre_1 = 1; |
||
| 323 | int gMask=0xF; |
||
| 324 | |||
| 325 | int pnl; |
||
| 326 | FILE *gFp; |
||
| 327 | int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, |
||
| 328 | LPSTR lpszCmdLine, int nCmdShow) |
||
| 329 | { |
||
| 330 | char cres[100]; |
||
| 331 | double Voltage, Current, tinterval; |
||
| 332 | if (InitCVIRTE (hInstance, 0, 0) == 0) return -1; /* out of memory */ |
||
| 333 | SetStdioPort (CVI_STDIO_WINDOW); |
||
| 334 | if ((pnl = LoadPanel (0, "K617-ctrl.uir", P1)) < 0) return -1; |
||
| 335 | |||
| 336 | K617_open (1,4,3,0,13); |
||
| 337 | |||
| 338 | |||
| 339 | SetCtrlVal(pnl, P1_ONOFF, 0); |
||
| 340 | GetCtrlVal(pnl, P1_TINTERVAL, &tinterval); |
||
| 341 | SetCtrlAttribute (pnl, P1_TIMER, ATTR_INTERVAL, tinterval); |
||
| 342 | |||
| 343 | for (unsigned char ch=0;ch<1;ch++){ |
||
| 344 | int ison,i; |
||
| 345 | Voltage =K617_vsource_get(); |
||
| 346 | Current =K617_get(cres,&i); |
||
| 347 | SetCtrlVal(pnl, vset[ch], Voltage); |
||
| 348 | SetCtrlVal(pnl, iset[ch], Current); |
||
| 349 | GetCtrlVal(pnl, radiob[ch], &ison); |
||
| 350 | gMask = ison; |
||
| 351 | } |
||
| 352 | |||
| 353 | DisplayPanel (pnl); |
||
| 354 | RunUserInterface (); |
||
| 355 | DiscardPanel (pnl); |
||
| 356 | K617_close(); |
||
| 357 | |||
| 358 | if (gFp) fclose(gFp); |
||
| 359 | |||
| 360 | |||
| 185 | f9daq | 361 | return 0; |
| 362 | } |
||
| 363 | |||
| 279 | f9daq | 364 | |
| 365 | |||
| 366 | |||
| 367 | int CVICALLBACK SwitchOnOffCB (int panel, int control, int event, |
||
| 368 | void *callbackData, int eventData1, int eventData2) |
||
| 369 | { |
||
| 370 | unsigned char state; |
||
| 371 | switch (event) |
||
| 372 | { |
||
| 373 | case EVENT_COMMIT: |
||
| 374 | GetCtrlVal(panel, control, &state); |
||
| 375 | K617_vsource_operate (state); |
||
| 376 | break; |
||
| 377 | } |
||
| 378 | return 0; |
||
| 379 | } |
||
| 380 | |||
| 381 | int CVICALLBACK SetCB (int panel, int control, int event, |
||
| 382 | void *callbackData, int eventData1, int eventData2) |
||
| 383 | { |
||
| 384 | |||
| 385 | char cres[100]; |
||
| 386 | int i; |
||
| 387 | switch (event) |
||
| 388 | { |
||
| 389 | case EVENT_COMMIT: |
||
| 390 | |||
| 391 | for (unsigned char ch = 0; ch<1;ch++){ |
||
| 392 | //printf("ch %d %x\n", ch, gMask); |
||
| 393 | if (gMask){ |
||
| 394 | double Voltage; |
||
| 395 | double Current; |
||
| 396 | GetCtrlVal(panel, vset[ch], &Voltage); |
||
| 397 | GetCtrlVal(panel, iset[ch], &Current); |
||
| 398 | printf("->ch %d VSet %g Iset %g\n", ch, Voltage, Current); |
||
| 399 | |||
| 400 | K617_vsource_set (Voltage); |
||
| 401 | Voltage=K617_vsource_get(); |
||
| 402 | |||
| 403 | // TMI_Current(TMI_DeviceId, ch+1, Pre_1, Current); |
||
| 404 | Current=K617_get(cres,&i); |
||
| 405 | printf("<-ch %d VSet %g Iset %g\n", ch, Voltage, Current); |
||
| 406 | |||
| 407 | } |
||
| 408 | } |
||
| 409 | break; |
||
| 410 | } |
||
| 411 | return 0; |
||
| 412 | } |
||
| 413 | |||
| 414 | int CVICALLBACK ReadCB (int panel, int control, int event, |
||
| 415 | void *callbackData, int eventData1, int eventData2) |
||
| 416 | { |
||
| 417 | |||
| 418 | int iRet; |
||
| 419 | char ch=0; |
||
| 420 | double Voltage; |
||
| 421 | double Current; |
||
| 422 | char cv_cc; |
||
| 423 | char cres[100]; |
||
| 424 | |||
| 425 | switch (event) |
||
| 426 | { |
||
| 427 | case EVENT_COMMIT: |
||
| 428 | for (ch = 0; ch<1;ch++){ |
||
| 429 | if (gMask){ |
||
| 430 | int ison,i; |
||
| 431 | Voltage =K617_vsource_get(); |
||
| 432 | Current =K617_get(cres,&i); |
||
| 433 | cv_cc = 1; |
||
| 434 | printf("ch %d VSet %g Iset %g\n", ch, Voltage, Current); |
||
| 435 | SetCtrlVal(panel, vmon[ch], Voltage); |
||
| 436 | SetCtrlVal(panel, imon[ch], Current); |
||
| 437 | SetCtrlVal(panel, cvcc[ch], cv_cc); |
||
| 438 | } |
||
| 439 | } |
||
| 440 | break; |
||
| 441 | } |
||
| 442 | return 0; |
||
| 443 | } |
||
| 444 | |||
| 445 | int CVICALLBACK SetIntervalCB (int panel, int control, int event, |
||
| 446 | void *callbackData, int eventData1, int eventData2) { |
||
| 447 | double tinterval; |
||
| 448 | switch (event) { |
||
| 449 | case EVENT_COMMIT: |
||
| 450 | GetCtrlVal(panel, control, &tinterval); |
||
| 451 | SetCtrlAttribute (panel, P1_TIMER, ATTR_INTERVAL, tinterval); |
||
| 452 | break; |
||
| 453 | } |
||
| 454 | return 0; |
||
| 455 | } |
||
| 456 | |||
| 457 | int CVICALLBACK TimerOnOffCB (int panel, int control, int event, |
||
| 458 | void *callbackData, int eventData1, int eventData2) |
||
| 459 | { |
||
| 460 | int state; |
||
| 461 | switch (event) |
||
| 462 | { |
||
| 463 | case EVENT_COMMIT: |
||
| 464 | GetCtrlVal(panel, control, &state); |
||
| 465 | if (state){ |
||
| 466 | ResumeTimerCallbacks(); |
||
| 467 | } else { |
||
| 468 | SuspendTimerCallbacks (); |
||
| 469 | printf ("Disabling timer....\n"); |
||
| 470 | } |
||
| 471 | break; |
||
| 472 | } |
||
| 473 | return 0; |
||
| 474 | } |
||
| 475 | |||
| 476 | int CVICALLBACK ExitCB (int panel, int control, int event, |
||
| 477 | void *callbackData, int eventData1, int eventData2) |
||
| 478 | { |
||
| 479 | switch (event) |
||
| 480 | { |
||
| 481 | case EVENT_COMMIT: |
||
| 482 | QuitUserInterface(0); |
||
| 483 | break; |
||
| 484 | } |
||
| 485 | return 0; |
||
| 486 | } |
||
| 487 | |||
| 488 | int CVICALLBACK SetMaskCB (int panel, int control, int event, |
||
| 489 | void *callbackData, int eventData1, int eventData2) |
||
| 490 | { int ison; |
||
| 491 | switch (event) |
||
| 492 | { |
||
| 493 | case EVENT_COMMIT: |
||
| 494 | GetCtrlVal(panel, control, &ison); |
||
| 495 | for (int i=0;i<1;i++) if (control == radiob[i]) break; |
||
| 496 | gMask = ison; |
||
| 497 | break; |
||
| 498 | } |
||
| 499 | return 0; |
||
| 500 | } |
||
| 501 | |||
| 502 | |||
| 503 | int CVICALLBACK LogToFileCB (int panel, int control, int event, |
||
| 504 | void *callbackData, int eventData1, int eventData2) |
||
| 505 | { |
||
| 506 | |||
| 507 | switch (event) |
||
| 508 | { |
||
| 509 | case EVENT_COMMIT: |
||
| 510 | GetCtrlVal(panel, control, &gLogToFile); |
||
| 511 | |||
| 512 | break; |
||
| 513 | } |
||
| 514 | return 0; |
||
| 515 | } |
||
| 516 | |||
| 517 | int CVICALLBACK TimerCB (int panel, int control, int event, |
||
| 518 | void *callbackData, int eventData1, int eventData2) |
||
| 519 | { |
||
| 520 | switch (event) |
||
| 521 | { |
||
| 522 | |||
| 523 | unsigned char ch; |
||
| 524 | double current[4]; |
||
| 525 | double voltage; |
||
| 526 | char cv_cc = 0; |
||
| 527 | char cres[100]; |
||
| 528 | int i=0; |
||
| 529 | case EVENT_TIMER_TICK: |
||
| 530 | for (ch = 0; ch<1;ch++){ |
||
| 531 | if (gMask){ |
||
| 532 | voltage =K617_vsource_get(); |
||
| 533 | current[ch] =K617_get(cres,&i); |
||
| 534 | |||
| 535 | if (gLogToFile){ |
||
| 536 | if (!gFp) { |
||
| 537 | gFp= fopen("K617.log","w"); |
||
| 538 | fprintf(gFp,"#time\tch\tU\tI\tCV_CC\n"); |
||
| 539 | } |
||
| 540 | fprintf(gFp,"%ul\t%d\t%g\t%g\t%d\n", time(NULL), ch+1, voltage, current[ch], cv_cc); |
||
| 541 | } |
||
| 542 | } |
||
| 543 | } |
||
| 544 | PlotStripChart (panel, P1_GRAPH, current, 1, 0, 0, VAL_DOUBLE); |
||
| 545 | PlotStripChart (panel, P1_GRAPH_1, &voltage, 1, 0, 0, VAL_DOUBLE); |
||
| 546 | break; |
||
| 547 | } |
||
| 548 | return 0; |
||
| 549 | } |
||
| 550 | |||
| 551 | int CVICALLBACK TestCB (int panel, int control, int event, |
||
| 552 | void *callbackData, int eventData1, int eventData2) { |
||
| 553 | switch (event) { |
||
| 554 | case EVENT_COMMIT: |
||
| 555 | K617_test(); |
||
| 556 | break; |
||
| 557 | } |
||
| 558 | return 0; |
||
| 559 | } |
||
| 560 | |||
| 185 | f9daq | 561 | #endif |
| 279 | f9daq | 562 |