mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-17 15:27:13 +02:00
replace udpDestination struct with a class that accepts ipaddr
This commit is contained in:
@ -1379,15 +1379,8 @@ IpAddr CmdProxy::getIpFromAuto() {
|
||||
return val;
|
||||
}
|
||||
|
||||
defs::udpDestination CmdProxy::getUdpList() {
|
||||
uint32_t entry{};
|
||||
uint32_t port{};
|
||||
uint32_t port2{};
|
||||
uint32_t ip{};
|
||||
uint32_t ip2{};
|
||||
uint64_t mac{};
|
||||
uint64_t mac2{};
|
||||
|
||||
UdpDestination CmdProxy::getUdpEntry() {
|
||||
UdpDestination udpDestination{};
|
||||
bool hasEntry = false;
|
||||
|
||||
for (auto it : args) {
|
||||
@ -1395,40 +1388,40 @@ defs::udpDestination CmdProxy::getUdpList() {
|
||||
std::string key = it.substr(0, pos);
|
||||
std::string value = it.substr(pos + 1);
|
||||
if (key == "entry") {
|
||||
entry = StringTo<int>(value);
|
||||
udpDestination.setEntry(StringTo<int>(value));
|
||||
hasEntry = true;
|
||||
} else if (key == "ip") {
|
||||
if (value == "auto") {
|
||||
auto val = getIpFromAuto();
|
||||
LOG(logINFO) << "Setting udp_dstip of detector " << det_id
|
||||
<< " to " << val;
|
||||
ip = val.uint32();
|
||||
udpDestination.setIp(val);
|
||||
} else {
|
||||
ip = IpAddr(value).uint32();
|
||||
udpDestination.setIp(IpAddr(value));
|
||||
}
|
||||
} else if (key == "ip2") {
|
||||
if (value == "auto") {
|
||||
auto val = getIpFromAuto();
|
||||
LOG(logINFO) << "Setting udp_dstip2 of detector " << det_id
|
||||
<< " to " << val;
|
||||
ip2 = val.uint32();
|
||||
udpDestination.setIp2(val);
|
||||
} else {
|
||||
ip2 = IpAddr(value).uint32();
|
||||
udpDestination.setIp2(IpAddr(value));
|
||||
}
|
||||
} else if (key == "mac") {
|
||||
mac = MacAddr(value).uint64();
|
||||
udpDestination.setMac(MacAddr(value));
|
||||
} else if (key == "mac2") {
|
||||
mac2 = MacAddr(value).uint64();
|
||||
udpDestination.setMac2(MacAddr(value));
|
||||
} else if (key == "port") {
|
||||
port = StringTo<uint32_t>(value);
|
||||
udpDestination.setPort(StringTo<uint32_t>(value));
|
||||
} else if (key == "port2") {
|
||||
port2 = StringTo<uint32_t>(value);
|
||||
udpDestination.setPort2(StringTo<uint32_t>(value));
|
||||
}
|
||||
}
|
||||
if (!hasEntry) {
|
||||
throw sls::RuntimeError("Found no entry argument.");
|
||||
}
|
||||
return defs::udpDestination(entry, port, ip, mac, port2, ip2, mac2);
|
||||
return udpDestination;
|
||||
}
|
||||
|
||||
std::string CmdProxy::UDPDestinationList(int action) {
|
||||
@ -1454,7 +1447,7 @@ std::string CmdProxy::UDPDestinationList(int action) {
|
||||
if (args.empty()) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
auto t = getUdpList();
|
||||
auto t = getUdpEntry();
|
||||
det->setDestinationUDPList(t, det_id);
|
||||
os << ToString(args) << std::endl;
|
||||
} else {
|
||||
|
@ -1117,7 +1117,7 @@ class CmdProxy {
|
||||
std::string Trigger(int action);
|
||||
/* Network Configuration (Detector<->Receiver) */
|
||||
IpAddr getIpFromAuto();
|
||||
slsDetectorDefs::udpDestination getUdpList();
|
||||
UdpDestination getUdpEntry();
|
||||
std::string UDPDestinationList(int action);
|
||||
std::string UDPDestinationIP(int action);
|
||||
std::string UDPDestinationIP2(int action);
|
||||
|
@ -908,12 +908,12 @@ void Detector::setSourceUDPMAC2(const MacAddr mac, Positions pos) {
|
||||
pimpl->Parallel(&Module::setSourceUDPMAC2, pos, mac);
|
||||
}
|
||||
|
||||
Result<defs::udpDestination>
|
||||
Detector::getDestinationUDPList(const uint32_t entry, Positions pos) const {
|
||||
Result<UdpDestination> Detector::getDestinationUDPList(const uint32_t entry,
|
||||
Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getDestinationUDPList, pos, entry);
|
||||
}
|
||||
|
||||
void Detector::setDestinationUDPList(const defs::udpDestination dest,
|
||||
void Detector::setDestinationUDPList(const UdpDestination dest,
|
||||
const int module_id) {
|
||||
if (module_id == -1 && size() > 1) {
|
||||
throw sls::RuntimeError("Cannot set this parameter at detector level.");
|
||||
|
@ -939,31 +939,30 @@ void Module::setSourceUDPMAC2(const sls::MacAddr mac) {
|
||||
sendToDetector(F_SET_SOURCE_UDP_MAC2, mac, nullptr);
|
||||
}
|
||||
|
||||
slsDetectorDefs::udpDestination
|
||||
Module::getDestinationUDPList(const uint32_t entry) const {
|
||||
return sendToDetector<udpDestination>(F_GET_DEST_UDP_LIST, entry);
|
||||
sls::UdpDestination Module::getDestinationUDPList(const uint32_t entry) const {
|
||||
return sendToDetector<sls::UdpDestination>(F_GET_DEST_UDP_LIST, entry);
|
||||
}
|
||||
|
||||
void Module::setDestinationUDPList(const slsDetectorDefs::udpDestination dest) {
|
||||
void Module::setDestinationUDPList(const sls::UdpDestination dest) {
|
||||
// set them in the default way so the receivers are also set up
|
||||
if (dest.entry_ == 0) {
|
||||
if (dest.port_ != 0) {
|
||||
setDestinationUDPPort(dest.port_);
|
||||
if (dest.getEntry() == 0) {
|
||||
if (dest.getPort() != 0) {
|
||||
setDestinationUDPPort(dest.getPort());
|
||||
}
|
||||
if (dest.ip_ != 0) {
|
||||
setDestinationUDPIP(IpAddr(dest.ip_));
|
||||
if (dest.getIp() != 0) {
|
||||
setDestinationUDPIP(IpAddr(dest.getIp()));
|
||||
}
|
||||
if (dest.mac_ != 0) {
|
||||
setDestinationUDPMAC(MacAddr(dest.mac_));
|
||||
if (dest.getMac() != 0) {
|
||||
setDestinationUDPMAC(MacAddr(dest.getMac()));
|
||||
}
|
||||
if (dest.port2_ != 0) {
|
||||
setDestinationUDPPort2(dest.port2_);
|
||||
if (dest.getPort2() != 0) {
|
||||
setDestinationUDPPort2(dest.getPort2());
|
||||
}
|
||||
if (dest.ip2_ != 0) {
|
||||
setDestinationUDPIP2(IpAddr(dest.ip2_));
|
||||
if (dest.getIp2() != 0) {
|
||||
setDestinationUDPIP2(IpAddr(dest.getIp2()));
|
||||
}
|
||||
if (dest.mac2_ != 0) {
|
||||
setDestinationUDPMAC2(MacAddr(dest.mac2_));
|
||||
if (dest.getMac2() != 0) {
|
||||
setDestinationUDPMAC2(MacAddr(dest.getMac2()));
|
||||
}
|
||||
} else {
|
||||
sendToDetector(F_SET_DEST_UDP_LIST, dest, nullptr);
|
||||
|
@ -222,8 +222,8 @@ class Module : public virtual slsDetectorDefs {
|
||||
void setSourceUDPMAC(const sls::MacAddr mac);
|
||||
sls::MacAddr getSourceUDPMAC2() const;
|
||||
void setSourceUDPMAC2(const sls::MacAddr mac);
|
||||
udpDestination getDestinationUDPList(const uint32_t entry) const;
|
||||
void setDestinationUDPList(const defs::udpDestination dest);
|
||||
sls::UdpDestination getDestinationUDPList(const uint32_t entry) const;
|
||||
void setDestinationUDPList(const sls::UdpDestination dest);
|
||||
int getNumberofUDPDestinations() const;
|
||||
void setNumberofUDPDestinations(const int value);
|
||||
int getFirstUDPDestination() const;
|
||||
|
Reference in New Issue
Block a user