mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-14 13:57:13 +02:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
26c829d766 | |||
56c504abbb | |||
befdcf7f36 | |||
02f5c472a8 | |||
75ed2cd2e4 | |||
6a80bc5b54 |
@ -561,6 +561,15 @@ int receiveModuleGeneral(int file_des, sls_detector_module* myMod, int receiveA
|
||||
myMod->chipregs=chipptr;
|
||||
myMod->chanregs=chanptr;
|
||||
|
||||
#ifdef EIGERD
|
||||
//feature to exclude sending of trimbtis, nchips=0,nchans=0 in that case
|
||||
if(myMod->nchip == 0 && myMod->nchan == 0) {
|
||||
receiveAll=0;
|
||||
nchipold=0;
|
||||
nchanold=0;
|
||||
}
|
||||
#endif
|
||||
|
||||
nChips=myMod->nchip;
|
||||
nchipdiff=nChips-nchipold;
|
||||
if (nchipold!=nChips) {
|
||||
@ -571,6 +580,7 @@ int receiveModuleGeneral(int file_des, sls_detector_module* myMod, int receiveA
|
||||
printf("received %d chips\n",nChips);
|
||||
#endif
|
||||
|
||||
|
||||
nChans=myMod->nchan;
|
||||
nchandiff=nChans-nchanold;
|
||||
if (nchanold!=nChans) {
|
||||
|
Binary file not shown.
@ -627,6 +627,10 @@ int setModule(sls_detector_module myMod, int delay){
|
||||
for(i=0;i<myMod.ndac;i++)
|
||||
setDAC((enum detDacIndex)i,myMod.dacs[i],myMod.module,0,retval);
|
||||
|
||||
if(myMod.nchan==0 && myMod.nchip == 0)
|
||||
cprintf(BLUE,"Setting module without trimbits\n");
|
||||
else{
|
||||
cprintf(GREEN,"Setting module with trimbits\n");
|
||||
//includ gap pixels
|
||||
unsigned int tt[263680];
|
||||
int iy,ichip,ix,ip=0,ich=0;
|
||||
@ -647,6 +651,7 @@ int setModule(sls_detector_module myMod, int delay){
|
||||
cprintf(BG_RED,"Could not set trimbits\n");
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
return thisSettings;
|
||||
}
|
||||
@ -1126,11 +1131,13 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod){
|
||||
|
||||
destMod->serialnumber=srcMod->serialnumber;
|
||||
}
|
||||
if ((srcMod->nchip)>(destMod->nchip)) {
|
||||
//no trimbit feature
|
||||
if (destMod->nchip && ((srcMod->nchip)>(destMod->nchip))) {
|
||||
printf("Number of chip of source is larger than number of chips of destination\n");
|
||||
return FAIL;
|
||||
}
|
||||
if ((srcMod->nchan)>(destMod->nchan)) {
|
||||
//no trimbit feature
|
||||
if (destMod->nchan && ((srcMod->nchan)>(destMod->nchan))) {
|
||||
printf("Number of channels of source is larger than number of channels of destination\n");
|
||||
return FAIL;
|
||||
}
|
||||
@ -1164,6 +1171,7 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod){
|
||||
if (srcMod->offset>=0)
|
||||
destMod->offset=srcMod->offset;
|
||||
|
||||
if((destMod->nchip!=0) || (destMod->nchan!=0)) {
|
||||
for (ichip=0; ichip<(srcMod->nchip); ichip++) {
|
||||
if (*((srcMod->chipregs)+ichip)>=0)
|
||||
*((destMod->chipregs)+ichip)=*((srcMod->chipregs)+ichip);
|
||||
@ -1172,6 +1180,12 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod){
|
||||
if (*((srcMod->chanregs)+ichan)>=0)
|
||||
*((destMod->chanregs)+ichan)=*((srcMod->chanregs)+ichan);
|
||||
}
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
printf("Not Copying trimbits\n");
|
||||
#endif
|
||||
|
||||
|
||||
for (idac=0; idac<(srcMod->ndac); idac++) {
|
||||
if (*((srcMod->dacs)+idac)>=0)
|
||||
*((destMod->dacs)+idac)=*((srcMod->dacs)+idac);
|
||||
|
@ -1139,7 +1139,7 @@ int multiSlsDetector::getThresholdEnergy(int pos) {
|
||||
}
|
||||
|
||||
|
||||
int multiSlsDetector::setThresholdEnergy(int e_eV, int pos, detectorSettings isettings) {
|
||||
int multiSlsDetector::setThresholdEnergy(int e_eV, int pos, detectorSettings isettings, int tb) {
|
||||
|
||||
int posmin, posmax;
|
||||
int ret=-100;
|
||||
@ -1160,8 +1160,8 @@ int multiSlsDetector::setThresholdEnergy(int e_eV, int pos, detectorSettings ise
|
||||
for(int idet=posmin; idet<posmax; idet++){
|
||||
if(detectors[idet]){
|
||||
iret[idet]= new int(-1);
|
||||
Task* task = new Task(new func3_t<int,slsDetector,int,int,detectorSettings,int>(&slsDetector::setThresholdEnergy,
|
||||
detectors[idet],e_eV,-1,isettings,iret[idet]));
|
||||
Task* task = new Task(new func4_t<int,slsDetector,int,int,detectorSettings,int,int>(&slsDetector::setThresholdEnergy,
|
||||
detectors[idet],e_eV,-1,isettings,tb, iret[idet]));
|
||||
threadpool->add_task(task);
|
||||
}
|
||||
}
|
||||
@ -5158,7 +5158,7 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy){
|
||||
|
||||
|
||||
int multiSlsDetector::getData(const int isocket, const bool masking, int* image, const int size, uint64_t &acqIndex, uint64_t &frameIndex, uint32_t &subframeIndex, string &filename){
|
||||
bool data = true;
|
||||
|
||||
zmq_msg_t header_message;
|
||||
|
||||
//scan header-------------------------------------------------------------------
|
||||
@ -5179,14 +5179,6 @@ int multiSlsDetector::getData(const int isocket, const bool masking, int* image,
|
||||
rapidjson::ParseResult result = d.Parse( (char*)zmq_msg_data(&header_message), len);
|
||||
if (!result) {
|
||||
cprintf(RED,"%d Could not parse. len:%d: Message:%s \n", isocket, len, (char*)zmq_msg_data(&header_message) );
|
||||
fflush( stdout );
|
||||
char* buf = (char*)zmq_msg_data(&header_message);
|
||||
for(int i= 0;i < len; ++i) {
|
||||
cprintf(RED,"%02x ",buf[i]);
|
||||
}
|
||||
printf("\n");
|
||||
fflush( stdout );
|
||||
|
||||
}
|
||||
#ifdef VERYVERBOSE
|
||||
// htype is an array of strings
|
||||
@ -5203,47 +5195,38 @@ int multiSlsDetector::getData(const int isocket, const bool masking, int* image,
|
||||
cout << isocket << "type: " << d["type"].GetString() << endl;
|
||||
|
||||
#endif
|
||||
int temp = d["data"].GetUint64();
|
||||
data = temp?true:false;
|
||||
if(data){ //!isocket &&
|
||||
if(d["acqIndex"].GetUint64()!= (uint64_t)-1){ //!isocket &&
|
||||
acqIndex = d["acqIndex"].GetUint64();
|
||||
frameIndex = d["fIndex"].GetUint64();
|
||||
subframeIndex = -1;
|
||||
if(d["bitmode"].GetInt()==32 && d["detType"].GetUint()== EIGER) {
|
||||
subframeIndex = d["expLength"].GetUint();
|
||||
}
|
||||
filename.assign(d["fname"].GetString());
|
||||
filename = d["fname"].GetString();
|
||||
#ifdef VERYVERBOSE
|
||||
cout << "Acquisition index: " << acqIndex << endl;
|
||||
cout << "Frame index: " << frameIndex << endl;
|
||||
cout << "Subframe index: " << subframeIndex << endl;
|
||||
cout << "File name: " << filename << endl;
|
||||
#endif
|
||||
// if(frameIndex == (long long unsigned int)-1) cprintf(RED,"multi frame index -1!!\n");
|
||||
if(frameIndex == (long long unsigned int)-1) cprintf(RED,"multi frame index -1!!\n");
|
||||
}
|
||||
// close the message
|
||||
zmq_msg_close(&header_message);
|
||||
|
||||
|
||||
//end of acquisition
|
||||
if(!data){
|
||||
//cprintf(RED,"%d Received end of acquisition \n", isocket);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
|
||||
//scan data-------------------------------------------------------------------
|
||||
zmq_msg_t data_message;
|
||||
zmq_msg_init (&data_message);
|
||||
len = zmq_msg_recv(&data_message, zmqsocket[isocket], 0);
|
||||
//cprintf(GREEN,"%d data %d\n",isocket,len); fflush(stdout);
|
||||
//cprintf(GREEN,"%d data %d\n",isocket,len);
|
||||
|
||||
//end of socket ("end\0")
|
||||
/* if(len == 4){
|
||||
if(len == 4){
|
||||
zmq_msg_close(&data_message); // close the message
|
||||
//cprintf(RED,"%d Received end of acquisition len:%d\n", isocket, len);
|
||||
return FAIL;
|
||||
}*/
|
||||
}
|
||||
|
||||
//crappy image
|
||||
if (len < size ) {
|
||||
|
@ -453,9 +453,10 @@ class multiSlsDetector : public slsDetectorUtils {
|
||||
\param e_eV threshold in eV
|
||||
\param imod module number (-1 all)
|
||||
\param isettings ev. change settings
|
||||
\param tb 1 to include trimbits, 0 to exclude
|
||||
\returns current threshold value for imod in ev (-1 failed)
|
||||
*/
|
||||
int setThresholdEnergy(int e_eV, int imod=-1, detectorSettings isettings=GET_SETTINGS);
|
||||
int setThresholdEnergy(int e_eV, int imod=-1, detectorSettings isettings=GET_SETTINGS, int tb=1);
|
||||
|
||||
/**
|
||||
get detector settings
|
||||
|
@ -2886,7 +2886,7 @@ int slsDetector::setModule(int reg, int imod){
|
||||
|
||||
};
|
||||
|
||||
int slsDetector::setModule(sls_detector_module module, int iodelay, int tau, int e_eV, int* gainval, int* offsetval){
|
||||
int slsDetector::setModule(sls_detector_module module, int iodelay, int tau, int e_eV, int* gainval, int* offsetval, int tb){
|
||||
|
||||
int fnum=F_SET_MODULE;
|
||||
int retval;
|
||||
@ -2903,6 +2903,11 @@ int slsDetector::setModule(sls_detector_module module, int iodelay, int tau, int
|
||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||
if (connectControl() == OK){
|
||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
//to exclude trimbits
|
||||
if(!tb) {
|
||||
module.nchan=0;
|
||||
module.nchip=0;
|
||||
}
|
||||
sendModule(&module);
|
||||
|
||||
//not included in module
|
||||
@ -2936,16 +2941,21 @@ int slsDetector::setModule(sls_detector_module module, int iodelay, int tau, int
|
||||
if (ret!=FAIL) {
|
||||
if (detectorModules) {
|
||||
if (imod>=0 && imod<thisDetector->nMod[X]*thisDetector->nMod[Y]) {
|
||||
if(tb) {
|
||||
(detectorModules+imod)->nchan=module.nchan;
|
||||
(detectorModules+imod)->nchip=module.nchip;
|
||||
}
|
||||
(detectorModules+imod)->ndac=module.ndac;
|
||||
(detectorModules+imod)->nadc=module.nadc;
|
||||
if(tb) {
|
||||
thisDetector->nChips=module.nchip;
|
||||
thisDetector->nChans=module.nchan/module.nchip;
|
||||
}
|
||||
thisDetector->nDacs=module.ndac;
|
||||
thisDetector->nAdcs=module.nadc;
|
||||
|
||||
if(thisDetector->myDetectorType != JUNGFRAU){
|
||||
if(tb) {
|
||||
for (int ichip=0; ichip<thisDetector->nChips; ichip++) {
|
||||
if (chipregs)
|
||||
chipregs[ichip+thisDetector->nChips*imod]=module.chipregs[ichip];
|
||||
@ -2956,6 +2966,7 @@ int slsDetector::setModule(sls_detector_module module, int iodelay, int tau, int
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (adcs) {
|
||||
for (int i=0; i<thisDetector->nAdcs; i++)
|
||||
adcs[i+imod*thisDetector->nAdcs]=module.adcs[i];
|
||||
@ -3182,11 +3193,11 @@ int slsDetector::getThresholdEnergy(int imod){
|
||||
return thisDetector->currentThresholdEV;
|
||||
};
|
||||
|
||||
int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isettings){
|
||||
int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isettings, int tb){
|
||||
|
||||
//currently only for eiger
|
||||
if (thisDetector->myDetectorType == EIGER) {
|
||||
setThresholdEnergyAndSettings(e_eV,isettings);
|
||||
setThresholdEnergyAndSettings(e_eV,isettings,tb);
|
||||
return thisDetector->currentThresholdEV;
|
||||
}
|
||||
|
||||
@ -3226,7 +3237,7 @@ int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isetti
|
||||
|
||||
|
||||
|
||||
int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isettings) {
|
||||
int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isettings, int tb) {
|
||||
|
||||
//if settings provided, use that, else use the shared memory variable
|
||||
detectorSettings is = ((isettings != GET_SETTINGS) ? isettings: thisDetector->currentSettings);
|
||||
@ -3292,7 +3303,7 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti
|
||||
#endif
|
||||
//read the files
|
||||
myMod=createModule();
|
||||
if (NULL == readSettingsFile(settingsfname,thisDetector->myDetectorType, iodelay, tau, myMod)) {
|
||||
if (NULL == readSettingsFile(settingsfname,thisDetector->myDetectorType, iodelay, tau, myMod, tb)) {
|
||||
if(myMod)deleteModule(myMod);
|
||||
return FAIL;
|
||||
}
|
||||
@ -3327,13 +3338,13 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti
|
||||
int tau1 = -1; //not included in the module
|
||||
int iodelay2 = -1; //not included in the module
|
||||
int tau2 = -1; //not included in the module
|
||||
if (NULL == readSettingsFile(settingsfname1,thisDetector->myDetectorType, iodelay1, tau1, myMod1)) {
|
||||
if (NULL == readSettingsFile(settingsfname1,thisDetector->myDetectorType, iodelay1, tau1, myMod1, tb)) {
|
||||
setErrorMask((getErrorMask())|(SETTINGS_FILE_NOT_OPEN));
|
||||
deleteModule(myMod1);
|
||||
deleteModule(myMod2);
|
||||
return FAIL;
|
||||
}
|
||||
if (NULL == readSettingsFile(settingsfname2,thisDetector->myDetectorType, iodelay2, tau2, myMod2)) {
|
||||
if (NULL == readSettingsFile(settingsfname2,thisDetector->myDetectorType, iodelay2, tau2, myMod2, tb)) {
|
||||
setErrorMask((getErrorMask())|(SETTINGS_FILE_NOT_OPEN));
|
||||
deleteModule(myMod1);
|
||||
deleteModule(myMod2);
|
||||
@ -3349,7 +3360,7 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti
|
||||
iodelay = iodelay1;
|
||||
|
||||
//interpolate module
|
||||
myMod = interpolateTrim(thisDetector->myDetectorType, myMod1, myMod2, e_eV, trim1, trim2);
|
||||
myMod = interpolateTrim(thisDetector->myDetectorType, myMod1, myMod2, e_eV, trim1, trim2, tb);
|
||||
if (myMod == NULL) {
|
||||
printf("Could not interpolate, different dac values in files\n");
|
||||
setErrorMask((getErrorMask())|(SETTINGS_NOT_SET));
|
||||
@ -3365,7 +3376,7 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti
|
||||
|
||||
myMod->module=0;
|
||||
myMod->reg=thisDetector->currentSettings;
|
||||
setModule(*myMod, iodelay, tau, e_eV, 0, 0);
|
||||
setModule(*myMod, iodelay, tau, e_eV, 0, 0, tb);
|
||||
deleteModule(myMod);
|
||||
if (getSettings(-1) != is){
|
||||
printf( "Could not set settings in detector \n" );
|
||||
|
@ -953,10 +953,11 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
\param e_eV threashold in eV (detector specific)
|
||||
\param gainval pointer to extra gain values
|
||||
\param offsetval pointer to extra offset values
|
||||
\param tb 1 to include trimbits, 0 to exclude (used for eiger)
|
||||
\returns current register value
|
||||
\sa ::sls_detector_module
|
||||
*/
|
||||
int setModule(sls_detector_module module, int iodelay, int tau, int e_eV, int* gainval=0, int* offsetval=0);
|
||||
int setModule(sls_detector_module module, int iodelay, int tau, int e_eV, int* gainval=0, int* offsetval=0, int tb=1);
|
||||
//virtual int setModule(sls_detector_module module);
|
||||
|
||||
/**
|
||||
@ -987,17 +988,19 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
\param e_eV threshold in eV
|
||||
\param imod module number (-1 all)
|
||||
\param isettings ev. change settings
|
||||
\param tb 1 to include trimbits, 0 to exclude
|
||||
\returns current threshold value for imod in ev (-1 failed)
|
||||
*/
|
||||
int setThresholdEnergy(int e_eV, int imod=-1, detectorSettings isettings=GET_SETTINGS);
|
||||
int setThresholdEnergy(int e_eV, int imod=-1, detectorSettings isettings=GET_SETTINGS, int tb=1);
|
||||
|
||||
/**
|
||||
set threshold energy
|
||||
\param e_eV threshold in eV
|
||||
\param isettings ev. change settings
|
||||
\param tb 1 to include trimbits, 0 to exclude
|
||||
\returns OK if successful, else FAIL
|
||||
*/
|
||||
int setThresholdEnergyAndSettings(int e_eV, detectorSettings isettings);
|
||||
int setThresholdEnergyAndSettings(int e_eV, detectorSettings isettings, int tb=1);
|
||||
|
||||
/**
|
||||
get detector settings
|
||||
|
@ -210,7 +210,7 @@ class slsDetectorActions : public virtual slsDetectorBase
|
||||
/* *\/ */
|
||||
/* virtual detectorType getDetectorsType(int pos=-1)=0; */
|
||||
|
||||
virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS)=0;
|
||||
virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS, int tb=1)=0;
|
||||
virtual int setChannel(int64_t, int ich=-1, int ichip=-1, int imod=-1)=0;
|
||||
|
||||
|
||||
|
@ -429,7 +429,7 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
|
||||
virtual externalCommunicationMode setExternalCommunicationMode(externalCommunicationMode pol=GET_EXTERNAL_COMMUNICATION_MODE)=0;
|
||||
int setTimingMode(int i=-1){return slsDetectorUsers::getTimingMode( externalCommunicationType( setExternalCommunicationMode(externalCommunicationType( slsDetectorUsers::getTimingMode(i) ) ) ) );};
|
||||
|
||||
virtual int setThresholdEnergy(int e_eV, int imod, detectorSettings isettings=GET_SETTINGS)=0;
|
||||
virtual int setThresholdEnergy(int e_eV, int imod, detectorSettings isettings=GET_SETTINGS, int tb=1)=0;
|
||||
int setThresholdEnergy(int e_eV){return setThresholdEnergy(e_eV,-1);};
|
||||
|
||||
|
||||
|
@ -552,6 +552,10 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettings;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="thresholdnotb"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettings;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="trimbits"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettings;
|
||||
i++;
|
||||
@ -3289,10 +3293,10 @@ string slsDetectorCommand::cmdSettings(int narg, char *args[], int action) {
|
||||
return myDet->getDetectorSettings(myDet->getSettings());
|
||||
} else if (cmd=="threshold") {
|
||||
if (action==PUT_ACTION) {
|
||||
detectorType type = myDet->getDetectorsType();
|
||||
if (!sscanf(args[1],"%d",&val)) {
|
||||
return string("invalid threshold value");
|
||||
}
|
||||
detectorType type = myDet->getDetectorsType();
|
||||
if (type != EIGER || (type == EIGER && narg<=2)) {
|
||||
myDet->setThresholdEnergy(val);
|
||||
} else {
|
||||
@ -3304,6 +3308,25 @@ string slsDetectorCommand::cmdSettings(int narg, char *args[], int action) {
|
||||
}
|
||||
sprintf(ans,"%d",myDet->getThresholdEnergy());
|
||||
return string(ans);
|
||||
} else if (cmd=="thresholdnotb") {
|
||||
if (action==PUT_ACTION) {
|
||||
if (!sscanf(args[1],"%d",&val)) {
|
||||
return string("invalid threshold value");
|
||||
}
|
||||
detectorType type = myDet->getDetectorsType();
|
||||
if (type != EIGER)
|
||||
return string("not implemented for this detector");
|
||||
if (narg<=2) {
|
||||
myDet->setThresholdEnergy(val, -1, GET_SETTINGS, 0);
|
||||
} else {
|
||||
detectorSettings sett= myDet->getDetectorSettings(string(args[2]));
|
||||
if(sett == -1)
|
||||
return string("invalid settings value");
|
||||
myDet->setThresholdEnergy(val, -1, sett, 0);
|
||||
}
|
||||
}
|
||||
sprintf(ans,"%d",myDet->getThresholdEnergy());
|
||||
return string(ans);
|
||||
} else if (cmd=="trimbits") {
|
||||
if (narg>=2) {
|
||||
string sval=string(args[1]);
|
||||
@ -3386,7 +3409,8 @@ string slsDetectorCommand::helpSettings(int narg, char *args[], int action) {
|
||||
if (action==PUT_ACTION || action==HELP_ACTION) {
|
||||
os << "settings s \n sets the settings of the detector - can be standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain"
|
||||
"lownoise, dynamichg0,fixgain1,fixgain2,forceswitchg1, forceswitchg2"<< std::endl;
|
||||
os << "threshold eV\n sets the detector threshold in eV"<< std::endl;
|
||||
os << "threshold eV [sett]\n sets the detector threshold in eV. If sett is provided for eiger, uses settings sett"<< std::endl;
|
||||
os << "thresholdnotb eV [sett]\n sets the detector threshold in eV without loading trimbits. If sett is provided for eiger, uses settings sett"<< std::endl;
|
||||
os << "trimbits fname\n loads the trimfile fname to the detector. If no extension is specified, the serial number of each module will be attached."<< std::endl;
|
||||
os << "trim:mode fname\n trims the detector according to mode (can be noise, beam, improve, fix) and saves the resulting trimbits to file fname."<< std::endl;
|
||||
os << "trimval i \n sets all the trimbits to i" << std::endl;
|
||||
|
@ -421,7 +421,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
||||
// double* convertAngles(){return convertAngles(currentPosition);};
|
||||
// virtual double* convertAngles(double pos)=0;
|
||||
|
||||
virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS)=0;
|
||||
virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS, int tb=1)=0;
|
||||
virtual int setChannel(int64_t, int ich=-1, int ichip=-1, int imod=-1)=0;
|
||||
|
||||
virtual double getRateCorrectionTau()=0;
|
||||
|
@ -138,7 +138,7 @@ int energyConversion::writeCalibrationFile(string fname, int *gain, int *offset)
|
||||
|
||||
|
||||
|
||||
slsDetectorDefs::sls_detector_module* energyConversion::interpolateTrim(detectorType myDetectorType, sls_detector_module* a, sls_detector_module* b, const int energy, const int e1, const int e2){
|
||||
slsDetectorDefs::sls_detector_module* energyConversion::interpolateTrim(detectorType myDetectorType, sls_detector_module* a, sls_detector_module* b, const int energy, const int e1, const int e2, int tb){
|
||||
// only implemented for eiger currently (in terms of which dacs)
|
||||
if(myDetectorType != EIGER) {
|
||||
printf("Interpolation of Trim values not implemented for this detector!\n");
|
||||
@ -168,8 +168,10 @@ slsDetectorDefs::sls_detector_module* energyConversion::interpolateTrim(detector
|
||||
}
|
||||
|
||||
//Interpolate all trimbits
|
||||
if(tb) {
|
||||
for (int i = 0; i<myMod->nchan; i++)
|
||||
myMod->chanregs[i] = linearInterpolation(energy, e1, e2, a->chanregs[i], b->chanregs[i]);
|
||||
}
|
||||
return myMod;
|
||||
}
|
||||
|
||||
@ -180,7 +182,7 @@ slsDetectorDefs::sls_detector_module* energyConversion::interpolateTrim(detector
|
||||
/* I/O */
|
||||
|
||||
|
||||
slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string fname, detectorType myDetectorType, int& iodelay, int& tau, sls_detector_module* myMod){
|
||||
slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string fname, detectorType myDetectorType, int& iodelay, int& tau, sls_detector_module* myMod, int tb){
|
||||
|
||||
|
||||
|
||||
@ -372,13 +374,14 @@ slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string
|
||||
infile.read((char*) myMod->dacs,sizeof(dacs_t)*(myMod->ndac));
|
||||
infile.read((char*)&iodelay,sizeof(iodelay));
|
||||
infile.read((char*)&tau,sizeof(tau));
|
||||
infile.read((char*) myMod->chanregs,sizeof(int)*(myMod->nchan));
|
||||
#ifdef VERBOSE
|
||||
for(int i=0;i<myMod->ndac;i++)
|
||||
printf( "dac %d:%d \n", i, myMod->dacs[i] );
|
||||
printf( "iodelay:%d \n", iodelay );
|
||||
printf( "tau:%d \n", tau );
|
||||
#endif
|
||||
if(tb) {
|
||||
infile.read((char*) myMod->chanregs,sizeof(int)*(myMod->nchan));
|
||||
if(infile.eof()){
|
||||
printf( "Error, could not load trimbits end of file reached: %s \n\n", myfname.c_str() );
|
||||
if (nflag)
|
||||
@ -386,6 +389,7 @@ slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
infile.close();
|
||||
strcpy(settingsFile,fname.c_str());
|
||||
printf("Settings file loaded: %s\n",settingsFile);
|
||||
|
@ -88,9 +88,10 @@ class energyConversion
|
||||
\param energy energy to trim at
|
||||
\param e1 reference trim value
|
||||
\param e2 reference trim value
|
||||
\param tb 1 to include trimbits, 0 to exclude (used for eiger)
|
||||
\returns the pointer to the module structure with interpolated values or NULL if error
|
||||
*/
|
||||
sls_detector_module* interpolateTrim(detectorType myDetectorType, sls_detector_module* a, sls_detector_module* b, const int energy, const int e1, const int e2);
|
||||
sls_detector_module* interpolateTrim(detectorType myDetectorType, sls_detector_module* a, sls_detector_module* b, const int energy, const int e1, const int e2, int tb=1);
|
||||
|
||||
|
||||
|
||||
@ -103,10 +104,11 @@ class energyConversion
|
||||
\param iodelay io delay (detector specific)
|
||||
\param tau tau (detector specific)
|
||||
\param myMod pointer to the module structure which has to be set. <BR> If it is NULL a new module structure will be created
|
||||
\param tb 1 to include trimbits, 0 to exclude (used for eiger)
|
||||
\returns the pointer to myMod or NULL if reading the file failed
|
||||
*/
|
||||
|
||||
sls_detector_module* readSettingsFile(string fname, detectorType myDetectorType, int& iodelay, int& tau, sls_detector_module* myMod=NULL);
|
||||
sls_detector_module* readSettingsFile(string fname, detectorType myDetectorType, int& iodelay, int& tau, sls_detector_module* myMod=NULL, int tb=1);
|
||||
|
||||
/**
|
||||
writes a trim/settings file
|
||||
|
@ -129,8 +129,8 @@ public:
|
||||
Task(func2_t <char*,slsDetector,networkParameter,string,string>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(t),m12(0),m13(0){};
|
||||
/* Return: void, Param: none */
|
||||
Task(func00_t <void,slsDetector>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(t),m13(0){};
|
||||
/* Return: int, Param: int,int,detectorSettings */
|
||||
Task(func3_t <int,slsDetector,int,int,detectorSettings,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(t){};
|
||||
/* Return: int, Param: int,int,detectorSettings,int */
|
||||
Task(func4_t <int,slsDetector,int,int,detectorSettings,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(t){};
|
||||
|
||||
|
||||
|
||||
@ -178,7 +178,7 @@ private:
|
||||
/* Return: void, Param: none */
|
||||
func00_t <void,slsDetector>* m12;
|
||||
/* Return: int, Param: int,int,detectorSettings */
|
||||
func3_t <int,slsDetector,int,int,detectorSettings,int>* m13;
|
||||
func4_t <int,slsDetector,int,int,detectorSettings,int,int>* m13;
|
||||
};
|
||||
|
||||
|
||||
|
@ -100,6 +100,7 @@ enum communicationProtocol{
|
||||
|
||||
|
||||
genericSocket(const char* const host_ip_or_name, unsigned short int const port_number, communicationProtocol p, int ps = DEFAULT_PACKET_SIZE) :
|
||||
// portno(port_number),
|
||||
protocol(p),
|
||||
is_a_server(0),
|
||||
socketDescriptor(-1),
|
||||
@ -108,15 +109,11 @@ enum communicationProtocol{
|
||||
nsending(0),
|
||||
nsent(0),
|
||||
total_sent(0),// sender (client): where to? ip
|
||||
header_packet_size(0),
|
||||
portno(port_number)
|
||||
header_packet_size(0)
|
||||
{
|
||||
memset(&serverAddress, 0,sizeof(serverAddress));
|
||||
memset(&clientAddress,0,sizeof(clientAddress));
|
||||
// strcpy(hostname,host_ip_or_name);
|
||||
memset(lastClientIP, 0, INET_ADDRSTRLEN);
|
||||
memset(thisClientIP, 0, INET_ADDRSTRLEN);
|
||||
memset(dummyClientIP, 0, INET_ADDRSTRLEN);
|
||||
|
||||
strcpy(lastClientIP,"none");
|
||||
strcpy(thisClientIP,"none1");
|
||||
@ -167,6 +164,7 @@ enum communicationProtocol{
|
||||
*/
|
||||
|
||||
genericSocket(unsigned short int const port_number, communicationProtocol p, int ps = DEFAULT_PACKET_SIZE, const char *eth=NULL, int hsize=0):
|
||||
//portno(port_number),
|
||||
protocol(p),
|
||||
is_a_server(1),
|
||||
socketDescriptor(-1),
|
||||
@ -175,8 +173,7 @@ enum communicationProtocol{
|
||||
nsending(0),
|
||||
nsent(0),
|
||||
total_sent(0),
|
||||
header_packet_size(hsize),
|
||||
portno(port_number)
|
||||
header_packet_size(hsize)
|
||||
{
|
||||
|
||||
memset(&serverAddress, 0, sizeof(serverAddress));
|
||||
@ -184,9 +181,7 @@ enum communicationProtocol{
|
||||
/* // you can specify an IP address: */
|
||||
/* // or you can let it automatically select one: */
|
||||
/* myaddr.sin_addr.s_addr = INADDR_ANY; */
|
||||
memset(lastClientIP, 0, INET_ADDRSTRLEN);
|
||||
memset(thisClientIP, 0, INET_ADDRSTRLEN);
|
||||
memset(dummyClientIP, 0, INET_ADDRSTRLEN);
|
||||
|
||||
|
||||
strcpy(lastClientIP,"none");
|
||||
strcpy(thisClientIP,"none1");
|
||||
@ -615,7 +610,6 @@ enum communicationProtocol{
|
||||
|
||||
break;
|
||||
case UDP:
|
||||
|
||||
if (socketDescriptor<0) return -1;
|
||||
//if length given, listens to length, else listens for packetsize till length is reached
|
||||
if(length){
|
||||
@ -638,30 +632,12 @@ enum communicationProtocol{
|
||||
else{
|
||||
//normal
|
||||
nsending=packet_size;
|
||||
/* if(portno%2){
|
||||
cprintf(BLUE,"%d total_sent set to zero:%d\n",portno, total_sent);fflush(stdout);
|
||||
}else{
|
||||
cprintf(GREEN,"%d total_sent set to zero:%d\n",portno, total_sent);fflush(stdout);
|
||||
}*/
|
||||
while(1){
|
||||
nsent = recvfrom(socketDescriptor,(char*)buf+total_sent,nsending, 0, (struct sockaddr *) &clientAddress, &clientAddress_length);
|
||||
/* if(portno%2){
|
||||
cprintf(BLUE,"%d nsent:%d total_sent:%d\n", portno, nsent, total_sent);fflush(stdout);
|
||||
}else{
|
||||
cprintf(GREEN,"%d nsent:%d total_sent:%d\n", portno, nsent, total_sent);fflush(stdout);
|
||||
}*/
|
||||
if((nsent<=0) || (nsent == packet_size)) {
|
||||
|
||||
/* if(portno%2){
|
||||
cprintf(BLUE,"%d breaking out of loop %d\n",portno, nsent);fflush(stdout);
|
||||
}else{
|
||||
cprintf(GREEN,"%d breaking out of loop %d\n",portno, nsent);fflush(stdout);
|
||||
}*/
|
||||
if(nsent<=0 || nsent == packet_size)
|
||||
break;
|
||||
}
|
||||
if(nsent != packet_size && nsent != header_packet_size){
|
||||
cprintf(RED,"%d Incomplete Packet size %d\n",portno, nsent);fflush(stdout);
|
||||
}
|
||||
if(nsent != packet_size && nsent != header_packet_size)
|
||||
cprintf(RED,"Incomplete Packet size %d\n",nsent);
|
||||
}
|
||||
//nsent = 1040;
|
||||
total_sent+=nsent;
|
||||
@ -673,13 +649,8 @@ enum communicationProtocol{
|
||||
#ifdef VERY_VERBOSE
|
||||
cout << "sent "<< total_sent << " Bytes" << endl;
|
||||
#endif
|
||||
/*if(protocol == UDP){
|
||||
if(portno%2){
|
||||
cprintf(BLUE,"%d exiting total sent %d\n",portno, total_sent);fflush(stdout);
|
||||
}else{
|
||||
cprintf(GREEN,"%d exiting total sent %d\n",portno, total_sent);fflush(stdout);
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
return total_sent;
|
||||
|
||||
|
||||
@ -752,11 +723,11 @@ enum communicationProtocol{
|
||||
|
||||
|
||||
private:
|
||||
volatile int nsending;
|
||||
volatile int nsent;
|
||||
volatile int total_sent;
|
||||
|
||||
int nsending;
|
||||
int nsent;
|
||||
int total_sent;
|
||||
int header_packet_size;
|
||||
const int portno;
|
||||
|
||||
|
||||
// pthread_mutex_t mp;
|
||||
|
@ -35,7 +35,7 @@ void UDPBaseImplementation::initializeMembers(){
|
||||
|
||||
//**detector parameters***
|
||||
myDetectorType = GENERIC;
|
||||
memset(detHostname,0,MAX_STR_LENGTH);
|
||||
strcpy(detHostname,"");
|
||||
packetsPerFrame = 0;
|
||||
acquisitionPeriod = 0;
|
||||
acquisitionTime = 0;
|
||||
@ -51,15 +51,14 @@ void UDPBaseImplementation::initializeMembers(){
|
||||
activated = true;
|
||||
|
||||
//***connection parameters***
|
||||
memset(eth,0,MAX_STR_LENGTH);
|
||||
strcpy(eth,"");
|
||||
for(int i=0;i<MAX_NUMBER_OF_LISTENING_THREADS;i++){
|
||||
udpPortNum[i] = DEFAULT_UDP_PORTNO + i;
|
||||
}
|
||||
|
||||
//***file parameters***
|
||||
memset(fileName,0,MAX_STR_LENGTH);
|
||||
snprintf(fileName,MAX_STR_LENGTH,"run");
|
||||
memset(filePath,0,MAX_STR_LENGTH);
|
||||
strcpy(fileName,"run");
|
||||
strcpy(filePath,"");
|
||||
fileIndex = 0;
|
||||
scanTag = 0;
|
||||
frameIndexEnable = false;
|
||||
@ -97,8 +96,7 @@ char *UDPBaseImplementation::getDetectorHostname() const{
|
||||
return NULL;
|
||||
|
||||
char* output = new char[MAX_STR_LENGTH]();
|
||||
memset(output,0,MAX_STR_LENGTH);
|
||||
snprintf(output,MAX_STR_LENGTH,detHostname);
|
||||
strcpy(output,detHostname);
|
||||
//freed by calling function
|
||||
return output;
|
||||
}
|
||||
@ -117,8 +115,7 @@ char *UDPBaseImplementation::getFileName() const{
|
||||
return NULL;
|
||||
|
||||
char* output = new char[MAX_STR_LENGTH]();
|
||||
memset(output,0,MAX_STR_LENGTH);
|
||||
snprintf(output,MAX_STR_LENGTH,fileName);
|
||||
strcpy(output,fileName);
|
||||
//freed by calling function
|
||||
return output;
|
||||
}
|
||||
@ -130,8 +127,7 @@ char *UDPBaseImplementation::getFilePath() const{
|
||||
return NULL;
|
||||
|
||||
char* output = new char[MAX_STR_LENGTH]();
|
||||
memset(output,0,MAX_STR_LENGTH);
|
||||
snprintf(output,MAX_STR_LENGTH,filePath);
|
||||
strcpy(output,filePath);
|
||||
//freed by calling function
|
||||
return output;
|
||||
}
|
||||
@ -170,8 +166,7 @@ char *UDPBaseImplementation::getEthernetInterface() const{
|
||||
|
||||
|
||||
char* output = new char[MAX_STR_LENGTH]();
|
||||
memset(output,0,MAX_STR_LENGTH);
|
||||
snprintf(output,MAX_STR_LENGTH,eth);
|
||||
strcpy(output,eth);
|
||||
//freed by calling function
|
||||
return output;
|
||||
}
|
||||
@ -220,7 +215,7 @@ void UDPBaseImplementation::setFlippedData(int axis, int enable){
|
||||
flippedData[axis] = enable==0?0:1;
|
||||
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Flipped Data: %d , %d ", flippedData[0], flippedData[1]);
|
||||
sprintf(cstreambuf, "Flipped Data: %d , %d ", flippedData[0], flippedData[1]);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
@ -228,13 +223,11 @@ void UDPBaseImplementation::setFlippedData(int axis, int enable){
|
||||
/***file parameters***/
|
||||
void UDPBaseImplementation::setFileName(const char c[]){
|
||||
|
||||
if(strlen(c)){
|
||||
memset(fileName,0,MAX_STR_LENGTH);
|
||||
snprintf(fileName,MAX_STR_LENGTH,c);
|
||||
}
|
||||
if(strlen(c))
|
||||
strcpy(fileName, c);
|
||||
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "File name: %s ", fileName);
|
||||
sprintf(cstreambuf, "File name: %s ", fileName);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
@ -243,20 +236,20 @@ void UDPBaseImplementation::setFilePath(const char c[]){
|
||||
if(strlen(c)){
|
||||
//check if filepath exists
|
||||
struct stat st;
|
||||
if(stat(c,&st) == 0){
|
||||
memset(filePath,0,MAX_STR_LENGTH);
|
||||
snprintf(filePath,MAX_STR_LENGTH,c);
|
||||
}else{
|
||||
memset(filePath,0,MAX_STR_LENGTH);
|
||||
if(stat(c,&st) == 0)
|
||||
strcpy(filePath,c);
|
||||
else{
|
||||
strcpy(filePath,"");
|
||||
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "FilePath does not exist: %s ", filePath);
|
||||
sprintf(cstreambuf, "FilePath does not exist: %s ", filePath);
|
||||
FILE_LOG(logWARNING, cstreambuf);
|
||||
}
|
||||
strcpy(filePath, c);
|
||||
}
|
||||
/*{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "File path:: %s ", filePath);
|
||||
sprintf(cstreambuf, "File path:: %s ", filePath);
|
||||
FILE_LOG(logDEBUG, cstreambuf);
|
||||
}*/
|
||||
}
|
||||
@ -265,7 +258,7 @@ void UDPBaseImplementation::setFileIndex(const uint64_t i){
|
||||
|
||||
fileIndex = i;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "File Index: %lu ", fileIndex);
|
||||
sprintf(cstreambuf, "File Index: %lu ", fileIndex);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
@ -274,7 +267,7 @@ void UDPBaseImplementation::setScanTag(const int i){
|
||||
|
||||
scanTag = i;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Scan Tag: %d ", scanTag);
|
||||
sprintf(cstreambuf, "Scan Tag: %d ", scanTag);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
@ -282,7 +275,7 @@ void UDPBaseImplementation::setFrameIndexEnable(const bool b){
|
||||
|
||||
frameIndexEnable = b;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Frame Index Enable: %s ", stringEnable(frameIndexEnable).c_str());
|
||||
sprintf(cstreambuf, "Frame Index Enable: %s ", stringEnable(frameIndexEnable).c_str());
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
@ -290,7 +283,7 @@ void UDPBaseImplementation::setFileWriteEnable(const bool b){
|
||||
|
||||
fileWriteEnable = b;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "File Write Enable: %s ", stringEnable(fileWriteEnable).c_str());
|
||||
sprintf(cstreambuf, "File Write Enable: %s ", stringEnable(fileWriteEnable).c_str());
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
@ -298,7 +291,7 @@ void UDPBaseImplementation::setOverwriteEnable(const bool b){
|
||||
|
||||
overwriteEnable = b;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Overwrite Enable: %s ", stringEnable(overwriteEnable).c_str());
|
||||
sprintf(cstreambuf, "Overwrite Enable: %s ", stringEnable(overwriteEnable).c_str());
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
@ -306,7 +299,7 @@ int UDPBaseImplementation::setDataCompressionEnable(const bool b){
|
||||
|
||||
dataCompressionEnable = b;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Data Compression: %s ", stringEnable(dataCompressionEnable).c_str());
|
||||
sprintf(cstreambuf, "Data Compression: %s ", stringEnable(dataCompressionEnable).c_str());
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
|
||||
//overridden methods might return FAIL
|
||||
@ -319,7 +312,7 @@ void UDPBaseImplementation::setUDPPortNumber(const uint32_t i){
|
||||
|
||||
udpPortNum[0] = i;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "UDP Port Number[0]: %u ", udpPortNum[0]);
|
||||
sprintf(cstreambuf, "UDP Port Number[0]: %u ", udpPortNum[0]);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
@ -327,15 +320,15 @@ void UDPBaseImplementation::setUDPPortNumber2(const uint32_t i){
|
||||
|
||||
udpPortNum[1] = i;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "UDP Port Number[1]: %u ", udpPortNum[1]);
|
||||
sprintf(cstreambuf, "UDP Port Number[1]: %u ", udpPortNum[1]);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
void UDPBaseImplementation::setEthernetInterface(const char* c){
|
||||
memset(eth,0, MAX_STR_LENGTH);
|
||||
snprintf(eth,MAX_STR_LENGTH, c);
|
||||
|
||||
strcpy(eth, c);
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Ethernet Interface: %s ", eth);
|
||||
sprintf(cstreambuf, "Ethernet Interface: %s ", eth);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
@ -345,7 +338,7 @@ void UDPBaseImplementation::setShortFrameEnable(const int i){
|
||||
|
||||
shortFrameEnable = i;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Short Frame Enable: %d ", shortFrameEnable);
|
||||
sprintf(cstreambuf, "Short Frame Enable: %d ", shortFrameEnable);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
@ -353,7 +346,7 @@ int UDPBaseImplementation::setFrameToGuiFrequency(const uint32_t freq){
|
||||
|
||||
frameToGuiFrequency = freq;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Frame To Gui Frequency: %u ", frameToGuiFrequency);
|
||||
sprintf(cstreambuf, "Frame To Gui Frequency: %u ", frameToGuiFrequency);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
|
||||
//overrridden child classes might return FAIL
|
||||
@ -364,7 +357,7 @@ void UDPBaseImplementation::setFrameToGuiTimer(const uint32_t time_in_ms){
|
||||
|
||||
frameToGuiTimerinMS = time_in_ms;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Frame To Gui Timer: %u ", frameToGuiTimerinMS);
|
||||
sprintf(cstreambuf, "Frame To Gui Timer: %u ", frameToGuiTimerinMS);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
@ -373,7 +366,7 @@ uint32_t UDPBaseImplementation::setDataStreamEnable(const uint32_t enable){
|
||||
|
||||
dataStreamEnable = enable;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Streaming Data from Receiver: %d ", dataStreamEnable);
|
||||
sprintf(cstreambuf, "Streaming Data from Receiver: %d ", dataStreamEnable);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
|
||||
//overrridden child classes might return FAIL
|
||||
@ -385,7 +378,7 @@ int UDPBaseImplementation::setAcquisitionPeriod(const uint64_t i){
|
||||
|
||||
acquisitionPeriod = i;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Acquisition Period: %f s ", (double)acquisitionPeriod/(1E9));
|
||||
sprintf(cstreambuf, "Acquisition Period: %f s ", (double)acquisitionPeriod/(1E9));
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
|
||||
//overrridden child classes might return FAIL
|
||||
@ -396,7 +389,7 @@ int UDPBaseImplementation::setAcquisitionTime(const uint64_t i){
|
||||
|
||||
acquisitionTime = i;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Acquisition Time: %f s ", (double)acquisitionTime/(1E9));
|
||||
sprintf(cstreambuf, "Acquisition Time: %f s ", (double)acquisitionTime/(1E9));
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
|
||||
//overrridden child classes might return FAIL
|
||||
@ -407,7 +400,7 @@ int UDPBaseImplementation::setNumberOfFrames(const uint64_t i){
|
||||
|
||||
numberOfFrames = i;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Number of Frames: %lu ", numberOfFrames);
|
||||
sprintf(cstreambuf, "Number of Frames: %lu ", numberOfFrames);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
|
||||
//overrridden child classes might return FAIL
|
||||
@ -418,7 +411,7 @@ int UDPBaseImplementation::setDynamicRange(const uint32_t i){
|
||||
|
||||
dynamicRange = i;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Dynamic Range: %u ", dynamicRange);
|
||||
sprintf(cstreambuf, "Dynamic Range: %u ", dynamicRange);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
|
||||
//overrridden child classes might return FAIL
|
||||
@ -429,7 +422,7 @@ int UDPBaseImplementation::setTenGigaEnable(const bool b){
|
||||
|
||||
tengigaEnable = b;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Ten Giga Enable: %s ", stringEnable(tengigaEnable).c_str());
|
||||
sprintf(cstreambuf, "Ten Giga Enable: %s ", stringEnable(tengigaEnable).c_str());
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
|
||||
//overridden functions might return FAIL
|
||||
@ -440,7 +433,7 @@ int UDPBaseImplementation::setFifoDepth(const uint32_t i){
|
||||
|
||||
fifoDepth = i;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Fifo Depth: %u ", i);
|
||||
sprintf(cstreambuf, "Fifo Depth: %u ", i);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
|
||||
//overridden functions might return FAIL
|
||||
@ -459,7 +452,7 @@ int UDPBaseImplementation::setDetectorType(const detectorType d){
|
||||
myDetectorType = d;
|
||||
//if eiger, set numberofListeningThreads = 2;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Detector Type: %s ", getDetectorType(d).c_str());
|
||||
sprintf(cstreambuf, "Detector Type: %s ", getDetectorType(d).c_str());
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
|
||||
return OK;
|
||||
@ -467,12 +460,10 @@ int UDPBaseImplementation::setDetectorType(const detectorType d){
|
||||
|
||||
void UDPBaseImplementation::initialize(const char *c){
|
||||
|
||||
if(strlen(c)){
|
||||
memset(detHostname,0,MAX_STR_LENGTH);
|
||||
snprintf(detHostname, MAX_STR_LENGTH, c);
|
||||
}
|
||||
if(strlen(c))
|
||||
strcpy(detHostname, c);
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Detector Hostname: %s ", detHostname);
|
||||
sprintf(cstreambuf, "Detector Hostname: %s ", detHostname);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
|
||||
}
|
||||
@ -484,7 +475,7 @@ void UDPBaseImplementation::resetAcquisitionCount(){
|
||||
|
||||
totalPacketsCaught = 0;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Total Packets Caught: %lu ", totalPacketsCaught);
|
||||
sprintf(cstreambuf, "Total Packets Caught: %lu ", totalPacketsCaught);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
@ -537,7 +528,7 @@ int UDPBaseImplementation::setActivate(int enable){
|
||||
activated = enable;
|
||||
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Activation: %s ", stringEnable(activated).c_str());
|
||||
sprintf(cstreambuf, "Activation: %s ", stringEnable(activated).c_str());
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
|
@ -146,9 +146,9 @@ void UDPStandardImplementation::initializeMembers(){
|
||||
}
|
||||
#endif
|
||||
for(int i=0; i<MAX_NUMBER_OF_WRITER_THREADS; i++){
|
||||
memset(completeFileName[i], 0, MAX_STR_LENGTH);
|
||||
memset(fileNamePerThread[i], 0, MAX_STR_LENGTH);
|
||||
memset(fileHeader[i], 0, FILE_HEADER_SIZE);
|
||||
strcpy(completeFileName[i],"");
|
||||
strcpy(fileNamePerThread[i],"");
|
||||
strcpy(fileHeader[i],"");
|
||||
sfilefd[i] = 0;
|
||||
}
|
||||
maxFramesPerFile = 0;
|
||||
@ -190,7 +190,7 @@ void UDPStandardImplementation::initializeMembers(){
|
||||
//***receiver to GUI parameters***
|
||||
for(int i=0; i<MAX_NUMBER_OF_WRITER_THREADS; i++){
|
||||
latestData[i] = 0;
|
||||
memset(guiFileName[i],0,MAX_STR_LENGTH);
|
||||
strcpy(guiFileName[i],"");
|
||||
guiNumPackets[i] = 0;
|
||||
frametoGuiCounter[i] = 0;
|
||||
}
|
||||
@ -309,7 +309,7 @@ int UDPStandardImplementation::setupFifoStructure(){
|
||||
}
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Number of Frames per buffer: %d ",numberofJobsPerBuffer);
|
||||
sprintf(cstreambuf, "Number of Frames per buffer: %d ",numberofJobsPerBuffer);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
}
|
||||
@ -332,7 +332,7 @@ int UDPStandardImplementation::setupFifoStructure(){
|
||||
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Total Fifo Size: %u ",fifoSize);
|
||||
sprintf(cstreambuf, "Total Fifo Size: %u ",fifoSize);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
@ -426,13 +426,10 @@ void UDPStandardImplementation::setFileName(const char c[]){
|
||||
|
||||
|
||||
char oldfilename[MAX_STR_LENGTH];
|
||||
memset(oldfilename,0,MAX_STR_LENGTH);
|
||||
snprintf(oldfilename,MAX_STR_LENGTH, fileName);
|
||||
strcpy(oldfilename,fileName);
|
||||
|
||||
if(strlen(c)){
|
||||
memset(fileName,0,MAX_STR_LENGTH);
|
||||
snprintf(fileName,MAX_STR_LENGTH, c);
|
||||
}
|
||||
if(strlen(c))
|
||||
strcpy(fileName, c);
|
||||
|
||||
if(strlen(fileName)){
|
||||
int detindex = -1;
|
||||
@ -448,7 +445,7 @@ void UDPStandardImplementation::setFileName(const char c[]){
|
||||
}
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "File name: %s ",fileName);
|
||||
sprintf(cstreambuf, "File name: %s ",fileName);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
}
|
||||
@ -491,7 +488,7 @@ int UDPStandardImplementation::setDataCompressionEnable(const bool b){
|
||||
initializeFilter();
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Data Compression: %s ",stringEnable(dataCompressionEnable).c_str());
|
||||
sprintf(cstreambuf, "Data Compression: %s ",stringEnable(dataCompressionEnable).c_str());
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
return OK;
|
||||
@ -542,7 +539,7 @@ void UDPStandardImplementation::setShortFrameEnable(const int i){
|
||||
initializeFilter();
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Short Frame Enable: %d ", shortFrameEnable);
|
||||
sprintf(cstreambuf, "Short Frame Enable: %d ", shortFrameEnable);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
}
|
||||
@ -556,7 +553,7 @@ int UDPStandardImplementation::setFrameToGuiFrequency(const uint32_t freq){
|
||||
return FAIL;
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Frame to Gui Frequency: %u ",frameToGuiFrequency);
|
||||
sprintf(cstreambuf, "Frame to Gui Frequency: %u ",frameToGuiFrequency);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
return OK;
|
||||
@ -571,7 +568,7 @@ uint32_t UDPStandardImplementation::setDataStreamEnable(const uint32_t enable){
|
||||
dataStreamEnable = enable;
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Data Send to Gui: %d ", dataStreamEnable);
|
||||
sprintf(cstreambuf, "Data Send to Gui: %d ", dataStreamEnable);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
@ -602,7 +599,7 @@ int UDPStandardImplementation::setAcquisitionPeriod(const uint64_t i){
|
||||
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Acquisition Period: %f s", (double)acquisitionPeriod/(1E9));
|
||||
sprintf(cstreambuf, "Acquisition Period: %f s", (double)acquisitionPeriod/(1E9));
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
@ -623,7 +620,7 @@ int UDPStandardImplementation::setAcquisitionTime(const uint64_t i){
|
||||
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Acquisition Period: %f s ", (double)acquisitionTime/(1E9));
|
||||
sprintf(cstreambuf, "Acquisition Period: %f s ", (double)acquisitionTime/(1E9));
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
@ -644,7 +641,7 @@ int UDPStandardImplementation::setNumberOfFrames(const uint64_t i){
|
||||
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Number of Frames: %lu ", numberOfFrames);
|
||||
sprintf(cstreambuf, "Number of Frames: %lu ", numberOfFrames);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
@ -662,7 +659,7 @@ int UDPStandardImplementation::setDynamicRange(const uint32_t i){
|
||||
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Setting Dynamic Range to %u ", i);
|
||||
sprintf(cstreambuf, "Setting Dynamic Range to %u ", i);
|
||||
FILE_LOG(logDEBUG1, cstreambuf);
|
||||
}
|
||||
|
||||
@ -686,7 +683,6 @@ int UDPStandardImplementation::setDynamicRange(const uint32_t i){
|
||||
}
|
||||
for(int i=0;i<numberofWriterThreads;i++){
|
||||
latestData[i] = new char[bufferSize+sizeof(sls_detector_header)]();
|
||||
memset(latestData[i], 0, bufferSize+sizeof(sls_detector_header));
|
||||
}
|
||||
//restructure fifo
|
||||
numberofJobsPerBuffer = -1;
|
||||
@ -699,7 +695,7 @@ int UDPStandardImplementation::setDynamicRange(const uint32_t i){
|
||||
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Dynamic Range: %u ", dynamicRange);
|
||||
sprintf(cstreambuf, "Dynamic Range: %u ", dynamicRange);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
return OK;
|
||||
@ -711,7 +707,7 @@ int UDPStandardImplementation::setTenGigaEnable(const bool b){
|
||||
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Setting Ten Giga to %s ", stringEnable(b).c_str());
|
||||
sprintf(cstreambuf, "Setting Ten Giga to %s ", stringEnable(b).c_str());
|
||||
FILE_LOG(logDEBUG1, cstreambuf);
|
||||
|
||||
}
|
||||
@ -735,7 +731,7 @@ int UDPStandardImplementation::setTenGigaEnable(const bool b){
|
||||
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "packetsPerFrame: %u\n"
|
||||
sprintf(cstreambuf, "packetsPerFrame: %u\n"
|
||||
"onePacketSize: %d\n"
|
||||
"oneDataSize: %d\n"
|
||||
"bufferSize: %d ",
|
||||
@ -755,7 +751,6 @@ int UDPStandardImplementation::setTenGigaEnable(const bool b){
|
||||
}
|
||||
for(int i=0;i<numberofWriterThreads;i++){
|
||||
latestData[i] = new char[bufferSize+sizeof(sls_detector_header)]();
|
||||
memset(latestData[i], 0, bufferSize+sizeof(sls_detector_header));
|
||||
}
|
||||
|
||||
//restructure fifo
|
||||
@ -768,7 +763,7 @@ int UDPStandardImplementation::setTenGigaEnable(const bool b){
|
||||
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Ten Giga: %s ", stringEnable(tengigaEnable).c_str());
|
||||
sprintf(cstreambuf, "Ten Giga: %s ", stringEnable(tengigaEnable).c_str());
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
return OK;
|
||||
@ -781,7 +776,7 @@ int UDPStandardImplementation::setFifoDepth(const uint32_t i){
|
||||
if(i != fifoDepth){
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Fifo Depth: %u ", i);
|
||||
sprintf(cstreambuf, "Fifo Depth: %u ", i);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
fifoDepth = i;
|
||||
@ -819,11 +814,11 @@ int UDPStandardImplementation::setDetectorType(const detectorType d){
|
||||
case EIGER:
|
||||
case JUNGFRAUCTB:
|
||||
case JUNGFRAU:
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, " ***** %s Receiver *** ", getDetectorType(d).c_str());
|
||||
sprintf(cstreambuf, " ***** %s Receiver *** ", getDetectorType(d).c_str());
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
break;
|
||||
default:
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "This is an unknown receiver type %d ", (int)d);
|
||||
sprintf(cstreambuf, "This is an unknown receiver type %d ", (int)d);
|
||||
FILE_LOG(logERROR, cstreambuf);
|
||||
return FAIL;
|
||||
}
|
||||
@ -918,7 +913,7 @@ int UDPStandardImplementation::setDetectorType(const detectorType d){
|
||||
excludeMissingPackets=true;
|
||||
break;
|
||||
default:
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "This is an unknown receiver type %d ", (int)d);
|
||||
sprintf(cstreambuf, "This is an unknown receiver type %d ", (int)d);
|
||||
FILE_LOG(logERROR, cstreambuf);
|
||||
return FAIL;
|
||||
}
|
||||
@ -955,14 +950,10 @@ int UDPStandardImplementation::setDetectorType(const detectorType d){
|
||||
if(latestData[i]) {delete[] latestData[i];latestData[i] = 0;}
|
||||
}
|
||||
for(int i=0; i<numberofWriterThreads; i++){
|
||||
if(excludeMissingPackets){
|
||||
if(excludeMissingPackets)
|
||||
latestData[i] = new char[bufferSize+sizeof(sls_detector_header)]();
|
||||
memset(latestData[i], 0, bufferSize+sizeof(sls_detector_header));
|
||||
}
|
||||
else{
|
||||
else
|
||||
latestData[i] = new char[bufferSize]();
|
||||
memset(latestData[i], 0, bufferSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -973,7 +964,7 @@ int UDPStandardImplementation::setDetectorType(const detectorType d){
|
||||
}
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Detector type set to %s ", getDetectorType(d).c_str());
|
||||
sprintf(cstreambuf, "Detector type set to %s ", getDetectorType(d).c_str());
|
||||
FILE_LOG(logDEBUG1, cstreambuf);
|
||||
}
|
||||
return OK;
|
||||
@ -1037,7 +1028,7 @@ int UDPStandardImplementation::startReceiver(char *c){
|
||||
//reset gui variables
|
||||
frametoGuiCounter[i] = 0;
|
||||
guiNumPackets[i] = 0;
|
||||
memset(guiFileName[i],0,MAX_STR_LENGTH);
|
||||
strcpy(guiFileName[i],"");
|
||||
|
||||
}
|
||||
pthread_mutex_lock(&writeMutex);
|
||||
@ -1056,16 +1047,16 @@ int UDPStandardImplementation::startReceiver(char *c){
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
if(myDetectorType != EIGER){
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Data Compression has been %s ", stringEnable(dataCompressionEnable).c_str());
|
||||
sprintf(cstreambuf, "Data Compression has been %s ", stringEnable(dataCompressionEnable).c_str());
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Number of Jobs Per Buffer: %d\n"
|
||||
sprintf(cstreambuf, "Number of Jobs Per Buffer: %d\n"
|
||||
"Max Frames Per File: %lu ",
|
||||
numberofJobsPerBuffer, maxFramesPerFile);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
|
||||
if(frameToGuiFrequency) {
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Frequency of frames sent to gui: %u ", frameToGuiFrequency);
|
||||
sprintf(cstreambuf, "Frequency of frames sent to gui: %u ", frameToGuiFrequency);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
} else
|
||||
FILE_LOG(logINFO, "Frequency of frames sent to gui: Random ");
|
||||
@ -1073,8 +1064,7 @@ int UDPStandardImplementation::startReceiver(char *c){
|
||||
|
||||
//create UDP sockets
|
||||
if(createUDPSockets() == FAIL){
|
||||
memset(c, 0, MAX_STR_LENGTH);
|
||||
snprintf(c,MAX_STR_LENGTH,"Could not create UDP Socket(s).");
|
||||
strcpy(c,"Could not create UDP Socket(s).");
|
||||
FILE_LOG(logERROR,"Could not create UDP Socket(s). ");
|
||||
return FAIL;
|
||||
}
|
||||
@ -1082,8 +1072,7 @@ int UDPStandardImplementation::startReceiver(char *c){
|
||||
if(setupWriter() == FAIL){
|
||||
//stop udp socket
|
||||
shutDownUDPSockets();
|
||||
memset(c, 0, MAX_STR_LENGTH);
|
||||
snprintf(c,MAX_STR_LENGTH,"Could not create file");
|
||||
strcpy(c,"Could not create file");
|
||||
FILE_LOG(logERROR, "Could not create file ");
|
||||
|
||||
for(int i=0; i < numberofWriterThreads; i++)
|
||||
@ -1092,9 +1081,8 @@ int UDPStandardImplementation::startReceiver(char *c){
|
||||
}
|
||||
|
||||
//For compression, just for gui purposes
|
||||
if(dataCompressionEnable){
|
||||
memset(completeFileName[0],0,MAX_STR_LENGTH);
|
||||
snprintf(completeFileName[0], MAX_STR_LENGTH, "%s/%s_fxxx_%lld_xx.root", filePath,fileNamePerThread[0],(long long int)fileIndex);}
|
||||
if(dataCompressionEnable)
|
||||
sprintf(completeFileName[0], "%s/%s_fxxx_%lld_xx.root", filePath,fileNamePerThread[0],(long long int)fileIndex);
|
||||
|
||||
//initialize semaphore to synchronize between writer and gui reader threads
|
||||
for(int i=0;i<numberofWriterThreads;i++){
|
||||
@ -1128,7 +1116,7 @@ int UDPStandardImplementation::startReceiver(char *c){
|
||||
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Receiver Started\n"
|
||||
sprintf(cstreambuf, "Receiver Started\n"
|
||||
"Status: %s ", runStatusType(status).c_str());
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
@ -1165,7 +1153,7 @@ void UDPStandardImplementation::stopReceiver(){
|
||||
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Receiver Stopped\n"
|
||||
sprintf(cstreambuf, "Receiver Stopped\n"
|
||||
"Status: %s ", runStatusType(status).c_str());
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
@ -1184,7 +1172,7 @@ int UDPStandardImplementation::shutDownUDPSockets(){
|
||||
udpSocket[i]->ShutDownSocket();
|
||||
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Shut down UDP Sock %d ", i);
|
||||
sprintf(cstreambuf, "Shut down UDP Sock %d ", i);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
|
||||
delete udpSocket[i];
|
||||
@ -1279,7 +1267,7 @@ void UDPStandardImplementation::closeFile(int ithread){
|
||||
if(!dataCompressionEnable){
|
||||
if(sfilefd[ithread]){
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Going to close file: %d ", fileno(sfilefd[ithread]));
|
||||
sprintf(cstreambuf, "Going to close file: %d ", fileno(sfilefd[ithread]));
|
||||
FILE_LOG(logDEBUG4, cstreambuf);
|
||||
|
||||
fflush(sfilefd[ithread]);
|
||||
@ -1293,7 +1281,7 @@ void UDPStandardImplementation::closeFile(int ithread){
|
||||
#if (defined(MYROOT1) && defined(ALLFILE_DEBUG)) || !defined(MYROOT1)
|
||||
if(sfilefd[0]){
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "sfilefd: %d ", fileno(sfilefd[0]));
|
||||
sprintf(cstreambuf, "sfilefd: %d ", fileno(sfilefd[0]));
|
||||
FILE_LOG(logDEBUG4, cstreambuf);
|
||||
|
||||
fclose(sfilefd[0]);
|
||||
@ -1336,7 +1324,7 @@ int UDPStandardImplementation::setActivate(int enable){
|
||||
if(enable != -1){
|
||||
activated = enable;
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Activation: %s ", stringEnable(activated).c_str());
|
||||
sprintf(cstreambuf, "Activation: %s ", stringEnable(activated).c_str());
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
@ -1394,7 +1382,7 @@ int UDPStandardImplementation::createDataCallbackThreads(bool destroy){
|
||||
currentThreadIndex = i;
|
||||
if(pthread_create(&dataCallbackThreads[i], NULL,startDataCallbackThread, (void*) this)){
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Could not create data call back thread with index %d ", i);
|
||||
sprintf(cstreambuf, "Could not create data call back thread with index %d ", i);
|
||||
FILE_LOG(logERROR, cstreambuf);
|
||||
return FAIL;
|
||||
}
|
||||
@ -1460,7 +1448,7 @@ int UDPStandardImplementation::createListeningThreads(bool destroy){
|
||||
currentThreadIndex = i;
|
||||
if(pthread_create(&listeningThreads[i], NULL,startListeningThread, (void*) this)){
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Could not create listening thread with index %d ", i);
|
||||
sprintf(cstreambuf, "Could not create listening thread with index %d ", i);
|
||||
FILE_LOG(logERROR, cstreambuf);
|
||||
return FAIL;
|
||||
}
|
||||
@ -1526,7 +1514,7 @@ int UDPStandardImplementation::createWriterThreads(bool destroy){
|
||||
currentThreadIndex = i;
|
||||
if(pthread_create(&writingThreads[i], NULL,startWritingThread, (void*) this)){
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Could not create writer thread with index %d ", i);
|
||||
sprintf(cstreambuf, "Could not create writer thread with index %d ", i);
|
||||
FILE_LOG(logERROR, cstreambuf);
|
||||
return FAIL;
|
||||
}
|
||||
@ -1607,9 +1595,8 @@ int UDPStandardImplementation::createUDPSockets(){
|
||||
|
||||
|
||||
//if eth is mistaken with ip address
|
||||
if (strchr(eth,'.') != NULL){
|
||||
memset(eth,0,MAX_STR_LENGTH);
|
||||
}
|
||||
if (strchr(eth,'.') != NULL)
|
||||
strcpy(eth,"");
|
||||
|
||||
shutDownUDPSockets();
|
||||
int headerpacketsize = 0;
|
||||
@ -1627,7 +1614,7 @@ int UDPStandardImplementation::createUDPSockets(){
|
||||
else{
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Ethernet Interface: %s", eth);
|
||||
sprintf(cstreambuf, "Ethernet Interface: %s", eth);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
for(int i=0;i<numberofListeningThreads;i++)
|
||||
@ -1641,7 +1628,7 @@ int UDPStandardImplementation::createUDPSockets(){
|
||||
cout << "UDP port opened at port " << port[i] << endl;
|
||||
}else{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Could not create UDP socket on port %u error: %d ", port[i], iret);
|
||||
sprintf(cstreambuf, "Could not create UDP socket on port %u error: %d ", port[i], iret);
|
||||
FILE_LOG(logERROR, cstreambuf);
|
||||
shutDownUDPSockets();
|
||||
return FAIL;
|
||||
@ -1690,7 +1677,7 @@ int UDPStandardImplementation::setupWriter(){
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
for(int i=0; i<numberofWriterThreads; i++){
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "%d Going to post 1st semaphore ",i);
|
||||
sprintf(cstreambuf, "%d Going to post 1st semaphore ",i);
|
||||
FILE_LOG(logDEBUG4, cstreambuf);
|
||||
|
||||
sem_post(&writerSemaphore[i]);
|
||||
@ -1723,15 +1710,14 @@ int UDPStandardImplementation::createNewFile(int ithread){
|
||||
|
||||
|
||||
//create file name
|
||||
memset(completeFileName[ithread],0,MAX_STR_LENGTH);
|
||||
if(!frameIndexEnable)
|
||||
snprintf(completeFileName[ithread], MAX_STR_LENGTH, "%s/%s_%lld.raw", filePath,fileNamePerThread[ithread],(long long int)fileIndex);
|
||||
sprintf(completeFileName[ithread], "%s/%s_%lld.raw", filePath,fileNamePerThread[ithread],(long long int)fileIndex);
|
||||
else
|
||||
snprintf(completeFileName[ithread], MAX_STR_LENGTH, "%s/%s_f%012lld_%lld.raw", filePath,fileNamePerThread[ithread],(long long int)lastFrameNumberInFile[ithread]+1,(long long int)fileIndex);
|
||||
sprintf(completeFileName[ithread], "%s/%s_f%012lld_%lld.raw", filePath,fileNamePerThread[ithread],(long long int)lastFrameNumberInFile[ithread]+1,(long long int)fileIndex);
|
||||
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "%s ", completeFileName[ithread]);
|
||||
sprintf(cstreambuf, "%s ", completeFileName[ithread]);
|
||||
FILE_LOG(logDEBUG4, cstreambuf);
|
||||
}
|
||||
//filewrite enable & we allowed to create/close files
|
||||
@ -1754,7 +1740,7 @@ int UDPStandardImplementation::createNewFile(int ithread){
|
||||
if(!overwriteEnable){
|
||||
if (NULL == (sfilefd[ithread] = fopen((const char *) (completeFileName[ithread]), "wx"))){
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Could not create/overwrite file %s ", completeFileName[ithread]);
|
||||
sprintf(cstreambuf, "Could not create/overwrite file %s ", completeFileName[ithread]);
|
||||
FILE_LOG(logERROR, cstreambuf);
|
||||
|
||||
sfilefd[ithread] = 0;
|
||||
@ -1762,7 +1748,7 @@ int UDPStandardImplementation::createNewFile(int ithread){
|
||||
}
|
||||
}else if (NULL == (sfilefd[ithread] = fopen((const char *) (completeFileName[ithread]), "w"))){
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Could not create file %s ", completeFileName[ithread]);
|
||||
sprintf(cstreambuf, "Could not create file %s ", completeFileName[ithread]);
|
||||
FILE_LOG(logERROR, cstreambuf);
|
||||
|
||||
sfilefd[ithread] = 0;
|
||||
@ -1834,14 +1820,13 @@ int UDPStandardImplementation::createCompressionFile(int ithread, int iframe){
|
||||
|
||||
#ifdef MYROOT1
|
||||
char temp[MAX_STR_LENGTH];
|
||||
memset(temp,0,MAX_STR_LENGTH);
|
||||
//create file name for gui purposes, and set up acquistion parameters
|
||||
snprintf(temp,MAX_STR_LENGTH, "%s/%s_fxxx_%d_%d.root", filePath,fileNamePerThread[ithread],fileIndex,ithread);
|
||||
sprintf(temp, "%s/%s_fxxx_%d_%d.root", filePath,fileNamePerThread[ithread],fileIndex,ithread);
|
||||
//file
|
||||
myFile[ithread] = new TFile(temp,"RECREATE");/** later return error if it exists */
|
||||
cprintf(GREEN,"Writing_Thread %d: Created Compression File: %s\n",ithread, temp);
|
||||
//tree
|
||||
snprintf(temp, MAX_STR_LENGTH,"%s_fxxx_%d_%d",fileNamePerThread[ithread],fileIndex,ithread);
|
||||
sprintf(temp, "%s_fxxx_%d_%d",fileNamePerThread[ithread],fileIndex,ithread);
|
||||
myTree[ithread]=singlePhotonDetectorObject[ithread]->initEventTree(temp, &iframe);
|
||||
//resets the pedestalSubtraction array and the commonModeSubtraction
|
||||
singlePhotonDetectorObject[ithread]->newDataSet();
|
||||
@ -1893,10 +1878,9 @@ void UDPStandardImplementation::startDataCallback(){
|
||||
struct timespec begin,end;
|
||||
|
||||
// server address to bind
|
||||
char hostName[100];
|
||||
memset(hostName,0,100);
|
||||
char hostName[100] = "tcp://*:";//"tcp://127.0.0.1:";
|
||||
int portno = DEFAULT_ZMQ_PORTNO + (detID*numberofListeningThreads+ithread);
|
||||
snprintf(hostName,100,"tcp://*:%d",portno);//"tcp://127.0.0.1:";
|
||||
sprintf(hostName,"%s%d",hostName,portno);
|
||||
|
||||
//socket details
|
||||
void *context = zmq_ctx_new();
|
||||
@ -1909,7 +1893,7 @@ void UDPStandardImplementation::startDataCallback(){
|
||||
// bind
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Thread %d: ZMQ Server at %s ", ithread, hostName);
|
||||
sprintf(cstreambuf, "Thread %d: ZMQ Server at %s ", ithread, hostName);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
@ -1921,6 +1905,9 @@ void UDPStandardImplementation::startDataCallback(){
|
||||
//infinite loop, exited only to change dynamic range, 10G parameters etc (then recreated again)
|
||||
while(true){
|
||||
|
||||
int oneframesize = oneDataSize * packetsPerFrame;
|
||||
char* buffer = new char[packetsPerFrame*oneDataSize]();
|
||||
memset(buffer,0xFF,oneframesize);
|
||||
bool randomSendNow = true;
|
||||
|
||||
//header details
|
||||
@ -1929,10 +1916,8 @@ void UDPStandardImplementation::startDataCallback(){
|
||||
"\"acqIndex\":%llu, "
|
||||
"\"fIndex\":%llu, "
|
||||
"\"bitmode\":%d, "
|
||||
"\"shapex\": %d, "
|
||||
"\"shapey\": %d, "
|
||||
"\"shape\":[%d, %d], "
|
||||
"\"fname\":\"%s\", "
|
||||
"\"data\": %d, "
|
||||
|
||||
"\"frameNumber\":%llu, "
|
||||
"\"expLength\":%u, "
|
||||
@ -1947,14 +1932,15 @@ void UDPStandardImplementation::startDataCallback(){
|
||||
"\"roundRNumber\":%u, "
|
||||
"\"detType\":%u, "
|
||||
"\"version\":%u"
|
||||
|
||||
"}\n\0";
|
||||
"}\n";
|
||||
int npixelsx=0, npixelsy=0;
|
||||
switch(myDetectorType) {
|
||||
case JUNGFRAU: npixelsx = JFRAU_PIXELS_IN_ONE_ROW; npixelsy = JFRAU_PIXELS_IN_ONE_COL; break;
|
||||
case EIGER: npixelsx = EIGER_PIXELS_IN_ONE_ROW; npixelsy = EIGER_PIXELS_IN_ONE_COL; break;
|
||||
default:break; /* will not work for other detectors*/
|
||||
}
|
||||
uint64_t acquisitionIndex = -1;
|
||||
uint64_t frameIndex = -1;
|
||||
#ifdef DEBUG
|
||||
int oldpnum = -1;
|
||||
#endif
|
||||
@ -1977,22 +1963,19 @@ void UDPStandardImplementation::startDataCallback(){
|
||||
cprintf(BLUE,"%d sending dummy\n");
|
||||
#endif
|
||||
|
||||
frameIndex = -1;
|
||||
acquisitionIndex = -1;
|
||||
{
|
||||
char buf[MAX_STR_LENGTH]="";memset(buf,0xFF,1000);
|
||||
int len = snprintf(buf,MAX_STR_LENGTH, jsonFmt,
|
||||
SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, "", 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
//cprintf(BLUE,"%d:Dummy:%s.\n",ithread, buf);fflush(stdout);
|
||||
zmq_send_const(zmqsocket, buf, len, 0);//ZMQ_SNDMORE);
|
||||
char buf[1000]="";memset(buf,0,1000);
|
||||
sprintf(buf,jsonFmt,
|
||||
SLS_DETECTOR_JSON_HEADER_VERSION, acquisitionIndex, frameIndex, dynamicRange, npixelsx, npixelsy,completeFileName[ithread],
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
|
||||
zmq_send(zmqsocket, buf,1000, 0);
|
||||
}
|
||||
cprintf(BLUE,"%d dummy\n",ithread);
|
||||
/* {
|
||||
//send final data
|
||||
char buf[MAX_STR_LENGTH]="";memset(buf,0xFF,0);
|
||||
int len = snprintf(buf,MAX_STR_LENGTH,"%s","end\n");
|
||||
zmq_send_const(zmqsocket, buf,len, 0);
|
||||
}*/
|
||||
zmq_send (zmqsocket, "end\n", 4, 0);
|
||||
|
||||
pthread_mutex_lock(&statusMutex);
|
||||
dataCallbackThreadsMask^=(1<<ithread);
|
||||
pthread_mutex_unlock(&statusMutex);
|
||||
@ -2025,24 +2008,19 @@ void UDPStandardImplementation::startDataCallback(){
|
||||
//update frame details
|
||||
sls_detector_header* header = (sls_detector_header*) (latestData[ithread]);
|
||||
uint64_t fnum = header->frameNumber;
|
||||
uint64_t frameIndex = fnum - startFrameIndex;
|
||||
uint64_t acquisitionIndex = fnum - startAcquisitionIndex;
|
||||
|
||||
frameIndex = fnum - startFrameIndex;
|
||||
acquisitionIndex = fnum - startAcquisitionIndex;
|
||||
{
|
||||
char buf[MAX_STR_LENGTH]="";memset(buf,0xFF,1000);
|
||||
int len = snprintf(buf,MAX_STR_LENGTH,jsonFmt,
|
||||
SLS_DETECTOR_JSON_HEADER_VERSION, acquisitionIndex, frameIndex, dynamicRange, npixelsx, npixelsy,completeFileName[ithread],1,
|
||||
// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
|
||||
|
||||
char buf[1000]="";memset(buf,0,1000);
|
||||
sprintf(buf,jsonFmt,
|
||||
SLS_DETECTOR_JSON_HEADER_VERSION, acquisitionIndex, frameIndex, dynamicRange, npixelsx, npixelsy,completeFileName[ithread],
|
||||
header->frameNumber, header->expLength, header->packetNumber, header->bunchId, header->timestamp,
|
||||
header->modId, header->xCoord, header->yCoord, header->zCoord, header->debug, header->roundRNumber, header->detType, header->version
|
||||
);
|
||||
//cprintf(BLUE,"%d:%s.\n",ithread, buf);fflush(stdout);
|
||||
zmq_send_const(zmqsocket, buf,len, ZMQ_SNDMORE);
|
||||
header->modId, header->xCoord, header->yCoord, header->zCoord, header->debug, header->roundRNumber, header->detType, header->version);
|
||||
|
||||
zmq_send(zmqsocket, buf,1000, 0);
|
||||
}
|
||||
//send data
|
||||
zmq_send_const(zmqsocket,(latestData[ithread]+sizeof(sls_detector_header)), bufferSize, 0);
|
||||
zmq_send(zmqsocket, (latestData[ithread]+sizeof(sls_detector_header)), bufferSize, 0);
|
||||
//start clock after sending
|
||||
if(!frameToGuiFrequency){
|
||||
randomSendNow = false;
|
||||
@ -2061,6 +2039,8 @@ void UDPStandardImplementation::startDataCallback(){
|
||||
|
||||
}/*--end of loop for each buffer (inner loop)*/
|
||||
|
||||
//free resources
|
||||
delete[] buffer;
|
||||
|
||||
//end of acquisition, wait for next acquisition/change of parameters
|
||||
sem_wait(&dataCallbackSemaphore[ithread]);
|
||||
@ -2108,7 +2088,6 @@ void UDPStandardImplementation::startListening(){
|
||||
carryonBufferSize = 0;
|
||||
if(tempBuffer){delete []tempBuffer;tempBuffer=0;}
|
||||
tempBuffer = new char[onePacketSize * (packetsPerFrame - 1)](); //store maximum of 1 packets less in a frame
|
||||
memset(tempBuffer,0,onePacketSize * (packetsPerFrame - 1));
|
||||
}
|
||||
|
||||
/* inner loop - loop for each buffer */
|
||||
@ -2123,7 +2102,7 @@ void UDPStandardImplementation::startListening(){
|
||||
if(activated && !udpSocket[ithread]){
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Listening_Thread %d: UDP Socket not created or shut down earlier ", ithread);
|
||||
sprintf(cstreambuf, "Listening_Thread %d: UDP Socket not created or shut down earlier ", ithread);
|
||||
FILE_LOG(logERROR, cstreambuf);
|
||||
}
|
||||
stopListening(ithread,0);
|
||||
@ -2270,11 +2249,6 @@ int UDPStandardImplementation::prepareAndListenBufferCompleteFrames(int ithread)
|
||||
//read first packet
|
||||
pnum = FIRSTPNUM; //first packet number to validate
|
||||
if(status != TRANSMITTING) rc = udpSocket[ithread]->ReceiveDataOnly(buffer[ithread] + offset);
|
||||
/*if(!ithread){
|
||||
cprintf(BLUE,"%d first rc:%d\n",ithread, rc);fflush(stdout);
|
||||
}else{
|
||||
cprintf(GREEN,"%d first rc:%d\n",ithread, rc);fflush(stdout);
|
||||
}*/
|
||||
if(rc <= 0) return 0;
|
||||
if(getFrameandPacketNumber(ithread,buffer[ithread] + offset,fi,pi,si,bi) == FAIL){
|
||||
pi = ALL_MASK_32; //got 0 from fpga
|
||||
@ -2302,7 +2276,7 @@ int UDPStandardImplementation::prepareAndListenBufferCompleteFrames(int ithread)
|
||||
if(!ithread) cout << "correct packet" << endl;
|
||||
#endif
|
||||
//copy only data
|
||||
memmove(buffer[ithread] + offset,buffer[ithread] + offset + headerlength, oneDataSize);
|
||||
memcpy(buffer[ithread] + offset,buffer[ithread] + offset + headerlength, oneDataSize);
|
||||
offset+=oneDataSize;
|
||||
|
||||
//if complete frame
|
||||
@ -2390,21 +2364,13 @@ int UDPStandardImplementation::prepareAndListenBufferCompleteFrames(int ithread)
|
||||
header->detType = (uint8_t) myDetectorType;
|
||||
header->version = (uint8_t) SLS_DETECTOR_HEADER_VERSION;
|
||||
|
||||
//#ifdef VERBOSE
|
||||
//if(!ithread)
|
||||
|
||||
/*if(!ithread) {
|
||||
#ifdef VERBOSE
|
||||
if(!ithread)
|
||||
cprintf(BLUE,
|
||||
"%d framenumber:%lu\tsubfnum:%u\tpnum:%u\tbunchid:%lu\txcoord:%u\tdettype:%u\tversion:%u\n",
|
||||
ithread, header->frameNumber, header->expLength, header->packetNumber,
|
||||
header->bunchId, header->xCoord, header->detType, header->version);fflush(stdout);
|
||||
}else{
|
||||
cprintf(GREEN,
|
||||
"%d framenumber:%lu\tsubfnum:%u\tpnum:%u\tbunchid:%lu\txcoord:%u\tdettype:%u\tversion:%u\n",
|
||||
ithread, header->frameNumber, header->expLength, header->packetNumber,
|
||||
header->bunchId, header->xCoord, header->detType, header->version);fflush(stdout);
|
||||
}*/
|
||||
//#endif
|
||||
"framenumber:%lu\tsubfnum:%u\tpnum:%u\tbunchid:%lu\txcoord:%u\tdettype:%u\tversion:%u\n",
|
||||
header->frameNumber, header->expLength, header->packetNumber,
|
||||
header->bunchId, header->xCoord, header->detType, header->version);
|
||||
#endif
|
||||
|
||||
//write packet count to buffer
|
||||
*((uint32_t*)(buffer[ithread])) = packetsPerFrame;
|
||||
@ -2467,7 +2433,7 @@ void UDPStandardImplementation::stopListening(int ithread, int numbytes){
|
||||
//free empty buffer
|
||||
if(numbytes <= 0){
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Listening %d: End of Acquisition", ithread);
|
||||
sprintf(cstreambuf, "Listening %d: End of Acquisition", ithread);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
while(!fifoFree[ithread]->push(buffer[ithread]));
|
||||
}
|
||||
@ -2504,7 +2470,7 @@ void UDPStandardImplementation::stopListening(int ithread, int numbytes){
|
||||
//#ifdef DEBUG4
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Listening Thread of %u got %d packets ", udpPortNum[ithread], totalListeningPacketCount[ithread]);
|
||||
sprintf(cstreambuf, "Listening Thread of %u got %d packets ", udpPortNum[ithread], totalListeningPacketCount[ithread]);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
//#endif
|
||||
@ -2701,7 +2667,6 @@ void UDPStandardImplementation::waitWritingBufferForNextAcquisition(int ithread)
|
||||
|
||||
//create file
|
||||
if((1<<ithread)&createFileMask){
|
||||
memset(fileNamePerThread[ithread],0,MAX_STR_LENGTH);
|
||||
//change the detector index in the file names
|
||||
if(myDetectorType == EIGER){
|
||||
int detindex = -1;
|
||||
@ -2711,15 +2676,15 @@ void UDPStandardImplementation::waitWritingBufferForNextAcquisition(int ithread)
|
||||
if (uscore!=string::npos){
|
||||
if (sscanf(tempname.substr(uscore+1,tempname.size()-uscore-1).c_str(),"d%d",&detindex)) {
|
||||
tempname=tempname.substr(0,uscore);
|
||||
snprintf(fileNamePerThread[ithread],MAX_STR_LENGTH,"%s_d%d",tempname.c_str(),detindex*2+ithread);
|
||||
sprintf(fileNamePerThread[ithread],"%s_d%d",tempname.c_str(),detindex*2+ithread);
|
||||
}
|
||||
}
|
||||
//only one half module, so no detid
|
||||
if(detindex == -1)
|
||||
snprintf(fileNamePerThread[ithread],MAX_STR_LENGTH,"%s_d%d",fileName,ithread);
|
||||
sprintf(fileNamePerThread[ithread],"%s_d%d",fileName,ithread);
|
||||
|
||||
}else
|
||||
snprintf(fileNamePerThread[0],MAX_STR_LENGTH,fileName);
|
||||
strcpy(fileNamePerThread[0],fileName);
|
||||
|
||||
if(dataCompressionEnable){
|
||||
#ifdef MYROOT1
|
||||
@ -2780,7 +2745,7 @@ void UDPStandardImplementation::stopWriting(int ithread, char* wbuffer){
|
||||
|
||||
{
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Writing %d: End of Acquisition ", ithread);
|
||||
sprintf(cstreambuf, "Writing %d: End of Acquisition ", ithread);
|
||||
FILE_LOG(logINFO, cstreambuf);
|
||||
}
|
||||
|
||||
@ -2876,19 +2841,15 @@ void UDPStandardImplementation::stopWriting(int ithread, char* wbuffer){
|
||||
|
||||
//thread 0 waits for all threads to finish & print statistics
|
||||
if(ithread == 0){
|
||||
/* cprintf(BLUE,"Thread 0: Waiting for all writer threads\n");*/
|
||||
//wait for all other threads
|
||||
while(writerThreadsMask)
|
||||
usleep(5000);
|
||||
/*cprintf(BLUE,"Thread 0: Waiting for all listener threads\n");*/
|
||||
//ensure listening threads done before updating status as it returns to client (from stopReceiver)
|
||||
while(listeningThreadsMask)
|
||||
usleep(5000);
|
||||
/*cprintf(BLUE,"Thread 0: Waiting for all datacallback threads\n");*/
|
||||
//ensure datacallbacks threads are done
|
||||
while(dataCallbackThreadsMask)
|
||||
usleep(5000);
|
||||
/*cprintf(BLUE,"Thread 0: Done, waiting for lock to say finished\n");*/
|
||||
//update status
|
||||
pthread_mutex_lock(&statusMutex);
|
||||
status = RUN_FINISHED;
|
||||
@ -2937,7 +2898,6 @@ void UDPStandardImplementation::stopWriting(int ithread, char* wbuffer){
|
||||
if (acquisitionFinishedCallBack)
|
||||
acquisitionFinishedCallBack((totalPacketsCaught/(packetsPerFrame*numberofListeningThreads)), pAcquisitionFinished);
|
||||
}
|
||||
/*cprintf(BLUE,"Thread %d: Done\n", ithread);*/
|
||||
}
|
||||
|
||||
|
||||
@ -3247,8 +3207,7 @@ void UDPStandardImplementation::writeFileWithoutCompression(int ithread, char* w
|
||||
void UDPStandardImplementation::updateFileHeader(int ithread){
|
||||
//update file header
|
||||
time_t t = time(0);
|
||||
memset(fileHeader[ithread],0,FILE_HEADER_SIZE);
|
||||
snprintf(fileHeader[ithread],FILE_HEADER_SIZE,
|
||||
sprintf(fileHeader[ithread],
|
||||
"\nHeader\t\t: %d bytes\n"
|
||||
"Top\t\t: %d\n"
|
||||
"Left\t\t: %d\n"
|
||||
@ -3320,8 +3279,7 @@ void UDPStandardImplementation::copyFrameToGui(int ithread, char* buffer, uint32
|
||||
|
||||
//copy date
|
||||
guiNumPackets[ithread] = numpackets;
|
||||
memset(guiFileName[ithread],0,MAX_STR_LENGTH);
|
||||
snprintf(guiFileName[ithread],MAX_STR_LENGTH,completeFileName[ithread]);
|
||||
strcpy(guiFileName[ithread],completeFileName[ithread]);
|
||||
|
||||
if(excludeMissingPackets) //copy also the header
|
||||
memcpy(latestData[ithread],buffer+ HEADER_SIZE_NUM_TOT_PACKETS, bufferSize + sizeof(sls_detector_header));
|
||||
@ -3506,13 +3464,9 @@ int UDPStandardImplementation::getFrameandPacketNumber(int ithread, char* wbuffe
|
||||
framenumber = 0;
|
||||
|
||||
char cstreambuf[MAX_STR_LENGTH]; memset(cstreambuf, 0, MAX_STR_LENGTH);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Fifo %d: Frame Number is zero from firmware. ", ithread);
|
||||
FILE_LOG(logERROR, cstreambuf);
|
||||
e_header = (eiger_packet_header_t*) (wbuffer);
|
||||
subframenumber = *( (uint32_t*) e_header->subFrameNumber);
|
||||
snprintf(cstreambuf, MAX_STR_LENGTH, "Fifo %d: Frame Number is zero from firmware. subnum: %u, fnum:%u, pnum:%u ", ithread, subframenumber,
|
||||
(uint32_t)(*( (uint64_t*) footer)),(*( (uint16_t*) footer->packetNumber))-1);
|
||||
sprintf(cstreambuf, "Fifo %d: Frame Number is zero from firmware. ", ithread);
|
||||
FILE_LOG(logERROR, cstreambuf);
|
||||
|
||||
return FAIL;
|
||||
}
|
||||
packetnumber = (*( (uint16_t*) footer->packetNumber))-1;
|
||||
|
Reference in New Issue
Block a user