daclist and dacvalues for ctb as well

This commit is contained in:
maliakal_d 2019-10-30 11:38:29 +01:00
parent 82570bc084
commit 4aba8b6ac0
2 changed files with 15 additions and 4 deletions

View File

@ -521,7 +521,7 @@ std::string CmdProxy::Dac(int action) {
WrongNumberOfParameters(1);
}
auto t = det->getDAC(static_cast<defs::dacIndex>(std::stoi(args[0])), mv, {det_id});
os << OutString(t) << (args.size() > 1 ? " mv\n" : "\n");
os << args[0] << ' ' << OutString(t) << (args.size() > 1 ? " mv\n" : "\n");
} else if (action == defs::PUT_ACTION) {
bool mv = false;
if (args.size() == 3) {
@ -533,7 +533,7 @@ std::string CmdProxy::Dac(int action) {
WrongNumberOfParameters(2);
}
det->setDAC(static_cast<defs::dacIndex>(std::stoi(args[0])), std::stoi(args[1]), mv, {det_id});
os << args[1] << (args.size() > 2 ? " mv\n" : "\n");
os << args[0] << ' ' << args[1] << (args.size() > 2 ? " mv\n" : "\n");
} else {
throw sls::RuntimeError("Unknown action");
}
@ -567,6 +567,15 @@ std::string CmdProxy::DacValues(int action) {
for (size_t i = 0; i < names.size(); ++i) {
// for multiple values for each command (to use ToString on vector)
std::ostringstream each;
size_t spacepos = names[i].find(' ');
// chip test board (dac)
if (spacepos != std::string::npos) {
if (args.size() == 0) {
args.resize(1);
}
args[0] = names[i].substr(spacepos + 1 -1);
names[i] = names[i].substr(0, spacepos);
}
Call(names[i], args, det_id, action, each);
res[i] = each.str();
res[i].pop_back(); //remove last \n character

View File

@ -11,6 +11,8 @@ auto PUT = slsDetectorDefs::PUT_ACTION;
TEST_CASE("dacs", "[.cmd]") {
REQUIRE_NOTHROW(multiSlsDetectorClient("daclist", GET));
REQUIRE_NOTHROW(multiSlsDetectorClient("dacvalues", GET));
int prev_val = 0;
if (test::type == slsDetectorDefs::EIGER) {
{
@ -626,14 +628,14 @@ TEST_CASE("dacs", "[.cmd]") {
{
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient("dac " + std::to_string(i), GET, nullptr, oss));
std::string s = (oss.str()).erase (0, strlen("dac "));
std::string s = (oss.str()).erase (0, ("dac " + std::to_string(i)).length() + 1);
prev_val = std::stoi(s);
}
{
REQUIRE_NOTHROW(multiSlsDetectorClient("dac " + std::to_string(i) + " 1000", PUT));
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient("dac " + std::to_string(i), GET, nullptr, oss));
REQUIRE(oss.str() == "dac 1000\n");
REQUIRE(oss.str() == "dac " + std::to_string(i) + " 1000\n");
}
REQUIRE_NOTHROW(multiSlsDetectorClient("dac " + std::to_string(i) + " " + std::to_string(prev_val), PUT));
}