mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 18:17:59 +02:00
included settting up of udpport from client and getting receiver mac from receiver and also listening to only one ethernet interface
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@371 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
@ -453,19 +453,23 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
||||
/** set hostname to default */
|
||||
strcpy(thisDetector->hostname,DEFAULT_HOSTNAME);
|
||||
|
||||
/** set client ip address */
|
||||
strcpy(thisDetector->receiverIP,"none");
|
||||
/** set client mac address */
|
||||
strcpy(thisDetector->receiverMAC,"none");
|
||||
/** set receiver tcp port */
|
||||
thisDetector->receiverTCPPort=DEFAULT_PORTNO+2;
|
||||
/** set receiver udp port */
|
||||
thisDetector->receiverUDPPort=DEFAULT_UDP_PORTNO;
|
||||
/** set receiver ip address/hostname */
|
||||
strcpy(thisDetector->receiver_hostname,"none");
|
||||
/** set receiver udp ip address */
|
||||
strcpy(thisDetector->receiverUDPIP,"none");
|
||||
/** set server mac address */
|
||||
strcpy(thisDetector->serverMAC,"00:aa:bb:cc:dd:ee");
|
||||
strcpy(thisDetector->detectorMAC,"00:aa:bb:cc:dd:ee");
|
||||
|
||||
/** sets onlineFlag to OFFLINE_FLAG */
|
||||
thisDetector->onlineFlag=OFFLINE_FLAG;
|
||||
/** set ports to defaults */
|
||||
thisDetector->controlPort=DEFAULT_PORTNO;
|
||||
thisDetector->stopPort=DEFAULT_PORTNO+1;
|
||||
thisDetector->receiverPort=DEFAULT_PORTNO+2;
|
||||
|
||||
/** set thisDetector->myDetectorType to type and according to this set nChans, nChips, nDacs, nAdcs, nModMax, dynamicRange, nMod*/
|
||||
thisDetector->myDetectorType=type;
|
||||
switch(thisDetector->myDetectorType) {
|
||||
@ -3459,7 +3463,6 @@ string slsDetector::getLastClientIP() {
|
||||
|
||||
int slsDetector::setPort(portType index, int num){
|
||||
|
||||
|
||||
int fnum=F_SET_PORT;
|
||||
int retval;
|
||||
// uint64_t ut;
|
||||
@ -3500,14 +3503,13 @@ int slsDetector::setPort(portType index, int num){
|
||||
break;
|
||||
case DATA_PORT:
|
||||
s=dataSocket;
|
||||
retval=thisDetector->receiverPort;
|
||||
if(strcmp(thisDetector->receiverIP,"none")){
|
||||
if (s==NULL) {cout<<"s is null"<<endl;setReceiverTCPSocket("",retval);}
|
||||
if (dataSocket){cout<<"datasocket now has value"<<endl; s=dataSocket;}
|
||||
retval=thisDetector->receiverTCPPort;
|
||||
if(strcmp(thisDetector->receiver_hostname,"none")){
|
||||
if (s==NULL) setReceiverTCPSocket("",retval);
|
||||
if (dataSocket)s=dataSocket;
|
||||
//else {cout<<"datasocket has no value"<<endl; setReceiverTCPSocket("",retval);}
|
||||
}
|
||||
online = (thisDetector->receiverOnlineFlag==ONLINE_FLAG);
|
||||
cout<<"online:"<<online<<endl;
|
||||
break;
|
||||
case STOP_PORT:
|
||||
s=stopSocket;
|
||||
@ -3548,11 +3550,9 @@ int slsDetector::setPort(portType index, int num){
|
||||
break;
|
||||
case DATA_PORT:
|
||||
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
|
||||
cout<<"online,ret=ok"<<endl;
|
||||
thisDetector->receiverPort=retval;
|
||||
cout<<"first trying to set online:"<<setReceiverOnline(ONLINE_FLAG)<<endl;
|
||||
cout<<"Setting up Receiver"<<endl;
|
||||
setReceiverIP(thisDetector->receiverIP);
|
||||
thisDetector->receiverTCPPort=retval;
|
||||
setReceiverOnline(ONLINE_FLAG);
|
||||
setReceiver(thisDetector->receiver_hostname);
|
||||
}
|
||||
break;
|
||||
case STOP_PORT:
|
||||
@ -3571,16 +3571,12 @@ int slsDetector::setPort(portType index, int num){
|
||||
thisDetector->controlPort=num;
|
||||
break;
|
||||
case DATA_PORT:
|
||||
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
|
||||
cout<<"online,ret=fail"<<endl;
|
||||
thisDetector->receiverPort=retval;
|
||||
}else{
|
||||
cout<<"not online,ret=fail"<<endl;
|
||||
thisDetector->receiverPort=num;
|
||||
if(strcmp(thisDetector->receiverIP,"none")){
|
||||
cout<<"ip not none, Setting up Receiver"<<endl;
|
||||
setReceiverIP(thisDetector->receiverIP);
|
||||
}
|
||||
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG)
|
||||
thisDetector->receiverTCPPort=retval;
|
||||
else{
|
||||
thisDetector->receiverTCPPort=num;
|
||||
if(strcmp(thisDetector->receiver_hostname,"none"))
|
||||
setReceiver(thisDetector->receiver_hostname);
|
||||
}
|
||||
break;
|
||||
case STOP_PORT:
|
||||
@ -3596,7 +3592,7 @@ int slsDetector::setPort(portType index, int num){
|
||||
retval=thisDetector->controlPort;
|
||||
break;
|
||||
case DATA_PORT:
|
||||
retval=thisDetector->receiverPort;
|
||||
retval=thisDetector->receiverTCPPort;
|
||||
break;
|
||||
case STOP_PORT:
|
||||
retval=thisDetector->stopPort;
|
||||
@ -3609,7 +3605,7 @@ int slsDetector::setPort(portType index, int num){
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << thisDetector->controlPort<< " " << thisDetector->receiverPort << " " << thisDetector->stopPort << endl;
|
||||
cout << thisDetector->controlPort<< " " << thisDetector->receiverTCPPort << " " << thisDetector->stopPort << endl;
|
||||
#endif
|
||||
|
||||
|
||||
@ -4445,15 +4441,16 @@ int slsDetector::exitServer(){
|
||||
char* slsDetector::setNetworkParameter(networkParameter index, string value) {
|
||||
|
||||
switch (index) {
|
||||
case RECEIVER_IP:
|
||||
return setReceiverIP(value);
|
||||
break;
|
||||
case RECEIVER_MAC:
|
||||
return setReceiverMAC(value);
|
||||
break;
|
||||
case SERVER_MAC:
|
||||
return setServerMAC(value);
|
||||
break;
|
||||
case DETECTOR_MAC:
|
||||
return setDetectorMAC(value);
|
||||
case RECEIVER_HOSTNAME:
|
||||
return setReceiver(value);
|
||||
case RECEIVER_UDP_IP:
|
||||
setUDPConnection(value,"");
|
||||
return getReceiverUDPIP();
|
||||
case RECEIVER_UDP_PORT:
|
||||
setUDPConnection("",value);
|
||||
return getReceiverUDPPort();
|
||||
default:
|
||||
return ("unknown network parameter");
|
||||
}
|
||||
@ -4463,14 +4460,17 @@ char* slsDetector::setNetworkParameter(networkParameter index, string value) {
|
||||
char* slsDetector::getNetworkParameter(networkParameter index) {
|
||||
|
||||
switch (index) {
|
||||
case RECEIVER_IP:
|
||||
return getReceiverIP();
|
||||
case DETECTOR_MAC:
|
||||
return getDetectorMAC();
|
||||
break;
|
||||
case RECEIVER_MAC:
|
||||
return getReceiverMAC();
|
||||
case RECEIVER_HOSTNAME:
|
||||
return getReceiver();
|
||||
break;
|
||||
case SERVER_MAC:
|
||||
return getServerMAC();
|
||||
case RECEIVER_UDP_IP:
|
||||
return getReceiverUDPIP();
|
||||
break;
|
||||
case RECEIVER_UDP_PORT:
|
||||
return getReceiverUDPPort();
|
||||
break;
|
||||
default:
|
||||
return ("unknown network parameter");
|
||||
@ -4483,14 +4483,16 @@ char* slsDetector::getNetworkParameter(networkParameter index) {
|
||||
|
||||
|
||||
|
||||
char* slsDetector::setReceiverIP(string receiverIP){
|
||||
char* slsDetector::setReceiver(string receiverIP){
|
||||
|
||||
|
||||
int wrongFormat=1;
|
||||
|
||||
struct sockaddr_in sa;
|
||||
if(receiverIP.length()<16){
|
||||
int result = inet_pton(AF_INET, receiverIP.c_str(), &(sa.sin_addr));
|
||||
if(result!=0){
|
||||
sprintf(thisDetector->receiverIP,receiverIP.c_str());
|
||||
strcpy(thisDetector->receiver_hostname,receiverIP.c_str());
|
||||
wrongFormat=0;
|
||||
}
|
||||
}
|
||||
@ -4499,79 +4501,139 @@ char* slsDetector::setReceiverIP(string receiverIP){
|
||||
std::cout<< "IP Address should be VALID and in xxx.xxx.xxx.xxx format" << endl;
|
||||
else{
|
||||
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
|
||||
|
||||
setFilePath(fileIO::getFilePath());
|
||||
setFileName(fileIO::getFileName());
|
||||
setFileIndex(fileIO::getFileIndex());
|
||||
if(thisDetector->myDetectorType==GOTTHARD){
|
||||
if(configureMAC()!=OK){
|
||||
setReceiverOnline(OFFLINE_FLAG);
|
||||
std::cout << "could not configure mac" << endl;
|
||||
}
|
||||
}
|
||||
setUDPConnection("","");
|
||||
}else
|
||||
std::cout << "cannot connect to receiver" << endl;
|
||||
}
|
||||
|
||||
return thisDetector->receiverIP;
|
||||
return thisDetector->receiver_hostname;
|
||||
}
|
||||
|
||||
|
||||
char* slsDetector::setReceiverMAC(string receiverMAC){
|
||||
if(receiverMAC.length()==17){
|
||||
if((receiverMAC[2]==':')&&(receiverMAC[5]==':')&&(receiverMAC[8]==':')&&
|
||||
(receiverMAC[11]==':')&&(receiverMAC[14]==':'))
|
||||
sprintf(thisDetector->receiverMAC,receiverMAC.c_str());
|
||||
else
|
||||
return("MAC Address should be in xx:xx:xx:xx:xx:xx format");
|
||||
}
|
||||
else
|
||||
return("MAC Address should be in xx:xx:xx:xx:xx:xx format");
|
||||
|
||||
return thisDetector->receiverMAC;
|
||||
};
|
||||
|
||||
|
||||
char* slsDetector::setServerMAC(string serverMAC){
|
||||
if(serverMAC.length()==17){
|
||||
if((serverMAC[2]==':')&&(serverMAC[5]==':')&&(serverMAC[8]==':')&&
|
||||
(serverMAC[11]==':')&&(serverMAC[14]==':'))
|
||||
sprintf(thisDetector->serverMAC,serverMAC.c_str());
|
||||
char* slsDetector::setDetectorMAC(string detectorMAC){
|
||||
if(detectorMAC.length()==17){
|
||||
if((detectorMAC[2]==':')&&(detectorMAC[5]==':')&&(detectorMAC[8]==':')&&
|
||||
(detectorMAC[11]==':')&&(detectorMAC[14]==':'))
|
||||
strcpy(thisDetector->detectorMAC,detectorMAC.c_str());
|
||||
else
|
||||
return("server MAC Address should be in xx:xx:xx:xx:xx:xx format");
|
||||
}
|
||||
else
|
||||
return("server MAC Address should be in xx:xx:xx:xx:xx:xx format");
|
||||
|
||||
return thisDetector->serverMAC;
|
||||
return thisDetector->detectorMAC;
|
||||
};
|
||||
|
||||
|
||||
|
||||
int slsDetector::setUDPConnection(string udpip, string udpport){
|
||||
|
||||
int ret = FAIL;
|
||||
int fnum = F_SETUP_UDP;
|
||||
char args[2][MAX_STR_LENGTH];
|
||||
char retval[MAX_STR_LENGTH]="";
|
||||
struct sockaddr_in sa;
|
||||
|
||||
|
||||
|
||||
//if no udp ip given
|
||||
/*convert to IP if its only a hostname**/
|
||||
if(!strcmp(thisDetector->receiverUDPIP,"none"))
|
||||
strcpy(thisDetector->receiverUDPIP,thisDetector->receiver_hostname);
|
||||
|
||||
//copy to member if given in argument
|
||||
if(udpip.length()){
|
||||
if(udpip.length()<16){
|
||||
int result = inet_pton(AF_INET, udpip.c_str(), &(sa.sin_addr));
|
||||
if(result!=0)
|
||||
strcpy(thisDetector->receiverUDPIP,udpip.c_str());
|
||||
else{
|
||||
std::cout<< "Receiver UDP IP Address should be VALID and in xxx.xxx.xxx.xxx format" << endl;
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(udpport.length())
|
||||
sscanf(udpport.c_str(),"%d",&thisDetector->receiverUDPPort);
|
||||
|
||||
|
||||
//copy arguments to args[][]
|
||||
strcpy(args[0],thisDetector->receiverUDPIP);
|
||||
sprintf(args[1],"%d",thisDetector->receiverUDPPort);
|
||||
|
||||
|
||||
|
||||
|
||||
//set up receiver for UDP Connection and get receivermac address
|
||||
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Setting up UDP Connection for Receiver " << arg[0] << "\t" << arg[1] << std::endl;
|
||||
#endif
|
||||
ret=thisReceiver->sendUDPDetails(fnum,retval,args);
|
||||
|
||||
if(ret!=FAIL){
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Receiver mac address: " << retval << std::endl;
|
||||
#endif
|
||||
strcpy(thisDetector->receiverUDPMAC,retval);
|
||||
strcpy(thisDetector->receiverUDPIP,args[0]);
|
||||
sscanf(args[1],"%d",&thisDetector->receiverUDPPort);
|
||||
|
||||
|
||||
//configure detector with udp details
|
||||
if(configureMAC()!=OK){
|
||||
setReceiverOnline(OFFLINE_FLAG);
|
||||
std::cout << "could not configure mac" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
if(ret==FORCE_UPDATE)
|
||||
updateReceiver();
|
||||
}else{
|
||||
ret=FAIL;
|
||||
std::cout << "cannot connect to receiver" << endl;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int slsDetector::configureMAC(int adc){
|
||||
int i;
|
||||
int ret=FAIL;
|
||||
int fnum=F_CONFIGURE_MAC;
|
||||
char mess[100];
|
||||
char arg[3][50];
|
||||
char arg[4][50];
|
||||
char cword[50]="", *pcword;
|
||||
string sword;
|
||||
strcpy(arg[0],getReceiverIP());
|
||||
strcpy(arg[1],getReceiverMAC());
|
||||
strcpy(arg[2],getServerMAC());
|
||||
//if udpip wasnt initialized in config file
|
||||
if(!(strcmp(thisDetector->receiverUDPIP,"none")))
|
||||
strcpy(thisDetector->receiverUDPIP,thisDetector->receiver_hostname);
|
||||
strcpy(arg[0],thisDetector->receiverUDPIP);
|
||||
strcpy(arg[1],thisDetector->receiverUDPMAC);
|
||||
strcpy(arg[2],thisDetector->detectorMAC);
|
||||
sprintf(arg[3],"%x",thisDetector->receiverUDPPort);
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Configuring MAC with adc:"<< adc << std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
for(i=0;i<3;i++){
|
||||
if(!strcmp(arg[i],"none")){
|
||||
std::cout<< "Configure MAC Error. IP/MAC Addresses has INVALID format"<< std::endl;
|
||||
std::cout<< "Configure MAC Error. IP/MAC Addresses not set"<< std::endl;
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "IP/MAC Addresses in valid format "<< std::endl;
|
||||
std::cout<< "IP/MAC Addresses valid "<< std::endl;
|
||||
#endif
|
||||
|
||||
//converting IPaddress to hex.
|
||||
@ -4583,7 +4645,7 @@ int slsDetector::configureMAC(int adc){
|
||||
}
|
||||
strcpy(arg[0],cword);
|
||||
#ifdef VERBOSE
|
||||
std::cout<<"receiver ip:"<<arg[0]<<"."<<std::endl;
|
||||
std::cout<<"receiver udp ip:"<<arg[0]<<"."<<std::endl;
|
||||
#endif
|
||||
//converting MACaddress to hex.
|
||||
sword.assign(arg[1]);
|
||||
@ -4601,8 +4663,12 @@ int slsDetector::configureMAC(int adc){
|
||||
while(getline(ssstr,sword,':'))
|
||||
strcat(arg[2],sword.c_str());
|
||||
#ifdef VERBOSE
|
||||
std::cout<<"server mac:"<<arg[2]<<"."<<std::endl;
|
||||
std::cout<<"detecotor mac:"<<arg[2]<<"."<<std::endl;
|
||||
#endif
|
||||
#ifdef VERBOSE
|
||||
std::cout<<"receiver udp port:"<<arg[3]<<"."<<std::endl;
|
||||
#endif
|
||||
|
||||
//send to server
|
||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||
if (controlSocket) {
|
||||
@ -4968,7 +5034,7 @@ int slsDetector::writeConfigurationFile(ofstream &outfile, int id){
|
||||
slsDetectorCommand *cmd=new slsDetectorCommand(this);
|
||||
int nvar=15;
|
||||
|
||||
string names[]={ \
|
||||
string names[20]={ \
|
||||
"hostname", \
|
||||
"port", \
|
||||
"stopport", \
|
||||
@ -4987,26 +5053,27 @@ int slsDetector::writeConfigurationFile(ofstream &outfile, int id){
|
||||
|
||||
// to be added in the future
|
||||
// "trimen",
|
||||
// "receiverPort",
|
||||
// "receiverTCPPort",
|
||||
|
||||
if (thisDetector->myDetectorType==GOTTHARD) {
|
||||
names[0]= "hostname";
|
||||
names[1]= "port";
|
||||
names[2]= "stopport";
|
||||
names[3]= "receiverport";
|
||||
names[4]= "settingsdir";
|
||||
names[5]= "angdir";
|
||||
names[6]= "moveflag";
|
||||
names[7]= "lock";
|
||||
names[8]= "caldir";
|
||||
names[9]= "ffdir";
|
||||
names[10]= "extsig";
|
||||
names[11]="receivermac";
|
||||
names[12]="servermac";
|
||||
names[13]="receiverip";
|
||||
names[14]="outdir";
|
||||
names[15]="vhighvoltage";
|
||||
nvar=16;
|
||||
names[3]= "settingsdir";
|
||||
names[4]= "angdir";
|
||||
names[5]= "moveflag";
|
||||
names[6]= "lock";
|
||||
names[7]= "caldir";
|
||||
names[8]= "ffdir";
|
||||
names[9]= "extsig";
|
||||
names[10]="detectormac";
|
||||
names[11]= "rx_tcpport";
|
||||
names[12]= "rx_udpport";
|
||||
names[13]="rx_hostname";
|
||||
names[14]="rx_udpip";
|
||||
names[15]="outdir";
|
||||
names[16]="vhighvoltage";
|
||||
nvar=17;
|
||||
}
|
||||
|
||||
|
||||
@ -5281,7 +5348,7 @@ slsDetectorDefs::synchronizationMode slsDetector::setSynchronization(synchroniza
|
||||
int slsDetector::setReceiverOnline(int off) {
|
||||
// int prev = thisDetector->receiverOnlineFlag;
|
||||
if (off!=GET_ONLINE_FLAG) {
|
||||
if(strcmp(thisDetector->receiverIP,"none")){
|
||||
if(strcmp(thisDetector->receiver_hostname,"none")){
|
||||
thisDetector->receiverOnlineFlag=off;
|
||||
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG){
|
||||
setReceiverTCPSocket();
|
||||
@ -5302,7 +5369,7 @@ string slsDetector::checkReceiverOnline() {
|
||||
//this already sets the online/offline flag
|
||||
setReceiverTCPSocket();
|
||||
if(thisDetector->receiverOnlineFlag==OFFLINE_FLAG)
|
||||
return string(thisDetector->receiverIP);
|
||||
return string(thisDetector->receiver_hostname);
|
||||
else
|
||||
return string("");
|
||||
}
|
||||
@ -5345,27 +5412,27 @@ int slsDetector::setReceiverTCPSocket(string const name, int const receiver_port
|
||||
std::cout<< "setting receiver" << std::endl;
|
||||
#endif
|
||||
strcpy(thisName,name.c_str());
|
||||
strcpy(thisDetector->receiverIP,thisName);
|
||||
strcpy(thisDetector->receiver_hostname,thisName);
|
||||
if (dataSocket){
|
||||
delete dataSocket;
|
||||
dataSocket=NULL;
|
||||
}
|
||||
} else
|
||||
strcpy(thisName,thisDetector->receiverIP);
|
||||
strcpy(thisName,thisDetector->receiver_hostname);
|
||||
|
||||
//if receiverPort given
|
||||
//if receiverTCPPort given
|
||||
if (receiver_port>0) {
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "setting data port" << std::endl;
|
||||
#endif
|
||||
thisRP=receiver_port;
|
||||
thisDetector->receiverPort=thisRP;
|
||||
thisDetector->receiverTCPPort=thisRP;
|
||||
if (dataSocket){
|
||||
delete dataSocket;
|
||||
dataSocket=NULL;
|
||||
}
|
||||
} else
|
||||
thisRP=thisDetector->receiverPort;
|
||||
thisRP=thisDetector->receiverTCPPort;
|
||||
|
||||
//create data socket
|
||||
if (!dataSocket) {
|
||||
|
@ -81,8 +81,6 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
int controlPort;
|
||||
/** is the port used to stop the acquisition normally it should not be changed*/
|
||||
int stopPort;
|
||||
/** is the port used to communicate with the receiver*/
|
||||
int receiverPort;
|
||||
|
||||
/** detector type \ see :: detectorType*/
|
||||
detectorType myDetectorType;
|
||||
@ -232,14 +230,18 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
|
||||
|
||||
/* receiver*/
|
||||
|
||||
|
||||
/** ip address of the receiver **/
|
||||
char receiverIP[MAX_STR_LENGTH];
|
||||
/** mac address of the receiver **/
|
||||
char receiverMAC[MAX_STR_LENGTH];
|
||||
/** mac address of the server **/
|
||||
char serverMAC[MAX_STR_LENGTH];
|
||||
/** ip address/hostname of the receiver for the client to connect to**/
|
||||
char receiver_hostname[MAX_STR_LENGTH];
|
||||
/** is the port used to communicate between client and the receiver*/
|
||||
int receiverTCPPort;
|
||||
/** is the port used to communicate between detector and the receiver*/
|
||||
int receiverUDPPort;
|
||||
/** 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 **/
|
||||
char receiverUDPMAC[MAX_STR_LENGTH];
|
||||
/** mac address of the detector **/
|
||||
char detectorMAC[MAX_STR_LENGTH];
|
||||
/** online flag - is set if the receiver is connected, unset if socket connection is not possible */
|
||||
int receiverOnlineFlag;
|
||||
|
||||
@ -364,7 +366,7 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
/** returns the detector stop port \sa sharedSlsDetector */
|
||||
int getStopPort() {return thisDetector->stopPort;};
|
||||
/** returns the receiver port \sa sharedSlsDetector */
|
||||
int getReceiverPort() {return thisDetector->receiverPort;};
|
||||
int getReceiverPort() {return thisDetector->receiverTCPPort;};
|
||||
|
||||
/** Locks/Unlocks the connection to the server
|
||||
/param lock sets (1), usets (0), gets (-1) the lock
|
||||
@ -1614,19 +1616,22 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
|
||||
|
||||
|
||||
|
||||
/** returns the detector MAC address\sa sharedSlsDetector */
|
||||
char* getDetectorMAC() {return thisDetector->detectorMAC;};
|
||||
/** returns the receiver IP address \sa sharedSlsDetector */
|
||||
char* getReceiverIP() {return thisDetector->receiverIP;};
|
||||
/** returns the receiver MAC address \sa sharedSlsDetector */
|
||||
char* getReceiverMAC() {return thisDetector->receiverMAC;};
|
||||
/** returns the server MAC address\sa sharedSlsDetector */
|
||||
char* getServerMAC() {return thisDetector->serverMAC;};
|
||||
/** validates and sets the receiver IP address \sa sharedSlsDetector */
|
||||
char* setReceiverIP(string receiverIP);
|
||||
/** validates the format of receiver MAC address and sets it \sa sharedSlsDetector */
|
||||
char* setReceiverMAC(string receiverMAC);
|
||||
/** validates the format of server MAC address and sets it \sa sharedSlsDetector */
|
||||
char* setServerMAC(string serverMAC);
|
||||
char* getReceiver() {return thisDetector->receiver_hostname;};
|
||||
/** returns the receiver UDP IP address \sa sharedSlsDetector */
|
||||
char* getReceiverUDPIP() {return thisDetector->receiverUDPIP;};
|
||||
/** returns the receiver UDP IP address \sa sharedSlsDetector */
|
||||
char* getReceiverUDPPort() {char *c= new char[MAX_STR_LENGTH];sprintf(c,"%d",thisDetector->receiverUDPPort); return c;};
|
||||
|
||||
/** validates the format of detector MAC address and sets it \sa sharedSlsDetector */
|
||||
char* setDetectorMAC(string serverMAC);
|
||||
/** validates and sets the receiver IP address/hostname \sa sharedSlsDetector */
|
||||
char* setReceiver(string receiver);
|
||||
|
||||
/** Gets MAC from receiver and sets up UDP Connection */
|
||||
int setUDPConnection(string udpip, string udpport);
|
||||
|
||||
|
||||
};
|
||||
|
@ -321,15 +321,19 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
|
||||
/* communication configuration */
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="receiverip"; //
|
||||
descrToFuncMap[i].m_pFuncName="rx_hostname"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdNetworkParameter;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="receivermac"; //
|
||||
descrToFuncMap[i].m_pFuncName="rx_udpip"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdNetworkParameter;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="servermac"; //
|
||||
descrToFuncMap[i].m_pFuncName="rx_udpport"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdNetworkParameter;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="detectormac"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdNetworkParameter;
|
||||
i++;
|
||||
|
||||
@ -337,6 +341,10 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdConfigureMac;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="rx_tcpport"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPort;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="port"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPort;
|
||||
i++;
|
||||
@ -345,10 +353,6 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPort;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="receiverport"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPort;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="lock"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdLock;
|
||||
i++;
|
||||
@ -2218,17 +2222,22 @@ string slsDetectorCommand::helpScans(int narg, char *args[], int action) {
|
||||
string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int action) {
|
||||
|
||||
networkParameter t;
|
||||
|
||||
int i;
|
||||
if (action==HELP_ACTION)
|
||||
return helpNetworkParameter(narg,args,action);
|
||||
|
||||
if (cmd=="receiverip") {
|
||||
myDet->setOnline(ONLINE_FLAG);
|
||||
t=RECEIVER_IP;
|
||||
} else if (cmd=="receivermac") {
|
||||
t=RECEIVER_MAC;
|
||||
} else if (cmd=="servermac") {
|
||||
t=SERVER_MAC;
|
||||
myDet->setOnline(ONLINE_FLAG);
|
||||
|
||||
if (cmd=="detectormac") {
|
||||
t=DETECTOR_MAC;
|
||||
} else if (cmd=="rx_hostname") {
|
||||
t=RECEIVER_HOSTNAME;
|
||||
} else if (cmd=="rx_udpport") {
|
||||
t=RECEIVER_UDP_PORT;
|
||||
} else if (cmd=="rx_udpip") {
|
||||
t=RECEIVER_UDP_IP;
|
||||
if (!(sscanf(args[1],"%d",&i)))
|
||||
return ("cannot parse argument") + string(args[1]);
|
||||
} else return ("unknown network parameter")+cmd;
|
||||
|
||||
if (action==PUT_ACTION)
|
||||
@ -2244,15 +2253,16 @@ string slsDetectorCommand::helpNetworkParameter(int narg, char *args[], int acti
|
||||
|
||||
ostringstream os;
|
||||
if (action==PUT_ACTION || action==HELP_ACTION) {
|
||||
os << "receiverip ip \n sets receiver ip to ip"<< std::endl;
|
||||
os << "receivermac mac \n sets receiver mac to mac"<< std::endl;
|
||||
os << "servermac mac \n sets server mac to mac"<< std::endl;
|
||||
|
||||
os << "detectormac mac \n sets detector mac to mac"<< std::endl;
|
||||
os << "rx_hostname name \n sets receiver ip/hostname to name"<< std::endl;
|
||||
os << "rx_udpip ip \n sets receiver udp ip to ip"<< std::endl;
|
||||
os << "rx_udpport port \n sets receiver udp port to port"<< std::endl;
|
||||
}
|
||||
if (action==GET_ACTION || action==HELP_ACTION) {
|
||||
os << "receiverip \n gets receiver ip "<< std::endl;
|
||||
os << "receivermac \n gets receiver mac "<< std::endl;
|
||||
os << "servermac \n gets server mac "<< std::endl;
|
||||
os << "detectormac \n gets detector mac "<< std::endl;
|
||||
os << "rx_hostname \n gets receiver ip "<< std::endl;
|
||||
os << "rx_udpip \n gets receiver udp ip "<< std::endl;
|
||||
os << "rx_udpport \n gets receiver udp port "<< std::endl;
|
||||
}
|
||||
return os.str();
|
||||
|
||||
@ -2276,7 +2286,7 @@ string slsDetectorCommand::cmdPort(int narg, char *args[], int action) {
|
||||
|
||||
if (cmd=="port") {
|
||||
index=CONTROL_PORT;
|
||||
} else if (cmd=="receiverport") {
|
||||
} else if (cmd=="rx_tcpport") {
|
||||
index=DATA_PORT;
|
||||
} else if (cmd=="stopport") {
|
||||
index=STOP_PORT;
|
||||
@ -2300,13 +2310,13 @@ string slsDetectorCommand::helpPort(int narg, char *args[], int action) {
|
||||
ostringstream os;
|
||||
if (action==PUT_ACTION || action==HELP_ACTION) {
|
||||
os << "port i \n sets the communication control port"<< std::endl;
|
||||
os << "receiverport i \n sets the communication receiver port"<< std::endl;
|
||||
os << "rx_tcpport i \n sets the communication receiver port"<< std::endl;
|
||||
os << "stopport i \n sets the communication stop port "<< std::endl;
|
||||
|
||||
}
|
||||
if (action==GET_ACTION || action==HELP_ACTION) {
|
||||
os << "port \n gets the communication control port"<< std::endl;
|
||||
os << "receiverport \n gets the communication receiver port"<< std::endl;
|
||||
os << "rx_tcpport \n gets the communication receiver port"<< std::endl;
|
||||
os << "stopport \n gets the communication stop port "<< std::endl;
|
||||
}
|
||||
return os.str();
|
||||
|
Reference in New Issue
Block a user