merge fix from 6.1.0

This commit is contained in:
2021-11-26 10:59:23 +01:00
100 changed files with 2740 additions and 1568 deletions

View File

@ -69,9 +69,6 @@ list(APPEND DETECTOR_LIBRARY_TARGETS slsDetectorStatic)
if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE)
set_property(TARGET ${DETECTOR_LIBRARY_TARGETS} PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
# set_property(TARGET slsDetectorObject PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
# set_property(TARGET slsDetectorStatic PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
# set_property(TARGET slsDetectorShared PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
endif()
@ -100,7 +97,7 @@ if(SLS_USE_TEXTCLIENT)
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
COMPILE_DEFINITIONS ${val2}=1
)
if(SLS_LTO_AVAILABLE)
if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE)
set_property(TARGET ${val1} PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
endif()
endforeach()

View File

@ -81,6 +81,8 @@ class Detector {
Result<int64_t> getDetectorServerVersion(Positions pos = {}) const;
Result<std::string> getKernelVersion(Positions pos = {}) const;
/* [Jungfrau][Gotthard][Mythen3][Gotthard2][CTB][Moench] */
Result<int64_t> getSerialNumber(Positions pos = {}) const;
@ -1751,7 +1753,8 @@ class Detector {
/** [Jungfrau][CTB][Moench] Advanced user Function! */
void resetFPGA(Positions pos = {});
/** [Jungfrau][Eiger][Gotthard][CTB][Moench][Mythen3][Gotthard2]
/** [[deprecated ("Replaced by updateDetectorServer, which does not require
* tftp")]] [Jungfrau][Eiger][Gotthard][CTB][Moench][Mythen3][Gotthard2]
* Advanced user Function! \n
* Copy detector server fname from tftp folder of hostname to detector. Also
* creates a symbolic link to a shorter name (without vx.x.x). Then the
@ -1762,22 +1765,55 @@ class Detector {
void copyDetectorServer(const std::string &fname,
const std::string &hostname, Positions pos = {});
/** [Jungfrau][Eiger][Ctb][Moench][Mythen3][Gotthard2] Copies detector
* server via TCP (without tftp).\nMakes a symbolic link with a shorter
* name (without vx.x.x).\nThen, detector controller reboots (except
* Eiger).\n[Jungfrau][Ctb][Moench]Also changes respawn server to the
* link, which is effective after a reboot.
*/
void updateDetectorServer(const std::string &fname, Positions pos = {});
/** [Jungfrau][Ctb][Moench][Mythen3][Gotthard2] \n
* Advanced Command!! You could damage the detector. Please use with
* caution.\nUpdates the kernel image. Then, detector controller reboots
* with new kernel
*/
void updateKernel(const std::string &fname, Positions pos = {});
/** [Jungfrau][Gotthard][CTB][Moench][Mythen3][Gotthard2] Advanced user
* Function! */
void rebootController(Positions pos = {});
/** [[deprecated ("Replaced by overloaded updateDetectorServer, which does
* not require tftp and has one less argument")]] Advanced user Function!\n
* [Jungfrau][Gotthard][CTB][Moench] Updates the firmware, detector server,
* make a soft link and then reboots detector controller. \n
* [Mythen3][Gotthard2] Will require a script to start up the shorter named
* server link at start up \n sname is name of detector server binary found
* on tftp folder of host pc \n hostname is name of pc to tftp from \n fname
* is programming file name with full path to it
*/
void updateFirmwareAndServer(const std::string &sname,
const std::string &hostname,
const std::string &fname, Positions pos = {});
/**
* Advanced user Function!\n [Jungfrau][Gotthard][CTB][Moench] Updates the
* firmware, detector server, make a soft link and then reboots detector
* controller. \n [Mythen3][Gotthard2] Will require a script to start up the
* shorter named server link at start up \n sname is name of detector
* server binary found on tftp folder of host pc \n hostname is name of pc
* to tftp from \n fname is programming file name with full path to it
* shorter named server link at start up \n sname is full path name of
* detector server \n fname is programming file name with full path to it
*/
void updateFirmwareAndServer(const std::string &sname,
const std::string &hostname,
const std::string &fname, Positions pos = {});
Result<bool> getUpdateMode(Positions pos = {}) const;
/** Restarts detector server in update mode. This is useful when
* server-firmware compatibility is at its worst and server cannot start up
* normally */
void setUpdateMode(const bool updatemode, Positions pos = {});
/** Advanced user Function! \n
* Goes to stop server. Hence, can be called while calling blocking
* acquire(). \n [Eiger] Address is +0x100 for only left, +0x200 for only

View File

@ -275,7 +275,7 @@ std::string CmdProxy::Versions(int action) {
if (!args.empty()) {
WrongNumberOfParameters(0);
}
auto t = det->getFirmwareVersion();
auto t = det->getFirmwareVersion(std::vector<int>{det_id});
os << "\nDetector Type: " << OutString(det->getDetectorType())
<< "\nPackage Version: " << det->getPackageVersion() << std::hex
<< "\nClient Version: 0x" << det->getClientVersion();
@ -285,10 +285,14 @@ std::string CmdProxy::Versions(int action) {
os << "\nFirmware Version: " << OutStringHex(t);
}
os << "\nDetector Server Version: "
<< OutStringHex(det->getDetectorServerVersion());
<< OutStringHex(
det->getDetectorServerVersion(std::vector<int>{det_id}));
os << "\nDetector Server Version: "
<< OutString(det->getKernelVersion({std::vector<int>{det_id}}));
if (det->getUseReceiverFlag().squash(true)) {
os << "\nReceiver Version: "
<< OutStringHex(det->getReceiverVersion());
<< OutStringHex(
det->getReceiverVersion(std::vector<int>{det_id}));
}
os << std::dec << '\n';
} else if (action == defs::PUT_ACTION) {
@ -1430,8 +1434,9 @@ std::string CmdProxy::UDPDestinationList(int action) {
throw sls::RuntimeError("udp_dstlist must be at module level.");
}
if (rx_id < 0 || rx_id >= MAX_UDP_DESTINATION) {
throw sls::RuntimeError(
"Invalid receiver index to get round robin entry.");
throw sls::RuntimeError(std::string("Invalid receiver index ") +
std::to_string(rx_id) +
std::string(" to set round robin entry."));
}
auto t = det->getDestinationUDPList(rx_id, std::vector<int>{det_id});
os << OutString(t) << '\n';
@ -2869,11 +2874,14 @@ std::string CmdProxy::CopyDetectorServer(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
LOG(logWARNING) << "Deprecated! Replaced by updatedetectorserver that "
"requires no tftp.\n";
os << "[server_name (in tftp folder)] "
"[pc_host_name]\n\t[Jungfrau][Eiger][Ctb][Moench][Mythen3]["
"Gotthard2] Copies detector server via tftp from pc. Ensure that "
"Gotthard2] Copies detector server via TFTP from pc. Ensure that "
"server is in the pc's tftp folder. Makes a symbolic link with a "
"shorter name (without vx.x.x). Then, detector reboots (except "
"shorter name (without vx.x.x). Then, detector controller "
"reboots (except "
"Eiger).\n\t[Jungfrau][Ctb][Moench]Also changes respawn server "
"to the link, which is effective after a reboot."
<< '\n';
@ -2891,30 +2899,98 @@ std::string CmdProxy::CopyDetectorServer(int action) {
return os.str();
}
std::string CmdProxy::UpdateFirmwareAndDetectorServer(int action) {
std::string CmdProxy::UpdateDetectorServer(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[server_name (in tftp folder)] [pc_host_name] [fname.pof (incl "
"full path)]\n\t[Jungfrau][Gotthard][CTB][Moench] Updates the "
"firmware, detector server, creates the symbolic link and then "
"reboots detector controller. \n\t[Mythen3][Gotthard2] will "
"require a script to start up the shorter named server link at "
"start up. \n\tsname is name of detector server binary found on "
"tftp folder of host pc \n\thostname is name of pc to tftp from "
"\n\tfname is programming file name"
os << "[server_name with full "
"path]\n\t[Jungfrau][Eiger][Ctb][Moench][Mythen3]["
"Gotthard2] Copies detector server via TCP (without tftp). Makes "
"a symbolic link with a shorter name (without vx.x.x). Then, "
"detector controller reboots (except "
"Eiger).\n\t[Jungfrau][Ctb][Moench]Also changes respawn server "
"to the link, which is effective after a reboot."
<< '\n';
} else if (action == defs::GET_ACTION) {
throw sls::RuntimeError("Cannot get");
} else if (action == defs::PUT_ACTION) {
if (args.size() != 3) {
WrongNumberOfParameters(3);
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
if (args[2].find(".pof") == std::string::npos) {
throw sls::RuntimeError("Programming file must be a pof file.");
det->updateDetectorServer(args[0], std::vector<int>{det_id});
os << "successful\n";
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
std::string CmdProxy::UpdateKernel(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[kernel_name with full "
"path]\n\t[Jungfrau][Ctb][Moench][Mythen3]["
"Gotthard2] Advanced Command!! You could damage the detector. "
"Please use"
" with caution.\n\tUpdates the kernel image. Then, detector "
"controller "
"reboots with new kernel."
<< '\n';
} else if (action == defs::GET_ACTION) {
throw sls::RuntimeError("Cannot get");
} else if (action == defs::PUT_ACTION) {
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
det->updateKernel(args[0], std::vector<int>{det_id});
os << "successful\n";
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
std::string CmdProxy::UpdateFirmwareAndDetectorServer(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "\n\tUsing tftp: Deprecated!! [server_name"
" (in tftp folder)] [pc_host_name] [fname.pof (incl full path)]"
"\n\tWithout tftp: Recommended [server_name (incl fullpath)] "
"[fname.pof (incl full path)] "
"This does not use tftp."
"\n\t\t[Jungfrau][Gotthard][CTB][Moench] Updates the "
"firmware, detector server, creates the symbolic link and then "
"reboots detector controller. \n\t\t[Mythen3][Gotthard2] will "
"require a script to start up the shorter named server link at "
"start up. \n\t\tsname is full path name of detector server "
"binary"
"\n\t\tfname is full path of programming file"
<< '\n';
} else if (action == defs::GET_ACTION) {
throw sls::RuntimeError("Cannot get");
} else if (action == defs::PUT_ACTION) {
if (args.size() != 3 && args.size() != 2) {
WrongNumberOfParameters(2);
}
int fpos = args.size() - 1;
if (args[fpos].find(".pof") == std::string::npos &&
args[fpos].find(".rbf") == std::string::npos) {
throw sls::RuntimeError("Programming file must be a pof/rbf file.");
}
if (args.size() == 3) {
LOG(logWARNING)
<< "Deprecated! Recommend to use same command without tftp (no "
"pc name) and using full path to the server binary";
det->updateFirmwareAndServer(args[0], args[1], args[2],
std::vector<int>{det_id});
} else {
det->updateFirmwareAndServer(args[0], args[1],
std::vector<int>{det_id});
}
det->updateFirmwareAndServer(args[0], args[1], args[2],
std::vector<int>{det_id});
os << "successful\n";
} else {
throw sls::RuntimeError("Unknown action");

View File

@ -837,6 +837,7 @@ class CmdProxy {
{"clientversion", &CmdProxy::ClientVersion},
{"firmwareversion", &CmdProxy::FirmwareVersion},
{"detectorserverversion", &CmdProxy::detectorserverversion},
{"kernelversion", &CmdProxy::kernelversion},
{"rx_version", &CmdProxy::rx_version},
{"serialnumber", &CmdProxy::serialnumber},
{"moduleid", &CmdProxy::moduleid},
@ -1128,8 +1129,11 @@ class CmdProxy {
{"programfpga", &CmdProxy::ProgramFpga},
{"resetfpga", &CmdProxy::resetfpga},
{"copydetectorserver", &CmdProxy::CopyDetectorServer},
{"updatedetectorserver", &CmdProxy::UpdateDetectorServer},
{"updatekernel", &CmdProxy::UpdateKernel},
{"rebootcontroller", &CmdProxy::rebootcontroller},
{"update", &CmdProxy::UpdateFirmwareAndDetectorServer},
{"updatemode", &CmdProxy::updatemode},
{"reg", &CmdProxy::Register},
{"adcreg", &CmdProxy::AdcRegister},
{"setbit", &CmdProxy::BitOperations},
@ -1252,6 +1256,8 @@ class CmdProxy {
/* Advanced */
std::string ProgramFpga(int action);
std::string CopyDetectorServer(int action);
std::string UpdateDetectorServer(int action);
std::string UpdateKernel(int action);
std::string UpdateFirmwareAndDetectorServer(int action);
std::string Register(int action);
std::string AdcRegister(int action);
@ -1276,6 +1282,10 @@ class CmdProxy {
detectorserverversion, getDetectorServerVersion,
"\n\tOn-board detector server software version in format [0xYYMMDD].");
GET_COMMAND(
kernelversion, getKernelVersion,
"\n\tGet kernel version on the detector including time and date.");
GET_COMMAND_HEX(rx_version, getReceiverVersion,
"\n\tReceiver version in format [0xYYMMDD].");
@ -2245,6 +2255,12 @@ class CmdProxy {
"\n\t[Jungfrau][Ctb][Moench][Gotthard][Mythen3]["
"Gotthard2] Reboot controller of detector.");
INTEGER_COMMAND_VEC_ID(
updatemode, getUpdateMode, setUpdateMode, StringTo<int>,
"[0|1]\n\tRestart the detector server in update mode or not. This is "
"useful when server-firmware compatibility is at its worst and server "
"cannot start up normally");
EXECUTE_SET_COMMAND(
firmwaretest, executeFirmwareTest,
"\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][Ctb][Moench] Firmware "

View File

@ -9,6 +9,7 @@
#include "Module.h"
#include "sls/Pattern.h"
#include "sls/container_utils.h"
#include "sls/file_utils.h"
#include "sls/logger.h"
#include "sls/sls_detector_defs.h"
#include "sls/versionAPI.h"
@ -117,6 +118,10 @@ Result<int64_t> Detector::getDetectorServerVersion(Positions pos) const {
return pimpl->Parallel(&Module::getDetectorServerVersion, pos);
}
Result<std::string> Detector::getKernelVersion(Positions pos) const {
return pimpl->Parallel(&Module::getKernelVersion, pos);
}
Result<int64_t> Detector::getSerialNumber(Positions pos) const {
return pimpl->Parallel(&Module::getSerialNumber, pos);
}
@ -2157,6 +2162,7 @@ void Detector::setAdditionalJsonParameter(const std::string &key,
// Advanced
void Detector::programFPGA(const std::string &fname, Positions pos) {
LOG(logINFO) << "Updating Firmware...";
std::vector<char> buffer = pimpl->readProgrammingFile(fname);
pimpl->Parallel(&Module::programFPGA, pos, buffer);
rebootController(pos);
@ -2168,12 +2174,30 @@ void Detector::resetFPGA(Positions pos) {
void Detector::copyDetectorServer(const std::string &fname,
const std::string &hostname, Positions pos) {
LOG(logINFO) << "Updating Detector Server (via tftp)...";
pimpl->Parallel(&Module::copyDetectorServer, pos, fname, hostname);
if (getDetectorType().squash() != defs::EIGER) {
rebootController(pos);
}
}
void Detector::updateDetectorServer(const std::string &fname, Positions pos) {
LOG(logINFO) << "Updating Detector Server (no tftp)...";
std::vector<char> buffer = readBinaryFile(fname, "Update Detector Server");
std::string filename = sls::getFileNameFromFilePath(fname);
pimpl->Parallel(&Module::updateDetectorServer, pos, buffer, filename);
if (getDetectorType().squash() != defs::EIGER) {
rebootController(pos);
}
}
void Detector::updateKernel(const std::string &fname, Positions pos) {
LOG(logINFO) << "Updating Kernel...";
std::vector<char> buffer = sls::readBinaryFile(fname, "Update Kernel");
pimpl->Parallel(&Module::updateKernel, pos, buffer);
rebootController(pos);
}
void Detector::rebootController(Positions pos) {
pimpl->Parallel(&Module::rebootController, pos);
}
@ -2182,10 +2206,34 @@ void Detector::updateFirmwareAndServer(const std::string &sname,
const std::string &hostname,
const std::string &fname,
Positions pos) {
LOG(logINFO) << "Updating Firmware and Detector Server (with tftp)...";
LOG(logINFO) << "Updating Detector Server (via tftp)...";
pimpl->Parallel(&Module::copyDetectorServer, pos, sname, hostname);
programFPGA(fname, pos);
}
void Detector::updateFirmwareAndServer(const std::string &sname,
const std::string &fname,
Positions pos) {
LOG(logINFO) << "Updating Firmware and Detector Server (no tftp)...";
LOG(logINFO) << "Updating Detector Server (no tftp)...";
std::vector<char> buffer = readBinaryFile(sname, "Update Detector Server");
std::string filename = sls::getFileNameFromFilePath(sname);
pimpl->Parallel(&Module::updateDetectorServer, pos, buffer, filename);
programFPGA(fname, pos);
}
Result<bool> Detector::getUpdateMode(Positions pos) const {
return pimpl->Parallel(&Module::getUpdateMode, pos);
}
void Detector::setUpdateMode(const bool updatemode, Positions pos) {
pimpl->Parallel(&Module::setUpdateMode, pos, updatemode);
if (getDetectorType().squash() != defs::EIGER) {
rebootController(pos);
}
}
Result<uint32_t> Detector::readRegister(uint32_t addr, Positions pos) const {
return pimpl->Parallel(&Module::readRegister, pos, addr);
}
@ -2264,7 +2312,7 @@ Result<sls::IpAddr> Detector::getLastClientIP(Positions pos) const {
Result<std::string> Detector::executeCommand(const std::string &value,
Positions pos) {
return pimpl->Parallel(&Module::execCommand, pos, value);
return pimpl->Parallel(&Module::executeCommand, pos, value);
}
Result<int64_t> Detector::getNumberOfFramesFromStart(Positions pos) const {

View File

@ -12,6 +12,7 @@
#include "sls/ToString.h"
#include "sls/container_utils.h"
#include "sls/file_utils.h"
#include "sls/network_utils.h"
#include "sls/string_utils.h"
@ -337,7 +338,9 @@ void DetectorImpl::updateDetectorSize() {
<< shm()->numberOfChannels.y;
for (auto &module : modules) {
module->updateNumberOfModule(shm()->numberOfModule);
if (module->getUpdateMode() == 0) {
module->updateNumberOfModule(shm()->numberOfModule);
}
}
}
@ -1261,8 +1264,7 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
throw RuntimeError("programfpga not implemented for this detector");
}
LOG(logINFO)
<< "Updating Firmware. This can take awhile. Please be patient...";
LOG(logINFO) << "This can take awhile. Please be patient.";
LOG(logDEBUG1) << "Programming FPGA with file name:" << fname;
// check if it exists
@ -1280,14 +1282,7 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
}
// get srcSize to print progress
if (fseek(src, 0, SEEK_END) != 0) {
throw RuntimeError("Program FPGA: Seek error in src file");
}
size_t srcSize = ftell(src);
if (srcSize <= 0) {
throw RuntimeError("Program FPGA: Could not get length of source file");
}
rewind(src);
ssize_t srcSize = sls::getFileSize(src, "Program FPGA");
// create temp destination file
char destfname[] = "/tmp/SLS_DET_MCB.XXXXXX";
@ -1359,36 +1354,12 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
if (close(dst) != 0) {
throw RuntimeError("Program FPGA: Could not close destination file");
}
LOG(logINFOBLUE) << "File has been converted to " << destfname;
LOG(logINFO) << "File has been converted to " << destfname;
// loading dst file to memory
// FILE *fp = fopen("/tmp/SLS_DET_MCB.tzgmUT", "r");
FILE *fp = fopen(destfname, "r");
if (fp == nullptr) {
throw RuntimeError("Program FPGA: Could not open rawbin file");
}
if (fseek(fp, 0, SEEK_END) != 0) {
throw RuntimeError("Program FPGA: Seek error in rawbin file");
}
size_t filesize = ftell(fp);
if (filesize <= 0) {
throw RuntimeError("Program FPGA: Could not get length of rawbin file");
}
rewind(fp);
std::vector<char> buffer(filesize, 0);
if (fread(buffer.data(), sizeof(char), filesize, fp) != filesize) {
throw RuntimeError("Program FPGA: Could not read rawbin file");
}
if (fclose(fp) != 0) {
throw RuntimeError(
"Program FPGA: Could not close destination file after converting");
}
// unlink(destfname); // delete temporary file
LOG(logDEBUG1) << "Successfully loaded the rawbin file to program memory";
LOG(logDEBUG1) << "Read file into memory";
// load converted file to memory
std::vector<char> buffer = readBinaryFile(destfname, "Program FPGA");
// delete temporary
unlink(destfname);
return buffer;
}

View File

@ -284,7 +284,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
/**
* Convert raw file
* [Jungfrau][Ctb] from pof file
* [Jungfrau][Ctb][Moench] from pof file
* [Mythen3][Gotthard2] from rbf file
* @param fname name of pof/rbf file
* @returns binary of the program

View File

@ -94,6 +94,12 @@ int64_t Module::getDetectorServerVersion() const {
return sendToDetector<int64_t>(F_GET_SERVER_VERSION);
}
std::string Module::getKernelVersion() const {
char retval[MAX_STR_LENGTH]{};
sendToDetector(F_GET_KERNEL_VERSION, nullptr, retval);
return retval;
}
int64_t Module::getSerialNumber() const {
return sendToDetector<int64_t>(F_GET_SERIAL_NUMBER);
}
@ -1351,7 +1357,7 @@ void Module::setReceiverHostname(const std::string &receiverIP,
for (int i = 0; i != MAX_UDP_DESTINATION; ++i) {
if (strcmp(shm()->receivers[i].hostname, "none")) {
shm()->useReceiverFlag = true;
LOG(logINFORED) << "still one RR, so use receeverflag true";
LOG(logINFORED) << "still one RR, so use receiverflag true";
}
}
return;
@ -1772,14 +1778,14 @@ void Module::sendReceiverRateCorrections(const std::vector<int64_t> &t) {
LOG(logDEBUG) << "Sending to receiver 0 [rate corrections: " << ToString(t)
<< ']';
// only to master receiver
auto client = ReceiverSocket(shm()->receivers[0].hostname,
shm()->receivers[0].tcpPort);
client.Send(F_SET_RECEIVER_RATE_CORRECT);
client.Send(static_cast<int>(t.size()));
client.Send(t);
if (client.Receive<int>() == FAIL) {
auto receiver = ReceiverSocket(shm()->receivers[0].hostname,
shm()->receivers[0].tcpPort);
receiver.Send(F_SET_RECEIVER_RATE_CORRECT);
receiver.Send(static_cast<int>(t.size()));
receiver.Send(t);
if (receiver.Receive<int>() == FAIL) {
throw RuntimeError("Receiver " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage());
" returned error: " + receiver.readErrorMessage());
}
}
@ -2039,8 +2045,8 @@ void Module::sendVetoPhoton(const int chipIndex,
client.Send(gainIndices);
client.Send(values);
if (client.Receive<int>() == FAIL) {
throw RuntimeError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage());
throw DetectorError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage());
}
}
@ -2051,15 +2057,15 @@ void Module::getVetoPhoton(const int chipIndex,
client.Send(F_GET_VETO_PHOTON);
client.Send(chipIndex);
if (client.Receive<int>() == FAIL) {
throw RuntimeError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage());
throw DetectorError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage());
}
auto nch = client.Receive<int>();
if (nch != shm()->nChan.x) {
throw RuntimeError("Could not get veto photon. Expected " +
std::to_string(shm()->nChan.x) + " channels, got " +
std::to_string(nch));
throw DetectorError("Could not get veto photon. Expected " +
std::to_string(shm()->nChan.x) + " channels, got " +
std::to_string(nch));
}
std::vector<int> gainIndices(nch);
std::vector<int> values(nch);
@ -2287,8 +2293,8 @@ void Module::getBadChannels(const std::string &fname) const {
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
client.Send(F_GET_BAD_CHANNELS);
if (client.Receive<int>() == FAIL) {
throw RuntimeError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage());
throw DetectorError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage());
}
// receive badchannels
auto nch = client.Receive<int>();
@ -2344,8 +2350,8 @@ void Module::setBadChannels(const std::string &fname) {
client.Send(badchannels);
}
if (client.Receive<int>() == FAIL) {
throw RuntimeError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage());
throw DetectorError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage());
}
}
@ -2726,8 +2732,8 @@ void Module::setAdditionalJsonHeader(
client.Send(&buff[0], buff.size());
if (client.Receive<int>() == FAIL) {
throw RuntimeError("Receiver " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage());
throw ReceiverError("Receiver " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage());
}
}
@ -2762,14 +2768,15 @@ void Module::programFPGA(std::vector<char> buffer) {
case JUNGFRAU:
case CHIPTESTBOARD:
case MOENCH:
programFPGAviaBlackfin(buffer);
sendProgram(true, buffer, F_PROGRAM_FPGA, "Update Firmware");
break;
case MYTHEN3:
case GOTTHARD2:
programFPGAviaNios(buffer);
sendProgram(false, buffer, F_PROGRAM_FPGA, "Update Firmware");
break;
default:
throw RuntimeError("Program FPGA is not implemented for this detector");
throw RuntimeError("Updating Firmware via the package is not "
"implemented for this detector");
}
}
@ -2780,7 +2787,8 @@ void Module::copyDetectorServer(const std::string &fname,
char args[2][MAX_STR_LENGTH]{};
sls::strcpy_safe(args[0], fname.c_str());
sls::strcpy_safe(args[1], hostname.c_str());
LOG(logINFO) << "Sending detector server " << args[0] << " from host "
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
<< "): Sending detector server " << args[0] << " from host "
<< args[1];
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
client.Send(F_COPY_DET_SERVER);
@ -2790,15 +2798,65 @@ void Module::copyDetectorServer(const std::string &fname,
std::ostringstream os;
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage();
throw RuntimeError(os.str());
throw DetectorError(os.str());
}
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
<< "): detector server copied";
<< "): Detector server copied";
}
void Module::updateDetectorServer(std::vector<char> buffer,
const std::string &serverName) {
switch (shm()->detType) {
case JUNGFRAU:
case CHIPTESTBOARD:
case MOENCH:
sendProgram(true, buffer, F_UPDATE_DETECTOR_SERVER,
"Update Detector Server (no tftp)", serverName);
break;
case MYTHEN3:
case GOTTHARD2:
case EIGER:
sendProgram(false, buffer, F_UPDATE_DETECTOR_SERVER,
"Update Detector Server (no tftp)", serverName);
break;
default:
throw RuntimeError(
"Updating DetectorServer via the package is not implemented "
"for this detector");
}
}
void Module::updateKernel(std::vector<char> buffer) {
switch (shm()->detType) {
case JUNGFRAU:
case CHIPTESTBOARD:
case MOENCH:
sendProgram(true, buffer, F_UPDATE_KERNEL, "Update Kernel");
break;
case MYTHEN3:
case GOTTHARD2:
sendProgram(false, buffer, F_UPDATE_KERNEL, "Update Kernel");
break;
default:
throw RuntimeError("Updating Kernel via the package is not implemented "
"for this detector");
}
}
void Module::rebootController() {
sendToDetector(F_REBOOT_CONTROLLER);
LOG(logINFO) << "Controller rebooted successfully!";
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
<< "): Controller rebooted successfully!";
}
bool Module::getUpdateMode() const {
return sendToDetector<int>(F_GET_UPDATE_MODE);
}
void Module::setUpdateMode(const bool updatemode) {
sendToDetector(F_SET_UPDATE_MODE, static_cast<int>(updatemode), nullptr);
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
<< "): Update Mode set to " << updatemode << "!";
}
uint32_t Module::readRegister(uint32_t addr) const {
@ -2876,11 +2934,25 @@ sls::IpAddr Module::getLastClientIP() const {
return sendToDetector<sls::IpAddr>(F_GET_LAST_CLIENT_IP);
}
std::string Module::execCommand(const std::string &cmd) {
std::string Module::executeCommand(const std::string &cmd) {
char arg[MAX_STR_LENGTH]{};
char retval[MAX_STR_LENGTH]{};
sls::strcpy_safe(arg, cmd.c_str());
sendToDetector(F_EXEC_COMMAND, arg, retval);
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
<< "): Sending command " << cmd;
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
client.Send(F_EXEC_COMMAND);
client.Send(arg);
if (client.Receive<int>() == FAIL) {
std::cout << '\n';
std::ostringstream os;
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage();
throw DetectorError(os.str());
}
client.Receive(retval);
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
<< "): command executed";
return retval;
}
@ -3499,8 +3571,8 @@ void Module::setModule(sls_detector_module &module, bool trimbits) {
client.Send(F_SET_MODULE);
sendModule(&module, client);
if (client.Receive<int>() == FAIL) {
throw RuntimeError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage());
throw DetectorError("Module " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage());
}
}
@ -3747,193 +3819,128 @@ sls_detector_module Module::readSettingsFile(const std::string &fname,
return myMod;
}
void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
// send program from memory to detector
LOG(logINFO) << "Sending programming binary (from pof) to module "
<< moduleIndex << " (" << shm()->hostname << ")";
void Module::sendProgram(bool blackfin, std::vector<char> buffer,
const int functionEnum,
const std::string &functionType,
const std::string serverName) {
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
<< "): Sending " << functionType;
// send fnum and filesize
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
client.Send(F_PROGRAM_FPGA);
client.Send(functionEnum);
uint64_t filesize = buffer.size();
client.Send(filesize);
// checksum
// send checksum
std::string checksum = sls::md5_calculate_checksum(buffer.data(), filesize);
LOG(logDEBUG1) << "Checksum:" << checksum;
char cChecksum[MAX_STR_LENGTH];
memset(cChecksum, 0, MAX_STR_LENGTH);
char cChecksum[MAX_STR_LENGTH] = {0};
strcpy(cChecksum, checksum.c_str());
client.Send(cChecksum);
// opening file fail
if (client.Receive<int>() == FAIL) {
std::cout << '\n';
std::ostringstream os;
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage();
throw RuntimeError(os.str());
// send server name
if (functionEnum == F_UPDATE_DETECTOR_SERVER) {
char sname[MAX_STR_LENGTH] = {0};
strcpy(sname, serverName.c_str());
client.Send(sname);
}
// sending program in parts of 2mb each
uint64_t unitprogramsize = 0;
int currentPointer = 0;
while (filesize > 0) {
unitprogramsize = MAX_FPGAPROGRAMSIZE; // 2mb
if (unitprogramsize > filesize) { // less than 2mb
unitprogramsize = filesize;
}
LOG(logDEBUG) << "unitprogramsize:" << unitprogramsize
<< "\t filesize:" << filesize;
client.Send(&buffer[currentPointer], unitprogramsize);
if (client.Receive<int>() == FAIL) {
std::cout << '\n';
std::ostringstream os;
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage();
throw RuntimeError(os.str());
}
filesize -= unitprogramsize;
currentPointer += unitprogramsize;
}
// checksum
// validate memory allocation etc in detector
if (client.Receive<int>() == FAIL) {
std::ostringstream os;
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage();
throw RuntimeError(os.str());
throw DetectorError(os.str());
}
// send program
if (blackfin) {
uint64_t unitprogramsize = 0;
int currentPointer = 0;
while (filesize > 0) {
unitprogramsize = MAX_BLACKFIN_PROGRAM_SIZE;
if (unitprogramsize > filesize) {
unitprogramsize = filesize;
}
LOG(logDEBUG) << "unitprogramsize:" << unitprogramsize
<< "\t filesize:" << filesize;
client.Send(&buffer[currentPointer], unitprogramsize);
if (client.Receive<int>() == FAIL) {
std::cout << '\n';
std::ostringstream os;
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage();
throw DetectorError(os.str());
}
filesize -= unitprogramsize;
currentPointer += unitprogramsize;
}
} else {
client.Send(buffer);
}
// tmp checksum verified in detector
if (client.Receive<int>() == FAIL) {
std::ostringstream os;
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage();
throw DetectorError(os.str());
}
LOG(logINFO) << "Checksum verified for module " << moduleIndex << " ("
<< shm()->hostname << ")";
// simulating erasing flash
{
LOG(logINFO) << "(Simulating) Erasing Flash for module " << moduleIndex
<< " (" << shm()->hostname << ")";
printf("%d%%\r", 0);
std::cout << std::flush;
// erasing takes 65 seconds, printing here (otherwise need threads
// in server-unnecessary)
const int ERASE_TIME = 65;
int count = ERASE_TIME + 1;
while (count > 0) {
std::this_thread::sleep_for(std::chrono::seconds(1));
--count;
printf("%d%%\r",
static_cast<int>(
(static_cast<double>(ERASE_TIME - count) / ERASE_TIME) *
100));
std::cout << std::flush;
// simulating erasing and writing to
if (blackfin) {
if (functionEnum == F_PROGRAM_FPGA) {
simulatingActivityinDetector("Erasing Flash",
BLACKFIN_ERASE_FLASH_TIME);
simulatingActivityinDetector("Writing to Flash",
BLACKFIN_WRITE_TO_FLASH_TIME);
}
} else {
if (functionEnum == F_PROGRAM_FPGA) {
simulatingActivityinDetector("Erasing Flash",
NIOS_ERASE_FLASH_TIME_FPGA);
simulatingActivityinDetector("Writing to Flash",
NIOS_WRITE_TO_FLASH_TIME_FPGA);
} else if (functionEnum == F_UPDATE_KERNEL) {
simulatingActivityinDetector("Erasing Flash",
NIOS_ERASE_FLASH_TIME_KERNEL);
simulatingActivityinDetector("Writing to Flash",
NIOS_WRITE_TO_FLASH_TIME_KERNEL);
}
printf("\n");
}
// simulating writing to flash
{
LOG(logINFO) << "(Simulating) Writing to Flash for module "
<< moduleIndex << " (" << shm()->hostname << ")";
printf("%d%%\r", 0);
std::cout << std::flush;
// writing takes 30 seconds, printing here (otherwise need threads
// in server-unnecessary)
const int ERASE_TIME = 30;
int count = ERASE_TIME + 1;
while (count > 0) {
std::this_thread::sleep_for(std::chrono::seconds(1));
--count;
printf("%d%%\r",
static_cast<int>(
(static_cast<double>(ERASE_TIME - count) / ERASE_TIME) *
100));
std::cout << std::flush;
}
printf("\n");
}
// update verified
if (client.Receive<int>() == FAIL) {
std::ostringstream os;
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage();
throw RuntimeError(os.str());
throw DetectorError(os.str());
}
LOG(logINFO) << "FPGA programmed successfully";
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
<< "): " << functionType << " successful";
}
void Module::programFPGAviaNios(std::vector<char> buffer) {
LOG(logINFO) << "Sending programming binary (from rbf) to Module "
void Module::simulatingActivityinDetector(const std::string &functionType,
const int timeRequired) {
LOG(logINFO) << "(Simulating) " << functionType << " for module "
<< moduleIndex << " (" << shm()->hostname << ")";
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
client.Send(F_PROGRAM_FPGA);
uint64_t filesize = buffer.size();
client.Send(filesize);
// checksum
std::string checksum = sls::md5_calculate_checksum(buffer.data(), filesize);
LOG(logDEBUG1) << "Checksum:" << checksum;
char cChecksum[MAX_STR_LENGTH];
memset(cChecksum, 0, MAX_STR_LENGTH);
strcpy(cChecksum, checksum.c_str());
client.Send(cChecksum);
// validate file size before sending program
if (client.Receive<int>() == FAIL) {
std::ostringstream os;
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage();
throw RuntimeError(os.str());
}
client.Send(buffer);
// simulating erasing flash
{
LOG(logINFO) << "(Simulating) Erasing Flash for module " << moduleIndex
<< " (" << shm()->hostname << ")";
printf("%d%%\r", 0);
printf("%d%%\r", 0);
std::cout << std::flush;
const int ERASE_TIME = timeRequired;
int count = ERASE_TIME + 1;
while (count > 0) {
std::this_thread::sleep_for(std::chrono::seconds(1));
--count;
printf(
"%d%%\r",
static_cast<int>(
(static_cast<double>(ERASE_TIME - count) / ERASE_TIME) * 100));
std::cout << std::flush;
// erasing takes 10 seconds, printing here (otherwise need threads
// in server-unnecessary)
const int ERASE_TIME = 10;
int count = ERASE_TIME + 1;
while (count > 0) {
std::this_thread::sleep_for(std::chrono::seconds(1));
--count;
printf("%d%%\r",
static_cast<int>(
(static_cast<double>(ERASE_TIME - count) / ERASE_TIME) *
100));
std::cout << std::flush;
}
printf("\n");
}
// simulating writing to flash
{
LOG(logINFO) << "(Simulating) Writing to Flash for module "
<< moduleIndex << " (" << shm()->hostname << ")";
printf("%d%%\r", 0);
std::cout << std::flush;
// writing takes 45 seconds, printing here (otherwise need threads
// in server-unnecessary)
const int ERASE_TIME = 45;
int count = ERASE_TIME + 1;
while (count > 0) {
std::this_thread::sleep_for(std::chrono::seconds(1));
--count;
printf("%d%%\r",
static_cast<int>(
(static_cast<double>(ERASE_TIME - count) / ERASE_TIME) *
100));
std::cout << std::flush;
}
printf("\n");
}
if (client.Receive<int>() == FAIL) {
std::ostringstream os;
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage();
throw RuntimeError(os.str());
}
LOG(logINFO) << "FPGA programmed successfully";
printf("\n");
}
} // namespace sls

View File

@ -99,6 +99,7 @@ class Module : public virtual slsDetectorDefs {
int64_t getFirmwareVersion() const;
int64_t getDetectorServerVersion() const;
std::string getKernelVersion() const;
int64_t getSerialNumber() const;
int getModuleId() const;
int64_t getReceiverSoftwareVersion() const;
@ -549,7 +550,12 @@ class Module : public virtual slsDetectorDefs {
void resetFPGA();
void copyDetectorServer(const std::string &fname,
const std::string &hostname);
void updateDetectorServer(std::vector<char> buffer,
const std::string &serverName);
void updateKernel(std::vector<char> buffer);
void rebootController();
bool getUpdateMode() const;
void setUpdateMode(const bool updatemode);
uint32_t readRegister(uint32_t addr) const;
uint32_t writeRegister(uint32_t addr, uint32_t val);
void setBit(uint32_t addr, int n);
@ -573,7 +579,7 @@ class Module : public virtual slsDetectorDefs {
bool getLockDetector() const;
void setLockDetector(bool lock);
sls::IpAddr getLastClientIP() const;
std::string execCommand(const std::string &cmd);
std::string executeCommand(const std::string &cmd);
int64_t getNumberOfFramesFromStart() const;
int64_t getActualTime() const;
int64_t getMeasurementTime() const;
@ -763,11 +769,20 @@ class Module : public virtual slsDetectorDefs {
std::string getTrimbitFilename(detectorSettings settings, int e_eV);
sls_detector_module readSettingsFile(const std::string &fname,
bool trimbits = true);
void programFPGAviaBlackfin(std::vector<char> buffer);
void programFPGAviaNios(std::vector<char> buffer);
void sendProgram(bool blackfin, std::vector<char> buffer,
const int functionEnum, const std::string &functionType,
const std::string serverName = "");
void simulatingActivityinDetector(const std::string &functionType,
const int timeRequired);
const int moduleIndex;
mutable sls::SharedMemory<sharedModule> shm{0, 0};
static const int BLACKFIN_ERASE_FLASH_TIME = 65;
static const int BLACKFIN_WRITE_TO_FLASH_TIME = 30;
static const int NIOS_ERASE_FLASH_TIME_FPGA = 10;
static const int NIOS_WRITE_TO_FLASH_TIME_FPGA = 45;
static const int NIOS_ERASE_FLASH_TIME_KERNEL = 9;
static const int NIOS_WRITE_TO_FLASH_TIME_KERNEL = 40;
};
} // namespace sls

View File

@ -103,6 +103,13 @@ TEST_CASE("detectorserverversion", "[.cmd]") {
REQUIRE_THROWS(proxy.Call("detectorserverversion", {"0"}, -1, PUT));
}
TEST_CASE("kernelversion", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
REQUIRE_NOTHROW(proxy.Call("kernelversion", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("kernelversion", {"0"}, -1, PUT));
}
TEST_CASE("serialnumber", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
@ -533,7 +540,13 @@ TEST_CASE("fliprows", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER || det_type == defs::JUNGFRAU) {
bool jungfrauhw2 = false;
if (det_type == defs::JUNGFRAU &&
((det.getSerialNumber().tsquash("inconsistent serial number to test") &
0x30000) == 0x30000)) {
jungfrauhw2 = true;
}
if (det_type == defs::EIGER || jungfrauhw2) {
auto previous = det.getFlipRows();
auto previous_numudp = det.getNumberofUDPInterfaces();
if (det_type == defs::JUNGFRAU) {
@ -1544,32 +1557,47 @@ TEST_CASE("readnrows", "[.cmd]") {
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER || det_type == defs::JUNGFRAU) {
auto prev_val = det.getReadNRows();
{
std::ostringstream oss;
proxy.Call("readnrows", {"256"}, -1, PUT, oss);
REQUIRE(oss.str() == "readnrows 256\n");
bool jungfrauhw2 = false;
if (det_type == defs::JUNGFRAU &&
((det.getSerialNumber().tsquash(
"inconsistent serial number to test") &
0x30000) == 0x30000)) {
jungfrauhw2 = true;
}
{
std::ostringstream oss;
proxy.Call("readnrows", {}, -1, GET, oss);
REQUIRE(oss.str() == "readnrows 256\n");
}
{
std::ostringstream oss;
proxy.Call("readnrows", {"16"}, -1, PUT, oss);
REQUIRE(oss.str() == "readnrows 16\n");
}
if (det_type == defs::JUNGFRAU) {
REQUIRE_THROWS(proxy.Call("readnrows", {"7"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("readnrows", {"20"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("readnrows", {"44"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("readnrows", {"513"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("readnrows", {"1"}, -1, PUT));
}
REQUIRE_THROWS(proxy.Call("readnrows", {"0"}, -1, PUT));
for (int i = 0; i != det.size(); ++i) {
det.setReadNRows(prev_val[i], {i});
if (det_type == defs::JUNGFRAU && !jungfrauhw2) {
{
std::ostringstream oss;
proxy.Call("readnrows", {}, -1, GET, oss);
REQUIRE(oss.str() == "readnrows 512\n");
}
} else {
auto prev_val = det.getReadNRows();
{
std::ostringstream oss;
proxy.Call("readnrows", {"256"}, -1, PUT, oss);
REQUIRE(oss.str() == "readnrows 256\n");
}
{
std::ostringstream oss;
proxy.Call("readnrows", {}, -1, GET, oss);
REQUIRE(oss.str() == "readnrows 256\n");
}
{
std::ostringstream oss;
proxy.Call("readnrows", {"16"}, -1, PUT, oss);
REQUIRE(oss.str() == "readnrows 16\n");
}
if (det_type == defs::JUNGFRAU) {
REQUIRE_THROWS(proxy.Call("readnrows", {"7"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("readnrows", {"20"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("readnrows", {"44"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("readnrows", {"513"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("readnrows", {"1"}, -1, PUT));
}
REQUIRE_THROWS(proxy.Call("readnrows", {"0"}, -1, PUT));
for (int i = 0; i != det.size(); ++i) {
det.setReadNRows(prev_val[i], {i});
}
}
} else {
REQUIRE_THROWS(proxy.Call("readnrows", {}, -1, GET));
@ -1998,8 +2026,6 @@ TEST_CASE("stop", "[.cmd]") {
REQUIRE_THROWS(proxy.Call("stop", {}, -1, GET));
auto det_type = det.getDetectorType().squash();
std::chrono::nanoseconds prev_val;
bool virtualDet =
det.isVirtualDetectorServer().tsquash("inconsistent virtual servers");
if (det_type != defs::MYTHEN3) {
prev_val = det.getExptime().tsquash("inconsistent exptime to test");
} else {
@ -2030,11 +2056,8 @@ TEST_CASE("stop", "[.cmd]") {
{
std::ostringstream oss;
proxy.Call("status", {}, -1, GET, oss);
if (!virtualDet && det_type == defs::JUNGFRAU) {
REQUIRE(oss.str() == "status stopped\n");
} else {
REQUIRE(oss.str() == "status idle\n");
}
REQUIRE(((oss.str() == "status stopped\n") ||
(oss.str() == "status idle\n")));
}
det.setExptime(-1, prev_val);
det.setPeriod(prev_period);
@ -2046,8 +2069,6 @@ TEST_CASE("status", "[.cmd]") {
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
std::chrono::nanoseconds prev_val;
bool virtualDet =
det.isVirtualDetectorServer().tsquash("inconsistent virtual servers");
if (det_type != defs::MYTHEN3) {
prev_val = det.getExptime().tsquash("inconsistent exptime to test");
} else {
@ -2074,11 +2095,8 @@ TEST_CASE("status", "[.cmd]") {
{
std::ostringstream oss;
proxy.Call("status", {}, -1, GET, oss);
if (!virtualDet && det_type == defs::JUNGFRAU) {
REQUIRE(oss.str() == "status stopped\n");
} else {
REQUIRE(oss.str() == "status idle\n");
}
REQUIRE(((oss.str() == "status stopped\n") ||
(oss.str() == "status idle\n")));
}
det.setExptime(-1, prev_val);
det.setPeriod(prev_period);
@ -2701,6 +2719,25 @@ TEST_CASE("copydetectorserver", "[.cmd]") {
}
}
TEST_CASE("updatekernel", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD ||
det_type == defs::MOENCH || det_type == defs::MYTHEN3 ||
det_type == defs::GOTTHARD2) {
// TODO: send real server?
// std::ostringstream oss;
// proxy.Call("updatekernel",{"juImage_detector.lzma",
// "pc13784"}, -1, PUT, oss);
// REQUIRE(oss.str() == "updatekernel successful\n");
REQUIRE_THROWS(proxy.Call("updatekernel", {}, -1, GET));
} else {
REQUIRE_THROWS(proxy.Call("updatekernel", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("updatekernel", {}, -1, PUT));
}
}
TEST_CASE("rebootcontroller", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);