new getDetectorType functions

This commit is contained in:
Erik Frojdh
2019-01-18 10:53:49 +01:00
parent 13d6d3f866
commit 10539f8533
10 changed files with 74 additions and 95 deletions

View File

@ -49,7 +49,7 @@ slsDetector::slsDetector(int multiId, int id, bool verify)
/* called from multi constructor to populate structure,
* so sls shared memory will be opened, not created */
// getDetectorType Froom shm will check if it was already existing
// getDetectorType From shm will check if it was already existing
detectorType type = getDetectorTypeFromShm(multiId, verify);
initSharedMemory(false, type, multiId, verify);
@ -752,16 +752,16 @@ slsDetectorDefs::detectorType slsDetector::getDetectorTypeFromShm(int multiId, b
// static function
slsDetectorDefs::detectorType slsDetector::getDetectorType(const char *name, int cport) {
slsDetectorDefs::detectorType slsDetector::getDetectorTypeAsEnum(const std::string& hostname, int cport) {
int fnum = F_GET_DETECTOR_TYPE;
int ret = FAIL;
detectorType retval = GENERIC;
MySocketTCP* mySocket = nullptr;
try {
mySocket = new MySocketTCP(name, cport);
mySocket = new MySocketTCP(hostname.c_str(), cport);
} catch(...) {
FILE_LOG(logERROR) << "Cannot create socket to control server " << name
FILE_LOG(logERROR) << "Cannot create socket to control server " << hostname
<< " over port " << cport;
return retval;
}
@ -773,7 +773,7 @@ slsDetectorDefs::detectorType slsDetector::getDetectorType(const char *name, int
mySocket->ReceiveDataOnly(&retval,sizeof(retval));
mySocket->Disconnect();
} else {
FILE_LOG(logERROR) << "Cannot connect to server " << name << " over port " << cport;
FILE_LOG(logERROR) << "Cannot connect to server " << hostname << " over port " << cport;
}
if (ret != FAIL) {
FILE_LOG(logDEBUG1) << "Detector type is " << retval;
@ -838,23 +838,20 @@ int slsDetector::setDetectorType(detectorType const type) {
int slsDetector::setDetectorType(const std::string& detector_type) {
return setDetectorType(getDetectorType(detector_type));
}
// int slsDetector::setDetectorType(const std::string& detector_type) {
// return setDetectorType(getDetectorType(detector_type));
// }
slsDetectorDefs::detectorType slsDetector::getDetectorsType() {
slsDetectorDefs::detectorType slsDetector::getDetectorTypeAsEnum() {
return thisDetector->myDetectorType;
}
std::string slsDetector::sgetDetectorsType() {
return getDetectorType(getDetectorsType());
std::string slsDetector::getDetectorTypeAsString() {
return slsDetectorDefs::detectorTypeToString(getDetectorTypeAsEnum());
}
std::string slsDetector::getDetectorType() {
return sgetDetectorsType();
}
int slsDetector::getTotalNumberOfChannels() {
@ -2697,7 +2694,7 @@ std::string slsDetector::setReceiver(const std::string& receiverIP) {
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) {
FILE_LOG(logDEBUG1) <<
"detector type:" << (slsDetectorDefs::getDetectorType(thisDetector->myDetectorType)) <<
"detector type:" << (slsDetectorDefs::detectorTypeToString(thisDetector->myDetectorType)) <<
"\ndetector id:" << detId <<
"\ndetector hostname:" << thisDetector->hostname <<
"\nfile path:" << thisDetector->receiver_filePath <<

View File

@ -373,7 +373,6 @@ public:
*/
void disconnectStop();
using slsDetectorDefs::getDetectorType;
/**
* Get detector type by connecting to the detector without creating an object
@ -381,7 +380,19 @@ public:
* @param cport TCP control port
* @returns detector tpe or GENERIC if failed
*/
static detectorType getDetectorType(const char *name, int cport=DEFAULT_PORTNO);
static detectorType getDetectorTypeAsEnum(const std::string& hostname, int cport=DEFAULT_PORTNO);
/**
* Get Detector type from shared memory variable
* @returns detector type from shared memory variable
*/
detectorType getDetectorTypeAsEnum();
/**
* Gets string version of detector type from shared memory variable
* @returns string version of detector type from shared memory variable
*/
std::string getDetectorTypeAsString();
/**
* Gets detector type from detector and set it in receiver
@ -394,27 +405,8 @@ public:
* Gets detector type (string) from detector and set it in receiver
* @param type string of detector type
* @returns detector type in receiver
*/
int setDetectorType(const std::string& detector_type);
/**
* Get Detector type from shared memory variable
* @returns detector type from shared memory variable
*/
detectorType getDetectorsType();
/**
* Gets string version of detector type from shared memory variable
* @returns string version of detector type from shared memory variable
*/
std::string sgetDetectorsType();
/**
* Just to overload getDetectorType from users
* Gets string version of detector type from shared memory variable
* @returns gets string version of detector type from shared memory variable
*/
std::string getDetectorType();
// */
// int setDetectorType(const std::string& detector_type);
/**
* Returns the total number of channels from shared memory
@ -1805,7 +1797,7 @@ private:
/** pointer to dac valuse in shared memory */
int *dacs {nullptr};
/** pointer to channal registers in shared memory */
/** pointer to channel registers in shared memory */
int *chanregs {nullptr};
};

View File

@ -3295,7 +3295,7 @@ std::string slsDetectorCommand::cmdSettings(int narg, char *args[], int action,
if (sett == -1)
return std::string("unknown settings scanned " + std::string(args[1]));
sett = myDet->setSettings(sett, detPos);
if (myDet->getDetectorsType(detPos) == EIGER) {
if (myDet->getDetectorTypeAsEnum(detPos) == EIGER) {
return myDet->getDetectorSettings(sett);
}
}
@ -3305,7 +3305,7 @@ std::string slsDetectorCommand::cmdSettings(int narg, char *args[], int action,
if (!sscanf(args[1], "%d", &val)) {
return std::string("invalid threshold value");
}
detectorType type = myDet->getDetectorsType(detPos);
detectorType type = myDet->getDetectorTypeAsEnum(detPos);
if (type != EIGER || (type == EIGER && narg <= 2)) {
myDet->setThresholdEnergy(val, GET_SETTINGS, 1, detPos);
} else {
@ -3322,7 +3322,7 @@ std::string slsDetectorCommand::cmdSettings(int narg, char *args[], int action,
if (!sscanf(args[1], "%d", &val)) {
return std::string("invalid threshold value");
}
detectorType type = myDet->getDetectorsType(detPos);
detectorType type = myDet->getDetectorTypeAsEnum(detPos);
if (type != EIGER)
return std::string("not implemented for this detector");
if (narg <= 2) {
@ -4049,7 +4049,7 @@ std::string slsDetectorCommand::cmdADC(int narg, char *args[], int action, int d
return std::string("cannot decode adc ") + cmd;
myDet->setOnline(ONLINE_FLAG, detPos);
if (myDet->getDetectorsType(detPos) == EIGER || myDet->getDetectorsType(detPos) == JUNGFRAU) {
if (myDet->getDetectorTypeAsEnum(detPos) == EIGER || myDet->getDetectorTypeAsEnum(detPos) == JUNGFRAU) {
int val = myDet->getADC(adc, detPos);
if (val == -1)
sprintf(answer, "%d", val);
@ -4106,7 +4106,7 @@ std::string slsDetectorCommand::cmdADC(int narg, char *args[], int action, int d
return std::string("cannot decode adc ")+cmd;
myDet->setOnline(ONLINE_FLAG, detPos);
if (myDet->getDetectorsType(detPos) == EIGER || myDet->getDetectorsType(detPos) == JUNGFRAU){
if (myDet->getDetectorTypeAsEnum(detPos) == EIGER || myDet->getDetectorTypeAsEnum(detPos) == JUNGFRAU){
int val = myDet->getADC(adc, detPos);
if (val == -1)
sprintf(answer,"%d",val);

View File

@ -6,7 +6,7 @@
int slsDetectorUsers::getNumberOfDetectors() {
int slsDetectorUsers::getNumberOfDetectors() const {
return detector.getNumberOfDetectors();
}
@ -30,7 +30,7 @@ int slsDetectorUsers::getDetectorSize(int &x, int &y, int &nx, int &ny, int detP
}
std::string slsDetectorUsers::getDetectorType(int detPos){
return detector.sgetDetectorsType(detPos);
return detector.getDetectorTypeAsString(detPos);
}
int slsDetectorUsers::setOnline(int const online, int detPos){
return detector.setOnline(online, detPos);

View File

@ -100,7 +100,7 @@ public:
* Returns the number of detectors in the multidetector structure
* @returns number of detectors
*/
int getNumberOfDetectors();
int getNumberOfDetectors() const;
/**
* Returns the maximum number of channels of all detectors
@ -215,14 +215,14 @@ public:
/**
* Check Detector Version Compatibility
* @param detPos -1 for all detectors in list or specific detector position
* @returns true if compatibile, else false
* @returns true if compatible, else false
*/
bool isDetectorVersionCompatible(int detPos = -1);
/**
* Check Receiver Version Compatibility
* @param detPos -1 for all detectors in list or specific detector position
* @returns true if compatibile, else false
* @returns true if compatible, else false
*/
bool isReceiverVersionCompatible(int detPos = -1);
@ -761,7 +761,7 @@ public:
*********************************************************************/
/**
* register calbback for accessing detector final data in client,
* register callback for accessing detector final data in client,
* also enables data streaming in client and receiver
* @param userCallback function for plotting/analyzing the data.
* Its arguments are