mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 07:20:01 +02:00
merge from 4.2.0
This commit is contained in:
parent
ab9fed45fb
commit
9f3ad4e2f4
@ -178,120 +178,100 @@ void Beb_GetModuleConfiguration(int* master, int* top, int* normal) {
|
||||
|
||||
|
||||
|
||||
void Beb_EndofDataSend(int tengiga) {
|
||||
int Beb_IsTransmitting(int* retval, int tengiga, int waitForDelay) {
|
||||
//mapping new memory
|
||||
u_int32_t* csp0base=0;
|
||||
int l_framepktLsbcounter, l_framepktMsbcounter, l_txndelaycounter, l_framedelaycounter;
|
||||
int r_framepktLsbcounter, r_framepktMsbcounter, r_txndelaycounter, r_framedelaycounter;
|
||||
int l_framepktLsbcounter_new, l_framepktMsbcounter_new, l_txndelaycounter_new, l_framedelaycounter_new;
|
||||
int r_framepktLsbcounter_new, r_framepktMsbcounter_new, r_txndelaycounter_new, r_framedelaycounter_new;
|
||||
int addr_l_framepktLsbcounter, addr_l_framepktMsbcounter, addr_l_txndelaycounter, addr_l_framedelaycounter;
|
||||
int addr_r_framepktLsbcounter, addr_r_framepktMsbcounter, addr_r_txndelaycounter, addr_r_framedelaycounter;
|
||||
|
||||
switch(tengiga) {
|
||||
case 0:
|
||||
addr_l_framepktLsbcounter = ONE_GIGA_LEFT_INDEX_LSB_COUNTER;
|
||||
addr_l_framepktMsbcounter = ONE_GIGA_LEFT_INDEX_MSB_COUNTER;
|
||||
addr_l_txndelaycounter = ONE_GIGA_LEFT_TXN_DELAY_COUNTER;
|
||||
addr_l_framedelaycounter = ONE_GIGA_LEFT_FRAME_DELAY_COUNTER;
|
||||
addr_r_framepktLsbcounter = ONE_GIGA_RIGHT_INDEX_LSB_COUNTER;
|
||||
addr_r_framepktMsbcounter = ONE_GIGA_RIGHT_INDEX_MSB_COUNTER;
|
||||
addr_r_txndelaycounter = ONE_GIGA_RIGHT_TXN_DELAY_COUNTER;
|
||||
addr_r_framedelaycounter = ONE_GIGA_RIGHT_FRAME_DELAY_COUNTER;
|
||||
break;
|
||||
case 1:
|
||||
addr_l_framepktLsbcounter = TEN_GIGA_LEFT_INDEX_LSB_COUNTER;
|
||||
addr_l_framepktMsbcounter = TEN_GIGA_LEFT_INDEX_MSB_COUNTER;
|
||||
u_int32_t* csp0base = 0;
|
||||
int addr_l_txndelaycounter = 0, addr_l_framedelaycounter = 0;
|
||||
int addr_r_txndelaycounter = 0, addr_r_framedelaycounter = 0;
|
||||
int addr_l_framepktLsbcounter = 0, addr_l_framepktMsbcounter = 0;
|
||||
int addr_r_framepktLsbcounter = 0, addr_r_framepktMsbcounter = 0;
|
||||
if (tengiga) {
|
||||
addr_l_txndelaycounter = TEN_GIGA_LEFT_TXN_DELAY_COUNTER;
|
||||
addr_l_framedelaycounter = TEN_GIGA_LEFT_FRAME_DELAY_COUNTER;
|
||||
addr_r_framepktLsbcounter = TEN_GIGA_RIGHT_INDEX_LSB_COUNTER;
|
||||
addr_r_framepktMsbcounter = TEN_GIGA_RIGHT_INDEX_MSB_COUNTER;
|
||||
addr_r_txndelaycounter = TEN_GIGA_RIGHT_TXN_DELAY_COUNTER;
|
||||
addr_r_framedelaycounter = TEN_GIGA_RIGHT_FRAME_DELAY_COUNTER;
|
||||
break;
|
||||
addr_l_framepktLsbcounter = TEN_GIGA_LEFT_INDEX_LSB_COUNTER;
|
||||
addr_l_framepktMsbcounter = TEN_GIGA_LEFT_INDEX_MSB_COUNTER;
|
||||
addr_r_framepktLsbcounter = TEN_GIGA_RIGHT_INDEX_LSB_COUNTER;
|
||||
addr_r_framepktMsbcounter = TEN_GIGA_RIGHT_INDEX_MSB_COUNTER;
|
||||
} else {
|
||||
addr_l_txndelaycounter = ONE_GIGA_LEFT_TXN_DELAY_COUNTER;
|
||||
addr_l_framedelaycounter = ONE_GIGA_LEFT_FRAME_DELAY_COUNTER;
|
||||
addr_r_txndelaycounter = ONE_GIGA_RIGHT_TXN_DELAY_COUNTER;
|
||||
addr_r_framedelaycounter = ONE_GIGA_RIGHT_FRAME_DELAY_COUNTER;
|
||||
addr_l_framepktLsbcounter = ONE_GIGA_LEFT_INDEX_LSB_COUNTER;
|
||||
addr_l_framepktMsbcounter = ONE_GIGA_LEFT_INDEX_MSB_COUNTER;
|
||||
addr_r_framepktLsbcounter = ONE_GIGA_RIGHT_INDEX_LSB_COUNTER;
|
||||
addr_r_framepktMsbcounter = ONE_GIGA_RIGHT_INDEX_MSB_COUNTER;
|
||||
}
|
||||
|
||||
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_COUNTER_BASEADDR);
|
||||
if (fd < 0) {
|
||||
LOG(logERROR, ("Delay read counter fail\n"));
|
||||
return;
|
||||
if(fd < 0){
|
||||
cprintf(BG_RED,"Could not read Beb Delay read counter\n");
|
||||
return FAIL;
|
||||
} else {
|
||||
//read data first time
|
||||
l_framepktLsbcounter = Beb_Read32(csp0base, addr_l_framepktLsbcounter);
|
||||
l_framepktMsbcounter = Beb_Read32(csp0base, addr_l_framepktMsbcounter);
|
||||
l_txndelaycounter = Beb_Read32(csp0base, addr_l_txndelaycounter);
|
||||
l_framedelaycounter = Beb_Read32(csp0base, addr_l_framedelaycounter);
|
||||
r_framepktLsbcounter = Beb_Read32(csp0base, addr_r_framepktLsbcounter);
|
||||
r_framepktMsbcounter = Beb_Read32(csp0base, addr_r_framepktMsbcounter);
|
||||
r_txndelaycounter = Beb_Read32(csp0base, addr_r_txndelaycounter);
|
||||
r_framedelaycounter = Beb_Read32(csp0base, addr_r_framedelaycounter);
|
||||
LOG(logDEBUG1, ("\nLeft\n"
|
||||
"FramepacketLsbcounter: %d\n"
|
||||
"FramepacketMsbcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
"Framedelaycounter:%d\n"
|
||||
"\nRight\n"
|
||||
"FramepacketLsbcounter: %d\n"
|
||||
"FramepacketMsbcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
"Framedelaycounter:%d\n\n",
|
||||
l_framepktLsbcounter,l_framepktMsbcounter,l_txndelaycounter,l_framedelaycounter,
|
||||
r_framepktLsbcounter,r_framepktMsbcounter,r_txndelaycounter,r_framedelaycounter));
|
||||
|
||||
//keep comparing with previous values
|
||||
int maxtimer;
|
||||
while(1) {
|
||||
maxtimer = MAX(MAX(l_txndelaycounter,l_framedelaycounter),MAX(r_txndelaycounter,r_framedelaycounter));
|
||||
maxtimer /= 100;
|
||||
LOG(logDEBUG1, ("Will wait for %d us\n",maxtimer));
|
||||
usleep(maxtimer);
|
||||
|
||||
//read new values
|
||||
l_framepktLsbcounter_new = Beb_Read32(csp0base, addr_l_framepktLsbcounter);
|
||||
l_framepktMsbcounter_new = Beb_Read32(csp0base, addr_l_framepktMsbcounter);
|
||||
l_txndelaycounter_new = Beb_Read32(csp0base, addr_l_txndelaycounter);
|
||||
l_framedelaycounter_new = Beb_Read32(csp0base, addr_l_framedelaycounter);
|
||||
r_framepktLsbcounter_new = Beb_Read32(csp0base, addr_r_framepktLsbcounter);
|
||||
r_framepktMsbcounter_new = Beb_Read32(csp0base, addr_r_framepktMsbcounter);
|
||||
r_txndelaycounter_new = Beb_Read32(csp0base, addr_r_txndelaycounter);
|
||||
r_framedelaycounter_new = Beb_Read32(csp0base, addr_r_framedelaycounter);
|
||||
LOG(logDEBUG1, ("\nLeft\n"
|
||||
"FramepacketLsbcounter: %d\n"
|
||||
"FramepacketMsbcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
"Framedelaycounter:%d\n"
|
||||
"\nRight\n"
|
||||
"FramepacketLsbcounter: %d\n"
|
||||
"FramepacketMsbcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
"Framedelaycounter:%d\n\n",
|
||||
l_framepktLsbcounter_new,l_framepktMsbcounter_new,l_txndelaycounter_new,l_framedelaycounter_new,
|
||||
r_framepktLsbcounter_new,r_framepktMsbcounter_new,r_txndelaycounter_new,r_framedelaycounter_new));
|
||||
|
||||
if ((l_framepktLsbcounter == l_framepktLsbcounter_new) &&
|
||||
(l_framepktMsbcounter == l_framepktMsbcounter_new) &&
|
||||
(r_framepktLsbcounter == r_framepktLsbcounter_new) &&
|
||||
(r_framepktMsbcounter == r_framepktMsbcounter_new))
|
||||
break;
|
||||
|
||||
//update old values
|
||||
l_framepktLsbcounter = l_framepktLsbcounter_new;
|
||||
l_framepktMsbcounter = l_framepktMsbcounter_new;
|
||||
l_txndelaycounter = l_txndelaycounter_new;
|
||||
l_framedelaycounter = l_framedelaycounter_new;
|
||||
r_framepktLsbcounter = r_framepktLsbcounter_new;
|
||||
r_framepktMsbcounter = r_framepktMsbcounter_new;
|
||||
r_txndelaycounter = r_txndelaycounter_new;
|
||||
r_framedelaycounter = r_framedelaycounter_new;
|
||||
|
||||
int l_txndelaycounter = Beb_Read32(csp0base, addr_l_txndelaycounter);
|
||||
int l_framedelaycounter = Beb_Read32(csp0base, addr_l_framedelaycounter);
|
||||
int r_txndelaycounter = Beb_Read32(csp0base, addr_r_txndelaycounter);
|
||||
int r_framedelaycounter = Beb_Read32(csp0base, addr_r_framedelaycounter);
|
||||
int l_framepktLsbcounter = Beb_Read32(csp0base, addr_l_framepktLsbcounter);
|
||||
int l_framepktMsbcounter = Beb_Read32(csp0base, addr_l_framepktMsbcounter);
|
||||
int r_framepktLsbcounter = Beb_Read32(csp0base, addr_r_framepktLsbcounter);
|
||||
int r_framepktMsbcounter = Beb_Read32(csp0base, addr_r_framepktMsbcounter);
|
||||
#ifdef VERBOSE
|
||||
printf("\nFirst Read:\n"
|
||||
"\tLeft [Txndelaycounter:%d, Framedelaycounter:%d]\n"
|
||||
"\tRight [Txndelaycounter:%d, Framedelaycounter:%d]\n",
|
||||
"\tLeft [FramepacketLsbcounter:%d, FramepacketMsbcounter:%d]\n"
|
||||
"\tRight [FramepacketLsbcounter:%d, FramepacketMsbcounter:%d]\n",
|
||||
l_txndelaycounter,l_framedelaycounter, r_txndelaycounter,r_framedelaycounter,
|
||||
l_framepktLsbcounter, l_framepktMsbcounter, r_framepktLsbcounter, r_framepktMsbcounter);
|
||||
#endif
|
||||
// wait for max counter delay
|
||||
if (waitForDelay) {
|
||||
int maxtimer = (MAX(MAX(l_txndelaycounter,l_framedelaycounter),MAX(r_txndelaycounter,r_framedelaycounter))) / 100; // counter values in 10 ns
|
||||
printf("Will wait for %d us\n", maxtimer);
|
||||
usleep (maxtimer);
|
||||
}
|
||||
// wait for 1 ms
|
||||
else {
|
||||
printf("Will wait for 1 ms\n");
|
||||
usleep (1 * 1000);
|
||||
}
|
||||
|
||||
LOG(logINFO, ("Detector has sent all data\n"));
|
||||
// read values again
|
||||
int l_txndelaycounter2 = Beb_Read32(csp0base, addr_l_txndelaycounter);
|
||||
int l_framedelaycounter2 = Beb_Read32(csp0base, addr_l_framedelaycounter);
|
||||
int r_txndelaycounter2 = Beb_Read32(csp0base, addr_r_txndelaycounter);
|
||||
int r_framedelaycounter2 = Beb_Read32(csp0base, addr_r_framedelaycounter);
|
||||
int l_framepktLsbcounter2 = Beb_Read32(csp0base, addr_l_framepktLsbcounter);
|
||||
int l_framepktMsbcounter2 = Beb_Read32(csp0base, addr_l_framepktMsbcounter);
|
||||
int r_framepktLsbcounter2 = Beb_Read32(csp0base, addr_r_framepktLsbcounter);
|
||||
int r_framepktMsbcounter2 = Beb_Read32(csp0base, addr_r_framepktMsbcounter);
|
||||
#ifdef VERBOSE
|
||||
printf("\nSecond Read:\n"
|
||||
"\tLeft [Txndelaycounter:%d, Framedelaycounter:%d]\n"
|
||||
"\tRight [Txndelaycounter:%d, Framedelaycounter:%d]\n",
|
||||
"\tLeft [FramepacketLsbcounter:%d, FramepacketMsbcounter:%d]\n"
|
||||
"\tRight [FramepacketLsbcounter:%d, FramepacketMsbcounter:%d]\n",
|
||||
l_txndelaycounter2,l_framedelaycounter2, r_txndelaycounter2,r_framedelaycounter2,
|
||||
l_framepktLsbcounter2, l_framepktMsbcounter2, r_framepktLsbcounter2, r_framepktMsbcounter2);
|
||||
#endif
|
||||
// any change in values, it is still transmitting
|
||||
if (l_txndelaycounter != l_txndelaycounter2 || l_framedelaycounter != l_framedelaycounter2 ||
|
||||
r_txndelaycounter != r_txndelaycounter2 || r_framedelaycounter != r_framedelaycounter2 ||
|
||||
l_framepktLsbcounter != l_framepktLsbcounter2 || l_framepktMsbcounter != l_framepktMsbcounter2 ||
|
||||
r_framepktLsbcounter != r_framepktLsbcounter2 || r_framepktMsbcounter != r_framepktMsbcounter2) {
|
||||
*retval = 1;
|
||||
} else {
|
||||
*retval = 0;
|
||||
}
|
||||
//close file pointer
|
||||
Beb_close(fd,csp0base);
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,7 +34,7 @@ unsigned int Beb_GetBebInfoIndex(unsigned int beb_numb);
|
||||
|
||||
|
||||
void Beb_GetModuleConfiguration(int* master, int* top, int* normal);
|
||||
void Beb_EndofDataSend(int tengiga);
|
||||
int Beb_IsTransmitting(int* retval, int tengiga, int waitForDelay);
|
||||
|
||||
int Beb_SetMasterViaSoftware();
|
||||
int Beb_SetSlaveViaSoftware();
|
||||
|
Binary file not shown.
@ -2129,19 +2129,23 @@ enum runStatus getRunStatus() {
|
||||
#else
|
||||
|
||||
int i = Feb_Control_AcquisitionInProgress();
|
||||
switch (i) {
|
||||
case STATUS_ERROR:
|
||||
if (i == STATUS_ERROR) {
|
||||
LOG(logERROR, ("Status: ERROR reading status register\n"));
|
||||
return ERROR;
|
||||
case STATUS_IDLE:
|
||||
} else if (i == STATUS_IDLE) {
|
||||
int isTransmitting = 0;
|
||||
if (Beb_IsTransmitting(&isTransmitting, send_to_ten_gig, 0) == FAIL) {
|
||||
return ERROR;
|
||||
}
|
||||
if (isTransmitting) {
|
||||
printf("Status: TRANSMITTING\n");
|
||||
return TRANSMITTING;
|
||||
}
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
default:
|
||||
LOG(logINFOBLUE, ("Status: RUNNING...\n"));
|
||||
return RUNNING;
|
||||
}
|
||||
|
||||
return IDLE;
|
||||
LOG(logINFOBLUE, ("Status: RUNNING...\n"));
|
||||
return RUNNING;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -2175,7 +2179,18 @@ void readFrame(int *ret, char *mess) {
|
||||
}
|
||||
|
||||
//wait for detector to send
|
||||
Beb_EndofDataSend(send_to_ten_gig);
|
||||
int isTransmitting = 1;
|
||||
while (isTransmitting) {
|
||||
if (Beb_IsTransmitting(&isTransmitting, send_to_ten_gig, 1) == FAIL) {
|
||||
strcpy(mess,"Could not read delay counters\n");
|
||||
*ret = (int)FAIL;
|
||||
return;
|
||||
}
|
||||
if (isTransmitting) {
|
||||
printf("Transmitting...\n");
|
||||
}
|
||||
}
|
||||
printf("Detector has sent all data\n");
|
||||
LOG(logINFOGREEN, ("Acquisition successfully finished\n"));
|
||||
#endif
|
||||
}
|
||||
|
@ -63,10 +63,10 @@ enum CLKINDEX {RUN_CLK, NUM_CLOCKS};
|
||||
#define DEFAULT_SUBFRAME_DEADTIME (0)
|
||||
#define DEFAULT_DYNAMIC_RANGE (16)
|
||||
|
||||
#define DEFAULT_PARALLEL_MODE (0)
|
||||
#define DEFAULT_PARALLEL_MODE (1)
|
||||
#define DEFAULT_READOUT_STOREINRAM_MODE (0)
|
||||
#define DEFAULT_READOUT_OVERFLOW32_MODE (0)
|
||||
#define DEFAULT_CLK_SPEED (HALF_SPEED)
|
||||
#define DEFAULT_CLK_SPEED (FULL_SPEED)
|
||||
#define DEFAULT_IO_DELAY (650)
|
||||
#define DEFAULT_TIMING_MODE (AUTO_TIMING)
|
||||
#define DEFAULT_PHOTON_ENERGY (-1)
|
||||
|
@ -1567,15 +1567,15 @@ void* start_timer(void* arg) {
|
||||
if (adcConfigured == -1) {
|
||||
*((uint32_t*)(imageData)) = 0xCACACACA;
|
||||
}
|
||||
for (i = 4; i < imageSize; i += sizeof(uint16_t)) {
|
||||
*((uint16_t*)(imageData + i)) = i;
|
||||
for (i = sizeof(uint32_t); i < imageSize; i += sizeof(uint16_t)) {
|
||||
*((uint16_t*)(imageData + i)) = (uint16_t)i;
|
||||
}
|
||||
}
|
||||
|
||||
// Send data
|
||||
{
|
||||
int frameNr = 0;
|
||||
int frameHeaderNr = 2;
|
||||
uint16_t frameHeaderNr = 2;
|
||||
// loop over number of frames
|
||||
for(frameNr = 0; frameNr != numFrames; ++frameNr ) {
|
||||
|
||||
|
@ -1393,17 +1393,12 @@ void Module::setDynamicRange(int n) {
|
||||
// changes in dr
|
||||
if (n != prev_val) {
|
||||
// update speed for usability
|
||||
switch (n) {
|
||||
case 32:
|
||||
if (n == 32) {
|
||||
LOG(logINFO) << "Setting Clock to Quarter Speed to cope with Dynamic Range of 32";
|
||||
setClockDivider(RUN_CLOCK, 2);
|
||||
break;
|
||||
case 16:
|
||||
LOG(logINFO) << "Setting Clock to Full Speed to cope with Dynamic Range of " << n;
|
||||
} else if (prev_val == 32) {
|
||||
LOG(logINFO) << "Setting Clock to Full Speed for Dynamic Range of " << n;
|
||||
setClockDivider(RUN_CLOCK, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
updateRateCorrection();
|
||||
}
|
||||
|
@ -414,7 +414,7 @@ class EigerData : public GeneralData {
|
||||
imageSize = dataSize*packetsPerFrame;
|
||||
maxFramesPerFile = EIGER_MAX_FRAMES_PER_FILE;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsDetectorDefs::sls_receiver_header);
|
||||
defaultFifoDepth = 100;
|
||||
defaultFifoDepth = 1000;
|
||||
threadsPerReceiver = 2;
|
||||
headerPacketSize = 40;
|
||||
standardheader = true;
|
||||
@ -428,6 +428,7 @@ class EigerData : public GeneralData {
|
||||
void SetDynamicRange(int dr, bool tgEnable) {
|
||||
packetsPerFrame = (tgEnable ? 4 : 16) * dr;
|
||||
imageSize = dataSize*packetsPerFrame;
|
||||
defaultFifoDepth = (dr == 32 ? 100 : 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -187,7 +187,9 @@ void Implementation::SetupFifoStructure() {
|
||||
fifoDepth));
|
||||
} catch (...) {
|
||||
fifo.clear();
|
||||
throw sls::RuntimeError("Could not allocate memory for fifo structure " + std::to_string(i));
|
||||
fifoDepth = 0;
|
||||
throw sls::RuntimeError("Could not allocate memory for fifo structure " +
|
||||
std::to_string(i) + ". FifoDepth is now 0.");
|
||||
}
|
||||
// set the listener & dataprocessor threads to point to the right fifo
|
||||
if (listener.size())
|
||||
@ -1475,6 +1477,7 @@ void Implementation::setDynamicRange(const uint32_t i) {
|
||||
// to update npixelsx, npixelsy in file writer
|
||||
for (const auto &it : dataProcessor)
|
||||
it->SetPixelDimension();
|
||||
fifoDepth = generalData->defaultFifoDepth;
|
||||
SetupFifoStructure();
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
#define APIJUNGFRAU 0x200402
|
||||
#define APIMYTHEN3 0x200402
|
||||
#define APIMOENCH 0x200331
|
||||
#define APIEIGER 0x200402
|
||||
#define APILIB 0x200402
|
||||
#define APIRECEIVER 0x200402
|
||||
#define APIGUI 0x200331
|
||||
#define APIEIGER 0x200407
|
||||
|
@ -11,7 +11,7 @@ std::string ToString(const defs::runStatus s) {
|
||||
case defs::RUNNING:
|
||||
return std::string("running");
|
||||
case defs::TRANSMITTING:
|
||||
return std::string("data");
|
||||
return std::string("transmitting");
|
||||
case defs::RUN_FINISHED:
|
||||
return std::string("finished");
|
||||
case defs::STOPPED:
|
||||
|
Loading…
x
Reference in New Issue
Block a user