From c7293f88d0f99097bbada360856a80ea79a85bf5 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Tue, 10 Aug 2021 21:01:36 +0200 Subject: [PATCH] done --- .../src/slsDetectorServer_funcs.c | 12 +++--- slsDetectorSoftware/tests/test-CmdProxy.cpp | 40 +++++++++++-------- slsSupportLib/src/ToString.cpp | 10 ++--- 3 files changed, 36 insertions(+), 26 deletions(-) diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 978edd1b3..39798dba2 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -6762,8 +6762,10 @@ int set_current_source(int file_des) { int enable = args[0]; int fix = args[1]; 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) functionNotImplemented(); @@ -6797,7 +6799,7 @@ int set_current_source(int file_des) { int chipVersion = getChipVersion(); if (chipVersion == 11) { // require both - if ((fix != 0 && fix != -1) || (normal != 0 && normal != 1)) { + if ((fix != 0 && fix != 1) || (normal != 0 && normal != 1)) { ret = FAIL; strcpy(mess, "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 else { // require only fix - if (fix != 0 && fix != -1) { + if (fix != 0 && fix != 1) { ret = FAIL; strcpy(mess, "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; strcpy(mess, "Could not enable current source. Invalid value for parameter (select). Options: 0-63.\n"); - LOG(logERROR, (mess)); + LOG(logERROR, (mess)); } } #endif diff --git a/slsDetectorSoftware/tests/test-CmdProxy.cpp b/slsDetectorSoftware/tests/test-CmdProxy.cpp index 814b23599..de97d69d4 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy.cpp @@ -1475,7 +1475,7 @@ TEST_CASE("currentsource", "[.cmd]") { { std::ostringstream oss; proxy.Call("currentsource", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "currentsource 0\n"); + REQUIRE(oss.str() == "currentsource [0]\n"); } { 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", "fix"}, -1, PUT)); - REQUIRE_THROWS(proxy.Call("currentsource", - {"1", "ffgdfgix", "65"}, -1, PUT)); 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; - proxy.Call("currentsource", {"1", "fix", "65", "normal"}, - -1, PUT, oss); - REQUIRE(oss.str() == - "currentsource [1, fix, 65, normal]\n"); + proxy.Call("currentsource", + {"1", "fix", "0x0000000000000041", "normal"}, -1, + PUT, oss); + REQUIRE( + oss.str() == + "currentsource [1, fix, 0x0000000000000041, normal]\n"); } { std::ostringstream oss; proxy.Call("currentsource", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "currentsource 0\n"); + REQUIRE(oss.str() == "currentsource [0]\n"); } { std::ostringstream oss; @@ -1524,22 +1528,26 @@ TEST_CASE("currentsource", "[.cmd]") { } { std::ostringstream oss; - proxy.Call("currentsource", {"1", "nofix", "65", "normal"}, + proxy.Call("currentsource", + {"1", "nofix", "0x0000000000000041", "normal"}, -1, PUT, oss); - REQUIRE(oss.str() == - "currentsource [1, nofix, 65, normal]\n"); + REQUIRE(oss.str() == "currentsource [1, nofix, " + "0x0000000000000041, normal]\n"); } { std::ostringstream oss; proxy.Call("currentsource", {}, -1, GET, oss); - REQUIRE(oss.str() == - "currentsource [enabled, nofix, 65, normal]\n"); + REQUIRE(oss.str() == "currentsource [enabled, nofix, " + "0x0000000000000041, normal]\n"); } { std::ostringstream oss; - proxy.Call("currentsource", {"1", "nofix", "65", "low"}, -1, + proxy.Call("currentsource", + {"1", "nofix", "0x0000000000000041", "low"}, -1, PUT, oss); - REQUIRE(oss.str() == "currentsource [1, nofix, 65, low]\n"); + REQUIRE( + oss.str() == + "currentsource [1, nofix, 0x0000000000000041, low]\n"); } } } diff --git a/slsSupportLib/src/ToString.cpp b/slsSupportLib/src/ToString.cpp index aace92d94..b07d0d9ff 100644 --- a/slsSupportLib/src/ToString.cpp +++ b/slsSupportLib/src/ToString.cpp @@ -122,19 +122,19 @@ std::string ToString(const slsDetectorDefs::currentSrcParameters &r) { } oss << '['; if (r.enable) { - oss << "enabled" << std::endl; + oss << "enabled"; // [jungfrau] if (r.fix != -1) { - oss << (r.fix == 1 ? "fix" : "nofix") << std::endl; + oss << (r.fix == 1 ? ", fix" : ", nofix"); } // [jungfrau chip v1.1] if (r.normal != -1) { - oss << (r.normal == 1 ? "normal" : "low") << std::endl; - oss << "select: " << ToStringHex(r.select, 16) << std::endl; + oss << ", " << ToStringHex(r.select, 16); + oss << (r.normal == 1 ? ", normal" : ", low"); } // [jungfrau chip v1.0] else { - oss << "select: " << r.select << std::endl; + oss << ", " << r.select; } } else { oss << "disabled";