mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-18 15:57:13 +02:00
refactoring
This commit is contained in:
@ -2933,26 +2933,37 @@ std::string CmdProxy::UpdateFirmwareAndDetectorServer(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 "
|
||||
os << "\n\tDeprecated!! Replaced without using tftp (as shown next)[server_name"
|
||||
" (in tftp folder)] [pc_host_name] [fname.pof (incl full path)]";
|
||||
os << "\n\t[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[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"
|
||||
"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) {
|
||||
WrongNumberOfParameters(3);
|
||||
if (args.size() != 3 && args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
if (args[2].find(".pof") == std::string::npos) {
|
||||
throw sls::RuntimeError("Programming file must be a pof file.");
|
||||
|
||||
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.");
|
||||
}
|
||||
det->updateFirmwareAndServer(args[0], args[1], args[2],
|
||||
|
||||
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});
|
||||
}
|
||||
os << "successful\n";
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
|
@ -2154,18 +2154,9 @@ void Detector::copyDetectorServer(const std::string &fname,
|
||||
}
|
||||
|
||||
void Detector::updateDetectorServer(const std::string &fname, Positions pos) {
|
||||
LOG(logINFO) << "Updating Detector Server...";
|
||||
|
||||
std::vector<char> buffer =
|
||||
readBinaryFile(fname, "Update Detector Server");
|
||||
|
||||
// get only the file name
|
||||
std::string filename(fname);
|
||||
std::size_t slashPos = fname.rfind('/');
|
||||
if (slashPos != std::string::npos) {
|
||||
filename = fname.substr(slashPos + 1, fname.size() - 1);
|
||||
}
|
||||
|
||||
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);
|
||||
@ -2174,7 +2165,7 @@ void Detector::updateDetectorServer(const std::string &fname, Positions pos) {
|
||||
|
||||
void Detector::updateKernel(const std::string &fname, Positions pos) {
|
||||
LOG(logINFO) << "Updating Kernel...";
|
||||
std::vector<char> buffer = readBinaryFile(fname, "Update Kernel");
|
||||
std::vector<char> buffer = sls::readBinaryFile(fname, "Update Kernel");
|
||||
pimpl->Parallel(&Module::updateKernel, pos, buffer);
|
||||
rebootController(pos);
|
||||
}
|
||||
@ -2187,7 +2178,8 @@ void Detector::updateFirmwareAndServer(const std::string &sname,
|
||||
const std::string &hostname,
|
||||
const std::string &fname,
|
||||
Positions pos) {
|
||||
LOG(logINFO) << "Updating Firmware and Detector Server...";
|
||||
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);
|
||||
}
|
||||
@ -2196,7 +2188,10 @@ void Detector::updateFirmwareAndServer(const std::string &sname,
|
||||
const std::string &fname,
|
||||
Positions pos) {
|
||||
LOG(logINFO) << "Updating Firmware and Detector Server (no tftp)...";
|
||||
updateDetectorServer(sname, 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);
|
||||
programFPGA(fname, pos);
|
||||
}
|
||||
|
||||
|
@ -1280,14 +1280,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";
|
||||
|
Reference in New Issue
Block a user