This commit is contained in:
2019-08-07 15:23:58 +02:00
parent 615835f03d
commit 6a71e61c12
4 changed files with 125 additions and 18 deletions

View File

@ -124,6 +124,11 @@ class Detector {
void setPeriod(ns t, Positions pos = {}); void setPeriod(ns t, Positions pos = {});
// dhanya // dhanya
/**
* Get multidetector Id
* @returns multidetector Id
*/
int getMultiId() const;
/** /**
* Check version compatibility with detector software * Check version compatibility with detector software
@ -142,34 +147,67 @@ class Detector {
* @param pos detector position * @param pos detector position
* @returns detector firmware version * @returns detector firmware version
*/ */
int64_t getDetectorFirmwareVersion(Positions pos = {}) const; Result<int64_t> getDetectorFirmwareVersion(Positions pos = {}) const;
/** /**
* Get detector server version * Get detector server version
* @param pos detector position * @param pos detector position
* @returns detector server version * @returns detector server version
*/ */
int64_t getDetectorServerVersion(Positions pos = {}) const; Result<int64_t> getDetectorServerVersion(Positions pos = {}) const;
/** /**
* Get detector serial number * Get detector serial number
* @param pos detector position * @param pos detector position
* @returns detector serial number * @returns detector serial number
*/ */
int64_t getDetectorSerialNumber(Positions pos = {}) const; Result<int64_t> getDetectorSerialNumber(Positions pos = {}) const;
/** /**
* Get Client Software version * Get Client Software version
* @returns client software version * @returns client software version
*/ */
int64_t getClientSoftwareVersion() const; Result<int64_t> getClientSoftwareVersion() const;
/** /**
* Get Receiver software version * Get Receiver software version
* @param pos detector position * @param pos detector position
* @return receiver software version * @return receiver software version
*/ */
int64_t getReceiverSoftwareVersion(Positions pos = {}) const; Result<int64_t> getReceiverSoftwareVersion(Positions pos = {}) const;
/**
* Get user details of shared memory
* @returns string with user details
*/
std::string getUserDetails() const;
/**
* Frees shared memory and adds detectors to the list
* Also updates local detector cache
* @param name hostnames for the positions given
*/
void setHostname(const std::vector<std::string> &name);
/**
* Get Detector type as an enum
* @returns detector type
*/
detectorType Detector::getDetectorTypeAsEnum() const;
/**
* Get Detector type as an enum
* @param pos detector position
* @returns detector type
*/
Result<detectorType> getDetectorTypeAsEnum(Positions pos = {}) const;
/**
* Returns detector type as a string
* @param pos detector position
* @returns detector type as string
*/
Result<std::string> getDetectorTypeAsString(Positions pos = {});
}; };
} // namespace sls } // namespace sls

View File

@ -304,7 +304,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
*/ */
int64_t getId(idMode mode, int detPos = -1);//not needed anymore (later remove this_software_version from enum) int64_t getId(idMode mode, int detPos = -1);//not needed anymore (later remove this_software_version from enum)
int getMultiId()const{return multiId;} //public but part of multi int getMultiId()const{return multiId;} //part of multi also
/** /**
* Get Client Software version * Get Client Software version
@ -329,7 +329,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @param multiId multi detector Id * @param multiId multi detector Id
* @param detPos -1 for all detectors in list or specific detector position * @param detPos -1 for all detectors in list or specific detector position
*/ */
static void freeSharedMemory(int multiId, int detPos = -1);// static void freeSharedMemory(int multiId, int detPos = -1);// private or not needed
/** /**
* Free shared memory and delete shared memory structure * Free shared memory and delete shared memory structure
@ -338,21 +338,27 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* object back to state before object creation amap * object back to state before object creation amap
* @param detPos -1 for all detectors in list or specific detector position * @param detPos -1 for all detectors in list or specific detector position
*/ */
void freeSharedMemory(int detPos = -1); void freeSharedMemory(int detPos = -1);//
/** /**
* Get user details of shared memory * Get user details of shared memory
* @returns string with user details * @returns string with user details
*/ */
std::string getUserDetails(); std::string getUserDetails();// part of multi
/**
* Sets the hostname of all sls detectors in shared memory and updates local cache
* @param name hostname of all the sls detectors
*/
void setHostname(const std::vector<std::string> &name);//cannot set individually
/** /**
* Sets the hostname of all sls detectors in shared memory * Sets the hostname of all sls detectors in shared memory
* Connects to them * Connects to them
* @param name concatenated hostname of all the sls detectors * @param name concatenated hostname of all the sls detectors
* @param detPos -1 for all detectors in list or specific detector position * @param detPos -1 for all detectors in list or specific detector position
*/ */
void setHostname(const char *name, int detPos = -1); void setHostname(const char *name, int detPos = -1);// not needed
/** /**
* Gets the hostname of detector at particular position * Gets the hostname of detector at particular position
@ -369,7 +375,13 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @param name concatenated hostname of the sls detectors to be appended to * @param name concatenated hostname of the sls detectors to be appended to
* the list * the list
*/ */
void addMultipleDetectors(const char *name); void addMultipleDetectors(const char *name);// ????
/**
* Get Detector type as an enum
* @returns detector type
*/
detectorType getDetectorTypeAsEnum() const;
/** /**
* Get Detector type for a particular sls detector or get the first one * Get Detector type for a particular sls detector or get the first one
@ -377,7 +389,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @returns detector type of sls detector in position pos, if -1, returns * @returns detector type of sls detector in position pos, if -1, returns
* the first det type * the first det type
*/ */
detectorType getDetectorTypeAsEnum(int detPos = -1); detectorType getDetectorTypeAsEnum(int detPos);//??
/** /**
* Concatenates string types of all sls detectors or * Concatenates string types of all sls detectors or
@ -2335,6 +2347,9 @@ class multiSlsDetector : public virtual slsDetectorDefs {
/** Multi detector Id */ /** Multi detector Id */
const int multiId{0}; const int multiId{0};
/** multi detector type */
detectorType multiDetType;
/** Shared Memory object */ /** Shared Memory object */
sls::SharedMemory<sharedMultiSlsDetector> multi_shm{0, -1}; sls::SharedMemory<sharedMultiSlsDetector> multi_shm{0, -1};

View File

@ -121,11 +121,15 @@ Result<bool> Detector::getFileOverWrite(Positions pos) const {
} }
// dhanya // dhanya
Result<void> Detector::checkDetectorVersionCompatibility(Positions pos) const { int Detector::getMultiId() const {
pimpl->getMultiId());
}
void Detector::checkDetectorVersionCompatibility(Positions pos) const {
pimpl->Parallel(&slsDetector::checkDetectorVersionCompatibility, pos); pimpl->Parallel(&slsDetector::checkDetectorVersionCompatibility, pos);
} }
Result<void> Detector::checkReceiverVersionCompatibility(Positions pos) const { void Detector::checkReceiverVersionCompatibility(Positions pos) const {
pimpl->Parallel(&slsDetector::checkReceiverVersionCompatibility, pos); pimpl->Parallel(&slsDetector::checkReceiverVersionCompatibility, pos);
} }
@ -141,12 +145,31 @@ Result<int64_t> Detector::getDetectorSerialNumber(Positions pos) const {
return pimpl->Parallel(&slsDetector::getId, DETECTOR_SERIAL_NUMBER, pos); return pimpl->Parallel(&slsDetector::getId, DETECTOR_SERIAL_NUMBER, pos);
} }
Result<int64_t> Detector::getClientSoftwareVersion() const { Result<int64_t> Detector::getClientSoftwareVersion() const { return APILIB; }
return APILIB;
}
Result<int64_t> Detector::getReceiverSoftwareVersion(Positions pos) const { Result<int64_t> Detector::getReceiverSoftwareVersion(Positions pos) const {
return pimpl->Parallel(&slsDetector::getReceiverSoftwareVersion, pos); return pimpl->Parallel(&slsDetector::getReceiverSoftwareVersion, pos);
} }
std::string Detector::getUserDetails() const {
return pimpl->getUserDetails();
}
void Detector::setHostname(const std::vector<std::string> &name,
Positions pos) {
pimpl->setHostname(name);
}
detectorType Detector::getDetectorTypeAsEnum() const {
return pimpl->getDetectorTypeAsEnum();
}
Result<detectorType> Detector::getDetectorTypeAsEnum(Positions pos) const {
return pimpl->Parallel(&slsDetector::getDetectorTypeAsEnum, pos);
}
Result<std::string> Detector::getDetectorTypeAsString(Positions pos) const {
return pimpl->Parallel(&slsDetector::getDetectorTypeAsString, pos);
}
} // namespace sls } // namespace sls

View File

@ -30,7 +30,7 @@
using namespace sls; using namespace sls;
multiSlsDetector::multiSlsDetector(int multi_id, bool verify, bool update) multiSlsDetector::multiSlsDetector(int multi_id, bool verify, bool update)
: multiId(multi_id), multi_shm(multi_id, -1) { : multiId(multi_id), multiDetType(GENERIC), multi_shm(multi_id, -1) {
setupMultiDetector(verify, update); setupMultiDetector(verify, update);
} }
@ -332,6 +332,11 @@ void multiSlsDetector::initializeDetectorStructure() {
void multiSlsDetector::initializeMembers(bool verify) { void multiSlsDetector::initializeMembers(bool verify) {
// multiSlsDetector // multiSlsDetector
if (multi_shm()->numberOfDetectors == 0) {
multiDetType = GENERIC;
} else {
multiDetType = getDetectorTypeAsEnum();
}
zmqSocket.clear(); zmqSocket.clear();
// get objects from single det shared memory (open) // get objects from single det shared memory (open)
@ -385,6 +390,22 @@ std::string multiSlsDetector::exec(const char *cmd) {
return result; return result;
} }
void multiSlsDetector::setHostname(const std::vector<std::string> &name) {
// this check is there only to allow the previous detsizechan command
if (multi_shm()->numberOfDetectors != 0) {
FILE_LOG(logWARNING)
<< "There are already detector(s) in shared memory."
"Freeing Shared memory now.";
freeSharedMemory();
setupMultiDetector();
}
for (const auto &hostname : name) {
addSlsDetector(hostname);
}
updateOffsets();
}
void multiSlsDetector::setHostname(const char *name, int detPos) { void multiSlsDetector::setHostname(const char *name, int detPos) {
// single // single
if (detPos >= 0) { if (detPos >= 0) {
@ -461,6 +482,10 @@ void multiSlsDetector::addSlsDetector(std::unique_ptr<slsDetector> det) {
detectors.back()->getTotalNumberOfChannels(); detectors.back()->getTotalNumberOfChannels();
} }
slsDetectorDefs::detectorType multiSlsDetector::getDetectorTypeAsEnum() const {
return multiDetType;
}
slsDetectorDefs::detectorType slsDetectorDefs::detectorType
multiSlsDetector::getDetectorTypeAsEnum(int detPos) { multiSlsDetector::getDetectorTypeAsEnum(int detPos) {
// single // single
@ -842,6 +867,12 @@ void multiSlsDetector::readConfigurationFile(const std::string &fname) {
} }
} }
input_file.close(); input_file.close();
if (multi_shm()->numberOfDetectors == 0) {
multiDetType = GENERIC;
} else {
multiDetType = getDetectorTypeAsEnum();
}
} }
int multiSlsDetector::writeConfigurationFile(const std::string &fname) { int multiSlsDetector::writeConfigurationFile(const std::string &fname) {