This commit is contained in:
2021-08-17 14:05:59 +02:00
parent f72f678d45
commit c4c16ad9c0
10 changed files with 273 additions and 91 deletions

View File

@ -667,7 +667,7 @@ class Detector {
void setSourceUDPMAC2(const MacAddr mac, Positions pos = {});
Result<defs::udpDestination>
getDestinationUDPList(const int entry, Positions pos = {}) const;
getDestinationUDPList(const uint32_t entry, Positions pos = {}) const;
void setDestinationUDPList(const defs::udpDestination, const int module_id);

View File

@ -1380,40 +1380,69 @@ IpAddr CmdProxy::getIpFromAuto() {
}
defs::udpDestination CmdProxy::getUdpList() {
defs::udpDestination dest{};
uint32_t entry{};
uint32_t port{};
uint32_t port2{};
uint32_t ip{};
uint32_t ip2{};
uint64_t mac{};
uint64_t mac2{};
bool hasEntry = false;
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 == "ip") {
if (key == "entry") {
entry = 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;
dest.ip = val.uint32();
ip = val.uint32();
} else {
dest.ip = IpAddr(value).uint32();
ip = IpAddr(value).uint32();
}
} else if (key == "ip2") {
if (value == "auto") {
auto val = getIpFromAuto();
LOG(logINFO) << "Setting udp_dstip2 of detector " << det_id
<< " to " << val;
dest.ip2 = val.uint32();
ip2 = val.uint32();
} else {
dest.ip2 = IpAddr(value).uint32();
ip2 = IpAddr(value).uint32();
}
} else if (key == "mac") {
dest.mac = MacAddr(value).uint64();
mac = MacAddr(value).uint64();
} else if (key == "mac2") {
dest.mac2 = MacAddr(value).uint64();
mac2 = MacAddr(value).uint64();
} else if (key == "port") {
dest.port = StringTo<int>(value);
port = StringTo<uint32_t>(value);
} else if (key == "port2") {
dest.port2 = StringTo<int>(value);
port2 = StringTo<uint32_t>(value);
}
}
return dest;
// necessary arguments
if (hasEntry && ip != 0 && mac != 0 && port != 0) {
if (ip2 == 0 && mac2 == 0) {
// default (no second interface)
if (port2 == 0) {
return defs::udpDestination(entry, port, ip, mac);
}
// eiger (second udp port)
else {
return defs::udpDestination(entry, port, ip, mac, port2);
}
}
// jungfrau and gotthard2 (second interface)
if (ip2 != 0 && mac2 != 0 && port2 != 0) {
return defs::udpDestination(entry, port, ip, mac, port2, ip2, mac2);
}
}
throw sls::RuntimeError("Insufficient arguments");
}
std::string CmdProxy::UDPDestinationList(int action) {

View File

@ -909,7 +909,7 @@ void Detector::setSourceUDPMAC2(const MacAddr mac, Positions pos) {
}
Result<defs::udpDestination>
Detector::getDestinationUDPList(const int entry, Positions pos) const {
Detector::getDestinationUDPList(const uint32_t entry, Positions pos) const {
return pimpl->Parallel(&Module::getDestinationUDPList, pos, entry);
}

View File

@ -940,21 +940,26 @@ void Module::setSourceUDPMAC2(const sls::MacAddr mac) {
}
slsDetectorDefs::udpDestination
Module::getDestinationUDPList(const int entry) const {
// return sendToDetector<udpDestination>(F_GET_DEST_UDP_LIST);
return bla;
Module::getDestinationUDPList(const uint32_t entry) const {
return sendToDetector<udpDestination>(F_GET_DEST_UDP_LIST, entry);
}
void Module::setDestinationUDPList(const slsDetectorDefs::udpDestination dest) {
LOG(logINFO) << "setting stuff to " << dest;
bla.entry = dest.entry;
bla.ip = dest.ip;
bla.ip2 = dest.ip2;
bla.mac = dest.mac;
bla.mac2 = dest.mac2;
bla.port = dest.port;
bla.port2 = dest.port2;
// sendToDetector(F_SET_DEST_UDP_LIST, dest, nullptr);
// set them in the default way so the receivers are also set up
if (dest.entry_ == 0) {
setDestinationUDPPort(dest.port_);
setDestinationUDPIP(dest.ip_);
setDestinationUDPMAC(dest.mac_);
if (dest.port_ != 0) {
setDestinationUDPPort2(dest.port2_);
}
if (dest.ip2_ != 0) {
setDestinationUDPIP2(dest.ip2_);
setDestinationUDPMAC2(dest.mac2_);
}
} else {
sendToDetector(F_SET_DEST_UDP_LIST, dest, nullptr);
}
}
sls::IpAddr Module::getDestinationUDPIP() const {

View File

@ -222,7 +222,7 @@ class Module : public virtual slsDetectorDefs {
void setSourceUDPMAC(const sls::MacAddr mac);
sls::MacAddr getSourceUDPMAC2() const;
void setSourceUDPMAC2(const sls::MacAddr mac);
udpDestination getDestinationUDPList(const int entry) const;
udpDestination getDestinationUDPList(const uint32_t entry) const;
void setDestinationUDPList(const defs::udpDestination dest);
sls::IpAddr getDestinationUDPIP() const;
void setDestinationUDPIP(const sls::IpAddr ip);
@ -745,7 +745,6 @@ class Module : public virtual slsDetectorDefs {
const int moduleId;
mutable sls::SharedMemory<sharedSlsDetector> shm{0, 0};
udpDestination bla{};
};
} // namespace sls