diff --git a/slsDetectorServers/gotthard2DetectorServer/RegisterDefs.h b/slsDetectorServers/gotthard2DetectorServer/RegisterDefs.h index 94cdbf86a..4fb2b568a 100644 --- a/slsDetectorServers/gotthard2DetectorServer/RegisterDefs.h +++ b/slsDetectorServers/gotthard2DetectorServer/RegisterDefs.h @@ -8,6 +8,9 @@ /* Status register */ #define STATUS_REG (0x01 << MEM_MAP_SHIFT) +#define RUN_BUSY_OFST (0) +#define RUN_BUSY_MSK (0x00000001 << RUN_BUSY_OFST) + /* Set Cycles 64 bit register */ #define SET_CYCLES_LSB_REG (0x02 << MEM_MAP_SHIFT) #define SET_CYCLES_MSB_REG (0x03 << MEM_MAP_SHIFT) diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c index 784dc7727..fc488f305 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c @@ -168,6 +168,12 @@ void initStopServer() { void setupDetector() { FILE_LOG(logINFO, ("This Server is for 1 Gotthard2 module \n")); + + //Initialization of acquistion parameters + setTimer(FRAME_NUMBER, DEFAULT_NUM_FRAMES); + setTimer(CYCLES_NUMBER, DEFAULT_NUM_CYCLES); + setTimer(ACQUISITION_TIME, DEFAULT_EXPTIME); + setTimer(ACQUISITION_TIME, DEFAULT_PERIOD); } @@ -324,7 +330,10 @@ void* start_timer(void* arg) { // loop over number of frames for(frameNr=0; frameNr!= numFrames; ++frameNr ) { - //check if virtual_stop is high, then break + //check if virtual_stop is high + if(virtual_stop == 1){ + break; + } // sleep for exposure time struct timespec begin, end; @@ -374,12 +383,27 @@ enum runStatus getRunStatus(){ } void readFrame(int *ret, char *mess){ + // wait for status to be done + while(runBusy()){ + usleep(500); + } #ifdef VIRTUAL FILE_LOG(logINFOGREEN, ("acquisition successfully finished\n")); return; #endif } +u_int32_t runBusy() { +#ifdef VIRTUAL + return virtual_status; +#endif + u_int32_t s = (bus_r(STATUS_REG) & RUN_BUSY_MSK); + FILE_LOG(logDEBUG1, ("Status Register: %08x\n", s)); + return s; +} + + + /* common */ int calculateDataBytes(){ diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h index 1746553a2..8d735a80b 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h @@ -9,4 +9,10 @@ #define NCHAN (128) #define NCHIP (10) #define NDAC (16) -#define TEMP_CLK (20) /* MHz */ \ No newline at end of file +#define TEMP_CLK (20) /* MHz */ + +/** Default Parameters */ +#define DEFAULT_NUM_FRAMES (1) +#define DEFAULT_NUM_CYCLES (1) +#define DEFAULT_EXPTIME (1 * 1000 * 1000) // 1 ms +#define DEFAULT_PERIOD (1 * 1000 * 1000 * 1000) // 1 s \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h index 1b1e5521b..5ebf24efc 100755 --- a/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h @@ -386,7 +386,7 @@ int checkFifoForEndOfAcquisition(); int readFrameFromFifo(); #endif -#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(MYTHEN3D) +#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(MYTHEN3D) || defined(GOTTHARD2D) u_int32_t runBusy(); #endif