mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 12:57:13 +02:00
first try on setrxhostname
This commit is contained in:
@ -826,12 +826,10 @@ class Detector {
|
|||||||
* receiver property (not on detector). \n receiver is receiver hostname or
|
* receiver property (not on detector). \n receiver is receiver hostname or
|
||||||
* IP address, can include tcp port eg. hostname:port
|
* IP address, can include tcp port eg. hostname:port
|
||||||
*/
|
*/
|
||||||
void setRxHostname(const std::string &receiver, Positions pos = {},
|
void setRxHostname(const std::string &receiver, Positions pos = {});
|
||||||
const int rx_index = 0);
|
|
||||||
|
|
||||||
/** multiple rx hostnames. Single element will set it for all */
|
/** multiple rx hostnames. Single element will set it for all */
|
||||||
void setRxHostname(const std::vector<std::string> &name,
|
void setRxHostname(const std::vector<std::string> &name);
|
||||||
const int rx_index = 0);
|
|
||||||
|
|
||||||
Result<int> getRxPort(Positions pos = {}, const int rx_index = 0) const;
|
Result<int> getRxPort(Positions pos = {}, const int rx_index = 0) const;
|
||||||
|
|
||||||
|
@ -1569,9 +1569,14 @@ std::string CmdProxy::ReceiverHostname(int action) {
|
|||||||
else {
|
else {
|
||||||
// multiple receivers concatenated with +
|
// multiple receivers concatenated with +
|
||||||
if (args[0].find('+') != std::string::npos) {
|
if (args[0].find('+') != std::string::npos) {
|
||||||
if (det_id != -1) {
|
// allowing multiple receivers at module level
|
||||||
|
/*if (det_id != -1) {
|
||||||
throw sls::RuntimeError(
|
throw sls::RuntimeError(
|
||||||
"Cannot add multiple receivers at module level");
|
"Cannot add multiple receivers at module level");
|
||||||
|
}*/
|
||||||
|
if (rx_id != -1) {
|
||||||
|
throw sls::RuntimeError(
|
||||||
|
"Cannot add multiple receivers at RR level");
|
||||||
}
|
}
|
||||||
auto t = sls::split(args[0], '+');
|
auto t = sls::split(args[0], '+');
|
||||||
det->setRxHostname(t);
|
det->setRxHostname(t);
|
||||||
|
@ -1076,17 +1076,16 @@ Result<std::string> Detector::getRxHostname(Positions pos,
|
|||||||
return pimpl->Parallel(&Module::getReceiverHostname, pos, rx_index);
|
return pimpl->Parallel(&Module::getReceiverHostname, pos, rx_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setRxHostname(const std::string &receiver, Positions pos,
|
// rr added using + at module level
|
||||||
const int rx_index) {
|
void Detector::setRxHostname(const std::string &receiver, Positions pos) {
|
||||||
pimpl->Parallel(&Module::setReceiverHostname, pos, receiver, rx_index);
|
pimpl->Parallel(&Module::setReceiverHostname, pos, receiver);
|
||||||
updateRxRateCorrections();
|
updateRxRateCorrections();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setRxHostname(const std::vector<std::string> &name,
|
void Detector::setRxHostname(const std::vector<std::string> &name) {
|
||||||
const int rx_index) {
|
|
||||||
// set all to same rx_hostname
|
// set all to same rx_hostname
|
||||||
if (name.size() == 1) {
|
if (name.size() == 1) {
|
||||||
pimpl->Parallel(&Module::setReceiverHostname, {}, name[0], rx_index);
|
pimpl->Parallel(&Module::setReceiverHostname, {}, name[0]);
|
||||||
} else {
|
} else {
|
||||||
if ((int)name.size() != size()) {
|
if ((int)name.size() != size()) {
|
||||||
throw RuntimeError(
|
throw RuntimeError(
|
||||||
@ -1095,8 +1094,7 @@ void Detector::setRxHostname(const std::vector<std::string> &name,
|
|||||||
}
|
}
|
||||||
// set each rx_hostname
|
// set each rx_hostname
|
||||||
for (int idet = 0; idet < size(); ++idet) {
|
for (int idet = 0; idet < size(); ++idet) {
|
||||||
pimpl->Parallel(&Module::setReceiverHostname, {idet}, name[idet],
|
pimpl->Parallel(&Module::setReceiverHostname, {idet}, name[idet]);
|
||||||
rx_index);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateRxRateCorrections();
|
updateRxRateCorrections();
|
||||||
|
@ -1261,64 +1261,83 @@ std::string Module::getReceiverHostname(const int rxIndex) const {
|
|||||||
return std::string(shm()->receivers[rxIndex].hostname);
|
return std::string(shm()->receivers[rxIndex].hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setReceiverHostname(const std::string &receiverIP,
|
void Module::setReceiverHostname(const std::string &receiverIP) {
|
||||||
const int rxIndex) {
|
|
||||||
LOG(logDEBUG1) << "Setting up Receiver with " << receiverIP;
|
LOG(logDEBUG1) << "Setting up Receiver with " << receiverIP;
|
||||||
|
|
||||||
if (receiverIP == "none") {
|
if (getRunStatus() == RUNNING) {
|
||||||
memset(shm()->receivers[rxIndex].hostname, 0, MAX_STR_LENGTH);
|
throw RuntimeError(
|
||||||
sls::strcpy_safe(shm()->receivers[rxIndex].hostname, "none");
|
"Cannot set rx hostname when detector is acquiring.");
|
||||||
shm()->useReceiverFlag = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getRunStatus() == RUNNING) {
|
if (receiverIP == "none") {
|
||||||
LOG(logWARNING) << "Acquisition already running, Stopping it.";
|
for (int i = 0; i != MAX_UDP_DESTINATION; ++i) {
|
||||||
stopAcquisition();
|
memset(shm()->receivers[i].hostname, 0, MAX_STR_LENGTH);
|
||||||
|
sls::strcpy_safe(shm()->receivers[i].hostname, "none");
|
||||||
|
}
|
||||||
|
shm()->useReceiverFlag = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> list;
|
||||||
|
// many rx hostames concatenated with + (RR)
|
||||||
|
if (receiverIP.find('+') != std::string::npos) {
|
||||||
|
auto t = sls::split(receiverIP, '+');
|
||||||
|
list.push_back(t);
|
||||||
|
} else {
|
||||||
|
list.push_back(receiverIP);
|
||||||
|
}
|
||||||
|
|
||||||
|
// clear all rxrs for current module
|
||||||
|
for (int i = 0; i != MAX_UDP_DESTINATION; ++i) {
|
||||||
|
memset(shm()->receivers[i].hostname, 0, MAX_STR_LENGTH);
|
||||||
|
sls::strcpy_safe(shm()->receivers[i].hostname, "none");
|
||||||
}
|
}
|
||||||
|
|
||||||
// start updating
|
// start updating
|
||||||
std::string host = receiverIP;
|
for (int i = 0; i != list.size(); ++i) {
|
||||||
auto res = sls::split(host, ':');
|
std::string host = receiverIP;
|
||||||
if (res.size() > 1) {
|
auto res = sls::split(host, ':');
|
||||||
host = res[0];
|
if (res.size() > 1) {
|
||||||
shm()->receivers[rxIndex].tcpPort = std::stoi(res[1]);
|
host = res[0];
|
||||||
|
shm()->receivers[i].tcpPort = std::stoi(res[1]);
|
||||||
|
}
|
||||||
|
sls::strcpy_safe(shm()->receivers[i].hostname, host.c_str());
|
||||||
|
shm()->useReceiverFlag = true;
|
||||||
|
checkReceiverVersionCompatibility();
|
||||||
|
|
||||||
|
// populate parameters from detector
|
||||||
|
rxParameters retval;
|
||||||
|
sendToDetector(F_GET_RECEIVER_PARAMETERS, nullptr, retval);
|
||||||
|
|
||||||
|
// populate from shared memory
|
||||||
|
retval.detType = shm()->detType;
|
||||||
|
retval.numberOfModule.x = shm()->numberOfModule.x;
|
||||||
|
retval.numberOfModule.y = shm()->numberOfModule.y;
|
||||||
|
retval.moduleIndex = moduleIndex;
|
||||||
|
memset(retval.hostname, 0, sizeof(retval.hostname));
|
||||||
|
strcpy_safe(retval.hostname, shm()->hostname);
|
||||||
|
|
||||||
|
sls::MacAddr retvals[2];
|
||||||
|
sendToReceiver(i, F_SETUP_RECEIVER, retval, retvals);
|
||||||
|
// update Modules with dest mac
|
||||||
|
if (retval.udp_dstmac == 0 && retvals[0] != 0) {
|
||||||
|
LOG(logINFO) << "Setting destination udp mac of "
|
||||||
|
"Module "
|
||||||
|
<< moduleIndex << " to " << retvals[0];
|
||||||
|
sendToDetector(F_SET_DEST_UDP_MAC, retvals[0], nullptr);
|
||||||
|
}
|
||||||
|
if (retval.udp_dstmac2 == 0 && retvals[1] != 0) {
|
||||||
|
LOG(logINFO) << "Setting destination udp mac2 of "
|
||||||
|
"Module "
|
||||||
|
<< moduleIndex << " to " << retvals[1];
|
||||||
|
sendToDetector(F_SET_DEST_UDP_MAC2, retvals[1], nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
shm()->numUDPInterfaces = retval.udpInterfaces;
|
||||||
|
|
||||||
|
// to use rx_hostname if empty and also update client zmqip
|
||||||
|
updateReceiverStreamingIP(i);
|
||||||
}
|
}
|
||||||
sls::strcpy_safe(shm()->receivers[rxIndex].hostname, host.c_str());
|
|
||||||
shm()->useReceiverFlag = true;
|
|
||||||
checkReceiverVersionCompatibility();
|
|
||||||
|
|
||||||
// populate parameters from detector
|
|
||||||
rxParameters retval;
|
|
||||||
sendToDetector(F_GET_RECEIVER_PARAMETERS, nullptr, retval);
|
|
||||||
|
|
||||||
// populate from shared memory
|
|
||||||
retval.detType = shm()->detType;
|
|
||||||
retval.numberOfModule.x = shm()->numberOfModule.x;
|
|
||||||
retval.numberOfModule.y = shm()->numberOfModule.y;
|
|
||||||
retval.moduleIndex = moduleIndex;
|
|
||||||
memset(retval.hostname, 0, sizeof(retval.hostname));
|
|
||||||
strcpy_safe(retval.hostname, shm()->hostname);
|
|
||||||
|
|
||||||
sls::MacAddr retvals[2];
|
|
||||||
sendToReceiver(rxIndex, F_SETUP_RECEIVER, retval, retvals);
|
|
||||||
// update Modules with dest mac
|
|
||||||
if (retval.udp_dstmac == 0 && retvals[0] != 0) {
|
|
||||||
LOG(logINFO) << "Setting destination udp mac of "
|
|
||||||
"Module "
|
|
||||||
<< moduleIndex << " to " << retvals[0];
|
|
||||||
sendToDetector(F_SET_DEST_UDP_MAC, retvals[0], nullptr);
|
|
||||||
}
|
|
||||||
if (retval.udp_dstmac2 == 0 && retvals[1] != 0) {
|
|
||||||
LOG(logINFO) << "Setting destination udp mac2 of "
|
|
||||||
"Module "
|
|
||||||
<< moduleIndex << " to " << retvals[1];
|
|
||||||
sendToDetector(F_SET_DEST_UDP_MAC2, retvals[1], nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
shm()->numUDPInterfaces = retval.udpInterfaces;
|
|
||||||
|
|
||||||
// to use rx_hostname if empty and also update client zmqip
|
|
||||||
updateReceiverStreamingIP(rxIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Module::getReceiverPort(const int rxIndex) const {
|
int Module::getReceiverPort(const int rxIndex) const {
|
||||||
|
@ -272,7 +272,7 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
* ************************************************/
|
* ************************************************/
|
||||||
bool getUseReceiverFlag() const;
|
bool getUseReceiverFlag() const;
|
||||||
std::string getReceiverHostname(const int rxIndex) const;
|
std::string getReceiverHostname(const int rxIndex) const;
|
||||||
void setReceiverHostname(const std::string &receiver, const int rxIndex);
|
void setReceiverHostname(const std::string &receiver);
|
||||||
int getReceiverPort(const int rxIndex) const;
|
int getReceiverPort(const int rxIndex) const;
|
||||||
int setReceiverPort(int port_number, const int rxIndex);
|
int setReceiverPort(int port_number, const int rxIndex);
|
||||||
int getReceiverFifoDepth() const;
|
int getReceiverFifoDepth() const;
|
||||||
|
Reference in New Issue
Block a user