warning in using abs for unsigned (missing packets) in rxr, but also trying to print to signed in command line (so as not to change api atm)

This commit is contained in:
2022-01-05 12:55:21 +01:00
parent 2dd98c6054
commit 77fb8280f1
4 changed files with 50 additions and 6 deletions

View File

@ -1,3 +1,4 @@
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
#include "CmdProxy.h"
@ -1273,6 +1274,40 @@ std::string CmdProxy::DetectorStatus(int action) {
return os.str();
}
std::string CmdProxy::RxMissingPackets(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "Number of missing packets for each port in receiver. If "
"negative, they are packets in excess. "
<< '\n';
} else if (action == defs::GET_ACTION) {
if (!args.empty()) {
WrongNumberOfParameters(0);
}
auto tmp = det->getNumMissingPackets(std::vector<int>{det_id});
// convert to signed missing packets (to get excess)
/*
Result<std::vector<int64_t>> mp(tmp.size());
for (unsigned int i = 0; i < mp.size(); ++i) {
mp[i] = static_cast<int64_t>(tmp[i]);
}
*/
Result<std::vector<int64_t>> mp;
for (auto val : tmp) {
mp.push_back(static_cast<int64_t>(val));
}
os << OutString(mp) << '\n';
} else if (action == defs::PUT_ACTION) {
throw sls::RuntimeError("Cannot put");
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
std::string CmdProxy::Scan(int action) {
std::ostringstream os;
os << cmd << ' ';