module udpport2

This commit is contained in:
Maliakal Dhanya
2014-09-26 11:18:59 +02:00
parent fa6ab0b324
commit d8c7201749
18 changed files with 253 additions and 102 deletions

View File

@ -488,6 +488,8 @@ int slsDetector::initializeDetectorSize(detectorType type) {
thisDetector->receiverTCPPort=DEFAULT_PORTNO+2;
/** set receiver udp port */
thisDetector->receiverUDPPort=DEFAULT_UDP_PORTNO;
/** set receiver udp port for Eiger */
thisDetector->receiverUDPPort2=DEFAULT_UDP_PORTNO+1;
/** set receiver ip address/hostname */
strcpy(thisDetector->receiver_hostname,"none");
/** set receiver udp ip address */
@ -4838,6 +4840,15 @@ char* slsDetector::setNetworkParameter(networkParameter index, string value) {
sscanf(value.c_str(),"%d",&i);
setReceiverUDPPort(i);
return getReceiverUDPPort();
case RECEIVER_UDP_PORT2:
sscanf(value.c_str(),"%d",&i);
if(thisDetector->myDetectorType == EIGER)
setReceiverUDPPort2(i);
else
setReceiverUDPPort(i);
if(thisDetector->myDetectorType == EIGER)
return getReceiverUDPPort2();
return getReceiverUDPPort();
default:
return ("unknown network parameter");
}
@ -4867,6 +4878,9 @@ char* slsDetector::getNetworkParameter(networkParameter index) {
case RECEIVER_UDP_PORT:
return getReceiverUDPPort();
break;
case RECEIVER_UDP_PORT2:
return getReceiverUDPPort2();
break;
default:
return ("unknown network parameter");
}
@ -5012,14 +5026,17 @@ int slsDetector::setReceiverUDPPort(int udpport){
return thisDetector->receiverUDPPort;
}
int slsDetector::setReceiverUDPPort2(int udpport){
thisDetector->receiverUDPPort2 = udpport;
return thisDetector->receiverUDPPort2;
}
int slsDetector::setUDPConnection(){
int ret = FAIL;
int fnum = F_SETUP_RECEIVER_UDP;
char args[2][MAX_STR_LENGTH];
char args[3][MAX_STR_LENGTH];
char retval[MAX_STR_LENGTH]="";
@ -5043,9 +5060,11 @@ int slsDetector::setUDPConnection(){
//copy arguments to args[][]
strcpy(args[0],thisDetector->receiverUDPIP);
sprintf(args[1],"%d",thisDetector->receiverUDPPort);
sprintf(args[2],"%d",thisDetector->receiverUDPPort2);
#ifdef VERBOSE
std::cout << "Receiver udp ip address: " << thisDetector->receiverUDPIP << std::endl;
std::cout << "Receiver udp port: " << thisDetector->receiverUDPPort << std::endl;
std::cout << "Receiver udp port2: " << thisDetector->receiverUDPPort2 << std::endl;
#endif
//set up receiver for UDP Connection and get receivermac address
@ -5084,7 +5103,7 @@ int slsDetector::configureMAC(){
int ret=FAIL;
int fnum=F_CONFIGURE_MAC,fnum2=F_RECEIVER_SHORT_FRAME;
char mess[100];
char arg[5][50];
char arg[6][50];
char cword[50]="", *pcword;
string sword;
int retval=-1;
@ -5112,6 +5131,7 @@ int slsDetector::configureMAC(){
sprintf(arg[2],"%x",thisDetector->receiverUDPPort);
strcpy(arg[3],thisDetector->detectorMAC);
strcpy(arg[4],thisDetector->detectorIP);
sprintf(arg[5],"%x",thisDetector->receiverUDPPort2);
#ifdef VERBOSE
std::cout<< "Configuring MAC"<< std::endl;
@ -5174,6 +5194,9 @@ int slsDetector::configureMAC(){
#ifdef VERBOSE
std::cout<<"detector ip:"<<arg[4]<<"."<<std::endl;
#endif
#ifdef VERBOSE
std::cout<<"receiver udp port2:"<<arg[5]<<"."<<std::endl;
#endif
//send to server
if (thisDetector->onlineFlag==ONLINE_FLAG) {

View File

@ -240,6 +240,8 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
int receiverTCPPort;
/** is the port used to communicate between detector and the receiver*/
int receiverUDPPort;
/** is the port used to communicate between second half module of Eiger detector and the receiver*/
int receiverUDPPort2;
/** ip address of the receiver for the detector to send packets to**/
char receiverUDPIP[MAX_STR_LENGTH];
/** mac address of receiver for the detector to send packets to **/
@ -1603,6 +1605,8 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
char* getReceiverUDPMAC() {return thisDetector->receiverUDPMAC;};
/** returns the receiver UDP IP address \sa sharedSlsDetector */
char* getReceiverUDPPort() {char *c= new char[MAX_STR_LENGTH];sprintf(c,"%d",thisDetector->receiverUDPPort); return c;};
/** returns the receiver UDP2 for Eiger IP address \sa sharedSlsDetector */
char* getReceiverUDPPort2() {char *c= new char[MAX_STR_LENGTH];sprintf(c,"%d",thisDetector->receiverUDPPort2); return c;};
/** validates the format of detector MAC address and sets it \sa sharedSlsDetector */
char* setDetectorMAC(string detectorMAC);
@ -1616,6 +1620,8 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
char* setReceiverUDPMAC(string udpmac);
/** sets the receiver udp port \sa sharedSlsDetector */
int setReceiverUDPPort(int udpport);
/** sets the receiver udp port2 for Eiger \sa sharedSlsDetector */
int setReceiverUDPPort2(int udpport);
/** Sets the read receiver frequency
if Receiver read upon gui request, readRxrFrequency=0,

View File

@ -344,6 +344,10 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdNetworkParameter;
i++;
descrToFuncMap[i].m_pFuncName="rx_udpport2"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdNetworkParameter;
i++;
descrToFuncMap[i].m_pFuncName="detectormac"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdNetworkParameter;
i++;
@ -2464,6 +2468,12 @@ string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int actio
if (!(sscanf(args[1],"%d",&i)))
return ("cannot parse argument") + string(args[1]);
}
} else if (cmd=="rx_udpport2") {
t=RECEIVER_UDP_PORT2;
if (action==PUT_ACTION){
if (!(sscanf(args[1],"%d",&i)))
return ("cannot parse argument") + string(args[1]);
}
} else return ("unknown network parameter")+cmd;
if (action==PUT_ACTION)
@ -2485,6 +2495,7 @@ string slsDetectorCommand::helpNetworkParameter(int narg, char *args[], int acti
os << "rx_udpip ip \n sets receiver udp ip to ip"<< std::endl;
os << "rx_udpmac mac \n sets receiver udp mac to mac"<< std::endl;
os << "rx_udpport port \n sets receiver udp port to port"<< std::endl;
os << "rx_udpport2 port \n sets receiver udp port to port. For Eiger, it is the second half module and for other detectors, same as rx_udpport"<< std::endl;
}
if (action==GET_ACTION || action==HELP_ACTION) {
os << "detectormac \n gets detector mac "<< std::endl;
@ -2492,6 +2503,8 @@ string slsDetectorCommand::helpNetworkParameter(int narg, char *args[], int acti
os << "rx_hostname \n gets receiver ip "<< std::endl;
os << "rx_udpmac \n gets receiver udp mac "<< std::endl;
os << "rx_udpport \n gets receiver udp port "<< std::endl;
os << "rx_udpport2 \n gets receiver udp port. For Eiger, it is the second half module and for other detectors, same as rx_udpport"<< std::endl;
}
return os.str();