diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index c0484413f..0c88d4852 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -1265,6 +1265,12 @@ class Detector { /** [Gotthard][Jungfrau][CTB] not possible to read back*/ void writeAdcRegister(uint32_t addr, uint32_t value, Positions pos = {}); + bool getInitialChecks() const; + + /** initial compaibility and other server start up checks + * default enabled */ + void setInitialChecks(const bool value); + /************************************************** * * * Insignificant * diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index cf9ae2231..c2520215c 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -1978,6 +1978,39 @@ std::string CmdProxy::BitOperations(int action) { return os.str(); } +std::string CmdProxy::InitialChecks(int action) { + std::ostringstream os; + os << cmd << ' '; + if (action == defs::HELP_ACTION) { + os << "[0, 1]\n\tEnable or disable intial compatibility and other checks at detector start up. It is enabled by default. Must come before 'hostname' command to take effect. Can be used to reprogram fpga when current firmware is incompatible." + << '\n'; + } else if (action == defs::GET_ACTION) { + if (det_id != -1) { + throw sls::RuntimeError( + "Cannot enable/disable initial checks at module level"); + } + if (!args.empty()) { + WrongNumberOfParameters(0); + } + auto t = det->getInitialChecks(); + os << t << '\n'; + } else if (action == defs::PUT_ACTION) { + if (det_id != -1) { + throw sls::RuntimeError( + "Cannot get initial checks enable at module level"); + } + if (args.size() != 1) { + WrongNumberOfParameters(1); + } + det->setInitialChecks(std::stoi(args[0])); + os << args.front() << '\n'; + } else { + throw sls::RuntimeError("Unknown action"); + } + return os.str(); +} + + /* Insignificant */ std::string CmdProxy::ExecuteCommand(int action) { diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index 84068708a..12a7d1c18 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -876,6 +876,7 @@ class CmdProxy { {"getbit", &CmdProxy::BitOperations}, {"firmwaretest", &CmdProxy::firmwaretest}, {"bustest", &CmdProxy::bustest}, + {"initialchecks", &CmdProxy::InitialChecks}, /* Insignificant */ {"port", &CmdProxy::port}, @@ -973,6 +974,7 @@ class CmdProxy { std::string Register(int action); std::string AdcRegister(int action); std::string BitOperations(int action); + std::string InitialChecks(int action); /* Insignificant */ std::string ExecuteCommand(int action); std::string UserDetails(int action); diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index da85cccbf..261c10366 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -1707,6 +1707,14 @@ void Detector::writeAdcRegister(uint32_t addr, uint32_t value, Positions pos) { pimpl->Parallel(&slsDetector::writeAdcRegister, pos, addr, value); } +bool Detector::getInitialChecks() const { + return pimpl->getInitialChecks(); +} + +void Detector::setInitialChecks(const bool value) { + pimpl->setInitialChecks(value); +} + // Insignificant Result Detector::getControlPort(Positions pos) const { diff --git a/slsDetectorSoftware/src/multiSlsDetector.cpp b/slsDetectorSoftware/src/multiSlsDetector.cpp index 7c8d91199..edd540ffe 100755 --- a/slsDetectorSoftware/src/multiSlsDetector.cpp +++ b/slsDetectorSoftware/src/multiSlsDetector.cpp @@ -212,6 +212,15 @@ std::string multiSlsDetector::getUserDetails() { return sstream.str(); } + +bool multiSlsDetector::getInitialChecks() const { + return multi_shm()->initialChecks; +} + +void multiSlsDetector::setInitialChecks(const bool value) { + multi_shm()->initialChecks = value; +} + void multiSlsDetector::initSharedMemory(bool verify) { if (!multi_shm.IsExisting()) { multi_shm.CreateSharedMemory(); @@ -240,6 +249,7 @@ void multiSlsDetector::initializeDetectorStructure() { multi_shm()->numberOfChannels.y = 0; multi_shm()->acquiringFlag = false; multi_shm()->receiver_upstream = false; + multi_shm()->initialChecks = true; } void multiSlsDetector::initializeMembers(bool verify) { @@ -323,8 +333,10 @@ void multiSlsDetector::setHostname(const std::vector &name) { FILE_LOG(logWARNING) << "There are already detector(s) in shared memory." "Freeing Shared memory now."; + bool initialChecks = multi_shm()->initialChecks; freeSharedMemory(); setupMultiDetector(); + multi_shm()->initialChecks = initialChecks; } for (const auto &hostname : name) { addSlsDetector(hostname); @@ -363,7 +375,7 @@ void multiSlsDetector::addSlsDetector(const std::string &hostname) { multi_shm()->numberOfDetectors = detectors.size(); detectors[pos]->setControlPort(port); detectors[pos]->setStopPort(port + 1); - detectors[pos]->setHostname(host); + detectors[pos]->setHostname(host, multi_shm()->initialChecks); // detector type updated by now multi_shm()->multiDetectorType = Parallel(&slsDetector::getDetectorType, {}).tsquash("Inconsistent detector types."); } diff --git a/slsDetectorSoftware/src/multiSlsDetector.h b/slsDetectorSoftware/src/multiSlsDetector.h index 5c3ca20f2..501483684 100755 --- a/slsDetectorSoftware/src/multiSlsDetector.h +++ b/slsDetectorSoftware/src/multiSlsDetector.h @@ -17,7 +17,7 @@ class detectorData; #include #define MULTI_SHMAPIVERSION 0x190809 -#define MULTI_SHMVERSION 0x190819 +#define MULTI_SHMVERSION 0x200131 #define SHORT_STRING_LENGTH 50 #define DATE_LENGTH 30 @@ -64,6 +64,9 @@ struct sharedMultiSlsDetector { /** data streaming (up stream) enable in receiver */ bool receiver_upstream; + + /** initial checks */ + bool initialChecks; }; class multiSlsDetector : public virtual slsDetectorDefs { @@ -248,6 +251,12 @@ class multiSlsDetector : public virtual slsDetectorDefs { /** Get user details of shared memory */ std::string getUserDetails(); + bool getInitialChecks() const; + + /** initial compaibility and other server start up checks + * default enabled */ + void setInitialChecks(const bool value); + /** * Connect to Virtual Detector Servers at local host * @param ndet number of detectors diff --git a/slsDetectorSoftware/src/slsDetector.cpp b/slsDetectorSoftware/src/slsDetector.cpp index f74a87144..0cb510332 100755 --- a/slsDetectorSoftware/src/slsDetector.cpp +++ b/slsDetectorSoftware/src/slsDetector.cpp @@ -279,13 +279,21 @@ void slsDetector::freeSharedMemory() { } } -void slsDetector::setHostname(const std::string &hostname) { +void slsDetector::setHostname(const std::string &hostname, const bool initialChecks) { sls::strcpy_safe(shm()->hostname, hostname.c_str()); auto client = DetectorSocket(shm()->hostname, shm()->controlPort); client.close(); FILE_LOG(logINFO) << "Checking Detector Version Compatibility"; - checkDetectorVersionCompatibility(); + if (!initialChecks) { + try { + checkDetectorVersionCompatibility(); + } catch (const DetectorError& e) { + FILE_LOG(logWARNING) << "Bypassing Initial Checks at your own risk!"; + } + } else { + checkDetectorVersionCompatibility(); + } FILE_LOG(logINFO) << "Detector connecting - updating!"; updateCachedDetectorVariables(); diff --git a/slsDetectorSoftware/src/slsDetector.h b/slsDetectorSoftware/src/slsDetector.h index d11bcafe7..03d825aa3 100755 --- a/slsDetectorSoftware/src/slsDetector.h +++ b/slsDetectorSoftware/src/slsDetector.h @@ -252,8 +252,11 @@ class slsDetector : public virtual slsDetectorDefs { /** * Sets the hostname, if online flag is set connects to update the detector * @param name hostname + * @param initialChecks enable or disable initial compatibility checks + * and other server start up checks. Enabled by default. Disable only + * for advanced users! */ - void setHostname(const std::string &hostname); + void setHostname(const std::string &hostname, const bool initialChecks); /** * Gets the hostname of detector diff --git a/slsDetectorSoftware/tests/test-CmdProxy.cpp b/slsDetectorSoftware/tests/test-CmdProxy.cpp index b47cd51a3..95c8bc8bf 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy.cpp @@ -35,6 +35,34 @@ TEST_CASE("type", "[.cmd]"){ } +TEST_CASE("initialchecks", "[.cmd]") { + Detector det; + CmdProxy proxy(&det); + auto check = det.getInitialChecks(); + auto dtstr = sls::ToString(check); + auto hostname = det.getHostname(); + std::string hostnamestr; + for (auto &it : hostname) { + hostnamestr += (it + "+"); + } + { + std::ostringstream oss; + proxy.Call("initialchecks", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "initialchecks 0\n"); + } + { + std::ostringstream oss; + proxy.Call("initialchecks", {}, -1, GET, oss); + REQUIRE(oss.str() == "initialchecks 0\n"); + } + { + det.setHostname(hostname); + std::ostringstream oss; + proxy.Call("initialchecks", {}, -1, GET, oss); + REQUIRE(oss.str() == "initialchecks 0\n"); + } + det.setInitialChecks(check); +} // TEST_CASE("dacs", "[.cmd]") { // REQUIRE_NOTHROW(multiSlsDetectorClient("daclist", GET)); diff --git a/slsSupportLib/include/versionAPI.h b/slsSupportLib/include/versionAPI.h index 0f41d796c..4deb8a5e7 100644 --- a/slsSupportLib/include/versionAPI.h +++ b/slsSupportLib/include/versionAPI.h @@ -9,4 +9,4 @@ #define APIJUNGFRAU 0x200131 #define APIMOENCH 0x200131 #define APIGOTTHARD2 0x200131 -#define APIMYTHEN3 0x200131 +#define APIMYTHEN3 0x200130