mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-19 00:07:13 +02:00
wip
This commit is contained in:
@ -1368,6 +1368,86 @@ std::string CmdProxy::Trigger(int action) {
|
||||
|
||||
/* Network Configuration (Detector<->Receiver) */
|
||||
|
||||
IpAddr CmdProxy::getIpFromAuto() {
|
||||
std::string rxHostname =
|
||||
det->getRxHostname(std::vector<int>{det_id}).squash("none");
|
||||
// Hostname could be ip try to decode otherwise look up the hostname
|
||||
auto val = sls::IpAddr{rxHostname};
|
||||
if (val == 0) {
|
||||
val = HostnameToIp(rxHostname.c_str());
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
defs::udpDestination CmdProxy::getUdpList() {
|
||||
defs::udpDestination dest{};
|
||||
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 (value == "auto") {
|
||||
auto val = getIpFromAuto();
|
||||
LOG(logINFO) << "Setting udp_dstip of detector " << det_id
|
||||
<< " to " << val;
|
||||
dest.ip = val.uint32();
|
||||
} else {
|
||||
dest.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();
|
||||
} else {
|
||||
dest.ip2 = IpAddr(value).uint32();
|
||||
}
|
||||
} else if (key == "mac") {
|
||||
dest.mac = MacAddr(value).uint64();
|
||||
} else if (key == "mac2") {
|
||||
dest.mac2 = MacAddr(value).uint64();
|
||||
} else if (key == "port") {
|
||||
dest.port = StringTo<int>(value);
|
||||
} else if (key == "port2") {
|
||||
dest.port2 = StringTo<int>(value);
|
||||
}
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
std::string CmdProxy::UDPDestinationList(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[entry=n_val] [ip=x.x.x.x] [(optional)ip2=x.x.x.x] "
|
||||
"\n[mac=xx:xx:xx:xx:xx:xx] "
|
||||
"[(optional)mac2=xx:xx:xx:xx:xx:xx]\n[port=value] "
|
||||
"[(optional)port2=value\n\tThe order of ip, mac and port does "
|
||||
"not matter. entry_value can be >0 only for Eiger and Jungfrau "
|
||||
"where round robin is implemented. If 'auto' used, then ip is "
|
||||
"set to ip of rx_hostname."
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
auto t = det->getDestinationUDPList(StringTo<int>(args[0]),
|
||||
std::vector<int>{det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.empty()) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
auto t = getUdpList();
|
||||
det->setDestinationUDPList(t, det_id);
|
||||
os << ToString(args) << std::endl;
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::UDPDestinationIP(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
@ -1387,13 +1467,7 @@ std::string CmdProxy::UDPDestinationIP(int action) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
if (args[0] == "auto") {
|
||||
std::string rxHostname =
|
||||
det->getRxHostname(std::vector<int>{det_id}).squash("none");
|
||||
// Hostname could be ip try to decode otherwise look up the hostname
|
||||
auto val = sls::IpAddr{rxHostname};
|
||||
if (val == 0) {
|
||||
val = HostnameToIp(rxHostname.c_str());
|
||||
}
|
||||
auto val = getIpFromAuto();
|
||||
LOG(logINFO) << "Setting udp_dstip of detector " << det_id << " to "
|
||||
<< val;
|
||||
det->setDestinationUDPIP(val, std::vector<int>{det_id});
|
||||
@ -1429,13 +1503,7 @@ std::string CmdProxy::UDPDestinationIP2(int action) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
if (args[0] == "auto") {
|
||||
std::string rxHostname =
|
||||
det->getRxHostname(std::vector<int>{det_id}).squash("none");
|
||||
// Hostname could be ip try to decode otherwise look up the hostname
|
||||
auto val = sls::IpAddr{rxHostname};
|
||||
if (val == 0) {
|
||||
val = HostnameToIp(rxHostname.c_str());
|
||||
}
|
||||
auto val = getIpFromAuto();
|
||||
LOG(logINFO) << "Setting udp_dstip2 of detector " << det_id
|
||||
<< " to " << val;
|
||||
det->setDestinationUDPIP2(val, std::vector<int>{det_id});
|
||||
|
@ -855,6 +855,7 @@ class CmdProxy {
|
||||
/* Network Configuration (Detector<->Receiver) */
|
||||
{"numinterfaces", &CmdProxy::numinterfaces},
|
||||
{"selinterface", &CmdProxy::selinterface},
|
||||
{"udp_dstlist", &CmdProxy::UDPDestinationList},
|
||||
{"udp_srcip", &CmdProxy::udp_srcip},
|
||||
{"udp_srcip2", &CmdProxy::udp_srcip2},
|
||||
{"udp_dstip", &CmdProxy::UDPDestinationIP},
|
||||
@ -1112,6 +1113,9 @@ class CmdProxy {
|
||||
std::string Scan(int action);
|
||||
std::string Trigger(int action);
|
||||
/* Network Configuration (Detector<->Receiver) */
|
||||
IpAddr getIpFromAuto();
|
||||
slsDetectorDefs::udpDestination getUdpList();
|
||||
std::string UDPDestinationList(int action);
|
||||
std::string UDPDestinationIP(int action);
|
||||
std::string UDPDestinationIP2(int action);
|
||||
/* Receiver Config */
|
||||
|
@ -899,6 +899,19 @@ void Detector::setSourceUDPMAC2(const MacAddr mac, Positions pos) {
|
||||
pimpl->Parallel(&Module::setSourceUDPMAC2, pos, mac);
|
||||
}
|
||||
|
||||
Result<defs::udpDestination>
|
||||
Detector::getDestinationUDPList(const int entry, Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getDestinationUDPList, pos, entry);
|
||||
}
|
||||
|
||||
void Detector::setDestinationUDPList(const defs::udpDestination dest,
|
||||
const int module_id) {
|
||||
if (module_id == -1 && size() > 1) {
|
||||
throw sls::RuntimeError("Cannot set this parameter at detector level.");
|
||||
}
|
||||
pimpl->Parallel(&Module::setDestinationUDPList, {module_id}, dest);
|
||||
}
|
||||
|
||||
Result<IpAddr> Detector::getDestinationUDPIP(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getDestinationUDPIP, pos);
|
||||
}
|
||||
|
@ -928,6 +928,24 @@ void Module::setSourceUDPMAC2(const sls::MacAddr mac) {
|
||||
sendToDetector(F_SET_SOURCE_UDP_MAC2, mac, nullptr);
|
||||
}
|
||||
|
||||
slsDetectorDefs::udpDestination
|
||||
Module::getDestinationUDPList(const int entry) const {
|
||||
// return sendToDetector<udpDestination>(F_GET_DEST_UDP_LIST);
|
||||
return bla;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
sls::IpAddr Module::getDestinationUDPIP() const {
|
||||
return sendToDetector<sls::IpAddr>(F_GET_DEST_UDP_IP);
|
||||
}
|
||||
|
@ -221,6 +221,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 int entry) const;
|
||||
void setDestinationUDPList(const defs::udpDestination dest);
|
||||
sls::IpAddr getDestinationUDPIP() const;
|
||||
void setDestinationUDPIP(const sls::IpAddr ip);
|
||||
sls::IpAddr getDestinationUDPIP2() const;
|
||||
@ -744,6 +746,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
|
||||
const int moduleId;
|
||||
mutable sls::SharedMemory<sharedSlsDetector> shm{0, 0};
|
||||
udpDestination bla{};
|
||||
};
|
||||
|
||||
} // namespace sls
|
Reference in New Issue
Block a user