using detid to calculte zmq port in case of shmget error and det id does not start with 0 and 1 as in receiver zmq server ports

This commit is contained in:
Dhanya Maliakal 2016-12-02 08:53:08 +01:00
parent 790cef37ff
commit dd9387ef29
3 changed files with 12 additions and 7 deletions

View File

@ -5070,9 +5070,11 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy){
//number of sockets
int numSockets = thisMultiDetector->numberOfDetectors;
if(getDetectorsType() == EIGER)
numSockets *= 2;
int numSocketsPerDetector = 1;
if(getDetectorsType() == EIGER){
numSocketsPerDetector = 2;
}
numSockets *= numSocketsPerDetector;
if(destroy){
cprintf(MAGENTA,"Going to destroy data sockets\n");
@ -5099,7 +5101,7 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy){
//get name of rx_hostname
char rx_hostname[100];
strcpy(dataSocketServerDetails[i],"tcp://");
strcpy(rx_hostname, detectors[i/numSockets]->getReceiver());
strcpy(rx_hostname, detectors[i/numSocketsPerDetector]->getReceiver());
cout<<"rx_hostname:"<<rx_hostname<<endl;
//append it (first into ip) to tcp://
if(strchr(rx_hostname,'.')!=NULL)
@ -5114,7 +5116,8 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy){
strcat(dataSocketServerDetails[i],inet_ntoa(*(struct in_addr*)he->h_addr));
}
//add port
sprintf(dataSocketServerDetails[i],"%s:%d",dataSocketServerDetails[i],DEFAULT_ZMQ_PORTNO + i);
sprintf(dataSocketServerDetails[i],"%s:%d",dataSocketServerDetails[i],DEFAULT_ZMQ_PORTNO +
(detectors[i/numSocketsPerDetector]->getDetectorId())*numSocketsPerDetector + (i%numSocketsPerDetector));//using this instead of i in the offchance, detid doesnt start at 0 (shmget error)
//create context
context[i] = zmq_ctx_new();
@ -5272,7 +5275,7 @@ void multiSlsDetector::readFrameFromReceiver(){
ny = getTotalNumberOfChannels(slsDetectorDefs::Y);
//calculating offsets (for eiger interleaving ports)
int offsetX[numSockets]; int offsetY[numSockets];
bool bottom[numSockets];
int bottom[numSockets];
if(maxX){
for(int i=0; i<numSockets; ++i){
offsetY[i] = (maxY - (thisMultiDetector->offsetY[i/numSocketsPerSLSDetector] + slsmaxY)) * maxX * bytesperchannel;

View File

@ -754,6 +754,8 @@ int slsDetector::initializeDetectorSize(detectorType type) {
thisDetector->tenGigaEnable=0;
thisDetector->acquiringFlag = false;
thisDetector->flippedData[0] = 0;
thisDetector->flippedData[1] = 0;
for (int ia=0; ia<MAX_ACTIONS; ia++) {
strcpy(thisDetector->actionScript[ia],"none");

View File

@ -268,7 +268,7 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
/** flag for acquiring */
bool acquiringFlag;
/** flipped data across x or y axis */
bool flippedData[2];
int flippedData[2];
} sharedSlsDetector;