mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-18 07:47:12 +02:00
entry removed and using parsing for rr
This commit is contained in:
@ -67,7 +67,7 @@ int main(int argc, char *argv[]) {
|
||||
sls::Detector det(parser.multi_id());
|
||||
sls::CmdProxy proxy(&det);
|
||||
proxy.Call(parser.command(), parser.arguments(), parser.detector_id(),
|
||||
action);
|
||||
action, std::cout, parser.receiver_id());
|
||||
} catch (const sls::RuntimeError &e) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
@ -29,10 +29,11 @@ std::ostream &operator<<(std::ostream &os,
|
||||
|
||||
void CmdProxy::Call(const std::string &command,
|
||||
const std::vector<std::string> &arguments, int detector_id,
|
||||
int action, std::ostream &os) {
|
||||
int action, std::ostream &os, int receiver_id) {
|
||||
cmd = command;
|
||||
args = arguments;
|
||||
det_id = detector_id;
|
||||
rx_id = receiver_id;
|
||||
|
||||
std::string temp;
|
||||
while (temp != cmd) {
|
||||
@ -1381,16 +1382,13 @@ IpAddr CmdProxy::getIpFromAuto() {
|
||||
|
||||
UdpDestination CmdProxy::getUdpEntry() {
|
||||
UdpDestination udpDestination{};
|
||||
bool hasEntry = false;
|
||||
udpDestination.entry = rx_id;
|
||||
|
||||
for (auto it : args) {
|
||||
size_t pos = it.find('=');
|
||||
std::string key = it.substr(0, pos);
|
||||
std::string value = it.substr(pos + 1);
|
||||
if (key == "entry") {
|
||||
udpDestination.entry = StringTo<int>(value);
|
||||
hasEntry = true;
|
||||
} else if (key == "ip") {
|
||||
if (key == "ip") {
|
||||
if (value == "auto") {
|
||||
auto val = getIpFromAuto();
|
||||
LOG(logINFO) << "Setting udp_dstip of detector " << det_id
|
||||
@ -1418,9 +1416,6 @@ UdpDestination CmdProxy::getUdpEntry() {
|
||||
udpDestination.port2 = StringTo<uint32_t>(value);
|
||||
}
|
||||
}
|
||||
if (!hasEntry) {
|
||||
throw sls::RuntimeError("Found no entry argument.");
|
||||
}
|
||||
return udpDestination;
|
||||
}
|
||||
|
||||
@ -1437,16 +1432,29 @@ std::string CmdProxy::UDPDestinationList(int action) {
|
||||
"set to ip of rx_hostname."
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
if (!args.empty()) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getDestinationUDPList(StringTo<int>(args[0]),
|
||||
std::vector<int>{det_id});
|
||||
if (det_id == -1) {
|
||||
throw sls::RuntimeError("udp_dstlist must be at module level.");
|
||||
}
|
||||
if (rx_id < 0 || rx_id >= MAX_UDP_DESTINATION) {
|
||||
throw sls::RuntimeError(
|
||||
"Invalid receiver index to get round robin entry.");
|
||||
}
|
||||
auto t = det->getDestinationUDPList(rx_id, std::vector<int>{det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.empty()) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
if (det_id == -1) {
|
||||
throw sls::RuntimeError("udp_dstlist must be at module level.");
|
||||
}
|
||||
if (rx_id < 0 || rx_id >= MAX_UDP_DESTINATION) {
|
||||
throw sls::RuntimeError(
|
||||
"Invalid receiver index to set round robin entry.");
|
||||
}
|
||||
auto t = getUdpEntry();
|
||||
det->setDestinationUDPList(t, det_id);
|
||||
os << ToString(args) << std::endl;
|
||||
|
@ -529,7 +529,8 @@ class CmdProxy {
|
||||
|
||||
void Call(const std::string &command,
|
||||
const std::vector<std::string> &arguments, int detector_id = -1,
|
||||
int action = -1, std::ostream &os = std::cout);
|
||||
int action = -1, std::ostream &os = std::cout,
|
||||
int receiver_id = -1);
|
||||
|
||||
bool ReplaceIfDepreciated(std::string &command);
|
||||
size_t GetFunctionMapSize() const noexcept { return functions.size(); };
|
||||
@ -541,6 +542,7 @@ class CmdProxy {
|
||||
std::string cmd;
|
||||
std::vector<std::string> args;
|
||||
int det_id{-1};
|
||||
int rx_id{-1};
|
||||
|
||||
template <typename V> std::string OutStringHex(const V &value) {
|
||||
if (value.equal())
|
||||
|
Reference in New Issue
Block a user