jungfrau: currentsource

This commit is contained in:
maliakal_d 2021-08-10 20:39:07 +02:00
parent fce35e35a1
commit a0784d23bb
3 changed files with 18 additions and 19 deletions

View File

@ -964,11 +964,11 @@ std::string CmdProxy::CurrentSource(int action) {
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "[0|1]\n\t[Gotthard2] Enable or disable current source. Default " os << "[0|1]\n\t[Gotthard2] Enable or disable current source. Default "
"is disabled.\n[0|1] [fix|nofix] [select source] " "is disabled.\n[0|1] [fix|nofix] [select source] [(only for "
"[normal|low]\n\t[Jungfrau] Disable or enable current source " "chipv1.1)normal|low]\n\t[Jungfrau] Disable or enable current "
"with some parameters. The select source is 0-63 for chipv1.0 " "source with some parameters. The select source is 0-63 for "
"and a 64 bit mask for chipv1.1. To disable, one needs only one " "chipv1.0 and a 64 bit mask for chipv1.1. To disable, one needs "
"argument '0'." "only one argument '0'."
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) { } else if (action == defs::GET_ACTION) {
if (args.size() != 0) { if (args.size() != 0) {
@ -978,7 +978,7 @@ std::string CmdProxy::CurrentSource(int action) {
os << OutString(t) << '\n'; os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) { } else if (action == defs::PUT_ACTION) {
if (args.size() == 1) { if (args.size() == 1) {
det->setCurrentsource( det->setCurrentSource(
defs::currentSrcParameters(StringTo<bool>(args[0]))); defs::currentSrcParameters(StringTo<bool>(args[0])));
} else if (args.size() >= 3) { } else if (args.size() >= 3) {
// scan fix // scan fix
@ -992,8 +992,8 @@ std::string CmdProxy::CurrentSource(int action) {
". Did you mean fix or nofix?"); ". Did you mean fix or nofix?");
} }
if (args.size() == 3) { if (args.size() == 3) {
det->setCurrentsource(defs::currentSrcParameters( det->setCurrentSource(defs::currentSrcParameters(
StringTo<bool>(args[0]), fix, StringTo<int64_t>(args[2]))); fix, StringTo<int64_t>(args[2])));
} else if (args.size() == 4) { } else if (args.size() == 4) {
bool normalCurrent = false; bool normalCurrent = false;
if (args[3] == "normal") { if (args[3] == "normal") {
@ -1004,9 +1004,8 @@ std::string CmdProxy::CurrentSource(int action) {
throw sls::RuntimeError("Invalid argument: " + args[3] + throw sls::RuntimeError("Invalid argument: " + args[3] +
". Did you mean normal or low?"); ". Did you mean normal or low?");
} }
det->setCurrentsource(defs::currentSrcParameters( det->setCurrentSource(defs::currentSrcParameters(
StringTo<bool>(args[0]), fix, StringTo<int64_t>(args[2]), fix, StringTo<int64_t>(args[2]), normalCurrent));
normalCurrent));
} else { } else {
throw sls::RuntimeError( throw sls::RuntimeError(
"Invalid number of parareters for this command."); "Invalid number of parareters for this command.");

View File

@ -1428,7 +1428,7 @@ TEST_CASE("currentsource", "[.cmd]") {
CmdProxy proxy(&det); CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash(); auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD2 || detType == defs::Jungfrau) { if (det_type == defs::GOTTHARD2 || det_type == defs::JUNGFRAU) {
auto prev_val = det.getCurrentSource(); auto prev_val = det.getCurrentSource();
if (det_type == defs::GOTTHARD2) { if (det_type == defs::GOTTHARD2) {
@ -1461,11 +1461,11 @@ TEST_CASE("currentsource", "[.cmd]") {
REQUIRE_THROWS( REQUIRE_THROWS(
proxy.Call("currentsource", {"1", "fix"}, -1, PUT)); proxy.Call("currentsource", {"1", "fix"}, -1, PUT));
REQUIRE_THROWS( REQUIRE_THROWS(
proxy.Call("currentsource", {"1", "fix", 64}, -1, PUT)); proxy.Call("currentsource", {"1", "fix", "64"}, -1, PUT));
REQUIRE_THROWS( REQUIRE_THROWS(
proxy.Call("currentsource", {"1", "dfg", 64}, -1, PUT)); proxy.Call("currentsource", {"1", "dfg", "64"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("currentsource", REQUIRE_THROWS(proxy.Call(
{"1", "fix", 63, "normal"}, -1, PUT)); "currentsource", {"1", "fix", "63", "normal"}, -1, PUT));
{ {
std::ostringstream oss; std::ostringstream oss;
proxy.Call("currentsource", {"1", "fix", "63"}, -1, PUT, proxy.Call("currentsource", {"1", "fix", "63"}, -1, PUT,
@ -1501,9 +1501,9 @@ TEST_CASE("currentsource", "[.cmd]") {
REQUIRE_THROWS( REQUIRE_THROWS(
proxy.Call("currentsource", {"1", "fix"}, -1, PUT)); proxy.Call("currentsource", {"1", "fix"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("currentsource", REQUIRE_THROWS(proxy.Call("currentsource",
{"1", "ffgdfgix", 65}, -1, PUT)); {"1", "ffgdfgix", "65"}, -1, PUT));
REQUIRE_THROWS(proxy.Call( REQUIRE_THROWS(proxy.Call(
"currentsource", {"1", "fix", 65, "normaldgf"}, -1, PUT)); "currentsource", {"1", "fix", "65", "normaldgf"}, -1, PUT));
{ {
std::ostringstream oss; std::ostringstream oss;

View File

@ -465,7 +465,7 @@ typedef struct {
/** [Gotthard2][Jungfrau] disable */ /** [Gotthard2][Jungfrau] disable */
currentSrcParameters() : enable(0), fix(-1), normal(-1), select(0) {} currentSrcParameters() : enable(0), fix(-1), normal(-1), select(0) {}
/** [Gotthard2] enable */ /** [Gotthard2] enable or disable */
currentSrcParameters(bool ena) currentSrcParameters(bool ena)
: enable(static_cast<int>(ena)), fix(-1), normal(-1), select(0) {} : enable(static_cast<int>(ena)), fix(-1), normal(-1), select(0) {}