Rev 217 | 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]; |
| 265 | f9daq | 130 | |
| 201 | f9daq | 131 | |
| 217 | f9daq | 132 | |
| 203 | f9daq | 133 | GetCtrlVal(ph, PANEL_CH0, &imask[0] ); |
| 134 | GetCtrlVal(ph, PANEL_CH1, &imask[1] ); |
||
| 135 | GetCtrlVal(ph, PANEL_CH2, &imask[2] ); |
||
| 136 | GetCtrlVal(ph, PANEL_CH3, &imask[3] ); |
||
| 137 | mask = 0; |
||
| 138 | for (int i=0; i<4; i++) { |
||
| 139 | if (imask[i]) mask |= (1<<i); |
||
| 201 | f9daq | 140 | } |
| 203 | f9daq | 141 | |
| 265 | f9daq | 142 | |
| 143 | |||
| 203 | f9daq | 144 | GetCtrlVal(ph,PANEL_NEVE, &neve); |
| 145 | GetCtrlVal(ph,PANEL_DEBUG, &verbose); |
||
| 146 | GetCtrlVal(ph,PANEL_PFREQ, &pfreq); |
||
| 147 | GetCtrlVal(ph,PANEL_ENABLEDOUTPUT, &enabledoutput); |
||
| 148 | |||
| 149 | GetCtrlVal(ph,PANEL_FREQUENCY, &frequency); |
||
| 150 | GetCtrlVal(ph,PANEL_TRGDELAY, &trgdelay); |
||
| 151 | GetCtrlVal(ph,PANEL_TRGCHANNEL, &trgchannel); |
||
| 152 | |||
| 265 | f9daq | 153 | |
| 203 | f9daq | 154 | GetCtrlVal(ph,PANEL_TRGTYPE, &trgtype); |
| 155 | GetCtrlVal(ph,PANEL_TRGLEVEL, &trglevel); |
||
| 156 | GetCtrlVal(ph,PANEL_TRGPOLARITY, &trgpolarity); |
||
| 157 | GetCtrlVal(ph,PANEL_RANGE, &range); |
||
| 158 | |||
| 217 | f9daq | 159 | GetCtrlVal(ph,PANEL_TWIN0, &twin[0]); |
| 160 | GetCtrlVal(ph,PANEL_TWIN1, &twin[1]); |
||
| 203 | f9daq | 161 | //printf("mask=0x%x\n",mask); |
| 162 | |||
| 163 | DRSSetMask( (unsigned char)( mask & 0xF ) ); |
||
| 164 | |||
| 165 | DRSSetFrequency( frequency ); |
||
| 166 | DRSSetTriggerDelay(trgdelay ); |
||
| 167 | DRSSetTriggerChannel(trgchannel ); |
||
| 168 | DRSSetTriggerType( trgtype ); |
||
| 169 | DRSSetTriggerLevel(trglevel); |
||
| 170 | DRSSetTriggerPolarity(trgpolarity); |
||
| 171 | |||
| 172 | DRSSetRange ( range ); |
||
| 173 | |||
| 174 | |||
| 175 | |||
| 176 | FILE *fp= NULL; |
||
| 177 | |||
| 178 | if (enabledoutput) { |
||
| 217 | f9daq | 179 | if (args[0]) { |
| 180 | GetCtrlVal(ph, PANEL_FILENAME, filename ); |
||
| 181 | fp = fopen(filename,"wb"); |
||
| 182 | } else { |
||
| 183 | GetCtrlVal(p2, SCAN_FILENAME, filename ); |
||
| 184 | fp = fopen(filename,"ab"); |
||
| 185 | } |
||
| 203 | f9daq | 186 | } |
| 187 | |||
| 188 | static unsigned char *buffer; |
||
| 189 | |||
| 190 | int buffer_size = 0; |
||
| 191 | const int nBoards=1; |
||
| 192 | const int waveDepth=1024; |
||
| 207 | f9daq | 193 | |
| 203 | f9daq | 194 | if (buffer_size == 0) { |
| 207 | f9daq | 195 | buffer_size = 8; // file header + time header |
| 196 | buffer_size += nBoards * (4 + 4*(4+waveDepth*4)); // bin widths |
||
| 197 | buffer_size += 24 + nBoards * (8 + 4*(8+waveDepth*2)); |
||
| 198 | buffer = (unsigned char *)malloc(buffer_size); |
||
| 199 | } |
||
| 200 | |||
| 203 | f9daq | 201 | time_t t=0,told=0, tstart=0; |
| 202 | |||
| 203 | if (!DRSInit()) { |
||
| 265 | f9daq | 204 | |
| 203 | f9daq | 205 | time(&tstart); |
| 206 | told=tstart; |
||
| 217 | f9daq | 207 | int nev=0; |
| 208 | for (int k = 0;k<4;k++){ |
||
| 209 | gSum[k]=0; |
||
| 210 | } |
||
| 211 | for (int i=0; i<neve; i++) { |
||
| 203 | f9daq | 212 | start_timer(1);// 1 s timeout |
| 213 | int retval = DRSRead(0); |
||
| 214 | stop_timer(); |
||
| 215 | int nb = ( retval == 0 && fp ) ? DRSToBuffer( buffer , i ) : 0; |
||
| 216 | SetCtrlVal(ph,PANEL_CEVE,i); |
||
| 217 | if (retval) i--; |
||
| 217 | f9daq | 218 | nev++; |
| 203 | f9daq | 219 | if (!daq_on) break; |
| 220 | time(&t); |
||
| 221 | if (t!=told ) { |
||
| 222 | rate = (i-neveold); |
||
| 223 | printf("%d events in %2.2f min (%d s) Rate %f Hz %s ",i+1, (double)(t-tstart)/60.,(t-tstart), rate , ctime(&t)); |
||
| 224 | GetCtrlVal(ph,PANEL_PFREQ, &pfreq); |
||
| 225 | neveold = i; |
||
| 226 | } |
||
| 227 | told=t; |
||
| 228 | // Save data |
||
| 229 | if (nb>0 && fp) fwrite(buffer, 1,nb ,fp); |
||
| 230 | // Plot Data |
||
| 217 | f9daq | 231 | for (int k=0; k<4; k++) { |
| 232 | if ( (mask & ( 0x1<<k )) ){ |
||
| 233 | float *t=DRSGetTime(k); |
||
| 234 | float *x=DRSGetWave(k); |
||
| 235 | ; |
||
| 236 | for (int j=0 ; j<1024 ; j++) { |
||
| 237 | xs[k][j]= x[j]*1e-3; |
||
| 238 | |||
| 239 | if (t[j]> twin[0] && t[j] < twin[1]) gSum[k]+= fabs(xs[k][j]); |
||
| 240 | if (verbose) printf("[%d] %d. x= %3.2f y=%3.2f\n", k, i, t[j], x[j] ); |
||
| 241 | //h[k]->Fill( t[i], x[i]*1e-3); |
||
| 242 | } |
||
| 203 | f9daq | 243 | |
| 217 | f9daq | 244 | if (i % pfreq == 0) { |
| 245 | |||
| 246 | const int col[4]= {VAL_WHITE,VAL_RED,VAL_GREEN,VAL_BLUE}; |
||
| 247 | if (plothandle[k]) DeleteGraphPlot (ph, PANEL_GRAPH, plothandle[k], VAL_IMMEDIATE_DRAW); |
||
| 248 | 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]); |
||
| 249 | } |
||
| 203 | f9daq | 250 | } |
| 217 | f9daq | 251 | |
| 203 | f9daq | 252 | } |
| 253 | |||
| 254 | |||
| 255 | } |
||
| 256 | time(&t); |
||
| 217 | f9daq | 257 | printf("%d events in %2.2f min (%d s) %s",nev, (double)(t-tstart)/60.,t-tstart, ctime(&t)); |
| 203 | f9daq | 258 | DRSEnd(); |
| 259 | } |
||
| 260 | |||
| 261 | if (fp) fclose(fp); |
||
| 262 | |||
| 263 | free(buffer); |
||
| 264 | |||
| 265 | return 0; |
||
| 266 | |||
| 195 | f9daq | 267 | } |
| 268 | |||
| 269 | |||
| 270 | |||
| 203 | f9daq | 271 | int CVICALLBACK scan(void *functionData) { |
| 195 | f9daq | 272 | |
| 207 | f9daq | 273 | int dx[3]={0,0,0}; |
| 274 | int nx[3]={0,0,0}; |
||
| 275 | int x0[3]={0,0,0}; |
||
| 276 | int ix[3]={0,0,0}; |
||
| 277 | int idx[3]={0,0,0}; |
||
| 203 | f9daq | 278 | int size; |
| 207 | f9daq | 279 | char posrec[4]="POSR"; |
| 280 | char runbuf[4]="PRUN"; |
||
| 203 | f9daq | 281 | |
| 207 | f9daq | 282 | int n[3]; |
| 203 | f9daq | 283 | char filename[0xFF]; |
| 284 | int enabledoutput; |
||
| 285 | |||
| 286 | FILE *fp; |
||
| 217 | f9daq | 287 | GetCtrlVal(p2, SCAN_FILENAME, filename ); |
| 203 | f9daq | 288 | |
| 289 | GetCtrlVal(ph,PANEL_ENABLEDOUTPUT, &enabledoutput); |
||
| 290 | |||
| 291 | if ( GetFileInfo(filename,&size) ) { |
||
| 217 | f9daq | 292 | MessagePopup ("Warning","File exist. Remove it first or choose another file"); |
| 293 | return 0; |
||
| 203 | f9daq | 294 | } |
| 295 | GetCtrlVal(p2, SCAN_STEPX, &dx[0]); |
||
| 296 | GetCtrlVal(p2, SCAN_STEPY, &dx[1]); |
||
| 297 | GetCtrlVal(p2, SCAN_NSTEPSX, &nx[0]); |
||
| 298 | GetCtrlVal(p2, SCAN_NSTEPSY, &nx[1]); |
||
| 299 | GetCtrlVal(p2, SCAN_STARTX, &x0[0]); |
||
| 300 | GetCtrlVal(p2, SCAN_STARTY, &x0[1]); |
||
| 217 | f9daq | 301 | for (int k=0;k<4;k++) { |
| 302 | H2D_Init(k, "charge","Induced charge", |
||
| 303 | nx[0], x0[0] - dx[0]*0.5 ,x0[0] + dx[0] * ( nx[0] - 0.5) , |
||
| 304 | nx[1], x0[1] - dx[1]*0.5 ,x0[1] + dx[1] * ( nx[1] - 0.5)); |
||
| 305 | H1D_Init(k, "charge","Induced charge projection x", |
||
| 306 | nx[0], x0[0] - dx[0]*0.5 ,x0[0] + dx[0] * ( nx[0] - 0.5) ); |
||
| 307 | H1D_Init(100 + k, "charge","Induced charge projection y", |
||
| 308 | nx[1], x0[1] - dx[1]*0.5 ,x0[1] + dx[1] * ( nx[1] - 0.5) ); |
||
| 309 | } |
||
| 207 | f9daq | 310 | if (enabledoutput) { |
| 311 | fp = fopen(filename,"ab"); |
||
| 312 | if (fp) { |
||
| 313 | size=36; |
||
| 314 | fwrite(runbuf, 1,4 ,fp); |
||
| 315 | fwrite(&size , 1,4 ,fp); |
||
| 316 | fwrite(x0 , 1,4*3 ,fp); |
||
| 317 | fwrite(dx , 1,4*3 ,fp); |
||
| 318 | fwrite(nx , 1,4*3 ,fp); |
||
| 319 | fclose(fp); |
||
| 320 | } |
||
| 321 | } |
||
| 322 | |||
| 203 | f9daq | 323 | for (int i=0; i<nx[0]; i++) { |
| 324 | |||
| 325 | ix[0]= x0[0]+i*dx[0]; |
||
| 326 | #ifdef MIKRO |
||
| 327 | MIKRO_MoveTo(1,ix[0]); |
||
| 328 | #endif |
||
| 329 | SetCtrlVal (p2, SCAN_IX, i); |
||
| 330 | for (int j=0; j<nx[1]; j++) { |
||
| 331 | |||
| 332 | SetCtrlVal (p2, SCAN_IY, j); |
||
| 333 | |||
| 334 | ix[1]= x0[1]+j*dx[1]; |
||
| 335 | #ifdef MIKRO |
||
| 336 | MIKRO_MoveTo(2,ix[1]); |
||
| 337 | |||
| 338 | MIKRO_GetPosition(1,&n[0]); |
||
| 339 | SetCtrlVal (p2, SCAN_XP, n[0]); |
||
| 340 | MIKRO_GetPosition(2,&n[1]); |
||
| 341 | SetCtrlVal (p2, SCAN_YP, n[1]); |
||
| 207 | f9daq | 342 | |
| 343 | if (enabledoutput) { |
||
| 203 | f9daq | 344 | fp = fopen(filename,"ab"); |
| 345 | if (fp) { |
||
| 207 | f9daq | 346 | idx[0]=i; |
| 347 | idx[1]=j; |
||
| 348 | size=24; |
||
| 349 | fwrite(posrec, 1,4 ,fp); |
||
| 350 | fwrite(&size , 1,4 ,fp); |
||
| 351 | fwrite(n , 1,4*3 ,fp); |
||
| 352 | fwrite(idx , 1,4*3 ,fp); |
||
| 203 | f9daq | 353 | fclose(fp); |
| 354 | } |
||
| 355 | } |
||
| 356 | |||
| 357 | #endif |
||
| 358 | daq(functionData); |
||
| 217 | f9daq | 359 | |
| 360 | for (int k=0;k<4;k++) { |
||
| 361 | H2D_Fill(k, ix[0], ix[1] , gSum[k] ); |
||
| 362 | H1D_Fill(k, ix[0] , gSum[k] ); |
||
| 363 | H1D_Fill(100+ k, ix[1] , gSum[k] ); |
||
| 364 | } |
||
| 365 | PlotScanHistogramCB(0,0,EVENT_COMMIT,NULL, 0,0); |
||
| 203 | f9daq | 366 | if (!daq_on) break; |
| 367 | } |
||
| 368 | if (!daq_on) break; |
||
| 369 | } |
||
| 370 | |||
| 371 | return 0; |
||
| 195 | f9daq | 372 | } |
| 373 | |||
| 203 | f9daq | 374 | |
| 195 | f9daq | 375 | int CVICALLBACK StartCB (int panel, int control, int event, |
| 203 | f9daq | 376 | void *callbackData, int eventData1, int eventData2) { |
| 377 | ThreadFunctionPtr mythread = NULL; |
||
| 378 | switch (event) { |
||
| 379 | |||
| 380 | case EVENT_COMMIT: |
||
| 381 | |||
| 382 | controlID=0; |
||
| 383 | if (panel == ph && control == PANEL_START) { |
||
| 384 | mythread = daq; |
||
| 385 | controlID= control; |
||
| 386 | } |
||
| 387 | if (panel == p2 && control == SCAN_SCAN) mythread = scan; |
||
| 388 | if (mythread!=NULL) { |
||
| 389 | printf("New Thread panel=%d button=%d\n", panel, control); |
||
| 390 | |||
| 391 | // SetDimming(1); |
||
| 392 | |||
| 393 | daq_on=1; |
||
| 394 | CmtScheduleThreadPoolFunctionAdv (poolHandle, mythread, &controlID, |
||
| 395 | DEFAULT_THREAD_PRIORITY, |
||
| 396 | EndOfThread, |
||
| 397 | EVENT_TP_THREAD_FUNCTION_END, |
||
| 398 | NULL, RUN_IN_SCHEDULED_THREAD, |
||
| 399 | &tfID); |
||
| 400 | } |
||
| 401 | break; |
||
| 402 | } |
||
| 403 | return 0; |
||
| 195 | f9daq | 404 | } |
| 405 | |||
| 406 | int CVICALLBACK StopCB (int panel, int control, int event, |
||
| 203 | f9daq | 407 | void *callbackData, int eventData1, int eventData2) { |
| 408 | switch (event) { |
||
| 409 | case EVENT_COMMIT: |
||
| 410 | daq_on=0; |
||
| 411 | break; |
||
| 412 | } |
||
| 413 | return 0; |
||
| 195 | f9daq | 414 | } |
| 415 | |||
| 416 | int CVICALLBACK ExitCB (int panel, int control, int event, |
||
| 203 | f9daq | 417 | void *callbackData, int eventData1, int eventData2) { |
| 418 | switch (event) { |
||
| 419 | case EVENT_COMMIT: |
||
| 420 | QuitUserInterface (0); |
||
| 421 | break; |
||
| 422 | } |
||
| 423 | return 0; |
||
| 195 | f9daq | 424 | } |
| 203 | f9daq | 425 | |
| 426 | int CVICALLBACK MoveStageCB (int panel, int control, int event, |
||
| 427 | void *callbackData, int eventData1, int eventData2) { |
||
| 428 | int axis=0, step=1000, direction=1, n; |
||
| 429 | switch (event) { |
||
| 430 | case EVENT_COMMIT: |
||
| 431 | |||
| 432 | if (panel == p2) { |
||
| 433 | switch (control) { |
||
| 434 | case SCAN_BR : |
||
| 435 | axis = 1; |
||
| 436 | direction = 1; |
||
| 437 | GetCtrlVal(p2, SCAN_STEPX, &step); |
||
| 438 | break; |
||
| 439 | case SCAN_BL : |
||
| 440 | axis = 1; |
||
| 441 | direction = -1; |
||
| 442 | GetCtrlVal(p2, SCAN_STEPX, &step); |
||
| 443 | break; |
||
| 444 | case SCAN_BU : |
||
| 445 | axis = 2; |
||
| 446 | direction = 1; |
||
| 447 | GetCtrlVal(p2, SCAN_STEPY, &step); |
||
| 448 | break; |
||
| 449 | case SCAN_BD : |
||
| 450 | axis = 2; |
||
| 451 | direction = -1; |
||
| 452 | GetCtrlVal(p2, SCAN_STEPY, &step); |
||
| 453 | break; |
||
| 454 | } |
||
| 455 | #ifdef MIKRO |
||
| 456 | MIKRO_MoveFor(axis, direction*step ); |
||
| 457 | MIKRO_GetPosition(axis,&n); |
||
| 458 | if (axis == 1) SetCtrlVal (p2, SCAN_XP, n); |
||
| 459 | if (axis == 2) SetCtrlVal (p2, SCAN_YP, n); |
||
| 460 | #endif // MIKRO |
||
| 461 | } |
||
| 462 | |||
| 463 | break; |
||
| 464 | } |
||
| 465 | return 0; |
||
| 466 | } |
||
| 467 | |||
| 468 | |||
| 469 | |||
| 470 | |||
| 471 | |||
| 472 | int CVICALLBACK GoXCB (int panel, int control, int event, |
||
| 473 | void *callbackData, int eventData1, int eventData2) { |
||
| 474 | int n2; |
||
| 475 | switch (event) { |
||
| 476 | case EVENT_COMMIT: |
||
| 477 | GetCtrlVal (p2, SCAN_XG, &n2); |
||
| 478 | #ifdef MIKRO |
||
| 479 | MIKRO_MoveTo(1,n2); |
||
| 480 | MIKRO_GetPosition(1,&n2); |
||
| 481 | |||
| 482 | #endif |
||
| 483 | SetCtrlVal (p2, SCAN_XP, n2); |
||
| 484 | break; |
||
| 485 | } |
||
| 486 | return 0; |
||
| 487 | } |
||
| 488 | |||
| 489 | int CVICALLBACK GoYCB (int panel, int control, int event, |
||
| 490 | void *callbackData, int eventData1, int eventData2) { |
||
| 491 | int n2; |
||
| 492 | switch (event) { |
||
| 493 | case EVENT_COMMIT: |
||
| 494 | GetCtrlVal (p2, SCAN_YG, &n2); |
||
| 495 | #ifdef MIKRO |
||
| 496 | MIKRO_MoveTo(2,n2); |
||
| 497 | MIKRO_GetPosition(2,&n2); |
||
| 498 | |||
| 499 | #endif |
||
| 500 | SetCtrlVal (p2, SCAN_YP, n2); |
||
| 501 | break; |
||
| 502 | } |
||
| 503 | return 0; |
||
| 504 | } |
||
| 505 | |||
| 506 | int CVICALLBACK GetCurrentPositionCB (int panel, int control, int event, |
||
| 507 | void *callbackData, int eventData1, int eventData2) { |
||
| 508 | |||
| 509 | int n[2]; |
||
| 510 | switch (event) { |
||
| 511 | case EVENT_COMMIT: |
||
| 512 | #ifdef MIKRO |
||
| 513 | MIKRO_GetPosition(1,&n[0]); |
||
| 514 | SetCtrlVal (p2, SCAN_XP, n[0]); |
||
| 515 | MIKRO_GetPosition(2,&n[1]); |
||
| 516 | SetCtrlVal (p2, SCAN_YP, n[1]); |
||
| 517 | #endif |
||
| 518 | break; |
||
| 519 | } |
||
| 520 | return 0; |
||
| 521 | } |
||
| 522 | |||
| 523 | int CVICALLBACK HomeCB (int panel, int control, int event, |
||
| 524 | void *callbackData, int eventData1, int eventData2) { |
||
| 525 | switch (event) { |
||
| 526 | case EVENT_COMMIT: |
||
| 527 | #ifdef MIKRO |
||
| 528 | MIKRO_ReferenceMove(1); |
||
| 529 | MIKRO_ReferenceMove(2); |
||
| 530 | GetCurrentPositionCB(panel, control, event, NULL, 0, 0); |
||
| 531 | #endif |
||
| 532 | break; |
||
| 533 | } |
||
| 534 | return 0; |
||
| 535 | } |
||
| 217 | f9daq | 536 | |
| 537 | int CVICALLBACK PlotScanHistogramCB (int panel, int control, int event, |
||
| 538 | void *callbackData, int eventData1, int eventData2) { |
||
| 539 | int hid=0; |
||
| 540 | int nx; |
||
| 541 | int ny; |
||
| 542 | switch (event) { |
||
| 543 | case EVENT_COMMIT: |
||
| 544 | GetCtrlVal (p2, SCAN_CHANNEL, &hid); |
||
| 545 | GetCtrlVal(p2, SCAN_NSTEPSX, &nx); |
||
| 546 | GetCtrlVal(p2, SCAN_NSTEPSY, &ny); |
||
| 547 | if (nx>1 && ny>1) { |
||
| 548 | H2D_Draw(hid,p2,SCAN_GRAPH,&scanplothandle); |
||
| 549 | printf("redraw 2d\n"); |
||
| 550 | } else { |
||
| 551 | if (nx>1) { |
||
| 552 | printf("redraw 1d x\n"); |
||
| 553 | H1D_Draw(hid,p2,SCAN_GRAPH,&scanplothandle); |
||
| 554 | } |
||
| 555 | if (ny>1) { |
||
| 556 | printf("redraw 1d x\n"); |
||
| 557 | H1D_Draw(100+hid,p2,SCAN_GRAPH,&scanplothandle); |
||
| 558 | } |
||
| 559 | } |
||
| 560 | break; |
||
| 561 | } |
||
| 562 | return 0; |
||
| 563 | } |
||
| 564 | |||
| 565 | int CVICALLBACK OpenGuiCB (int panel, int control, int event, |
||
| 566 | void *callbackData, int eventData1, int eventData2) { |
||
| 567 | switch (event) { |
||
| 568 | case EVENT_COMMIT: |
||
| 569 | DisplayPanel (ph); |
||
| 570 | DisplayPanel (p2); |
||
| 571 | break; |
||
| 572 | } |
||
| 573 | return 0; |
||
| 574 | } |
||
| 265 | f9daq | 575 | |
| 576 | int CVICALLBACK CalibrateCB (int panel, int control, int event, |
||
| 577 | void *callbackData, int eventData1, int eventData2) { |
||
| 578 | int status = 0; |
||
| 579 | switch (event) { |
||
| 580 | case EVENT_COMMIT: |
||
| 581 | status = DRSCalibrateTiming(); |
||
| 582 | printf("DRSCalibrateTiming() status = %d\n", status); |
||
| 583 | break; |
||
| 584 | } |
||
| 585 | return 0; |
||
| 586 | } |