changes which commented out virtual for child functions and some other changes for configuremac and setclientip and setclientmac

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@96 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d 2012-01-13 09:44:04 +00:00
parent c50716f623
commit 19f7712e65
2 changed files with 142 additions and 68 deletions

View File

@ -2844,7 +2844,6 @@ int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isetti
detectorSettings slsDetector::setSettings( detectorSettings isettings, int imod){ detectorSettings slsDetector::setSettings( detectorSettings isettings, int imod){
std::cout<<"dfgfdgdgdf"<<endl;
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "slsDetector setSettings "<< std::endl; std::cout<< "slsDetector setSettings "<< std::endl;
#endif #endif
@ -2978,7 +2977,12 @@ int slsDetector::updateDetectorNoWait() {
int64_t retval, tns=-1; int64_t retval, tns=-1;
char lastClientIP[INET_ADDRSTRLEN]; char lastClientIP[INET_ADDRSTRLEN];
switch(thisDetector->myDetectorType){
case GOTTHARD:
n = controlSocket->ReceiveDataOnly(lastClientIP,sizeof(lastClientIP));
cout << "Updating detector last modified by " << lastClientIP << endl;
break;
default:
n = controlSocket->ReceiveDataOnly(lastClientIP,sizeof(lastClientIP)); n = controlSocket->ReceiveDataOnly(lastClientIP,sizeof(lastClientIP));
cout << "Updating detector last modified by " << lastClientIP << endl; cout << "Updating detector last modified by " << lastClientIP << endl;
@ -3021,7 +3025,7 @@ int slsDetector::updateDetectorNoWait() {
//retval=setTrains(tns); //retval=setTrains(tns);
n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
thisDetector->timerValue[CYCLES_NUMBER]=retval; thisDetector->timerValue[CYCLES_NUMBER]=retval;
}
return OK; return OK;
} }
@ -5068,9 +5072,10 @@ int slsDetector::getScanPrecision(int iscan){
char* slsDetector::setClientIP(string clientIP){ char* slsDetector::setClientIP(string clientIP){
int wrongFormat=1; int wrongFormat=1;
struct sockaddr_in sa; struct sockaddr_in sa;
if(clientIP.length()==15){ if(clientIP.length()<16){
if((clientIP[3]==':')&&(clientIP[7]==':')&&(clientIP[11]==':')){ if((clientIP[3]=='.')&&(clientIP[7]=='.')&&(clientIP[11]=='.')){
int result = inet_pton(AF_INET, clientIP.c_str(), &(sa.sin_addr)); int result = inet_pton(AF_INET, clientIP.c_str(), &(sa.sin_addr));
if(result!=0){ if(result!=0){
sprintf(thisDetector->clientIP,clientIP.c_str()); sprintf(thisDetector->clientIP,clientIP.c_str());
@ -5103,14 +5108,72 @@ char* slsDetector::setClientMAC(string clientMAC){
int slsDetector::configureMAC(){ int slsDetector::configureMAC(){
if(!strcmp(getClientIP(),"none")) int retval;
return -1; int ret=FAIL;
else if(!strcmp(getClientMAC(),"none")) int fnum=F_CONFIGURE_MAC;
return -1; char mess[100];
char arg[2][50];
char cword[50]="", *pcword;
string sword;
strcpy(arg[0],getClientIP());
strcpy(arg[1],getClientMAC());
cout<<"\n\ndfgfdgklfdhgldf\n\n\n";
return 0; #ifdef VERBOSE
std::cout<< "slsDetector configureMAC "<< std::endl;
#endif
if(!strcmp(arg[0],"none"))
return -1;
else if(!strcmp(arg[1],"none"))
return -1;
#ifdef VERBOSE
std::cout<< "IP/MAC Addresses in valid format "<< std::endl;
#endif
//converting IPaddress to hex.
pcword = strtok (arg[0],".");
while (pcword != NULL) {
sprintf(arg[0],"%02x",atoi(pcword));
strcat(cword,arg[0]);
pcword = strtok (NULL, ".");
}
strcpy(arg[0],cword);
std::cout<<"arg0:"<<arg[0]<<"."<<std::endl;
//converting MACaddress to hex.
sword.assign(arg[1]);
strcpy(arg[1],"");
stringstream sstr(sword);
while(getline(sstr,sword,':'))
strcat(arg[1],sword.c_str());
std::cout<<"arg1:"<<arg[1]<<"."<<std::endl;
//send to server
if (thisDetector->onlineFlag==ONLINE_FLAG) {
if (controlSocket) {
if (controlSocket->Connect()>=0) {
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
controlSocket->SendDataOnly(arg,sizeof(arg));
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret!=FAIL)
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
else {
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
}
controlSocket->Disconnect();
if (ret==FORCE_UPDATE)
updateDetector();
}
}
}
#ifdef VERBOSE
std::cout<< "Configuring MAC - returned "<< retval << std::endl;
#endif
if (ret==FAIL) {
std::cout<< "Configuring MAC failed " << std::endl;
}
return retval;
} }
@ -8155,7 +8218,7 @@ int slsDetector::retrieveDetectorSetup(string fname1, int level){
#endif #endif
myfname=fname; myfname=fname;
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "trim file name is "<< myfname << std::endl; std::cout<< "file name is "<< myfname << std::endl;
#endif #endif
infile.open(myfname.c_str(), ios_base::in); infile.open(myfname.c_str(), ios_base::in);
if (infile.is_open()) { if (infile.is_open()) {
@ -8288,7 +8351,7 @@ int slsDetector::retrieveDetectorSetup(string fname1, int level){
strcpy(thisDetector->settingsFile,fname.c_str()); strcpy(thisDetector->settingsFile,fname.c_str());
return myMod; return myMod;
} else { } else {
std::cout<< "could not open trim file " << myfname << std::endl; std::cout<< "could not open settings file " << myfname << std::endl;
if (nflag) if (nflag)
deleteModule(myMod); deleteModule(myMod);

View File

@ -341,8 +341,8 @@ typedef struct sharedSlsDetector {
//slsDetector(string const fname); //slsDetector(string const fname);
// ~slsDetector(){while(dataQueue.size()>0){}}; // ~slsDetector(){while(dataQueue.size()>0){}};
/** destructor */ /** destructor */
virtual ~slsDetector();//{ disconnect_channels();}; ~slsDetector();//{ disconnect_channels();};
//virtual ~slsDetector();//{ disconnect_channels();};
/** sets the onlineFlag /** sets the onlineFlag
\param off can be: <BR> GET_ONLINE_FLAG, returns wether the detector is in online or offline state;<BR> OFFLINE_FLAG, detector in offline state (i.e. no communication to the detector - using only local structure - no data acquisition possible!);<BR> ONLINE_FLAG detector in online state (i.e. communication to the detector updating the local structure) */ \param off can be: <BR> GET_ONLINE_FLAG, returns wether the detector is in online or offline state;<BR> OFFLINE_FLAG, detector in offline state (i.e. no communication to the detector - using only local structure - no data acquisition possible!);<BR> ONLINE_FLAG detector in online state (i.e. communication to the detector updating the local structure) */
@ -370,15 +370,15 @@ typedef struct sharedSlsDetector {
Should be implemented in the specific detector class Should be implemented in the specific detector class
/sa mythenDetector::readConfigurationFile /sa mythenDetector::readConfigurationFile
*/ */
int readConfigurationFile(string const fname);
virtual int readConfigurationFile(string const fname); // virtual int readConfigurationFile(string const fname);
/** /**
Purely virtual function Purely virtual function
Should be implemented in the specific detector class Should be implemented in the specific detector class
/sa mythenDetector::writeConfigurationFile /sa mythenDetector::writeConfigurationFile
*/ */
virtual int writeConfigurationFile(string const fname); int writeConfigurationFile(string const fname);
//virtual int writeConfigurationFile(string const fname);
/* /*
It should be possible to dump all the settings of the detector (including trimbits, threshold energy, gating/triggering, acquisition time etc. It should be possible to dump all the settings of the detector (including trimbits, threshold energy, gating/triggering, acquisition time etc.
in a file and retrieve it for repeating the measurement with identicals ettings, if necessary in a file and retrieve it for repeating the measurement with identicals ettings, if necessary
@ -389,14 +389,15 @@ typedef struct sharedSlsDetector {
Should be implemented in the specific detector class Should be implemented in the specific detector class
/sa mythenDetector::dumpDetectorSetup /sa mythenDetector::dumpDetectorSetup
*/ */
virtual int dumpDetectorSetup(string const fname, int level=0); int dumpDetectorSetup(string const fname, int level=0);
//virtual int dumpDetectorSetup(string const fname, int level=0);
/** /**
Purely virtual function Purely virtual function
Should be implemented in the specific detector class Should be implemented in the specific detector class
/sa mythenDetector::retrieveDetectorSetup /sa mythenDetector::retrieveDetectorSetup
*/ */
virtual int retrieveDetectorSetup(string const fname, int level=0); int retrieveDetectorSetup(string const fname, int level=0);
//virtual int retrieveDetectorSetup(string const fname, int level=0);
/** /**
configure the socket communication and initializes the socket instances configure the socket communication and initializes the socket instances
@ -498,7 +499,8 @@ typedef struct sharedSlsDetector {
\sa mythenDetector::readSettingsFile \sa mythenDetector::readSettingsFile
*/ */
virtual sls_detector_module* readSettingsFile(string fname, sls_detector_module* myMod=NULL); sls_detector_module* readSettingsFile(string fname, sls_detector_module* myMod=NULL);
//virtual sls_detector_module* readSettingsFile(string fname, sls_detector_module* myMod=NULL);
/** /**
Pure virtual function Pure virtual function
@ -509,7 +511,8 @@ typedef struct sharedSlsDetector {
\sa ::sls_detector_module mythenDetector::writeSettingsFile(string, sls_detector_module) \sa ::sls_detector_module mythenDetector::writeSettingsFile(string, sls_detector_module)
*/ */
virtual int writeSettingsFile(string fname, sls_detector_module mod); int writeSettingsFile(string fname, sls_detector_module mod);
//virtual int writeSettingsFile(string fname, sls_detector_module mod);
/** /**
Pure virtual function Pure virtual function
@ -519,7 +522,8 @@ typedef struct sharedSlsDetector {
\returns OK or FAIL if the file could not be written \returns OK or FAIL if the file could not be written
\sa ::sls_detector_module sharedSlsDetector mythenDetector::writeSettingsFile(string, int) \sa ::sls_detector_module sharedSlsDetector mythenDetector::writeSettingsFile(string, int)
*/ */
virtual int writeSettingsFile(string fname, int imod); int writeSettingsFile(string fname, int imod);
//virtual int writeSettingsFile(string fname, int imod);
/** /**
@ -719,7 +723,9 @@ typedef struct sharedSlsDetector {
\offset reference to the offset variable \offset reference to the offset variable
\sa sharedSlsDetector mythenDetector::readCalibrationFile \sa sharedSlsDetector mythenDetector::readCalibrationFile
*/ */
virtual int readCalibrationFile(string fname, float &gain, float &offset); int readCalibrationFile(string fname, float &gain, float &offset);
//virtual int readCalibrationFile(string fname, float &gain, float &offset);
/** /**
writes a calibration file writes a calibration file
@ -728,7 +734,8 @@ typedef struct sharedSlsDetector {
\param offset \param offset
\sa sharedSlsDetector mythenDetector::writeCalibrationFile \sa sharedSlsDetector mythenDetector::writeCalibrationFile
*/ */
virtual int writeCalibrationFile(string fname, float gain, float offset); int writeCalibrationFile(string fname, float gain, float offset);
//virtual int writeCalibrationFile(string fname, float gain, float offset);
/** /**
@ -999,7 +1006,8 @@ typedef struct sharedSlsDetector {
\returns current register value \returns current register value
\sa ::sls_detector_module \sa ::sls_detector_module
*/ */
virtual int setModule(int reg, int imod=-1); int setModule(int reg, int imod=-1);
//virtual int setModule(int reg, int imod=-1);
/** /**
configure chip configure chip
@ -1007,14 +1015,16 @@ typedef struct sharedSlsDetector {
\returns current register value \returns current register value
\sa ::sls_detector_module \sa ::sls_detector_module
*/ */
virtual int setModule(sls_detector_module module); int setModule(sls_detector_module module);
//virtual int setModule(sls_detector_module module);
/** /**
get module get module
\param imod module number \param imod module number
\returns pointer to module structure (which has bee created and must then be deleted) \returns pointer to module structure (which has bee created and must then be deleted)
*/ */
virtual sls_detector_module *getModule(int imod); sls_detector_module *getModule(int imod);
//virtual sls_detector_module *getModule(int imod);
// calibration functions // calibration functions
// int setCalibration(int imod, detectorSettings isettings, float gain, float offset); // int setCalibration(int imod, detectorSettings isettings, float gain, float offset);
@ -1055,7 +1065,8 @@ typedef struct sharedSlsDetector {
in this function trimbits/settings and calibration files are searched in the settingsDir and calDir directories and the detector is initialized in this function trimbits/settings and calibration files are searched in the settingsDir and calDir directories and the detector is initialized
*/ */
virtual detectorSettings setSettings(detectorSettings isettings, int imod=-1); detectorSettings setSettings(detectorSettings isettings, int imod=-1);
//virtual detectorSettings setSettings(detectorSettings isettings, int imod=-1);
/** /**