mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
set starting frame number of next acquisition for both jungfrau and e… (#27)
* set starting frame number of next acquisition for both jungfrau and eiger. firmware has not implemented a get, so workaround. tests included. frame number 0 not allowed due to Eiger. Eiger max frame is 48 bit, while jungfrau is 64 bit * made argument of setstartingframenumber const
This commit is contained in:
@ -36,6 +36,7 @@ int Beb_activated = 1;
|
||||
uint32_t Beb_detid = 0;
|
||||
int Beb_top =0;
|
||||
|
||||
uint64_t Beb_deactivatedStartFrameNumber = 0;
|
||||
|
||||
|
||||
void BebInfo_BebInfo(struct BebInfo* bebInfo, unsigned int beb_num) {
|
||||
@ -409,6 +410,10 @@ int Beb_Activate(int enable) {
|
||||
}
|
||||
|
||||
|
||||
int Beb_GetActivate() {
|
||||
return Beb_activated;
|
||||
}
|
||||
|
||||
int Beb_Set32bitOverflow(int val) {
|
||||
if (!Beb_activated)
|
||||
return val;
|
||||
@ -1262,6 +1267,62 @@ int Beb_SetDetectorPosition(int pos[]) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int Beb_SetStartingFrameNumber(uint64_t value) {
|
||||
if (!Beb_activated) {
|
||||
Beb_deactivatedStartFrameNumber = value;
|
||||
return OK;
|
||||
}
|
||||
FILE_LOG(logINFO, ("Setting start frame number: %llu\n", (long long unsigned int)value));
|
||||
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base, XPAR_PLB_GPIO_TEST_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Set Start Frame Number FAIL\n"));
|
||||
return FAIL;
|
||||
} else {
|
||||
// since the read is not implemented in firmware yet
|
||||
Beb_deactivatedStartFrameNumber = value;
|
||||
|
||||
// decrement for firmware
|
||||
uint64_t valueInFirmware = value - 1;
|
||||
Beb_Write32(csp0base, UDP_HEADER_FRAME_NUMBER_LSB_OFST, valueInFirmware & (0xffffffff));
|
||||
Beb_Write32(csp0base, UDP_HEADER_FRAME_NUMBER_MSB_OFST, (valueInFirmware >> 32) & (0xffffffff));
|
||||
Beb_close(fd,csp0base);
|
||||
}
|
||||
|
||||
uint64_t retval = -1;
|
||||
if ((Beb_GetStartingFrameNumber(&retval) == OK) && (retval == value)) {
|
||||
FILE_LOG(logINFO, ("Going to reset Frame Number\n"));
|
||||
Beb_ResetFrameNumber();
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
int Beb_GetStartingFrameNumber(uint64_t* retval) {
|
||||
if (!Beb_activated) {
|
||||
*retval = Beb_deactivatedStartFrameNumber;
|
||||
return OK;
|
||||
}
|
||||
FILE_LOG(logDEBUG1, ("Getting start frame number\n"));
|
||||
|
||||
// since it is not implemented in firmware yet
|
||||
*retval = Beb_deactivatedStartFrameNumber;
|
||||
/*
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base, XPAR_PLB_GPIO_TEST_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Set Start Frame Number FAIL\n"));
|
||||
return FAIL;
|
||||
} else {
|
||||
*retval = Beb_Read32(csp0base, UDP_HEADER_FRAME_NUMBER_MSB_OFST);
|
||||
uint32_t lretval = Beb_Read32(csp0base, UDP_HEADER_FRAME_NUMBER_MSB_OFST);
|
||||
*retval = (*retval << 32) | lretval;
|
||||
Beb_close(fd,csp0base);
|
||||
}
|
||||
*/
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
uint16_t Beb_swap_uint16( uint16_t val) {
|
||||
return (val << 8) | (val >> 8 );
|
||||
|
@ -39,6 +39,7 @@ void Beb_EndofDataSend(int tengiga);
|
||||
int Beb_SetMasterViaSoftware();
|
||||
int Beb_SetSlaveViaSoftware();
|
||||
int Beb_Activate(int enable);
|
||||
int Beb_GetActivate();
|
||||
int Beb_Set32bitOverflow(int val);
|
||||
int Beb_SetNetworkParameter(enum NETWORKINDEX mode, int val);
|
||||
int Beb_ResetToHardwareSettings();
|
||||
@ -74,6 +75,8 @@ int Beb_GetBebFPGATemp();
|
||||
|
||||
void Beb_SetDetectorNumber(uint32_t detid);
|
||||
int Beb_SetDetectorPosition(int pos[]);
|
||||
int Beb_SetStartingFrameNumber(uint64_t value);
|
||||
int Beb_GetStartingFrameNumber(uint64_t* retval);
|
||||
|
||||
uint16_t Beb_swap_uint16( uint16_t val);
|
||||
int Beb_open(u_int32_t** csp0base, u_int32_t offset);
|
||||
|
@ -202,8 +202,9 @@
|
||||
#define UDP_HEADER_Y_OFST (16)
|
||||
#define UDP_HEADER_Y_MSK (0xFFFF << UDP_HEADER_Y_OFST)
|
||||
|
||||
|
||||
|
||||
// udp header (frame number)
|
||||
#define UDP_HEADER_FRAME_NUMBER_LSB_OFST (0x0140)
|
||||
#define UDP_HEADER_FRAME_NUMBER_MSB_OFST (0x0160)
|
||||
|
||||
|
||||
|
||||
|
@ -85,6 +85,7 @@ int eiger_virtual_status=0;
|
||||
int eiger_virtual_activate=1;
|
||||
pthread_t eiger_virtual_tid;
|
||||
int eiger_virtual_stop = 0;
|
||||
uint64_t eiger_virtual_startingframenumber = 0;
|
||||
#endif
|
||||
|
||||
|
||||
@ -444,6 +445,7 @@ void setupDetector() {
|
||||
setSpeed(CLOCK_DIVIDER, DEFAULT_CLK_SPEED);//clk_devider,half speed
|
||||
setIODelay(DEFAULT_IO_DELAY);
|
||||
setTiming(DEFAULT_TIMING_MODE);
|
||||
setStartingFrameNumber(DEFAULT_STARTING_FRAME_NUMBER);
|
||||
//SetPhotonEnergyCalibrationParameters(-5.8381e-5,1.838515,5.09948e-7,-4.32390e-11,1.32527e-15);
|
||||
setRateCorrection(DEFAULT_RATE_CORRECTION);
|
||||
int enable[2] = {DEFAULT_EXT_GATING_ENABLE, DEFAULT_EXT_GATING_POLARITY};
|
||||
@ -658,6 +660,24 @@ enum readOutFlags setReadOutFlags(enum readOutFlags val) {
|
||||
|
||||
/* parameters - timer */
|
||||
|
||||
int setStartingFrameNumber(uint64_t value) {
|
||||
#ifdef VIRTUAL
|
||||
eiger_virtual_startingframenumber = value;
|
||||
return OK;
|
||||
#else
|
||||
return Beb_SetStartingFrameNumber(value);
|
||||
#endif
|
||||
}
|
||||
|
||||
int getStartingFrameNumber(uint64_t* retval) {
|
||||
#ifdef VIRTUAL
|
||||
*retval = eiger_virtual_startingframenumber;
|
||||
return OK;
|
||||
#else
|
||||
return Beb_GetStartingFrameNumber(retval);
|
||||
#endif
|
||||
}
|
||||
|
||||
int64_t setTimer(enum timerIndex ind, int64_t val) {
|
||||
#ifndef VIRTUAL
|
||||
int64_t subdeadtime = 0;
|
||||
@ -1609,8 +1629,6 @@ int prepareAcquisition() {
|
||||
#ifndef VIRTUAL
|
||||
FILE_LOG(logINFO, ("Going to prepare for acquisition with counter_bit:%d\n",Feb_Control_Get_Counter_Bit()));
|
||||
Feb_Control_PrepareForAcquisition();
|
||||
FILE_LOG(logINFO, ("Going to reset Frame Number\n"));
|
||||
Beb_ResetFrameNumber();
|
||||
#endif
|
||||
return OK;
|
||||
|
||||
|
@ -51,6 +51,7 @@ enum {E_PARALLEL, E_NON_PARALLEL, E_SAFE};
|
||||
|
||||
/** Default Parameters */
|
||||
#define DEFAULT_NUM_FRAMES (1)
|
||||
#define DEFAULT_STARTING_FRAME_NUMBER (1)
|
||||
#define DEFAULT_NUM_CYCLES (1)
|
||||
#define DEFAULT_EXPTIME (1E9) //ns
|
||||
#define DEFAULT_PERIOD (1E9) //ns
|
||||
@ -74,6 +75,8 @@ enum {E_PARALLEL, E_NON_PARALLEL, E_SAFE};
|
||||
#define DEFAULT_TEST_MODE (0)
|
||||
#define DEFAULT_HIGH_VOLTAGE (0)
|
||||
|
||||
#define UDP_HEADER_MAX_FRAME_VALUE (0xFFFFFFFFFFFF)
|
||||
|
||||
#define DAC_MIN_MV (0)
|
||||
#define DAC_MAX_MV (2048)
|
||||
#define LTC2620_MIN_VAL (0) // including LTC defines instead of LTC262.h (includes bit banging and blackfin read and write)
|
||||
|
Reference in New Issue
Block a user