diff --git a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer index 4e842b523..b7aa41052 100755 Binary files a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer and b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer differ diff --git a/slsDetectorSoftware/include/multiSlsDetector.h b/slsDetectorSoftware/include/multiSlsDetector.h index 9813dbb33..a66abfa57 100755 --- a/slsDetectorSoftware/include/multiSlsDetector.h +++ b/slsDetectorSoftware/include/multiSlsDetector.h @@ -306,6 +306,13 @@ class multiSlsDetector : public virtual slsDetectorDefs { */ std::string getUserDetails(); // part of multi + /** + * Connect to Virtual Detector Servers at local host + * @param ndet number of detectors + * @param port starting port number + */ + void setVirtualDetectorServers(const int numdet, const int port); + /** * Sets the hostname of all sls detectors in shared memory and updates local * cache diff --git a/slsDetectorSoftware/src/multiSlsDetector.cpp b/slsDetectorSoftware/src/multiSlsDetector.cpp index 2564dd221..0f3c801fa 100755 --- a/slsDetectorSoftware/src/multiSlsDetector.cpp +++ b/slsDetectorSoftware/src/multiSlsDetector.cpp @@ -351,6 +351,15 @@ std::string multiSlsDetector::exec(const char *cmd) { return result; } +void multiSlsDetector::setVirtualDetectorServers(const int numdet, const int port) { + std::vector hostnames; + for (int i = 0; i < numdet; ++i) { + // * 2 is for control and stop port + hostnames.push_back(std::string("localhost:") + std::to_string(port + i * 2)); + } + setHostname(hostnames); +} + void multiSlsDetector::setHostname(const std::vector &name) { // this check is there only to allow the previous detsizechan command if (multi_shm()->numberOfDetectors != 0) { @@ -363,6 +372,7 @@ void multiSlsDetector::setHostname(const std::vector &name) { for (const auto &hostname : name) { addSlsDetector(hostname); } + updateDetectorSize(); } void multiSlsDetector::setHostname(const char *name, int detPos) { @@ -392,7 +402,7 @@ std::string multiSlsDetector::getHostname(int detPos) const { // multi auto r = serialCall(&slsDetector::getHostname); - return sls::concatenateIfDifferent(r); + return sls::concatenateNonEmptyStrings(r); } void multiSlsDetector::addMultipleDetectors(const char *name) { diff --git a/slsDetectorSoftware/src/slsDetectorCommand.cpp b/slsDetectorSoftware/src/slsDetectorCommand.cpp index 615a6cefa..cc3ac0423 100755 --- a/slsDetectorSoftware/src/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/src/slsDetectorCommand.cpp @@ -268,6 +268,14 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) { descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdHostname; ++i; + /*! \page config + - virtual [n] [p] \c connects to n virtual detector servers at local host starting at port p \c Returns the list of the hostnames of the multi-detector structure. \c (string) + */ + descrToFuncMap[i].m_pFuncName = "virtual"; + descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdHostname; + ++i; + + /*! \page config - user \c Returns user details from shared memory. Only allowed at multi detector level. Cannot put. \c (string) */ @@ -2345,7 +2353,7 @@ std::string slsDetectorCommand::cmdHostname(int narg, const char * const args[], if (action == PUT_ACTION) { if (detPos >= 0) { - return std::string("Wrong usage - setting hostname/add only from " + return std::string("Wrong usage - setting hostname/virtual only from " "multiDetector level"); } @@ -2357,10 +2365,23 @@ std::string slsDetectorCommand::cmdHostname(int narg, const char * const args[], if (narg > 2) strcat(hostname, "+"); } - - myDet->setHostname(hostname, detPos); + if (cmd == "hostname") { + myDet->setHostname(hostname, detPos); + } + else if (cmd == "virtual") { + int port = -1; + int numDetectors = 0; + if (!sscanf(args[1], "%d", &numDetectors)) { + throw sls::RuntimeError("Cannot scan number of detector servers from virtual command\n"); + } + if (!sscanf(args[2], "%d", &port)) { + throw sls::RuntimeError("Cannot scan port from virtual command\n"); + } + myDet->setVirtualDetectorServers(numDetectors, port); + } else { + throw sls::RuntimeError("unknown command\n"); + } } - return myDet->getHostname(detPos); } @@ -2372,6 +2393,7 @@ std::string slsDetectorCommand::helpHostname(int action) { if (action == PUT_ACTION || action == HELP_ACTION) { os << std::string("hostname name [name name]\t frees shared memory and " "sets the hostname (or IP adress). Only allowed at multi detector level.\n"); + os << std::string("virtual [n] [p]\t connects to n virtual detector servers at local host starting at port p \n"); } return os.str(); }