This commit is contained in:
maliakal_d 2021-08-10 21:01:36 +02:00
parent a0784d23bb
commit c7293f88d0
3 changed files with 36 additions and 26 deletions

View File

@ -6762,8 +6762,10 @@ int set_current_source(int file_des) {
int enable = args[0]; int enable = args[0];
int fix = args[1]; int fix = args[1];
int normal = args[2]; int normal = args[2];
LOG(logDEBUG1, ("Setting current source [enable:%d, fix:%d, select:%lld, normal :%d]\n", enable, fix, (long long int)select, normal)); LOG(logINFOBLUE, ("Setting current source [enable:%d, fix:%d, select:%lld, "
"normal:%d]\n",
enable, fix, (long long int)select, normal));
#if !defined(GOTTHARD2D) && !defined(JUNGFRAUD) #if !defined(GOTTHARD2D) && !defined(JUNGFRAUD)
functionNotImplemented(); functionNotImplemented();
@ -6797,7 +6799,7 @@ int set_current_source(int file_des) {
int chipVersion = getChipVersion(); int chipVersion = getChipVersion();
if (chipVersion == 11) { if (chipVersion == 11) {
// require both // require both
if ((fix != 0 && fix != -1) || (normal != 0 && normal != 1)) { if ((fix != 0 && fix != 1) || (normal != 0 && normal != 1)) {
ret = FAIL; ret = FAIL;
strcpy(mess, strcpy(mess,
"Could not enable current source. Invalid value for parameters (fix or normal). Options: 0 or 1.\n"); "Could not enable current source. Invalid value for parameters (fix or normal). Options: 0 or 1.\n");
@ -6807,7 +6809,7 @@ int set_current_source(int file_des) {
// chipv1.0 // chipv1.0
else { else {
// require only fix // require only fix
if (fix != 0 && fix != -1) { if (fix != 0 && fix != 1) {
ret = FAIL; ret = FAIL;
strcpy(mess, strcpy(mess,
"Could not enable current source. Invalid value for parameter (fix). Options: 0 or 1.\n"); "Could not enable current source. Invalid value for parameter (fix). Options: 0 or 1.\n");
@ -6823,7 +6825,7 @@ int set_current_source(int file_des) {
ret = FAIL; ret = FAIL;
strcpy(mess, strcpy(mess,
"Could not enable current source. Invalid value for parameter (select). Options: 0-63.\n"); "Could not enable current source. Invalid value for parameter (select). Options: 0-63.\n");
LOG(logERROR, (mess)); LOG(logERROR, (mess));
} }
} }
#endif #endif

View File

@ -1475,7 +1475,7 @@ TEST_CASE("currentsource", "[.cmd]") {
{ {
std::ostringstream oss; std::ostringstream oss;
proxy.Call("currentsource", {"0"}, -1, PUT, oss); proxy.Call("currentsource", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "currentsource 0\n"); REQUIRE(oss.str() == "currentsource [0]\n");
} }
{ {
std::ostringstream oss; std::ostringstream oss;
@ -1500,22 +1500,26 @@ TEST_CASE("currentsource", "[.cmd]") {
REQUIRE_THROWS(proxy.Call("currentsource", {"1"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("currentsource", {"1"}, -1, PUT));
REQUIRE_THROWS( REQUIRE_THROWS(
proxy.Call("currentsource", {"1", "fix"}, -1, PUT)); proxy.Call("currentsource", {"1", "fix"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("currentsource",
{"1", "ffgdfgix", "65"}, -1, PUT));
REQUIRE_THROWS(proxy.Call( REQUIRE_THROWS(proxy.Call(
"currentsource", {"1", "fix", "65", "normaldgf"}, -1, PUT)); "currentsource", {"1", "ffgdfgix", "0x0000000000000041"},
-1, PUT));
REQUIRE_THROWS(proxy.Call(
"currentsource",
{"1", "fix", "0x0000000000000041", "normaldgf"}, -1, PUT));
{ {
std::ostringstream oss; std::ostringstream oss;
proxy.Call("currentsource", {"1", "fix", "65", "normal"}, proxy.Call("currentsource",
-1, PUT, oss); {"1", "fix", "0x0000000000000041", "normal"}, -1,
REQUIRE(oss.str() == PUT, oss);
"currentsource [1, fix, 65, normal]\n"); REQUIRE(
oss.str() ==
"currentsource [1, fix, 0x0000000000000041, normal]\n");
} }
{ {
std::ostringstream oss; std::ostringstream oss;
proxy.Call("currentsource", {"0"}, -1, PUT, oss); proxy.Call("currentsource", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "currentsource 0\n"); REQUIRE(oss.str() == "currentsource [0]\n");
} }
{ {
std::ostringstream oss; std::ostringstream oss;
@ -1524,22 +1528,26 @@ TEST_CASE("currentsource", "[.cmd]") {
} }
{ {
std::ostringstream oss; std::ostringstream oss;
proxy.Call("currentsource", {"1", "nofix", "65", "normal"}, proxy.Call("currentsource",
{"1", "nofix", "0x0000000000000041", "normal"},
-1, PUT, oss); -1, PUT, oss);
REQUIRE(oss.str() == REQUIRE(oss.str() == "currentsource [1, nofix, "
"currentsource [1, nofix, 65, normal]\n"); "0x0000000000000041, normal]\n");
} }
{ {
std::ostringstream oss; std::ostringstream oss;
proxy.Call("currentsource", {}, -1, GET, oss); proxy.Call("currentsource", {}, -1, GET, oss);
REQUIRE(oss.str() == REQUIRE(oss.str() == "currentsource [enabled, nofix, "
"currentsource [enabled, nofix, 65, normal]\n"); "0x0000000000000041, normal]\n");
} }
{ {
std::ostringstream oss; std::ostringstream oss;
proxy.Call("currentsource", {"1", "nofix", "65", "low"}, -1, proxy.Call("currentsource",
{"1", "nofix", "0x0000000000000041", "low"}, -1,
PUT, oss); PUT, oss);
REQUIRE(oss.str() == "currentsource [1, nofix, 65, low]\n"); REQUIRE(
oss.str() ==
"currentsource [1, nofix, 0x0000000000000041, low]\n");
} }
} }
} }

View File

@ -122,19 +122,19 @@ std::string ToString(const slsDetectorDefs::currentSrcParameters &r) {
} }
oss << '['; oss << '[';
if (r.enable) { if (r.enable) {
oss << "enabled" << std::endl; oss << "enabled";
// [jungfrau] // [jungfrau]
if (r.fix != -1) { if (r.fix != -1) {
oss << (r.fix == 1 ? "fix" : "nofix") << std::endl; oss << (r.fix == 1 ? ", fix" : ", nofix");
} }
// [jungfrau chip v1.1] // [jungfrau chip v1.1]
if (r.normal != -1) { if (r.normal != -1) {
oss << (r.normal == 1 ? "normal" : "low") << std::endl; oss << ", " << ToStringHex(r.select, 16);
oss << "select: " << ToStringHex(r.select, 16) << std::endl; oss << (r.normal == 1 ? ", normal" : ", low");
} }
// [jungfrau chip v1.0] // [jungfrau chip v1.0]
else { else {
oss << "select: " << r.select << std::endl; oss << ", " << r.select;
} }
} else { } else {
oss << "disabled"; oss << "disabled";