mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 23:30:03 +02:00
Merge pull request #75 from slsdetectorgroup/nohardexit
initialchecks can be bypassed (version compatibility and oher tests a…
This commit is contained in:
commit
e4f2072067
@ -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 *
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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<int> Detector::getControlPort(Positions pos) const {
|
||||
|
@ -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<std::string> &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.");
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ class detectorData;
|
||||
#include <vector>
|
||||
|
||||
#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
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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));
|
||||
|
@ -9,4 +9,4 @@
|
||||
#define APIJUNGFRAU 0x200131
|
||||
#define APIMOENCH 0x200131
|
||||
#define APIGOTTHARD2 0x200131
|
||||
#define APIMYTHEN3 0x200131
|
||||
#define APIMYTHEN3 0x200130
|
||||
|
Loading…
x
Reference in New Issue
Block a user