Rev 210 | Rev 265 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 217 | f9daq | 1 | #include "H1D.h" |
| 2 | #include "H2D.h" |
||
| 203 | f9daq | 3 | #include <formatio.h> |
| 195 | f9daq | 4 | #include <utility.h> |
| 5 | #include <ansi_c.h> |
||
| 203 | f9daq | 6 | #include <cvirte.h> |
| 195 | f9daq | 7 | #include <userint.h> |
| 8 | #include "drs4.h" |
||
| 203 | f9daq | 9 | #include "drsread.h" |
| 195 | f9daq | 10 | |
| 203 | f9daq | 11 | #define MIKRO |
| 12 | |||
| 13 | #ifdef MIKRO |
||
| 14 | #include "MIKRO.h" |
||
| 15 | #endif |
||
| 16 | |||
| 195 | f9daq | 17 | static int daq_on; |
| 203 | f9daq | 18 | static int ph, p2,plothandle[4]= {0,0,0,0}; |
| 217 | f9daq | 19 | static int scanplothandle; |
| 195 | f9daq | 20 | static int tfID; |
| 21 | static int controlID; |
||
| 22 | |||
| 203 | f9daq | 23 | #define MAX_THREADS 10 |
| 195 | f9daq | 24 | |
| 203 | f9daq | 25 | static CmtThreadPoolHandle poolHandle = 0; |
| 195 | f9daq | 26 | |
| 217 | f9daq | 27 | static float gSum[4]={0,0,0,0}; |
| 195 | f9daq | 28 | int main (int argc, char *argv[]) { |
| 203 | f9daq | 29 | short port; |
| 30 | if (InitCVIRTE (0, argv, 0) == 0) |
||
| 31 | return -1; /* out of memory */ |
||
| 32 | if ((ph = LoadPanel (0, "drs4.uir", PANEL)) < 0) |
||
| 33 | return -1; |
||
| 34 | if ((p2 = LoadPanel (0, "drs4.uir", SCAN)) < 0) |
||
| 35 | return -1; |
||
| 36 | SetStdioPort (CVI_STDIO_WINDOW); |
||
| 37 | SetSleepPolicy(VAL_SLEEP_MORE); |
||
| 38 | CmtNewThreadPool (MAX_THREADS, &poolHandle); |
||
| 39 | |||
| 40 | DisplayPanel (ph); |
||
| 41 | DisplayPanel (p2); |
||
| 42 | |||
| 43 | #ifdef MIKRO |
||
| 44 | GetCtrlVal(p2, SCAN_PORT, &port); |
||
| 45 | if (MIKRO_Open (port)) MessagePopup ("Error", "Mikro Port Not found !\n Change in the GUI") ; |
||
| 46 | MIKRO_Init(1,0); |
||
| 47 | MIKRO_Init(2,0); |
||
| 48 | #endif |
||
| 49 | |||
| 50 | RunUserInterface (); |
||
| 51 | DiscardPanel (ph); |
||
| 52 | DiscardPanel (p2); |
||
| 53 | CmtDiscardThreadPool (poolHandle); |
||
| 54 | MIKRO_Close (); |
||
| 55 | return 0; |
||
| 195 | f9daq | 56 | } |
| 57 | |||
| 58 | |||
| 210 | f9daq | 59 | char strbuf[0xFF]; |
| 195 | f9daq | 60 | |
| 210 | f9daq | 61 | int gLog=0; |
| 195 | f9daq | 62 | |
| 210 | f9daq | 63 | int printf(const char *format, ...) { |
| 64 | va_list aptr; |
||
| 65 | int ret; |
||
| 66 | FILE *flog; |
||
| 195 | f9daq | 67 | |
| 210 | f9daq | 68 | va_start(aptr, format); |
| 69 | ret = vsprintf(strbuf, format, aptr); |
||
| 70 | va_end(aptr); |
||
| 71 | SetCtrlVal(ph,PANEL_STDIO,strbuf); |
||
| 72 | |||
| 73 | if (gLog) { |
||
| 74 | flog = fopen ("stdio.log", "a"); |
||
| 75 | fprintf (flog, "%s", strbuf); |
||
| 76 | fclose (flog); |
||
| 77 | } |
||
| 78 | return(ret); |
||
| 79 | } |
||
| 80 | |||
| 81 | |||
| 82 | |||
| 195 | f9daq | 83 | static void start_timer (double tout) { |
| 203 | f9daq | 84 | SetCtrlAttribute (ph, PANEL_TIMER, ATTR_INTERVAL, tout); |
| 85 | SetCtrlAttribute (ph, PANEL_TIMER, ATTR_ENABLED, 1); |
||
| 195 | f9daq | 86 | } |
| 87 | |||
| 88 | static void stop_timer ( void ) { |
||
| 203 | f9daq | 89 | SetCtrlAttribute (ph, PANEL_TIMER, ATTR_ENABLED, 0); |
| 90 | DRSSetTimeout(); |
||
| 195 | f9daq | 91 | } |
| 92 | |||
| 93 | |||
| 94 | |||
| 95 | |||
| 96 | void CVICALLBACK EndOfThread ( CmtThreadPoolHandle poolhandle, |
||
| 203 | f9daq | 97 | CmtThreadFunctionID functionID, unsigned int event, |
| 98 | int value, void *callbackData ) { |
||
| 195 | f9daq | 99 | |
| 203 | f9daq | 100 | daq_on=0; |
| 101 | //SetDimming(0); |
||
| 102 | printf("End of Thread \n"); |
||
| 103 | return ; |
||
| 195 | f9daq | 104 | |
| 105 | } |
||
| 106 | |||
| 107 | |||
| 217 | f9daq | 108 | static float xs[4][1024]; |
| 203 | f9daq | 109 | int CVICALLBACK daq(void *functionData) { |
| 195 | f9daq | 110 | |
| 111 | |||
| 203 | f9daq | 112 | int neve; |
| 113 | char filename[0xff]; |
||
| 114 | int imask[4]; |
||
| 115 | unsigned long mask; |
||
| 116 | int frequency; |
||
| 117 | double trgdelay; |
||
| 118 | double trglevel; |
||
| 119 | int trgtype; |
||
| 120 | int trgchannel; |
||
| 121 | int trgpolarity; |
||
| 122 | int verbose; |
||
| 123 | double range; |
||
| 124 | int pfreq; |
||
| 125 | int enabledoutput; |
||
| 126 | int neveold = 0; |
||
| 127 | double rate; |
||
| 128 | int *args = (int *) functionData; |
||
| 217 | f9daq | 129 | double twin[2]; |
| 201 | f9daq | 130 | |
| 217 | f9daq | 131 | |
| 203 | f9daq | 132 | GetCtrlVal(ph, PANEL_CH0, &imask[0] ); |
| 133 | GetCtrlVal(ph, PANEL_CH1, &imask[1] ); |
||
| 134 | GetCtrlVal(ph, PANEL_CH2, &imask[2] ); |
||
| 135 | GetCtrlVal(ph, PANEL_CH3, &imask[3] ); |
||
| 136 | mask = 0; |
||
| 137 | for (int i=0; i<4; i++) { |
||
| 138 | if (imask[i]) mask |= (1<<i); |
||
| 201 | f9daq | 139 | } |
| 203 | f9daq | 140 | |
| 141 | GetCtrlVal(ph,PANEL_NEVE, &neve); |
||
| 142 | GetCtrlVal(ph,PANEL_DEBUG, &verbose); |
||
| 143 | GetCtrlVal(ph,PANEL_PFREQ, &pfreq); |
||
| 144 | GetCtrlVal(ph,PANEL_ENABLEDOUTPUT, &enabledoutput); |
||
| 145 | |||
| 146 | GetCtrlVal(ph,PANEL_FREQUENCY, &frequency); |
||
| 147 | GetCtrlVal(ph,PANEL_TRGDELAY, &trgdelay); |
||
| 148 | GetCtrlVal(ph,PANEL_TRGCHANNEL, &trgchannel); |
||
| 149 | |||
| 150 | GetCtrlVal(ph,PANEL_TRGTYPE, &trgtype); |
||
| 151 | GetCtrlVal(ph,PANEL_TRGLEVEL, &trglevel); |
||
| 152 | GetCtrlVal(ph,PANEL_TRGPOLARITY, &trgpolarity); |
||
| 153 | GetCtrlVal(ph,PANEL_RANGE, &range); |
||
| 154 | |||
| 217 | f9daq | 155 | GetCtrlVal(ph,PANEL_TWIN0, &twin[0]); |
| 156 | GetCtrlVal(ph,PANEL_TWIN1, &twin[1]); |
||
| 203 | f9daq | 157 | //printf("mask=0x%x\n",mask); |
| 158 | |||
| 159 | DRSSetMask( (unsigned char)( mask & 0xF ) ); |
||
| 160 | |||
| 161 | DRSSetFrequency( frequency ); |
||
| 162 | DRSSetTriggerDelay(trgdelay ); |
||
| 163 | DRSSetTriggerChannel(trgchannel ); |
||
| 164 | DRSSetTriggerType( trgtype ); |
||
| 165 | DRSSetTriggerLevel(trglevel); |
||
| 166 | DRSSetTriggerPolarity(trgpolarity); |
||
| 167 | |||
| 168 | DRSSetRange ( range ); |
||
| 169 | |||
| 170 | |||
| 171 | |||
| 172 | FILE *fp= NULL; |
||
| 173 | |||
| 174 | if (enabledoutput) { |
||
| 217 | f9daq | 175 | if (args[0]) { |
| 176 | GetCtrlVal(ph, PANEL_FILENAME, filename ); |
||
| 177 | fp = fopen(filename,"wb"); |
||
| 178 | } else { |
||
| 179 | GetCtrlVal(p2, SCAN_FILENAME, filename ); |
||
| 180 | fp = fopen(filename,"ab"); |
||
| 181 | } |
||
| 203 | f9daq | 182 | } |
| 183 | |||
| 184 | static unsigned char *buffer; |
||
| 185 | |||
| 186 | int buffer_size = 0; |
||
| 187 | const int nBoards=1; |
||
| 188 | const int waveDepth=1024; |
||
| 207 | f9daq | 189 | |
| 203 | f9daq | 190 | if (buffer_size == 0) { |
| 207 | f9daq | 191 | buffer_size = 8; // file header + time header |
| 192 | buffer_size += nBoards * (4 + 4*(4+waveDepth*4)); // bin widths |
||
| 193 | buffer_size += 24 + nBoards * (8 + 4*(8+waveDepth*2)); |
||
| 194 | buffer = (unsigned char *)malloc(buffer_size); |
||
| 195 | } |
||
| 196 | |||
| 203 | f9daq | 197 | time_t t=0,told=0, tstart=0; |
| 198 | |||
| 199 | if (!DRSInit()) { |
||
| 200 | time(&tstart); |
||
| 201 | told=tstart; |
||
| 217 | f9daq | 202 | int nev=0; |
| 203 | for (int k = 0;k<4;k++){ |
||
| 204 | gSum[k]=0; |
||
| 205 | } |
||
| 206 | for (int i=0; i<neve; i++) { |
||
| 203 | f9daq | 207 | start_timer(1);// 1 s timeout |
| 208 | int retval = DRSRead(0); |
||
| 209 | stop_timer(); |
||
| 210 | int nb = ( retval == 0 && fp ) ? DRSToBuffer( buffer , i ) : 0; |
||
| 211 | SetCtrlVal(ph,PANEL_CEVE,i); |
||
| 212 | if (retval) i--; |
||
| 217 | f9daq | 213 | nev++; |
| 203 | f9daq | 214 | if (!daq_on) break; |
| 215 | time(&t); |
||
| 216 | if (t!=told ) { |
||
| 217 | rate = (i-neveold); |
||
| 218 | printf("%d events in %2.2f min (%d s) Rate %f Hz %s ",i+1, (double)(t-tstart)/60.,(t-tstart), rate , ctime(&t)); |
||
| 219 | GetCtrlVal(ph,PANEL_PFREQ, &pfreq); |
||
| 220 | neveold = i; |
||
| 221 | } |
||
| 222 | told=t; |
||
| 223 | // Save data |
||
| 224 | if (nb>0 && fp) fwrite(buffer, 1,nb ,fp); |
||
| 225 | // Plot Data |
||
| 217 | f9daq | 226 | for (int k=0; k<4; k++) { |
| 227 | if ( (mask & ( 0x1<<k )) ){ |
||
| 228 | float *t=DRSGetTime(k); |
||
| 229 | float *x=DRSGetWave(k); |
||
| 230 | ; |
||
| 231 | for (int j=0 ; j<1024 ; j++) { |
||
| 232 | xs[k][j]= x[j]*1e-3; |
||
| 233 | |||
| 234 | if (t[j]> twin[0] && t[j] < twin[1]) gSum[k]+= fabs(xs[k][j]); |
||
| 235 | if (verbose) printf("[%d] %d. x= %3.2f y=%3.2f\n", k, i, t[j], x[j] ); |
||
| 236 | //h[k]->Fill( t[i], x[i]*1e-3); |
||
| 237 | } |
||
| 203 | f9daq | 238 | |
| 217 | f9daq | 239 | if (i % pfreq == 0) { |
| 240 | |||
| 241 | const int col[4]= {VAL_WHITE,VAL_RED,VAL_GREEN,VAL_BLUE}; |
||
| 242 | if (plothandle[k]) DeleteGraphPlot (ph, PANEL_GRAPH, plothandle[k], VAL_IMMEDIATE_DRAW); |
||
| 243 | plothandle[k] = PlotXY (ph, PANEL_GRAPH, t, xs[k], 1024, VAL_FLOAT, VAL_FLOAT, VAL_THIN_LINE, VAL_NO_POINT, VAL_SOLID, 1, col[k]); |
||
| 244 | } |
||
| 203 | f9daq | 245 | } |
| 217 | f9daq | 246 | |
| 203 | f9daq | 247 | } |
| 248 | |||
| 249 | |||
| 250 | } |
||
| 251 | time(&t); |
||
| 217 | f9daq | 252 | printf("%d events in %2.2f min (%d s) %s",nev, (double)(t-tstart)/60.,t-tstart, ctime(&t)); |
| 203 | f9daq | 253 | DRSEnd(); |
| 254 | } |
||
| 255 | |||
| 256 | if (fp) fclose(fp); |
||
| 257 | |||
| 258 | free(buffer); |
||
| 259 | |||
| 260 | return 0; |
||
| 261 | |||
| 195 | f9daq | 262 | } |
| 263 | |||
| 264 | |||
| 265 | |||
| 203 | f9daq | 266 | int CVICALLBACK scan(void *functionData) { |
| 195 | f9daq | 267 | |
| 207 | f9daq | 268 | int dx[3]={0,0,0}; |
| 269 | int nx[3]={0,0,0}; |
||
| 270 | int x0[3]={0,0,0}; |
||
| 271 | int ix[3]={0,0,0}; |
||
| 272 | int idx[3]={0,0,0}; |
||
| 203 | f9daq | 273 | int size; |
| 207 | f9daq | 274 | char posrec[4]="POSR"; |
| 275 | char runbuf[4]="PRUN"; |
||
| 203 | f9daq | 276 | |
| 207 | f9daq | 277 | int n[3]; |
| 203 | f9daq | 278 | char filename[0xFF]; |
| 279 | int enabledoutput; |
||
| 280 | |||
| 281 | FILE *fp; |
||
| 217 | f9daq | 282 | GetCtrlVal(p2, SCAN_FILENAME, filename ); |
| 203 | f9daq | 283 | |
| 284 | GetCtrlVal(ph,PANEL_ENABLEDOUTPUT, &enabledoutput); |
||
| 285 | |||
| 286 | if ( GetFileInfo(filename,&size) ) { |
||
| 217 | f9daq | 287 | MessagePopup ("Warning","File exist. Remove it first or choose another file"); |
| 288 | return 0; |
||
| 203 | f9daq | 289 | } |
| 290 | GetCtrlVal(p2, SCAN_STEPX, &dx[0]); |
||
| 291 | GetCtrlVal(p2, SCAN_STEPY, &dx[1]); |
||
| 292 | GetCtrlVal(p2, SCAN_NSTEPSX, &nx[0]); |
||
| 293 | GetCtrlVal(p2, SCAN_NSTEPSY, &nx[1]); |
||
| 294 | GetCtrlVal(p2, SCAN_STARTX, &x0[0]); |
||
| 295 | GetCtrlVal(p2, SCAN_STARTY, &x0[1]); |
||
| 217 | f9daq | 296 | for (int k=0;k<4;k++) { |
| 297 | H2D_Init(k, "charge","Induced charge", |
||
| 298 | nx[0], x0[0] - dx[0]*0.5 ,x0[0] + dx[0] * ( nx[0] - 0.5) , |
||
| 299 | nx[1], x0[1] - dx[1]*0.5 ,x0[1] + dx[1] * ( nx[1] - 0.5)); |
||
| 300 | H1D_Init(k, "charge","Induced charge projection x", |
||
| 301 | nx[0], x0[0] - dx[0]*0.5 ,x0[0] + dx[0] * ( nx[0] - 0.5) ); |
||
| 302 | H1D_Init(100 + k, "charge","Induced charge projection y", |
||
| 303 | nx[1], x0[1] - dx[1]*0.5 ,x0[1] + dx[1] * ( nx[1] - 0.5) ); |
||
| 304 | } |
||
| 207 | f9daq | 305 | if (enabledoutput) { |
| 306 | fp = fopen(filename,"ab"); |
||
| 307 | if (fp) { |
||
| 308 | size=36; |
||
| 309 | fwrite(runbuf, 1,4 ,fp); |
||
| 310 | fwrite(&size , 1,4 ,fp); |
||
| 311 | fwrite(x0 , 1,4*3 ,fp); |
||
| 312 | fwrite(dx , 1,4*3 ,fp); |
||
| 313 | fwrite(nx , 1,4*3 ,fp); |
||
| 314 | fclose(fp); |
||
| 315 | } |
||
| 316 | } |
||
| 317 | |||
| 203 | f9daq | 318 | for (int i=0; i<nx[0]; i++) { |
| 319 | |||
| 320 | ix[0]= x0[0]+i*dx[0]; |
||
| 321 | #ifdef MIKRO |
||
| 322 | MIKRO_MoveTo(1,ix[0]); |
||
| 323 | #endif |
||
| 324 | SetCtrlVal (p2, SCAN_IX, i); |
||
| 325 | for (int j=0; j<nx[1]; j++) { |
||
| 326 | |||
| 327 | SetCtrlVal (p2, SCAN_IY, j); |
||
| 328 | |||
| 329 | ix[1]= x0[1]+j*dx[1]; |
||
| 330 | #ifdef MIKRO |
||
| 331 | MIKRO_MoveTo(2,ix[1]); |
||
| 332 | |||
| 333 | MIKRO_GetPosition(1,&n[0]); |
||
| 334 | SetCtrlVal (p2, SCAN_XP, n[0]); |
||
| 335 | MIKRO_GetPosition(2,&n[1]); |
||
| 336 | SetCtrlVal (p2, SCAN_YP, n[1]); |
||
| 207 | f9daq | 337 | |
| 338 | if (enabledoutput) { |
||
| 203 | f9daq | 339 | fp = fopen(filename,"ab"); |
| 340 | if (fp) { |
||
| 207 | f9daq | 341 | idx[0]=i; |
| 342 | idx[1]=j; |
||
| 343 | size=24; |
||
| 344 | fwrite(posrec, 1,4 ,fp); |
||
| 345 | fwrite(&size , 1,4 ,fp); |
||
| 346 | fwrite(n , 1,4*3 ,fp); |
||
| 347 | fwrite(idx , 1,4*3 ,fp); |
||
| 203 | f9daq | 348 | fclose(fp); |
| 349 | } |
||
| 350 | } |
||
| 351 | |||
| 352 | #endif |
||
| 353 | daq(functionData); |
||
| 217 | f9daq | 354 | |
| 355 | for (int k=0;k<4;k++) { |
||
| 356 | H2D_Fill(k, ix[0], ix[1] , gSum[k] ); |
||
| 357 | H1D_Fill(k, ix[0] , gSum[k] ); |
||
| 358 | H1D_Fill(100+ k, ix[1] , gSum[k] ); |
||
| 359 | } |
||
| 360 | PlotScanHistogramCB(0,0,EVENT_COMMIT,NULL, 0,0); |
||
| 203 | f9daq | 361 | if (!daq_on) break; |
| 362 | } |
||
| 363 | if (!daq_on) break; |
||
| 364 | } |
||
| 365 | |||
| 366 | return 0; |
||
| 195 | f9daq | 367 | } |
| 368 | |||
| 203 | f9daq | 369 | |
| 195 | f9daq | 370 | int CVICALLBACK StartCB (int panel, int control, int event, |
| 203 | f9daq | 371 | void *callbackData, int eventData1, int eventData2) { |
| 372 | ThreadFunctionPtr mythread = NULL; |
||
| 373 | switch (event) { |
||
| 374 | |||
| 375 | case EVENT_COMMIT: |
||
| 376 | |||
| 377 | controlID=0; |
||
| 378 | if (panel == ph && control == PANEL_START) { |
||
| 379 | mythread = daq; |
||
| 380 | controlID= control; |
||
| 381 | } |
||
| 382 | if (panel == p2 && control == SCAN_SCAN) mythread = scan; |
||
| 383 | if (mythread!=NULL) { |
||
| 384 | printf("New Thread panel=%d button=%d\n", panel, control); |
||
| 385 | |||
| 386 | // SetDimming(1); |
||
| 387 | |||
| 388 | daq_on=1; |
||
| 389 | CmtScheduleThreadPoolFunctionAdv (poolHandle, mythread, &controlID, |
||
| 390 | DEFAULT_THREAD_PRIORITY, |
||
| 391 | EndOfThread, |
||
| 392 | EVENT_TP_THREAD_FUNCTION_END, |
||
| 393 | NULL, RUN_IN_SCHEDULED_THREAD, |
||
| 394 | &tfID); |
||
| 395 | } |
||
| 396 | break; |
||
| 397 | } |
||
| 398 | return 0; |
||
| 195 | f9daq | 399 | } |
| 400 | |||
| 401 | int CVICALLBACK StopCB (int panel, int control, int event, |
||
| 203 | f9daq | 402 | void *callbackData, int eventData1, int eventData2) { |
| 403 | switch (event) { |
||
| 404 | case EVENT_COMMIT: |
||
| 405 | daq_on=0; |
||
| 406 | break; |
||
| 407 | } |
||
| 408 | return 0; |
||
| 195 | f9daq | 409 | } |
| 410 | |||
| 411 | int CVICALLBACK ExitCB (int panel, int control, int event, |
||
| 203 | f9daq | 412 | void *callbackData, int eventData1, int eventData2) { |
| 413 | switch (event) { |
||
| 414 | case EVENT_COMMIT: |
||
| 415 | QuitUserInterface (0); |
||
| 416 | break; |
||
| 417 | } |
||
| 418 | return 0; |
||
| 195 | f9daq | 419 | } |
| 203 | f9daq | 420 | |
| 421 | int CVICALLBACK MoveStageCB (int panel, int control, int event, |
||
| 422 | void *callbackData, int eventData1, int eventData2) { |
||
| 423 | int axis=0, step=1000, direction=1, n; |
||
| 424 | switch (event) { |
||
| 425 | case EVENT_COMMIT: |
||
| 426 | |||
| 427 | if (panel == p2) { |
||
| 428 | switch (control) { |
||
| 429 | case SCAN_BR : |
||
| 430 | axis = 1; |
||
| 431 | direction = 1; |
||
| 432 | GetCtrlVal(p2, SCAN_STEPX, &step); |
||
| 433 | break; |
||
| 434 | case SCAN_BL : |
||
| 435 | axis = 1; |
||
| 436 | direction = -1; |
||
| 437 | GetCtrlVal(p2, SCAN_STEPX, &step); |
||
| 438 | break; |
||
| 439 | case SCAN_BU : |
||
| 440 | axis = 2; |
||
| 441 | direction = 1; |
||
| 442 | GetCtrlVal(p2, SCAN_STEPY, &step); |
||
| 443 | break; |
||
| 444 | case SCAN_BD : |
||
| 445 | axis = 2; |
||
| 446 | direction = -1; |
||
| 447 | GetCtrlVal(p2, SCAN_STEPY, &step); |
||
| 448 | break; |
||
| 449 | } |
||
| 450 | #ifdef MIKRO |
||
| 451 | MIKRO_MoveFor(axis, direction*step ); |
||
| 452 | MIKRO_GetPosition(axis,&n); |
||
| 453 | if (axis == 1) SetCtrlVal (p2, SCAN_XP, n); |
||
| 454 | if (axis == 2) SetCtrlVal (p2, SCAN_YP, n); |
||
| 455 | #endif // MIKRO |
||
| 456 | } |
||
| 457 | |||
| 458 | break; |
||
| 459 | } |
||
| 460 | return 0; |
||
| 461 | } |
||
| 462 | |||
| 463 | |||
| 464 | |||
| 465 | |||
| 466 | |||
| 467 | int CVICALLBACK GoXCB (int panel, int control, int event, |
||
| 468 | void *callbackData, int eventData1, int eventData2) { |
||
| 469 | int n2; |
||
| 470 | switch (event) { |
||
| 471 | case EVENT_COMMIT: |
||
| 472 | GetCtrlVal (p2, SCAN_XG, &n2); |
||
| 473 | #ifdef MIKRO |
||
| 474 | MIKRO_MoveTo(1,n2); |
||
| 475 | MIKRO_GetPosition(1,&n2); |
||
| 476 | |||
| 477 | #endif |
||
| 478 | SetCtrlVal (p2, SCAN_XP, n2); |
||
| 479 | break; |
||
| 480 | } |
||
| 481 | return 0; |
||
| 482 | } |
||
| 483 | |||
| 484 | int CVICALLBACK GoYCB (int panel, int control, int event, |
||
| 485 | void *callbackData, int eventData1, int eventData2) { |
||
| 486 | int n2; |
||
| 487 | switch (event) { |
||
| 488 | case EVENT_COMMIT: |
||
| 489 | GetCtrlVal (p2, SCAN_YG, &n2); |
||
| 490 | #ifdef MIKRO |
||
| 491 | MIKRO_MoveTo(2,n2); |
||
| 492 | MIKRO_GetPosition(2,&n2); |
||
| 493 | |||
| 494 | #endif |
||
| 495 | SetCtrlVal (p2, SCAN_YP, n2); |
||
| 496 | break; |
||
| 497 | } |
||
| 498 | return 0; |
||
| 499 | } |
||
| 500 | |||
| 501 | int CVICALLBACK GetCurrentPositionCB (int panel, int control, int event, |
||
| 502 | void *callbackData, int eventData1, int eventData2) { |
||
| 503 | |||
| 504 | int n[2]; |
||
| 505 | switch (event) { |
||
| 506 | case EVENT_COMMIT: |
||
| 507 | #ifdef MIKRO |
||
| 508 | MIKRO_GetPosition(1,&n[0]); |
||
| 509 | SetCtrlVal (p2, SCAN_XP, n[0]); |
||
| 510 | MIKRO_GetPosition(2,&n[1]); |
||
| 511 | SetCtrlVal (p2, SCAN_YP, n[1]); |
||
| 512 | #endif |
||
| 513 | break; |
||
| 514 | } |
||
| 515 | return 0; |
||
| 516 | } |
||
| 517 | |||
| 518 | int CVICALLBACK HomeCB (int panel, int control, int event, |
||
| 519 | void *callbackData, int eventData1, int eventData2) { |
||
| 520 | switch (event) { |
||
| 521 | case EVENT_COMMIT: |
||
| 522 | #ifdef MIKRO |
||
| 523 | MIKRO_ReferenceMove(1); |
||
| 524 | MIKRO_ReferenceMove(2); |
||
| 525 | GetCurrentPositionCB(panel, control, event, NULL, 0, 0); |
||
| 526 | #endif |
||
| 527 | break; |
||
| 528 | } |
||
| 529 | return 0; |
||
| 530 | } |
||
| 217 | f9daq | 531 | |
| 532 | int CVICALLBACK PlotScanHistogramCB (int panel, int control, int event, |
||
| 533 | void *callbackData, int eventData1, int eventData2) { |
||
| 534 | int hid=0; |
||
| 535 | int nx; |
||
| 536 | int ny; |
||
| 537 | switch (event) { |
||
| 538 | case EVENT_COMMIT: |
||
| 539 | GetCtrlVal (p2, SCAN_CHANNEL, &hid); |
||
| 540 | GetCtrlVal(p2, SCAN_NSTEPSX, &nx); |
||
| 541 | GetCtrlVal(p2, SCAN_NSTEPSY, &ny); |
||
| 542 | if (nx>1 && ny>1) { |
||
| 543 | H2D_Draw(hid,p2,SCAN_GRAPH,&scanplothandle); |
||
| 544 | printf("redraw 2d\n"); |
||
| 545 | } else { |
||
| 546 | if (nx>1) { |
||
| 547 | printf("redraw 1d x\n"); |
||
| 548 | H1D_Draw(hid,p2,SCAN_GRAPH,&scanplothandle); |
||
| 549 | } |
||
| 550 | if (ny>1) { |
||
| 551 | printf("redraw 1d x\n"); |
||
| 552 | H1D_Draw(100+hid,p2,SCAN_GRAPH,&scanplothandle); |
||
| 553 | } |
||
| 554 | } |
||
| 555 | break; |
||
| 556 | } |
||
| 557 | return 0; |
||
| 558 | } |
||
| 559 | |||
| 560 | int CVICALLBACK OpenGuiCB (int panel, int control, int event, |
||
| 561 | void *callbackData, int eventData1, int eventData2) { |
||
| 562 | switch (event) { |
||
| 563 | case EVENT_COMMIT: |
||
| 564 | DisplayPanel (ph); |
||
| 565 | DisplayPanel (p2); |
||
| 566 | break; |
||
| 567 | } |
||
| 568 | return 0; |
||
| 569 | } |