/*---------------------------------------------------------------------- ** do_g3 - Go #2 - Kinetic test. **---------------------------------------------------------------------- */ int do_g3( char * par ) { #if IXON // make sure acquition is not in progress, then proceed... int rc; int naxis1, naxis2, i; int image_cnt; int status; float itime = 0.500; /* set to 0, as we will do external trigger */ float num_kinetics = 10000; struct timeval tm_start; struct timeval tm_now; int wid, hgt, temp_c; long l; float f; // prompt for num_kinetics num_kinetics = get_long ( "enter num_kinetics" , num_kinetics, 1, 20000 ); /*---- general camera setup ----------------------------------------------*/ rc = GetDetector( &naxis1, &naxis2); if( rc != DRV_SUCCESS ) { printf("GetDetector() error.\n"); return ERR_DEVICE_ERROR; } printf("Detector is %d x %d \n", naxis1, naxis2 ); // SetVSSpeed rc = SetVSSpeed( 4 ); // moris legal values are 0 to 4. (slow to fast) if( rc != DRV_SUCCESS ) { printf("SetVSSpeed() error.\n"); return ERR_DEVICE_ERROR; } // HSS: Select amp=1 (conventional), ch=1(16bit Channel), HHS=0 (1Mhz). // Preamp gail = 1x int amp = 1; int ch = 1; int hss = 0; int gain = 0; rc = SetADChannel( ch ); if( rc != DRV_SUCCESS ) { printf("SetADChannel() error.\n"); return ERR_DEVICE_ERROR; } rc = SetOutputAmplifier( amp ); if( rc != DRV_SUCCESS ) { printf("SetOutputAmplifier() error.\n"); return ERR_DEVICE_ERROR; } rc = SetHSSpeed( amp, hss ); if( rc != DRV_SUCCESS ) { printf("SetHSSpeed() error.\n"); return ERR_DEVICE_ERROR; } rc = SetPreAmpGain( gain ); if( rc != DRV_SUCCESS ) { printf("SetPreAmpGain() error.\n"); return ERR_DEVICE_ERROR; } /*---- basic mode setup ----------------------------------------------*/ rc = SetImage( 1, 1, 1, naxis1, 1, naxis2); if( rc != DRV_SUCCESS ) { printf("SetImage() error.\n"); return ERR_DEVICE_ERROR; } //>> rc = SetAcquisitionMode( 3 /* kinetic */); if( rc != DRV_SUCCESS ) { printf("SetAcquisitionMode() error.\n"); return ERR_DEVICE_ERROR; } rc = SetTriggerMode( 0 ); // 0=Internal, 1=External, 6=External Start if( rc != DRV_SUCCESS ) { printf("SetTriggerMode() error.\n"); return ERR_DEVICE_ERROR; } rc = SetExposureTime( itime ); if( rc != DRV_SUCCESS ) { printf("SetExposureTime() error.\n"); return ERR_DEVICE_ERROR; } rc = SetNumberAccumulations( 1 ); if( rc != DRV_SUCCESS ) { printf("SetNumberAccumulations() error.\n"); return ERR_DEVICE_ERROR; } rc = SetAccumulationCycleTime( itime ); // Set to itime, let system adjust to minimum. if( rc != DRV_SUCCESS ) { printf("SetAccumulationCycleTime() error.\n"); return ERR_DEVICE_ERROR; } //>> printf("SetNumberKinetics() is %f.\n", num_kinetics); rc = SetNumberKinetics( num_kinetics ); if( rc != DRV_SUCCESS ) { printf("SetNumberKinetics() error.\n"); return ERR_DEVICE_ERROR; } //>> // if internal trigger, SetKineticCycleTime rc = SetKineticCycleTime( itime ); // Use itime, system adjusts to minimum. if( rc != DRV_SUCCESS ) { printf("SetKineticCycleTime() error.\n"); return ERR_DEVICE_ERROR; } /*---- start Acquistion ----------------------------------------------*/ float a_itime, a_atime, a_ktime; rc = GetAcquisitionTimings( &a_itime, &a_atime, &a_ktime ); // get actual values. if( rc != DRV_SUCCESS ) { printf("GetAcquisitionTimings() error.\n"); return ERR_DEVICE_ERROR; } printf("AcquisitionTimings() itime=%.3f atime=%.3f ktime=%.3f \n", a_itime, a_atime, a_ktime ); GetDetector( &wid, &hgt); printf("GetDetector() w %d h %d \n", wid, hgt); GetMaximumExposure( &f ); printf("GetMaximumExposure() = %f \n", f); GetMaximumBinning( 4/*image*/,0, &i); printf("GetMaximumBinning(H) = %d \n", i); GetMaximumBinning( 4/*image*/,1, &i); printf("GetMaximumBinning(V) = %d \n", i); GetReadOutTime( &f ); printf("GetReadOutTime() %f \n", f); GetTemperature( &temp_c ); printf("GetTemperature() %d DegC \n", temp_c); GetSizeOfCircularBuffer( &l ); printf("GetSizeOfCircularBuffer() %ld \n", l); GetKeepCleanTime( &f ); printf("GetKeepCleanTime() %f seconds \n", f); gettimeofday( &tm_start, NULL); rc = StartAcquisition( ); if( rc != DRV_SUCCESS ) { printf("StartAcquisition() error. rc = %d\n", rc); return ERR_DEVICE_ERROR; } /*---- Get Images ----------------------------------------------*/ long first, last; int waits; image_cnt = 0; waits = 0; while( 1 ) { usleep( 50000 ); // 0.05sec // GetNumberNewImages return DRV_NO_NEW_DATA until new data has arrived. // When it returns DRV_SUCCESS, we can get the new data with GetImages() // GetImages() seem to alway return DRV_SUCCESS when the transfer is done. // Calling on the last image will just keep transfering the last images (alway // returning DRV_SUCCESS rc = GetNumberNewImages( &first, &last ); if( rc==DRV_NO_NEW_DATA ) { waits++; if( waits > 1000 ) // times out waiting for data is at 1000 * 0.050 , or 50 seconds. break; else continue; } if( rc != DRV_SUCCESS ) { printf("GetNumberNewImages() returns %d. Aborting... \n", rc); break; } waits = 0; // new data is available. Print out elaspse time. gettimeofday( &tm_now, NULL); printf("%6.3f [%3ld %3ld ] ", elapse_sec(&tm_start, &tm_now), first, last); // reads 1 image at a time. rc = GetImages( first, first, Data, naxis1*naxis2, &first, &last); if( rc != DRV_SUCCESS ) { printf("GetImages() Failed. Abort loop\n"); } image_cnt++; // while in kinetic acquisition, status is DRV_ACQUIRING. // After last image is acquired, status changes to DRV_IDLE. // GetStatus( &status ); printf(" %3d/%.0f [%3ld %3ld ] status=%d\n", image_cnt, num_kinetics, first, last, status); // send to DV if( 1 ) { //printf("Sending data to DV..\n"); buf_2_dv( "localhost", 30123, naxis1, naxis2, Data); } // are we done? if( image_cnt >= num_kinetics ) { printf("Got all images(). Done.\n"); break; } } GetStatus( &status ); printf("DONE. status=%d\n", status); sleep(2); rc = DRV_SUCCESS; for(i=0; i<2; i++ ) { rc = GetNumberNewImages( &first, &last ); printf("GetNumberNewImages( %ld %ld ) returns %d\n", first, last, rc); rc = GetImages( first, first, Data, naxis1*naxis2, &first, &last); printf("GetImages( %ld %ld ) returns %d\n", first, last, rc); sleep(1); } // any cleanup? #endif return 0; } //GetStatus() can provide: // #define DRV_ERROR_ACK 20013 // #define DRV_ACQ_BUFFER 20018 // #define DRV_KINETIC_TIME_NOT_MET 20022 // #define DRV_ACCUM_TIME_NOT_MET 20023 // #define DRV_SPOOLERROR 20026 // #define DRV_ACQUIRING 20072 // #define DRV_IDLE 20073 // #define DRV_TEMPCYCLE 20074