mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-28 01:00:02 +02:00
merged
This commit is contained in:
commit
55c35b6669
@ -24,6 +24,7 @@
|
||||
|
||||
#include "Beb.h"
|
||||
|
||||
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
|
||||
|
||||
|
||||
struct BebInfo beb_infos[10];
|
||||
@ -172,6 +173,111 @@ void Beb_GetModuleCopnfiguration(int* master, int* top){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Beb_EndofDataSend(int tengiga){
|
||||
//mapping new memory
|
||||
u_int32_t* csp0base=0;
|
||||
int l_framepktcounter2, l_txndelaycounter, l_framedelaycounter, r_framepktcounter2, r_txndelaycounter, r_framedelaycounter;
|
||||
int l_framepktcounter2_new, l_txndelaycounter_new, l_framedelaycounter_new, r_framepktcounter2_new, r_txndelaycounter_new, r_framedelaycounter_new;
|
||||
int addr_l_framepktcounter2, addr_l_txndelaycounter, addr_l_framedelaycounter, addr_r_framepktcounter2, addr_r_txndelaycounter, addr_r_framedelaycounter;
|
||||
|
||||
switch(tengiga){
|
||||
case 0:
|
||||
addr_l_framepktcounter2 = ONE_GIGA_LEFT_PKT_SEND_COUNTER;
|
||||
addr_l_txndelaycounter = ONE_GIGA_LEFT_TXN_DELAY_COUNTER;
|
||||
addr_l_framedelaycounter = ONE_GIGA_LEFT_FRAME_DELAY_COUNTER;
|
||||
addr_r_framepktcounter2 = ONE_GIGA_RIGHT_PKT_SEND_COUNTER;
|
||||
addr_r_txndelaycounter = ONE_GIGA_RIGHT_TXN_DELAY_COUNTER;
|
||||
addr_r_framedelaycounter = ONE_GIGA_RIGHT_FRAME_DELAY_COUNTER;
|
||||
break;
|
||||
case 1:
|
||||
addr_l_framepktcounter2 = TEN_GIGA_LEFT_PKT_SEND_COUNTER;
|
||||
addr_l_txndelaycounter = TEN_GIGA_LEFT_TXN_DELAY_COUNTER;
|
||||
addr_l_framedelaycounter = TEN_GIGA_LEFT_FRAME_DELAY_COUNTER;
|
||||
addr_r_framepktcounter2 = TEN_GIGA_RIGHT_PKT_SEND_COUNTER;
|
||||
addr_r_txndelaycounter = TEN_GIGA_RIGHT_TXN_DELAY_COUNTER;
|
||||
addr_r_framedelaycounter = TEN_GIGA_RIGHT_FRAME_DELAY_COUNTER;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_COUNTER_BASEADDR);
|
||||
if(fd < 0){
|
||||
cprintf(BG_RED,"Delay read counter fail\n");
|
||||
return;
|
||||
}else{
|
||||
//read data first time
|
||||
l_framepktcounter2 = Beb_Read32(csp0base, addr_l_framepktcounter2);
|
||||
l_txndelaycounter = Beb_Read32(csp0base, addr_l_txndelaycounter);
|
||||
l_framedelaycounter = Beb_Read32(csp0base, addr_l_framedelaycounter);
|
||||
r_framepktcounter2 = Beb_Read32(csp0base, addr_r_framepktcounter2);
|
||||
r_txndelaycounter = Beb_Read32(csp0base, addr_r_txndelaycounter);
|
||||
r_framedelaycounter = Beb_Read32(csp0base, addr_r_framedelaycounter);
|
||||
//#ifdef VERBOSE
|
||||
printf("\nLeft\n"
|
||||
"Framepacketcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
"Framedelaycounter:%d\n"
|
||||
"\nRight\n"
|
||||
"Framepacketcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
"Framedelaycounter:%d\n\n",
|
||||
l_framepktcounter2,l_txndelaycounter,l_framedelaycounter,
|
||||
r_framepktcounter2,r_txndelaycounter,r_framedelaycounter);
|
||||
//#endif
|
||||
|
||||
//keep comparing with previous values
|
||||
int maxtimer;
|
||||
while(1){
|
||||
maxtimer = MAX(MAX(l_txndelaycounter,l_framedelaycounter),MAX(r_txndelaycounter,r_framedelaycounter));
|
||||
maxtimer /= 100;
|
||||
printf("Will wait for %d us\n",maxtimer);
|
||||
usleep(maxtimer);
|
||||
|
||||
//read new values
|
||||
l_framepktcounter2_new = Beb_Read32(csp0base, addr_l_framepktcounter2);
|
||||
l_txndelaycounter_new = Beb_Read32(csp0base, addr_l_txndelaycounter);
|
||||
l_framedelaycounter_new = Beb_Read32(csp0base, addr_l_framedelaycounter);
|
||||
r_framepktcounter2_new = Beb_Read32(csp0base, addr_r_framepktcounter2);
|
||||
r_txndelaycounter_new = Beb_Read32(csp0base, addr_r_txndelaycounter);
|
||||
r_framedelaycounter_new = Beb_Read32(csp0base, addr_r_framedelaycounter);
|
||||
//#ifdef VERBOSE
|
||||
printf("\nLeft\n"
|
||||
"Framepacketcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
"Framedelaycounter:%d\n"
|
||||
"\nRight\n"
|
||||
"Framepacketcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
"Framedelaycounter:%d\n\n",
|
||||
l_framepktcounter2_new,l_txndelaycounter_new,l_framedelaycounter_new,
|
||||
r_framepktcounter2_new,r_txndelaycounter_new,r_framedelaycounter_new);
|
||||
//#endif
|
||||
|
||||
if ((l_framepktcounter2 == l_framepktcounter2_new) && (r_framepktcounter2 == r_framepktcounter2_new))
|
||||
break;
|
||||
|
||||
//update old values
|
||||
l_framepktcounter2 = l_framepktcounter2_new;
|
||||
l_txndelaycounter = l_txndelaycounter_new;
|
||||
l_framedelaycounter = l_framedelaycounter_new;
|
||||
r_framepktcounter2 = r_framepktcounter2_new;
|
||||
r_txndelaycounter = r_txndelaycounter_new;
|
||||
r_framedelaycounter = r_framedelaycounter_new;
|
||||
|
||||
}
|
||||
|
||||
printf("Detector has send all data\n");
|
||||
//close file pointer
|
||||
Beb_close(fd,csp0base);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* do not work at the moment */
|
||||
int Beb_SetMasterViaSoftware(){
|
||||
|
||||
|
@ -46,6 +46,8 @@ struct BebInfo{
|
||||
|
||||
|
||||
void Beb_GetModuleCopnfiguration(int* master, int* top);
|
||||
void Beb_EndofDataSend(int tengiga);
|
||||
|
||||
int Beb_SetMasterViaSoftware();
|
||||
int Beb_SetSlaveViaSoftware();
|
||||
int Beb_Activate(int enable);
|
||||
|
@ -153,3 +153,46 @@
|
||||
//temp so far
|
||||
#define FEB_REG_STATUS 0xa
|
||||
|
||||
//1g counters
|
||||
#define ONE_GIGA_LEFT_FRAME_SEND_COUNTER 0x04
|
||||
#define ONE_GIGA_LEFT_PKT_SEND_COUNTER 0x24
|
||||
|
||||
#define ONE_GIGA_LEFT_TXN_DELAY_COUNTER 0x104
|
||||
#define ONE_GIGA_LEFT_FRAME_DELAY_COUNTER 0x124
|
||||
|
||||
#define ONE_GIGA_RIGHT_FRAME_SEND_COUNTER 0x44
|
||||
#define ONE_GIGA_RIGHT_PKT_SEND_COUNTER 0x64
|
||||
|
||||
#define ONE_GIGA_RIGHT_TXN_DELAY_COUNTER 0x144
|
||||
#define ONE_GIGA_RIGHT_FRAME_DELAY_COUNTER 0x164
|
||||
|
||||
//10g counters
|
||||
#define TEN_GIGA_LEFT_FRAME_SEND_COUNTER 0x84
|
||||
#define TEN_GIGA_LEFT_PKT_SEND_COUNTER 0xa4
|
||||
|
||||
#define TEN_GIGA_LEFT_TXN_DELAY_COUNTER 0x184
|
||||
#define TEN_GIGA_LEFT_FRAME_DELAY_COUNTER 0x1a4
|
||||
|
||||
#define TEN_GIGA_RIGHT_FRAME_SEND_COUNTER 0xc4
|
||||
#define TEN_GIGA_RIGHT_PKT_SEND_COUNTER 0xe4
|
||||
|
||||
#define TEN_GIGA_RIGHT_TXN_DELAY_COUNTER 0x1c4
|
||||
#define TEN_GIGA_RIGHT_FRAME_DELAY_COUNTER 0x1e4
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
BIN
slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv2.2.0.16.2
Executable file
BIN
slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv2.2.0.16.2
Executable file
Binary file not shown.
@ -871,6 +871,11 @@ void readFrame(int *ret, char *mess){
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//wait for detector to send
|
||||
Beb_EndofDataSend(send_to_ten_gig);
|
||||
|
||||
|
||||
printf("*****Done Waiting...\n");
|
||||
*ret = (int)FINISHED;
|
||||
strcpy(mess,"acquisition successfully finished\n");
|
||||
|
@ -45,4 +45,5 @@ enum detAdcIndex{TEMP_FPGAEXT, TEMP_10GE, TEMP_DCDC, TEMP_SODL, TEMP_SODR, TEMP_
|
||||
enum detNetworkParameter{TXN_LEFT, TXN_RIGHT, TXN_FRAME,FLOWCTRL_10G};
|
||||
|
||||
|
||||
|
||||
#endif /* SLSDETECTORSERVER_DEFS_H_ */
|
||||
|
@ -61,6 +61,12 @@ XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR
|
||||
#define XPAR_PLB_GPIO_TEST_HIGHADDR 0xD101FFFF
|
||||
|
||||
|
||||
|
||||
/* Definitions for packet, frame and delay down counters */
|
||||
#define XPAR_COUNTER_BASEADDR 0xD1020000
|
||||
#define XPAR_COUNTER_HIGHADDR 0xD102FFFF
|
||||
|
||||
|
||||
/* Definitions for peripheral PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT */
|
||||
#define XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR 0xC4100000
|
||||
#define XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_HIGHADDR 0xC410FFFF
|
||||
|
@ -268,6 +268,7 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1)
|
||||
|
||||
getNMods();
|
||||
getMaxMods();
|
||||
threadStarted = false;
|
||||
threadpool = 0;
|
||||
if(createThreadPool() == FAIL)
|
||||
exit(-1);
|
||||
@ -4938,6 +4939,7 @@ int multiSlsDetector::getFramesCaughtByReceiver() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++)
|
||||
if (detectors[i]){
|
||||
ret1+=detectors[i]->getFramesCaughtByReceiver();
|
||||
|
@ -4029,27 +4029,30 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
|
||||
std::cout<< "Timer " << index << " set to "<< thisDetector->timerValue[index] << "ns" << std::endl;
|
||||
#endif
|
||||
|
||||
if ((thisDetector->myDetectorType==MYTHEN)&&(index==PROBES_NUMBER)) {
|
||||
setDynamicRange();
|
||||
//cout << "Changing probes: data size = " << thisDetector->dataBytes <<endl;
|
||||
}
|
||||
|
||||
/* set progress */
|
||||
if ((index==FRAME_NUMBER) || (index==CYCLES_NUMBER)) {
|
||||
setTotalProgress();
|
||||
}
|
||||
if(t!=-1){
|
||||
if ((thisDetector->myDetectorType==MYTHEN)&&(index==PROBES_NUMBER)) {
|
||||
setDynamicRange();
|
||||
//cout << "Changing probes: data size = " << thisDetector->dataBytes <<endl;
|
||||
}
|
||||
|
||||
//if eiger, rate corr on, a put statement, dr=32 &setting subexp or dr =16 & setting exptime, set ratecorr to update table
|
||||
double r;
|
||||
if( (thisDetector->myDetectorType == EIGER) &&
|
||||
getRateCorrection(r) &&
|
||||
(t>=0) &&
|
||||
/* set progress */
|
||||
if ((index==FRAME_NUMBER) || (index==CYCLES_NUMBER)) {
|
||||
setTotalProgress();
|
||||
}
|
||||
|
||||
(((index == SUBFRAME_ACQUISITION_TIME) && (thisDetector->dynamicRange == 32))||
|
||||
((index == ACQUISITION_TIME) && (thisDetector->dynamicRange == 16)))
|
||||
//if eiger, rate corr on, a put statement, dr=32 &setting subexp or dr =16 & setting exptime, set ratecorr to update table
|
||||
double r;
|
||||
if( (thisDetector->myDetectorType == EIGER) &&
|
||||
getRateCorrection(r) &&
|
||||
(t>=0) &&
|
||||
|
||||
&& (t>=0) && getRateCorrection(r)){
|
||||
setRateCorrection(r);
|
||||
(((index == SUBFRAME_ACQUISITION_TIME) && (thisDetector->dynamicRange == 32))||
|
||||
((index == ACQUISITION_TIME) && (thisDetector->dynamicRange == 16)))
|
||||
|
||||
&& (t>=0) && getRateCorrection(r)){
|
||||
setRateCorrection(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -7071,8 +7074,11 @@ string slsDetector::setFilePath(string s) {
|
||||
if(stat(s.c_str(),&st)){
|
||||
std::cout << "path does not exist" << endl;
|
||||
setErrorMask((getErrorMask())|(FILE_PATH_DOES_NOT_EXIST));
|
||||
}else
|
||||
}else{
|
||||
pthread_mutex_lock(&ms);
|
||||
fileIO::setFilePath(s);
|
||||
pthread_mutex_unlock(&ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -7084,8 +7090,11 @@ string slsDetector::setFilePath(string s) {
|
||||
if (connectData() == OK)
|
||||
ret=thisReceiver->sendString(fnum,retval,arg);
|
||||
disconnectData();
|
||||
if(ret!=FAIL)
|
||||
if(ret!=FAIL){
|
||||
pthread_mutex_lock(&ms);
|
||||
fileIO::setFilePath(string(retval));
|
||||
pthread_mutex_unlock(&ms);
|
||||
}
|
||||
else if(!s.empty()){
|
||||
std::cout << "path does not exist" << endl;
|
||||
setErrorMask((getErrorMask())|(FILE_PATH_DOES_NOT_EXIST));
|
||||
@ -7094,7 +7103,11 @@ string slsDetector::setFilePath(string s) {
|
||||
updateReceiver();
|
||||
}
|
||||
|
||||
return fileIO::getFilePath();
|
||||
pthread_mutex_lock(&ms);
|
||||
s = fileIO::getFilePath();
|
||||
pthread_mutex_unlock(&ms);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
@ -7139,7 +7152,11 @@ string slsDetector::setFileName(string s) {
|
||||
}
|
||||
}
|
||||
|
||||
return fileIO::getFileName();
|
||||
pthread_mutex_lock(&ms);
|
||||
s = fileIO::getFileName();
|
||||
pthread_mutex_unlock(&ms);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
@ -7451,16 +7468,22 @@ int slsDetector::updateReceiverNoWait() {
|
||||
#ifdef VERBOSE
|
||||
cout << "Updating receiver last modified by " << lastClientIP << std::endl;
|
||||
#endif
|
||||
|
||||
n = dataSocket->ReceiveDataOnly(&ind,sizeof(ind));
|
||||
pthread_mutex_lock(&ms);
|
||||
fileIO::setFileIndex(ind);
|
||||
pthread_mutex_unlock(&ms);
|
||||
|
||||
n = dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH);
|
||||
pthread_mutex_lock(&ms);
|
||||
fileIO::setFilePath(path);
|
||||
pthread_mutex_unlock(&ms);
|
||||
|
||||
n = dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH);
|
||||
pthread_mutex_lock(&ms);
|
||||
fileIO::setFileName(path);
|
||||
pthread_mutex_unlock(&ms);
|
||||
|
||||
return OK;
|
||||
|
||||
}
|
||||
@ -7611,7 +7634,9 @@ int slsDetector::setFrameIndex(int index){
|
||||
int arg = index;
|
||||
|
||||
if(thisDetector->receiverOnlineFlag==OFFLINE_FLAG){
|
||||
fileIO::setFrameIndex(index);
|
||||
pthread_mutex_lock(&ms);
|
||||
fileIO::setFrameIndex(index);
|
||||
pthread_mutex_unlock(&ms);
|
||||
}
|
||||
|
||||
else if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
|
||||
@ -7620,14 +7645,20 @@ int slsDetector::setFrameIndex(int index){
|
||||
#endif
|
||||
if (connectData() == OK)
|
||||
ret=thisReceiver->sendInt(fnum,retval,arg);
|
||||
disconnectData();
|
||||
if(ret!=FAIL)
|
||||
disconnectData();
|
||||
if(ret!=FAIL){
|
||||
pthread_mutex_lock(&ms);
|
||||
fileIO::setFrameIndex(retval);
|
||||
pthread_mutex_unlock(&ms);
|
||||
}
|
||||
if(ret==FORCE_UPDATE)
|
||||
updateReceiver();
|
||||
}
|
||||
pthread_mutex_lock(&ms);
|
||||
retval = fileIO::getFrameIndex();
|
||||
pthread_mutex_unlock(&ms);
|
||||
|
||||
return fileIO::getFrameIndex();
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
@ -146,18 +146,17 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
}
|
||||
|
||||
if(receiver){
|
||||
pthread_mutex_lock(&mg);
|
||||
if(getReceiverStatus()!=IDLE)
|
||||
stopReceiver();
|
||||
if(setReceiverOnline()==OFFLINE_FLAG)
|
||||
*stoppedFlag=1;
|
||||
//multi detectors shouldnt have different receiver read frequencies enabled/disabled
|
||||
if(setReadReceiverFrequency(0) < 0){
|
||||
std::cout << "Error: The receiver read frequency is invalid:" << setReadReceiverFrequency(0) << std::endl;
|
||||
*stoppedFlag=1;
|
||||
}
|
||||
|
||||
if(setReceiverOnline()==OFFLINE_FLAG)
|
||||
*stoppedFlag=1;
|
||||
pthread_mutex_unlock(&mg);
|
||||
}
|
||||
|
||||
|
||||
|
@ -395,7 +395,9 @@ int postProcessing::fillBadChannelMask() {
|
||||
|
||||
|
||||
void* postProcessing::processData(int delflag) {
|
||||
pthread_mutex_lock(&mg);
|
||||
if(setReceiverOnline()==OFFLINE_FLAG){
|
||||
pthread_mutex_unlock(&mg);
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< " ??????????????????????????????????????????? processing data - threaded mode " << *threadedProcessing << endl;
|
||||
@ -482,6 +484,7 @@ void* postProcessing::processData(int delflag) {
|
||||
}
|
||||
//receiver
|
||||
else{
|
||||
pthread_mutex_unlock(&mg);
|
||||
//cprintf(RED,"In post processing threads\n");
|
||||
|
||||
|
||||
@ -493,19 +496,24 @@ void* postProcessing::processData(int delflag) {
|
||||
else{
|
||||
int caught = -1;
|
||||
while(true){
|
||||
cout.flush();
|
||||
cout<<flush;
|
||||
usleep(20000); //20ms need this else connecting error to receiver (too fast)
|
||||
|
||||
//cout.flush();
|
||||
//cout<<flush;
|
||||
usleep(40000); //20ms need this else connecting error to receiver (too fast)
|
||||
|
||||
if (checkJoinThread()){
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
//get progress
|
||||
pthread_mutex_lock(&mg);
|
||||
if(setReceiverOnline() == ONLINE_FLAG){
|
||||
pthread_mutex_lock(&mg);
|
||||
caught = getFramesCaughtByReceiver();
|
||||
pthread_mutex_unlock(&mg);
|
||||
}
|
||||
pthread_mutex_unlock(&mg);
|
||||
|
||||
|
||||
//updating progress
|
||||
if(caught!= -1){
|
||||
setCurrentProgress(caught);
|
||||
@ -516,6 +524,9 @@ void* postProcessing::processData(int delflag) {
|
||||
if (checkJoinThread()){
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user