mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-20 00:37:12 +02:00
Merge branch 'developer' of git.psi.ch:sls_detectors_software/sls_detector_software into developer
This commit is contained in:
@ -207,6 +207,7 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1)
|
||||
|
||||
thisMultiDetector->receiver_read_freq = 0;
|
||||
thisMultiDetector->acquiringFlag = false;
|
||||
thisMultiDetector->externalgui = false;
|
||||
thisMultiDetector->alreadyExisting=1;
|
||||
}
|
||||
|
||||
@ -278,6 +279,7 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1)
|
||||
threadpool = 0;
|
||||
if(createThreadPool() == FAIL)
|
||||
exit(-1);
|
||||
gainDataEnable = false;
|
||||
|
||||
}
|
||||
|
||||
@ -3615,11 +3617,11 @@ string multiSlsDetector::getNetworkParameter(networkParameter p) {
|
||||
string multiSlsDetector::setNetworkParameter(networkParameter p, string s){
|
||||
|
||||
// disable data streaming before changing zmq port (but only if they were on)
|
||||
/*int prev_streaming = 0;*/
|
||||
if (p == RECEIVER_STREAMING_PORT) {
|
||||
/*prev_streaming = getStreamingSocketsCreatedInClient();*/
|
||||
enableDataStreamingFromReceiver(0);
|
||||
}
|
||||
int prev_streaming = 0;
|
||||
if (p == RECEIVER_STREAMING_PORT) {
|
||||
prev_streaming = getStreamingSocketsCreatedInClient();
|
||||
enableDataStreamingFromReceiver(0);
|
||||
}
|
||||
|
||||
if (s.find('+')==string::npos) {
|
||||
|
||||
@ -3672,11 +3674,11 @@ string multiSlsDetector::setNetworkParameter(networkParameter p, string s){
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
|
||||
//enable data streaming if it was on
|
||||
if (p == RECEIVER_STREAMING_PORT && prev_streaming)
|
||||
enableDataStreamingFromReceiver(1);
|
||||
*/
|
||||
|
||||
return getNetworkParameter(p);
|
||||
|
||||
}
|
||||
@ -5350,16 +5352,6 @@ slsDetectorDefs::runStatus multiSlsDetector::getReceiverStatus(){
|
||||
int multiSlsDetector::getFramesCaughtByReceiver() {
|
||||
int ret=0,ret1=0;
|
||||
|
||||
if(thisMultiDetector->numberOfDetectors>10) {
|
||||
if (detectors[0]){
|
||||
ret =detectors[0]->getFramesCaughtByReceiver();
|
||||
if(detectors[0]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<0));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++)
|
||||
if (detectors[i]){
|
||||
ret1+=detectors[i]->getFramesCaughtByReceiver();
|
||||
@ -5471,7 +5463,7 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy){
|
||||
|
||||
|
||||
|
||||
int multiSlsDetector::getData(const int isocket, const bool masking, int* image, const int size,
|
||||
int multiSlsDetector::getData(const int isocket, int* image, const int size,
|
||||
uint64_t &acqIndex, uint64_t &frameIndex, uint32_t &subframeIndex, string &filename) {
|
||||
|
||||
//fail is on parse error or end of acquisition
|
||||
@ -5481,14 +5473,6 @@ int multiSlsDetector::getData(const int isocket, const bool masking, int* image,
|
||||
//receiving incorrect size is replaced by 0xFF
|
||||
zmqSocket[isocket]->ReceiveData(isocket, image, size);
|
||||
|
||||
//jungfrau masking adcval
|
||||
if(masking){
|
||||
unsigned int snel = size/sizeof(int);
|
||||
for(unsigned int i=0;i<snel;++i){
|
||||
image[i] = (image[i] & 0x3FFF3FFF);
|
||||
}
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -5503,6 +5487,7 @@ void multiSlsDetector::readFrameFromReceiver(){
|
||||
int numSockets = thisMultiDetector->numberOfDetectors;
|
||||
int numSocketsPerSLSDetector = 1;
|
||||
bool jungfrau = false;
|
||||
double* gdata = NULL;
|
||||
switch(getDetectorsType()){
|
||||
case EIGER:
|
||||
numSocketsPerSLSDetector = 2;
|
||||
@ -5561,6 +5546,9 @@ void multiSlsDetector::readFrameFromReceiver(){
|
||||
return;
|
||||
}
|
||||
int* multiframe=new int[nel]();
|
||||
int* multiframegain=NULL;
|
||||
if (jungfrau)
|
||||
multiframegain = new int[nel]();
|
||||
int nch;
|
||||
|
||||
bool runningList[numSockets];
|
||||
@ -5587,7 +5575,7 @@ void multiSlsDetector::readFrameFromReceiver(){
|
||||
//if running
|
||||
if (runningList[isocket]) {
|
||||
//get individual images
|
||||
if(FAIL == getData(isocket, jungfrau, image, expectedslssize, currentAcquisitionIndex,currentFrameIndex,currentSubFrameIndex,currentFileName)){
|
||||
if(FAIL == getData(isocket, image, expectedslssize, currentAcquisitionIndex,currentFrameIndex,currentSubFrameIndex,currentFileName)){
|
||||
runningList[isocket] = false;
|
||||
numRunning--;
|
||||
continue;
|
||||
@ -5641,12 +5629,29 @@ void multiSlsDetector::readFrameFromReceiver(){
|
||||
|
||||
//send data to callback
|
||||
if(running){
|
||||
if (jungfrau) {
|
||||
// with gain data
|
||||
if (gainDataEnable) {
|
||||
memcpy(multiframegain, multiframe, nel * sizeof(int));
|
||||
for(unsigned int i=0;i<nel;++i){
|
||||
multiframegain[i] = ((multiframe[i] & 0xC0000000) >> 14) | ((multiframe[i] & 0x0000C000) >> 14) ;
|
||||
multiframe[i] = (multiframe[i] & 0x3FFF3FFF);
|
||||
}
|
||||
gdata = decodeData(multiframegain,nch);
|
||||
}
|
||||
// without gain data
|
||||
else {
|
||||
for(unsigned int i=0;i<nel;++i)
|
||||
multiframe[i] = (multiframe[i] & 0x3FFF3FFF);
|
||||
}
|
||||
}
|
||||
fdata = decodeData(multiframe,nch);
|
||||
if ((fdata) && (dataReady)){
|
||||
thisData = new detectorData(fdata,NULL,NULL,getCurrentProgress(),currentFileName.c_str(),nx,ny);
|
||||
thisData = new detectorData(fdata, NULL,NULL,getCurrentProgress(),currentFileName.c_str(),nx,ny, gdata);
|
||||
dataReady(thisData, currentFrameIndex, currentSubFrameIndex, pCallbackArg);
|
||||
delete thisData;
|
||||
fdata = NULL;
|
||||
gdata = NULL;
|
||||
//cout<<"Send frame #"<< currentFrameIndex << " to gui"<<endl;
|
||||
}
|
||||
setCurrentProgress(currentAcquisitionIndex+1);
|
||||
@ -5659,6 +5664,8 @@ void multiSlsDetector::readFrameFromReceiver(){
|
||||
//free resources
|
||||
delete [] image;
|
||||
delete[] multiframe;
|
||||
if (jungfrau)
|
||||
delete [] multiframegain;
|
||||
}
|
||||
|
||||
|
||||
@ -5909,8 +5916,10 @@ int multiSlsDetector::getStreamingSocketsCreatedInClient() {
|
||||
|
||||
int multiSlsDetector::enableDataStreamingFromReceiver(int enable){
|
||||
|
||||
if(enable >= 0){
|
||||
/*if(dataSocketsStarted != enable){*/
|
||||
//create client sockets only if no external gui
|
||||
if (!thisMultiDetector->externalgui) {
|
||||
if(enable >= 0){
|
||||
|
||||
//destroy data threads
|
||||
if(dataSocketsStarted)
|
||||
createReceivingDataSockets(true);
|
||||
@ -5925,12 +5934,10 @@ int multiSlsDetector::enableDataStreamingFromReceiver(int enable){
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/*}*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int ret=-100;
|
||||
if(!threadpool){
|
||||
cout << "Error in creating threadpool. Exiting" << endl;
|
||||
@ -5963,9 +5970,10 @@ int multiSlsDetector::enableDataStreamingFromReceiver(int enable){
|
||||
}
|
||||
}
|
||||
|
||||
if(ret != dataSocketsStarted)
|
||||
ret = -1;
|
||||
|
||||
if (!thisMultiDetector->externalgui) {
|
||||
if (ret != dataSocketsStarted)
|
||||
ret = -1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -6281,3 +6289,17 @@ void multiSlsDetector::setAcquiringFlag(bool b){
|
||||
bool multiSlsDetector::getAcquiringFlag(){
|
||||
return thisMultiDetector->acquiringFlag;
|
||||
}
|
||||
|
||||
|
||||
void multiSlsDetector::setExternalGuiFlag(bool b){
|
||||
thisMultiDetector->externalgui = b;
|
||||
}
|
||||
|
||||
bool multiSlsDetector::getExternalGuiFlag(){
|
||||
return thisMultiDetector->externalgui;
|
||||
}
|
||||
|
||||
|
||||
void multiSlsDetector::setGainDataEnableinDataCallback(bool e) {
|
||||
gainDataEnable = e;
|
||||
}
|
||||
|
Reference in New Issue
Block a user