This commit is contained in:
maliakal_d 2019-10-28 12:26:30 +01:00
parent 19b85b8e40
commit 7b59b7e7d5
4 changed files with 72 additions and 42 deletions

View File

@ -509,6 +509,8 @@ class CmdProxy {
/* Pattern */
/* Moench */
/* Advanced */
};
@ -738,6 +740,11 @@ class CmdProxy {
{"emax", &CmdProxy::MinMaxEnergyThreshold},
{"framemode", &CmdProxy::framemode},
{"detectormode", &CmdProxy::detectormode},
/* Advanced */
{"programfpga", &CmdProxy::ProgramFpga},
{"resetfpga", &CmdProxy::resetfpga},
@ -805,6 +812,8 @@ class CmdProxy {
/* Moench */
std::string JsonParameter(int action);
std::string MinMaxEnergyThreshold(int action);
/* Advanced */
std::string ProgramFpga(int action);
@ -1284,6 +1293,10 @@ class CmdProxy {
"[counting|interpolating|analog]\n\t[Moench] Detector mode (soft setting) in processor.");
/* Advanced */
EXECUTE_SET_COMMAND(resetfpga, resetFPGA,
"\n\t[Jungfrau][Ctb] Reset FPGA.");
DAC_COMMAND(adcvpp, getDAC, setDAC, defs::ADC_VPP,

View File

@ -1276,18 +1276,53 @@ std::string CmdProxy::MinMaxEnergyThreshold(int action) {
} else {
throw sls::RuntimeError("Unknown command, use list to list all commands");
}
} else if (action == defs::GET_ACTION) {
if (args.size() != 0) {
WrongNumberOfParameters(0);
} else {
bool emax = false;
if (cmd == "emin") {
emax = false;
} else if (cmd == "emax") {
emax = true;
} else {
throw sls::RuntimeError("Unknown command, use list to list all commands");
}
if (action == defs::GET_ACTION) {
if (args.size() != 0) {
WrongNumberOfParameters(0);
}
auto t = det->getDetectorMinMaxEnergyThreshold(emax, {det_id});
os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) {
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
det->setDetectorMinMaxEnergyThreshold(emax, std::stoi(args[0]), {det_id});
os << args.front() << '\n';
} else {
throw sls::RuntimeError("Unknown action");
}
auto t = det->getDetectorMinMaxEnergyThreshold((cmd == "emax" ? true :false), {det_id});
os << OutString(t) << '\n';
}
return os.str();
}
/* Advanced */
std::string CmdProxy::ProgramFpga(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[fname.pof]\n\t[Jungfrau][Ctb] Programs FPGA from pof file." << '\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->setDetectorMinMaxEnergyThreshold((cmd == "emax" ? true : false), std::stoi(args[0]), {det_id});
os << args.front() << '\n';
if (args[0].find(".pof") == std::string::npos) {
throw sls::RuntimeError("Programming file must be a pof file.");
}
det->programFPGA(args[0], {det_id});
os << "successful\n";
} else {
throw sls::RuntimeError("Unknown action");
}
@ -1295,5 +1330,4 @@ std::string CmdProxy::MinMaxEnergyThreshold(int action) {
}
} // namespace sls

View File

@ -255,20 +255,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
/* fpga */
/*! \page config
- <b>programfpga [file]</b> programs the FPGA with file f (with .pof extension). Used for JUNGFRAU only. Only put! \c Returns \c ("successful", "failed")
*/
descrToFuncMap[i].m_pFuncName = "programfpga";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdAdvanced;
++i;
/*! \page config
- <b>resetfpga [f]</b> resets FPGA, where f can be any value. Used for JUNGFRAU only. Only put! \c Returns \c ("successful", "failed")
*/
descrToFuncMap[i].m_pFuncName = "resetfpga";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdAdvanced;
++i;
/*! \page config
- <b>copydetectorserver [sname] [phost]</b> copies the detector server sname via tftp from pc with hostname phost and changes respawn server for all detector. Not for Eiger. Only put! \c Returns \c ("successful", "failed")
*/
@ -1916,24 +1902,7 @@ std::string slsDetectorCommand::cmdAdvanced(int narg, const char * const args[],
if (action == HELP_ACTION)
return helpAdvanced(action);
if (cmd == "programfpga") {
if (action == GET_ACTION)
return std::string("cannot get");
if (strstr(args[1], ".pof") == nullptr)
return std::string("wrong usage: programming file should have .pof extension");
std::string sval = std::string(args[1]);
myDet->programFPGA(sval, detPos);
return std::string("successful");
}
else if (cmd == "resetfpga") {
if (action == GET_ACTION)
return std::string("cannot get");
myDet->resetFPGA(detPos);
return std::string("successful");
}
else if (cmd == "copydetectorserver") {
if (cmd == "copydetectorserver") {
if (action == GET_ACTION)
return std::string("cannot get");
if (narg < 3)
@ -1975,8 +1944,6 @@ std::string slsDetectorCommand::helpAdvanced(int action) {
std::ostringstream os;
if (action == PUT_ACTION || action == HELP_ACTION) {
os << "programfpga f \t programs the fpga with file f (with .pof extension)." << std::endl;
os << "resetfpga f \t resets fpga, f can be any value" << std::endl;
os << "copydetectorserver s p \t copies the detector server s via tftp from pc with hostname p and changes respawn server. Not for Eiger. " << std::endl;
os << "rebootcontroller \t reboot controler blackfin of the detector. Not for Eiger." << std::endl;
os << "update s p f \t updates the firmware to f and detector server to f from host p via tftp and then reboots controller (blackfin). Not for Eiger. " << std::endl;

View File

@ -9,6 +9,22 @@
auto GET = slsDetectorDefs::GET_ACTION;
auto PUT = slsDetectorDefs::PUT_ACTION;
TEST_CASE("resetfpga", "[.cmd][.ctb][.jungfrau") {
if (test::type == slsDetectorDefs::JUNGFRAU || test::type == slsDetectorDefs::CHIPTESTBOARD) {
REQUIRE_NOTHROW(multiSlsDetectorClient("resetfpga", PUT));
} else {
REQUIRE_THROWS(multiSlsDetectorClient("resetfpga", GET));
}
}
TEST_CASE("programfpga", "[.cmd][.ctb][.jungfrau") {
if (test::type == slsDetectorDefs::JUNGFRAU || test::type == slsDetectorDefs::CHIPTESTBOARD) {
REQUIRE_THROWS(multiSlsDetectorClient("programfpga fdgd.oki", PUT));
} else {
REQUIRE_THROWS(multiSlsDetectorClient("programfpga", GET));
}
}
TEST_CASE("detectormode", "[.cmd][.moench]") {
{
std::ostringstream oss;