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 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

View File

@ -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");
}
}
}

View File

@ -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";