mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 04:47:14 +02:00
Dev/fix port size (#805)
* port datatype changing from int to uint16_t * throwing for -1 given for uint16_t ports
This commit is contained in:
@ -66,7 +66,7 @@ class Detector {
|
||||
|
||||
/** connects to n servers at local host starting at specific control port.
|
||||
* Every virtual server will have a stop port (control port + 1) */
|
||||
void setVirtualDetectorServers(int numServers, int startingPort);
|
||||
void setVirtualDetectorServers(int numServers, uint16_t startingPort);
|
||||
|
||||
/** Gets shared memory ID */
|
||||
int getShmId() const;
|
||||
@ -791,20 +791,20 @@ class Detector {
|
||||
*/
|
||||
void setDestinationUDPMAC2(const MacAddr mac, Positions pos = {});
|
||||
|
||||
Result<int> getDestinationUDPPort(Positions pos = {}) const;
|
||||
Result<uint16_t> getDestinationUDPPort(Positions pos = {}) const;
|
||||
|
||||
/** Default is 50001. \n If module_id is -1, ports for each module is
|
||||
* calculated (incremented by 1 if no 2nd interface) */
|
||||
void setDestinationUDPPort(int port, int module_id = -1);
|
||||
void setDestinationUDPPort(uint16_t port, int module_id = -1);
|
||||
|
||||
/** [Eiger] right port[Jungfrau][Moench] bottom half [Gotthard2] veto
|
||||
* debugging */
|
||||
Result<int> getDestinationUDPPort2(Positions pos = {}) const;
|
||||
Result<uint16_t> getDestinationUDPPort2(Positions pos = {}) const;
|
||||
|
||||
/** [Eiger] right port[Jungfrau][Moench] bottom half [Gotthard2] veto
|
||||
* debugging \n Default is 50002. \n If module_id is -1, ports for each
|
||||
* module is calculated (incremented by 1 if no 2nd interface)*/
|
||||
void setDestinationUDPPort2(int port, int module_id = -1);
|
||||
void setDestinationUDPPort2(uint16_t port, int module_id = -1);
|
||||
|
||||
/** Reconfigures Detector with UDP destination. More for debugging as the
|
||||
* configuration is done automatically when the detector has sufficient UDP
|
||||
@ -904,14 +904,14 @@ class Detector {
|
||||
/** multiple rx hostnames. Single element will set it for all */
|
||||
void setRxHostname(const std::vector<std::string> &name);
|
||||
|
||||
Result<int> getRxPort(Positions pos = {}) const;
|
||||
Result<uint16_t> getRxPort(Positions pos = {}) const;
|
||||
|
||||
/** TCP port for client-receiver communication. \n
|
||||
* Default is 1954. \n Must be different if multiple receivers on same pc.
|
||||
* \n Must be first command to set a receiver parameter to be able to
|
||||
* communicate. \n Multi command will automatically increment port for
|
||||
* individual modules.*/
|
||||
void setRxPort(int port, int module_id = -1);
|
||||
void setRxPort(uint16_t port, int module_id = -1);
|
||||
|
||||
Result<int> getRxFifoDepth(Positions pos = {}) const;
|
||||
|
||||
@ -1089,7 +1089,7 @@ class Detector {
|
||||
*/
|
||||
void setRxZmqStartingFrame(int fnum, Positions pos = {});
|
||||
|
||||
Result<int> getRxZmqPort(Positions pos = {}) const;
|
||||
Result<uint16_t> getRxZmqPort(Positions pos = {}) const;
|
||||
|
||||
/** Zmq port for data to be streamed out of the receiver. \n
|
||||
* Also restarts receiver zmq streaming if enabled. \n Default is 30001. \n
|
||||
@ -1098,7 +1098,7 @@ class Detector {
|
||||
* no 2nd interface). \n Restarts receiver zmq sockets only if it was
|
||||
* already enabled
|
||||
*/
|
||||
void setRxZmqPort(int port, int module_id = -1);
|
||||
void setRxZmqPort(uint16_t port, int module_id = -1);
|
||||
|
||||
Result<IpAddr> getRxZmqIP(Positions pos = {}) const;
|
||||
|
||||
@ -1108,7 +1108,7 @@ class Detector {
|
||||
* receiver. */
|
||||
void setRxZmqIP(const IpAddr ip, Positions pos = {});
|
||||
|
||||
Result<int> getClientZmqPort(Positions pos = {}) const;
|
||||
Result<uint16_t> getClientZmqPort(Positions pos = {}) const;
|
||||
|
||||
/** Port number to listen to zmq data streamed out from receiver or
|
||||
* intermediate process. \n Must be different for every detector (and udp
|
||||
@ -1117,7 +1117,7 @@ class Detector {
|
||||
* sockets only if it was already enabled \n Default connects to receiver
|
||||
* zmq streaming out port (30001).
|
||||
*/
|
||||
void setClientZmqPort(int port, int module_id = -1);
|
||||
void setClientZmqPort(uint16_t port, int module_id = -1);
|
||||
|
||||
Result<IpAddr> getClientZmqIp(Positions pos = {}) const;
|
||||
|
||||
@ -2068,18 +2068,18 @@ class Detector {
|
||||
* *
|
||||
* ************************************************/
|
||||
|
||||
Result<int> getControlPort(Positions pos = {}) const;
|
||||
Result<uint16_t> getControlPort(Positions pos = {}) const;
|
||||
|
||||
/** Detector Control TCP port (for client communication with Detector
|
||||
* control server) Default is 1952. Normally unchanged. Set different ports
|
||||
* for virtual servers on same pc */
|
||||
void setControlPort(int value, Positions pos = {});
|
||||
void setControlPort(uint16_t value, Positions pos = {});
|
||||
|
||||
Result<int> getStopPort(Positions pos = {}) const;
|
||||
Result<uint16_t> getStopPort(Positions pos = {}) const;
|
||||
|
||||
/** Port number of the stop server on detector for detector-client tcp
|
||||
* interface. Default is 1953. Normally unchanged. */
|
||||
void setStopPort(int value, Positions pos = {});
|
||||
void setStopPort(uint16_t value, Positions pos = {});
|
||||
|
||||
Result<bool> getDetectorLock(Positions pos = {}) const;
|
||||
|
||||
@ -2112,7 +2112,7 @@ class Detector {
|
||||
///@}
|
||||
|
||||
private:
|
||||
std::vector<int> getPortNumbers(int start_port);
|
||||
std::vector<uint16_t> getValidPortNumbers(uint16_t start_port);
|
||||
void updateRxRateCorrections();
|
||||
void setNumberofUDPInterfaces_(int n, Positions pos);
|
||||
};
|
||||
|
@ -197,7 +197,7 @@ std::string CmdProxy::VirtualServer(int action) {
|
||||
throw RuntimeError("Cannot execute this at module level");
|
||||
}
|
||||
det->setVirtualDetectorServers(StringTo<int>(args[0]),
|
||||
StringTo<int>(args[1]));
|
||||
StringTo<uint16_t>(args[1]));
|
||||
os << ToString(args);
|
||||
} else {
|
||||
throw RuntimeError("Unknown action");
|
||||
|
@ -187,7 +187,6 @@ namespace sls {
|
||||
return os.str(); \
|
||||
}
|
||||
|
||||
/** int or enum */
|
||||
#define INTEGER_COMMAND_VEC_ID_GET(CMDNAME, GETFCN, SETFCN, CONV, HLPSTR) \
|
||||
std::string CMDNAME(const int action) { \
|
||||
std::ostringstream os; \
|
||||
@ -1976,14 +1975,14 @@ class CmdProxy {
|
||||
|
||||
INTEGER_COMMAND_VEC_ID_GET(
|
||||
udp_dstport, getDestinationUDPPort, setDestinationUDPPort,
|
||||
StringTo<int>,
|
||||
StringTo<uint16_t>,
|
||||
"[n]\n\tPort number of the receiver (destination) udp "
|
||||
"interface. Default is 50001. \n\tIf multi command, ports for each "
|
||||
"module is calculated (incremented by 1 if no 2nd interface)");
|
||||
|
||||
INTEGER_COMMAND_VEC_ID_GET(
|
||||
udp_dstport2, getDestinationUDPPort2, setDestinationUDPPort2,
|
||||
StringTo<int>,
|
||||
StringTo<uint16_t>,
|
||||
"[n]\n\t[Jungfrau][Moench][Eiger][Gotthard2] Port number of the "
|
||||
"receiver (destination) udp interface 2. Default is 50002. "
|
||||
"\n\tIf multi command, ports for each module is calculated "
|
||||
@ -2041,7 +2040,7 @@ class CmdProxy {
|
||||
/* Receiver Config */
|
||||
|
||||
INTEGER_COMMAND_VEC_ID_GET(
|
||||
rx_tcpport, getRxPort, setRxPort, StringTo<int>,
|
||||
rx_tcpport, getRxPort, setRxPort, StringTo<uint16_t>,
|
||||
"[port]\n\tTCP port for client-receiver communication. Default is "
|
||||
"1954. Must be different if multiple receivers on same pc. Must be "
|
||||
"first command to set a receiver parameter. Multi command will "
|
||||
@ -2172,7 +2171,7 @@ class CmdProxy {
|
||||
"and then depending on the rx zmq frequency/ timer");
|
||||
|
||||
INTEGER_COMMAND_VEC_ID_GET(
|
||||
rx_zmqport, getRxZmqPort, setRxZmqPort, StringTo<int>,
|
||||
rx_zmqport, getRxZmqPort, setRxZmqPort, StringTo<uint16_t>,
|
||||
"[port]\n\tZmq port for data to be streamed out of the receiver. "
|
||||
"Also restarts receiver zmq streaming if enabled. Default is 30001. "
|
||||
"Modified only when using an intermediate process between receiver and "
|
||||
@ -2180,7 +2179,7 @@ class CmdProxy {
|
||||
"Multi command will automatically increment for individual modules.");
|
||||
|
||||
INTEGER_COMMAND_VEC_ID_GET(
|
||||
zmqport, getClientZmqPort, setClientZmqPort, StringTo<int>,
|
||||
zmqport, getClientZmqPort, setClientZmqPort, StringTo<uint16_t>,
|
||||
"[port]\n\tZmq port in client(gui) or intermediate process for "
|
||||
"data to be streamed to from receiver. Default connects to receiver "
|
||||
"zmq streaming out port (30001). Modified only when using an "
|
||||
@ -2619,13 +2618,13 @@ class CmdProxy {
|
||||
/* Insignificant */
|
||||
|
||||
INTEGER_COMMAND_VEC_ID(
|
||||
port, getControlPort, setControlPort, StringTo<int>,
|
||||
port, getControlPort, setControlPort, StringTo<uint16_t>,
|
||||
"[n]\n\tPort number of the control server on detector for "
|
||||
"detector-client tcp interface. Default is 1952. Normally unchanged. "
|
||||
"Set different ports for virtual servers on same pc.");
|
||||
|
||||
INTEGER_COMMAND_VEC_ID(
|
||||
stopport, getStopPort, setStopPort, StringTo<int>,
|
||||
stopport, getStopPort, setStopPort, StringTo<uint16_t>,
|
||||
"[n]\n\tPort number of the stop server on detector for detector-client "
|
||||
"tcp interface. Default is 1953. Normally unchanged.");
|
||||
|
||||
|
@ -107,7 +107,9 @@ void Detector::setHostname(const std::vector<std::string> &hostname) {
|
||||
pimpl->setHostname(hostname);
|
||||
}
|
||||
|
||||
void Detector::setVirtualDetectorServers(int numServers, int startingPort) {
|
||||
void Detector::setVirtualDetectorServers(int numServers,
|
||||
uint16_t startingPort) {
|
||||
validatePortRange(startingPort, numServers * 2);
|
||||
pimpl->setVirtualDetectorServers(numServers, startingPort);
|
||||
}
|
||||
|
||||
@ -982,10 +984,10 @@ void Detector::setNumberofUDPInterfaces_(int n, Positions pos) {
|
||||
throw RuntimeError("No modules added.");
|
||||
}
|
||||
bool previouslyClientStreaming = pimpl->getDataStreamingToClient();
|
||||
int clientStartingPort = getClientZmqPort({0}).squash(0);
|
||||
uint16_t clientStartingPort = getClientZmqPort({0}).squash(0);
|
||||
bool useReceiver = getUseReceiverFlag().squash(false);
|
||||
bool previouslyReceiverStreaming = false;
|
||||
int rxStartingPort = 0;
|
||||
uint16_t rxStartingPort = 0;
|
||||
if (useReceiver) {
|
||||
previouslyReceiverStreaming = getRxZmqDataStream(pos).squash(true);
|
||||
rxStartingPort = getRxZmqPort({0}).squash(0);
|
||||
@ -1108,34 +1110,36 @@ void Detector::setDestinationUDPMAC2(const MacAddr mac, Positions pos) {
|
||||
pimpl->Parallel(&Module::setDestinationUDPMAC2, pos, mac);
|
||||
}
|
||||
|
||||
Result<int> Detector::getDestinationUDPPort(Positions pos) const {
|
||||
Result<uint16_t> Detector::getDestinationUDPPort(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getDestinationUDPPort, pos);
|
||||
}
|
||||
|
||||
void Detector::setDestinationUDPPort(int port, int module_id) {
|
||||
void Detector::setDestinationUDPPort(uint16_t port, int module_id) {
|
||||
if (module_id == -1) {
|
||||
std::vector<int> port_list = getPortNumbers(port);
|
||||
std::vector<uint16_t> port_list = getValidPortNumbers(port);
|
||||
for (int idet = 0; idet < size(); ++idet) {
|
||||
pimpl->Parallel(&Module::setDestinationUDPPort, {idet},
|
||||
port_list[idet]);
|
||||
}
|
||||
} else {
|
||||
validatePortNumber(port);
|
||||
pimpl->Parallel(&Module::setDestinationUDPPort, {module_id}, port);
|
||||
}
|
||||
}
|
||||
|
||||
Result<int> Detector::getDestinationUDPPort2(Positions pos) const {
|
||||
Result<uint16_t> Detector::getDestinationUDPPort2(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getDestinationUDPPort2, pos);
|
||||
}
|
||||
|
||||
void Detector::setDestinationUDPPort2(int port, int module_id) {
|
||||
void Detector::setDestinationUDPPort2(uint16_t port, int module_id) {
|
||||
if (module_id == -1) {
|
||||
std::vector<int> port_list = getPortNumbers(port);
|
||||
std::vector<uint16_t> port_list = getValidPortNumbers(port);
|
||||
for (int idet = 0; idet < size(); ++idet) {
|
||||
pimpl->Parallel(&Module::setDestinationUDPPort2, {idet},
|
||||
port_list[idet]);
|
||||
}
|
||||
} else {
|
||||
validatePortNumber(port);
|
||||
pimpl->Parallel(&Module::setDestinationUDPPort2, {module_id}, port);
|
||||
}
|
||||
}
|
||||
@ -1235,21 +1239,23 @@ void Detector::setRxHostname(const std::vector<std::string> &name) {
|
||||
updateRxRateCorrections();
|
||||
}
|
||||
|
||||
Result<int> Detector::getRxPort(Positions pos) const {
|
||||
Result<uint16_t> Detector::getRxPort(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getReceiverPort, pos);
|
||||
}
|
||||
|
||||
void Detector::setRxPort(int port, int module_id) {
|
||||
void Detector::setRxPort(uint16_t port, int module_id) {
|
||||
if (module_id == -1) {
|
||||
std::vector<int> port_list(size());
|
||||
for (auto &it : port_list) {
|
||||
it = port++;
|
||||
}
|
||||
validatePortRange(port, size() - 1);
|
||||
|
||||
std::vector<uint16_t> port_list(size());
|
||||
std::iota(std::begin(port_list), std::end(port_list), port);
|
||||
|
||||
// no need to verify hostname-port combo as unique port(incremented)
|
||||
for (int idet = 0; idet < size(); ++idet) {
|
||||
pimpl->Parallel(&Module::setReceiverPort, {idet}, port_list[idet]);
|
||||
}
|
||||
} else {
|
||||
validatePortNumber(port);
|
||||
pimpl->verifyUniqueRxHost(port, module_id);
|
||||
pimpl->Parallel(&Module::setReceiverPort, {module_id}, port);
|
||||
}
|
||||
@ -1440,20 +1446,21 @@ void Detector::setRxZmqStartingFrame(int fnum, Positions pos) {
|
||||
pimpl->Parallel(&Module::setReceiverStreamingStartingFrame, pos, fnum);
|
||||
}
|
||||
|
||||
Result<int> Detector::getRxZmqPort(Positions pos) const {
|
||||
Result<uint16_t> Detector::getRxZmqPort(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getReceiverStreamingPort, pos);
|
||||
}
|
||||
|
||||
void Detector::setRxZmqPort(int port, int module_id) {
|
||||
void Detector::setRxZmqPort(uint16_t port, int module_id) {
|
||||
bool previouslyReceiverStreaming =
|
||||
getRxZmqDataStream(std::vector<int>{module_id}).squash(false);
|
||||
if (module_id == -1) {
|
||||
std::vector<int> port_list = getPortNumbers(port);
|
||||
std::vector<uint16_t> port_list = getValidPortNumbers(port);
|
||||
for (int idet = 0; idet < size(); ++idet) {
|
||||
pimpl->Parallel(&Module::setReceiverStreamingPort, {idet},
|
||||
port_list[idet]);
|
||||
}
|
||||
} else {
|
||||
validatePortNumber(port);
|
||||
pimpl->Parallel(&Module::setReceiverStreamingPort, {module_id}, port);
|
||||
}
|
||||
if (previouslyReceiverStreaming) {
|
||||
@ -1475,19 +1482,20 @@ void Detector::setRxZmqIP(const IpAddr ip, Positions pos) {
|
||||
}
|
||||
}
|
||||
|
||||
Result<int> Detector::getClientZmqPort(Positions pos) const {
|
||||
Result<uint16_t> Detector::getClientZmqPort(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getClientStreamingPort, pos);
|
||||
}
|
||||
|
||||
void Detector::setClientZmqPort(int port, int module_id) {
|
||||
void Detector::setClientZmqPort(uint16_t port, int module_id) {
|
||||
bool previouslyClientStreaming = pimpl->getDataStreamingToClient();
|
||||
if (module_id == -1) {
|
||||
std::vector<int> port_list = getPortNumbers(port);
|
||||
std::vector<uint16_t> port_list = getValidPortNumbers(port);
|
||||
for (int idet = 0; idet < size(); ++idet) {
|
||||
pimpl->Parallel(&Module::setClientStreamingPort, {idet},
|
||||
port_list[idet]);
|
||||
}
|
||||
} else {
|
||||
validatePortNumber(port);
|
||||
pimpl->Parallel(&Module::setClientStreamingPort, {module_id}, port);
|
||||
}
|
||||
if (previouslyClientStreaming) {
|
||||
@ -2665,21 +2673,23 @@ void Detector::setADCInvert(uint32_t value, Positions pos) {
|
||||
|
||||
// Insignificant
|
||||
|
||||
Result<int> Detector::getControlPort(Positions pos) const {
|
||||
Result<uint16_t> Detector::getControlPort(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getControlPort, pos);
|
||||
}
|
||||
|
||||
void Detector::setControlPort(int value, Positions pos) {
|
||||
void Detector::setControlPort(uint16_t value, Positions pos) {
|
||||
validatePortNumber(value);
|
||||
pimpl->verifyUniqueDetHost(value, pos);
|
||||
pimpl->Parallel(&Module::setControlPort, pos, value);
|
||||
}
|
||||
|
||||
Result<int> Detector::getStopPort(Positions pos) const {
|
||||
Result<uint16_t> Detector::getStopPort(Positions pos) const {
|
||||
// not verifying unique stop port (control port is sufficient)
|
||||
return pimpl->Parallel(&Module::getStopPort, pos);
|
||||
}
|
||||
|
||||
void Detector::setStopPort(int value, Positions pos) {
|
||||
void Detector::setStopPort(uint16_t value, Positions pos) {
|
||||
validatePortNumber(value);
|
||||
pimpl->Parallel(&Module::setStopPort, pos, value);
|
||||
}
|
||||
|
||||
@ -2714,13 +2724,17 @@ Result<ns> Detector::getMeasurementTime(Positions pos) const {
|
||||
|
||||
std::string Detector::getUserDetails() const { return pimpl->getUserDetails(); }
|
||||
|
||||
std::vector<int> Detector::getPortNumbers(int start_port) {
|
||||
std::vector<uint16_t> Detector::getValidPortNumbers(uint16_t start_port) {
|
||||
int num_sockets_per_detector = getNumberofUDPInterfaces({}).tsquash(
|
||||
"Number of UDP Interfaces is not consistent among modules");
|
||||
std::vector<int> res;
|
||||
|
||||
validatePortRange(start_port, (size() - 1) * num_sockets_per_detector);
|
||||
|
||||
std::vector<uint16_t> res;
|
||||
res.reserve(size());
|
||||
for (int idet = 0; idet < size(); ++idet) {
|
||||
res.push_back(start_port + (idet * num_sockets_per_detector));
|
||||
uint16_t port = start_port + (idet * num_sockets_per_detector);
|
||||
res.push_back(port);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
@ -242,7 +242,8 @@ std::string DetectorImpl::exec(const char *cmd) {
|
||||
return result;
|
||||
}
|
||||
|
||||
void DetectorImpl::setVirtualDetectorServers(const int numdet, const int port) {
|
||||
void DetectorImpl::setVirtualDetectorServers(const int numdet,
|
||||
const uint16_t port) {
|
||||
std::vector<std::string> hostnames;
|
||||
for (int i = 0; i < numdet; ++i) {
|
||||
// * 2 is for control and stop port
|
||||
@ -283,7 +284,7 @@ void DetectorImpl::addModule(const std::string &name) {
|
||||
LOG(logINFO) << "Adding module " << name;
|
||||
auto host = verifyUniqueDetHost(name);
|
||||
std::string hostname = host.first;
|
||||
int port = host.second;
|
||||
uint16_t port = host.second;
|
||||
|
||||
// get type by connecting
|
||||
detectorType type = Module::getTypeFromDetector(hostname, port);
|
||||
@ -1583,41 +1584,41 @@ defs::xy DetectorImpl::calculatePosition(int moduleIndex,
|
||||
return pos;
|
||||
}
|
||||
|
||||
void DetectorImpl::verifyUniqueDetHost(const int port,
|
||||
void DetectorImpl::verifyUniqueDetHost(const uint16_t port,
|
||||
std::vector<int> positions) const {
|
||||
// port for given positions
|
||||
if (positions.empty() || (positions.size() == 1 && positions[0] == -1)) {
|
||||
positions.resize(modules.size());
|
||||
std::iota(begin(positions), end(positions), 0);
|
||||
}
|
||||
std::vector<std::pair<std::string, int>> hosts(size());
|
||||
std::vector<std::pair<std::string, uint16_t>> hosts(size());
|
||||
for (auto it : positions) {
|
||||
hosts[it].second = port;
|
||||
}
|
||||
verifyUniqueHost(true, hosts);
|
||||
}
|
||||
|
||||
void DetectorImpl::verifyUniqueRxHost(const int port,
|
||||
void DetectorImpl::verifyUniqueRxHost(const uint16_t port,
|
||||
const int moduleId) const {
|
||||
std::vector<std::pair<std::string, int>> hosts(size());
|
||||
std::vector<std::pair<std::string, uint16_t>> hosts(size());
|
||||
hosts[moduleId].second = port;
|
||||
verifyUniqueHost(false, hosts);
|
||||
}
|
||||
|
||||
std::pair<std::string, int>
|
||||
std::pair<std::string, uint16_t>
|
||||
DetectorImpl::verifyUniqueDetHost(const std::string &name) {
|
||||
// extract port
|
||||
// C++17 could be auto [hostname, port] = ParseHostPort(name);
|
||||
auto res = ParseHostPort(name);
|
||||
std::string hostname = res.first;
|
||||
int port = res.second;
|
||||
uint16_t port = res.second;
|
||||
if (port == 0) {
|
||||
port = DEFAULT_TCP_CNTRL_PORTNO;
|
||||
}
|
||||
|
||||
int detSize = size();
|
||||
// mod not yet added
|
||||
std::vector<std::pair<std::string, int>> hosts(detSize + 1);
|
||||
std::vector<std::pair<std::string, uint16_t>> hosts(detSize + 1);
|
||||
hosts[detSize].first = hostname;
|
||||
hosts[detSize].second = port;
|
||||
|
||||
@ -1625,7 +1626,7 @@ DetectorImpl::verifyUniqueDetHost(const std::string &name) {
|
||||
return std::make_pair(hostname, port);
|
||||
}
|
||||
|
||||
std::pair<std::string, int>
|
||||
std::pair<std::string, uint16_t>
|
||||
DetectorImpl::verifyUniqueRxHost(const std::string &name,
|
||||
std::vector<int> positions) const {
|
||||
// no checks if setting to none
|
||||
@ -1636,7 +1637,7 @@ DetectorImpl::verifyUniqueRxHost(const std::string &name,
|
||||
// C++17 could be auto [hostname, port] = ParseHostPort(name);
|
||||
auto res = ParseHostPort(name);
|
||||
std::string hostname = res.first;
|
||||
int port = res.second;
|
||||
uint16_t port = res.second;
|
||||
|
||||
// hostname and port for given positions
|
||||
if (positions.empty() || (positions.size() == 1 && positions[0] == -1)) {
|
||||
@ -1644,7 +1645,7 @@ DetectorImpl::verifyUniqueRxHost(const std::string &name,
|
||||
std::iota(begin(positions), end(positions), 0);
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, int>> hosts(size());
|
||||
std::vector<std::pair<std::string, uint16_t>> hosts(size());
|
||||
for (auto it : positions) {
|
||||
hosts[it].first = hostname;
|
||||
hosts[it].second = port;
|
||||
@ -1654,7 +1655,7 @@ DetectorImpl::verifyUniqueRxHost(const std::string &name,
|
||||
return std::make_pair(hostname, port);
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, int>>
|
||||
std::vector<std::pair<std::string, uint16_t>>
|
||||
DetectorImpl::verifyUniqueRxHost(const std::vector<std::string> &names) const {
|
||||
if ((int)names.size() != size()) {
|
||||
throw RuntimeError(
|
||||
@ -1663,7 +1664,7 @@ DetectorImpl::verifyUniqueRxHost(const std::vector<std::string> &names) const {
|
||||
}
|
||||
|
||||
// extract ports
|
||||
std::vector<std::pair<std::string, int>> hosts;
|
||||
std::vector<std::pair<std::string, uint16_t>> hosts;
|
||||
for (const auto &name : names) {
|
||||
hosts.push_back(ParseHostPort(name));
|
||||
}
|
||||
@ -1673,7 +1674,7 @@ DetectorImpl::verifyUniqueRxHost(const std::vector<std::string> &names) const {
|
||||
}
|
||||
|
||||
void DetectorImpl::verifyUniqueHost(
|
||||
bool isDet, std::vector<std::pair<std::string, int>> &hosts) const {
|
||||
bool isDet, std::vector<std::pair<std::string, uint16_t>> &hosts) const {
|
||||
|
||||
// fill from shm if not provided
|
||||
for (int i = 0; i != size(); ++i) {
|
||||
@ -1689,7 +1690,7 @@ void DetectorImpl::verifyUniqueHost(
|
||||
|
||||
// remove the ones without a hostname
|
||||
hosts.erase(std::remove_if(hosts.begin(), hosts.end(),
|
||||
[](const std::pair<std::string, int> &x) {
|
||||
[](const std::pair<std::string, uint16_t> &x) {
|
||||
return (x.first == "none" ||
|
||||
x.first.empty());
|
||||
}),
|
||||
|
@ -220,7 +220,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
* @param numdet number of modules
|
||||
* @param port starting port number
|
||||
*/
|
||||
void setVirtualDetectorServers(const int numdet, const int port);
|
||||
void setVirtualDetectorServers(const int numdet, const uint16_t port);
|
||||
|
||||
/** Sets the hostname of all sls modules in shared memory and updates
|
||||
* local cache */
|
||||
@ -307,14 +307,16 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
void setDefaultDac(defs::dacIndex index, int defaultValue,
|
||||
defs::detectorSettings sett, Positions pos);
|
||||
|
||||
void verifyUniqueDetHost(const int port, std::vector<int> positions) const;
|
||||
void verifyUniqueRxHost(const int port, const int moduleId) const;
|
||||
void verifyUniqueDetHost(const uint16_t port,
|
||||
std::vector<int> positions) const;
|
||||
void verifyUniqueRxHost(const uint16_t port, const int moduleId) const;
|
||||
|
||||
std::pair<std::string, int> verifyUniqueDetHost(const std::string &name);
|
||||
std::pair<std::string, int>
|
||||
std::pair<std::string, uint16_t>
|
||||
verifyUniqueDetHost(const std::string &name);
|
||||
std::pair<std::string, uint16_t>
|
||||
verifyUniqueRxHost(const std::string &name,
|
||||
std::vector<int> positions) const;
|
||||
std::vector<std::pair<std::string, int>>
|
||||
std::vector<std::pair<std::string, uint16_t>>
|
||||
verifyUniqueRxHost(const std::vector<std::string> &names) const;
|
||||
|
||||
defs::ROI getRxROI() const;
|
||||
@ -439,9 +441,8 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
defs::xy getPortGeometry() const;
|
||||
defs::xy calculatePosition(int moduleIndex, defs::xy geometry) const;
|
||||
|
||||
void
|
||||
verifyUniqueHost(bool isDet,
|
||||
std::vector<std::pair<std::string, int>> &hosts) const;
|
||||
void verifyUniqueHost(
|
||||
bool isDet, std::vector<std::pair<std::string, uint16_t>> &hosts) const;
|
||||
|
||||
const int detectorIndex{0};
|
||||
SharedMemory<sharedDetector> shm{0, -1};
|
||||
|
@ -165,11 +165,15 @@ std::string Module::getReceiverSoftwareVersion() const {
|
||||
|
||||
// static function
|
||||
slsDetectorDefs::detectorType
|
||||
Module::getTypeFromDetector(const std::string &hostname, int cport) {
|
||||
Module::getTypeFromDetector(const std::string &hostname, uint16_t cport) {
|
||||
LOG(logDEBUG1) << "Getting Module type ";
|
||||
ClientSocket socket("Detector", hostname, cport);
|
||||
socket.Send(F_GET_DETECTOR_TYPE);
|
||||
socket.Receive<int>(); // TODO! Should we look at this OK/FAIL?
|
||||
if (socket.Receive<int>() == FAIL) {
|
||||
throw RuntimeError("Detector (" + hostname + ", " +
|
||||
std::to_string(cport) +
|
||||
") returned error at getting detector type");
|
||||
}
|
||||
auto retval = socket.Receive<detectorType>();
|
||||
LOG(logDEBUG1) << "Module type is " << retval;
|
||||
return retval;
|
||||
@ -1241,22 +1245,22 @@ void Module::setDestinationUDPMAC2(const MacAddr mac) {
|
||||
sendToDetector(F_SET_DEST_UDP_MAC2, mac, nullptr);
|
||||
}
|
||||
|
||||
int Module::getDestinationUDPPort() const {
|
||||
return sendToDetector<int>(F_GET_DEST_UDP_PORT);
|
||||
uint16_t Module::getDestinationUDPPort() const {
|
||||
return sendToDetector<uint16_t>(F_GET_DEST_UDP_PORT);
|
||||
}
|
||||
|
||||
void Module::setDestinationUDPPort(const int port) {
|
||||
void Module::setDestinationUDPPort(const uint16_t port) {
|
||||
sendToDetector(F_SET_DEST_UDP_PORT, port, nullptr);
|
||||
if (shm()->useReceiverFlag) {
|
||||
sendToReceiver(F_SET_RECEIVER_UDP_PORT, port, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
int Module::getDestinationUDPPort2() const {
|
||||
return sendToDetector<int>(F_GET_DEST_UDP_PORT2);
|
||||
uint16_t Module::getDestinationUDPPort2() const {
|
||||
return sendToDetector<uint16_t>(F_GET_DEST_UDP_PORT2);
|
||||
}
|
||||
|
||||
void Module::setDestinationUDPPort2(const int port) {
|
||||
void Module::setDestinationUDPPort2(const uint16_t port) {
|
||||
sendToDetector(F_SET_DEST_UDP_PORT2, port, nullptr);
|
||||
if (shm()->useReceiverFlag) {
|
||||
sendToReceiver(F_SET_RECEIVER_UDP_PORT2, port, nullptr);
|
||||
@ -1354,7 +1358,8 @@ std::string Module::getReceiverHostname() const {
|
||||
return std::string(shm()->rxHostname);
|
||||
}
|
||||
|
||||
void Module::setReceiverHostname(const std::string &hostname, const int port,
|
||||
void Module::setReceiverHostname(const std::string &hostname,
|
||||
const uint16_t port,
|
||||
const bool initialChecks) {
|
||||
{
|
||||
std::ostringstream oss;
|
||||
@ -1427,13 +1432,10 @@ void Module::setReceiverHostname(const std::string &hostname, const int port,
|
||||
updateReceiverStreamingIP();
|
||||
}
|
||||
|
||||
int Module::getReceiverPort() const { return shm()->rxTCPPort; }
|
||||
uint16_t Module::getReceiverPort() const { return shm()->rxTCPPort; }
|
||||
|
||||
int Module::setReceiverPort(int port_number) {
|
||||
if (port_number >= 0 && port_number != shm()->rxTCPPort) {
|
||||
shm()->rxTCPPort = port_number;
|
||||
}
|
||||
return shm()->rxTCPPort;
|
||||
void Module::setReceiverPort(uint16_t port_number) {
|
||||
shm()->rxTCPPort = port_number;
|
||||
}
|
||||
|
||||
int Module::getReceiverFifoDepth() const {
|
||||
@ -1645,11 +1647,11 @@ void Module::setReceiverStreamingStartingFrame(int fnum) {
|
||||
sendToReceiver(F_SET_RECEIVER_STREAMING_START_FNUM, fnum, nullptr);
|
||||
}
|
||||
|
||||
int Module::getReceiverStreamingPort() const {
|
||||
return sendToReceiver<int>(F_GET_RECEIVER_STREAMING_PORT);
|
||||
uint16_t Module::getReceiverStreamingPort() const {
|
||||
return sendToReceiver<uint16_t>(F_GET_RECEIVER_STREAMING_PORT);
|
||||
}
|
||||
|
||||
void Module::setReceiverStreamingPort(int port) {
|
||||
void Module::setReceiverStreamingPort(uint16_t port) {
|
||||
sendToReceiver(F_SET_RECEIVER_STREAMING_PORT, port, nullptr);
|
||||
}
|
||||
|
||||
@ -1668,9 +1670,9 @@ void Module::setReceiverStreamingIP(const IpAddr ip) {
|
||||
sendToReceiver(F_SET_RECEIVER_STREAMING_SRC_IP, ip, nullptr);
|
||||
}
|
||||
|
||||
int Module::getClientStreamingPort() const { return shm()->zmqport; }
|
||||
uint16_t Module::getClientStreamingPort() const { return shm()->zmqport; }
|
||||
|
||||
void Module::setClientStreamingPort(int port) { shm()->zmqport = port; }
|
||||
void Module::setClientStreamingPort(uint16_t port) { shm()->zmqport = port; }
|
||||
|
||||
IpAddr Module::getClientStreamingIP() const { return shm()->zmqip; }
|
||||
|
||||
@ -2839,15 +2841,17 @@ void Module::setADCInvert(uint32_t value) {
|
||||
}
|
||||
|
||||
// Insignificant
|
||||
int Module::getControlPort() const { return shm()->controlPort; }
|
||||
uint16_t Module::getControlPort() const { return shm()->controlPort; }
|
||||
|
||||
void Module::setControlPort(int port_number) {
|
||||
void Module::setControlPort(uint16_t port_number) {
|
||||
shm()->controlPort = port_number;
|
||||
}
|
||||
|
||||
int Module::getStopPort() const { return shm()->stopPort; }
|
||||
uint16_t Module::getStopPort() const { return shm()->stopPort; }
|
||||
|
||||
void Module::setStopPort(int port_number) { shm()->stopPort = port_number; }
|
||||
void Module::setStopPort(uint16_t port_number) {
|
||||
shm()->stopPort = port_number;
|
||||
}
|
||||
|
||||
bool Module::getLockDetector() const {
|
||||
return sendToDetector<int>(F_LOCK_SERVER, GET_FLAG);
|
||||
|
@ -19,7 +19,7 @@ namespace sls {
|
||||
class ServerInterface;
|
||||
|
||||
#define MODULE_SHMAPIVERSION 0x190726
|
||||
#define MODULE_SHMVERSION 0x200402
|
||||
#define MODULE_SHMVERSION 0x230913
|
||||
|
||||
/**
|
||||
* @short structure allocated in shared memory to store Module settings for
|
||||
@ -36,8 +36,8 @@ struct sharedModule {
|
||||
/** END OF FIXED PATTERN -----------------------------------------------*/
|
||||
|
||||
slsDetectorDefs::xy numberOfModule;
|
||||
int controlPort;
|
||||
int stopPort;
|
||||
uint16_t controlPort;
|
||||
uint16_t stopPort;
|
||||
char settingsDir[MAX_STR_LENGTH];
|
||||
/** list of the energies at which the Module has been trimmed */
|
||||
StaticVector<int, MAX_TRIMEN> trimEnergies;
|
||||
@ -46,11 +46,11 @@ struct sharedModule {
|
||||
slsDetectorDefs::xy nChip;
|
||||
int nDacs;
|
||||
char rxHostname[MAX_STR_LENGTH];
|
||||
int rxTCPPort;
|
||||
uint16_t rxTCPPort;
|
||||
/** if rxHostname and rxTCPPort can be connected to */
|
||||
bool useReceiverFlag;
|
||||
/** Listening tcp port from gui (only data) */
|
||||
int zmqport;
|
||||
uint16_t zmqport;
|
||||
/** Listening tcp ip address from gui (only data) **/
|
||||
IpAddr zmqip;
|
||||
int numUDPInterfaces;
|
||||
@ -102,7 +102,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
std::string getReceiverSoftwareVersion() const;
|
||||
static detectorType
|
||||
getTypeFromDetector(const std::string &hostname,
|
||||
int cport = DEFAULT_TCP_CNTRL_PORTNO);
|
||||
uint16_t cport = DEFAULT_TCP_CNTRL_PORTNO);
|
||||
|
||||
/** Get Detector type from shared memory */
|
||||
detectorType getDetectorType() const;
|
||||
@ -261,10 +261,10 @@ class Module : public virtual slsDetectorDefs {
|
||||
void setDestinationUDPMAC(const MacAddr mac);
|
||||
MacAddr getDestinationUDPMAC2() const;
|
||||
void setDestinationUDPMAC2(const MacAddr mac);
|
||||
int getDestinationUDPPort() const;
|
||||
void setDestinationUDPPort(int udpport);
|
||||
int getDestinationUDPPort2() const;
|
||||
void setDestinationUDPPort2(int udpport);
|
||||
uint16_t getDestinationUDPPort() const;
|
||||
void setDestinationUDPPort(uint16_t udpport);
|
||||
uint16_t getDestinationUDPPort2() const;
|
||||
void setDestinationUDPPort2(uint16_t udpport);
|
||||
void reconfigureUDPDestination();
|
||||
void validateUDPConfiguration();
|
||||
std::string printReceiverConfiguration();
|
||||
@ -286,10 +286,10 @@ class Module : public virtual slsDetectorDefs {
|
||||
* ************************************************/
|
||||
bool getUseReceiverFlag() const;
|
||||
std::string getReceiverHostname() const;
|
||||
void setReceiverHostname(const std::string &hostname, const int port,
|
||||
void setReceiverHostname(const std::string &hostname, const uint16_t port,
|
||||
const bool initialChecks);
|
||||
int getReceiverPort() const;
|
||||
int setReceiverPort(int port_number);
|
||||
uint16_t getReceiverPort() const;
|
||||
void setReceiverPort(uint16_t port_number);
|
||||
int getReceiverFifoDepth() const;
|
||||
void setReceiverFifoDepth(int n_frames);
|
||||
bool getReceiverSilentMode() const;
|
||||
@ -349,12 +349,12 @@ class Module : public virtual slsDetectorDefs {
|
||||
void setReceiverStreamingTimer(int time_in_ms = 200);
|
||||
int getReceiverStreamingStartingFrame() const;
|
||||
void setReceiverStreamingStartingFrame(int fnum);
|
||||
int getReceiverStreamingPort() const;
|
||||
void setReceiverStreamingPort(int port);
|
||||
uint16_t getReceiverStreamingPort() const;
|
||||
void setReceiverStreamingPort(uint16_t port);
|
||||
IpAddr getReceiverStreamingIP() const;
|
||||
void setReceiverStreamingIP(const IpAddr ip);
|
||||
int getClientStreamingPort() const;
|
||||
void setClientStreamingPort(int port);
|
||||
uint16_t getClientStreamingPort() const;
|
||||
void setClientStreamingPort(uint16_t port);
|
||||
IpAddr getClientStreamingIP() const;
|
||||
void setClientStreamingIP(const IpAddr ip);
|
||||
int getReceiverStreamingHwm() const;
|
||||
@ -597,10 +597,10 @@ class Module : public virtual slsDetectorDefs {
|
||||
* Insignificant *
|
||||
* *
|
||||
* ************************************************/
|
||||
int getControlPort() const;
|
||||
void setControlPort(int port_number);
|
||||
int getStopPort() const;
|
||||
void setStopPort(int port_number);
|
||||
uint16_t getControlPort() const;
|
||||
void setControlPort(uint16_t port_number);
|
||||
uint16_t getStopPort() const;
|
||||
void setStopPort(uint16_t port_number);
|
||||
bool getLockDetector() const;
|
||||
void setLockDetector(bool lock);
|
||||
IpAddr getLastClientIP() const;
|
||||
|
@ -11,6 +11,26 @@ namespace sls {
|
||||
using test::GET;
|
||||
using test::PUT;
|
||||
|
||||
void test_valid_port(const std::string &command,
|
||||
const std::vector<std::string> &arguments, int detector_id,
|
||||
int action) {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
|
||||
std::vector<std::string> arg(arguments);
|
||||
if (arg.empty())
|
||||
arg.push_back("0");
|
||||
|
||||
int test_values[3] = {77797, -1, 0};
|
||||
for (int i = 0; i != 3; ++i) {
|
||||
int port_number = test_values[i];
|
||||
arg[arg.size() - 1] = std::to_string(port_number);
|
||||
REQUIRE_THROWS(proxy.Call(command, arg, detector_id, action));
|
||||
/*REQUIRE_THROWS_WITH(proxy.Call(command, arguments, detector_id,
|
||||
action), "Invalid port range. Must be between 1 - 65535.");*/
|
||||
}
|
||||
}
|
||||
|
||||
void test_dac(defs::dacIndex index, const std::string &dacname, int dacvalue) {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
|
@ -5,6 +5,10 @@
|
||||
|
||||
namespace sls {
|
||||
|
||||
void test_valid_port(const std::string &command,
|
||||
const std::vector<std::string> &arguments, int detector_id,
|
||||
int action);
|
||||
|
||||
void test_dac(slsDetectorDefs::dacIndex index, const std::string &dacname,
|
||||
int dacvalue);
|
||||
void test_onchip_dac(slsDetectorDefs::dacIndex index,
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "sls/Detector.h"
|
||||
#include "sls/Version.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
#include "test-CmdProxy-global.h"
|
||||
#include <sstream>
|
||||
|
||||
#include "sls/versionAPI.h"
|
||||
@ -223,7 +224,7 @@ TEST_CASE("rx_tcpport", "[.cmd][.rx]") {
|
||||
CmdProxy proxy(&det);
|
||||
auto prev_val = det.getRxPort();
|
||||
|
||||
int port = 3500;
|
||||
uint16_t port = 3500;
|
||||
proxy.Call("rx_tcpport", {std::to_string(port)}, -1, PUT);
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
std::ostringstream oss;
|
||||
@ -237,6 +238,22 @@ TEST_CASE("rx_tcpport", "[.cmd][.rx]") {
|
||||
proxy.Call("rx_tcpport", {}, i, GET, oss);
|
||||
REQUIRE(oss.str() == "rx_tcpport " + std::to_string(port + i) + '\n');
|
||||
}
|
||||
|
||||
test_valid_port("rx_tcpport", {}, -1, PUT);
|
||||
test_valid_port("rx_tcpport", {}, 0, PUT);
|
||||
// should fail for the second module
|
||||
if (det.size() > 1) {
|
||||
REQUIRE_THROWS(proxy.Call("rx_tcpport", {"65535"}, -1, PUT));
|
||||
auto rxHostname = det.getRxHostname().squash("none");
|
||||
if (rxHostname != "none") {
|
||||
std::ostringstream oss;
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
oss << rxHostname << ":" << 65536 + i << "+";
|
||||
}
|
||||
REQUIRE_THROWS(proxy.Call("rx_hostname", {oss.str()}, -1, PUT));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setRxPort(prev_val[i], i);
|
||||
}
|
||||
@ -810,7 +827,7 @@ TEST_CASE("rx_zmqport", "[.cmd][.rx]") {
|
||||
proxy.Call("numinterfaces", {"2"}, -1, PUT);
|
||||
socketsperdetector *= 2;
|
||||
}
|
||||
int port = 3500;
|
||||
uint16_t port = 3500;
|
||||
proxy.Call("rx_zmqport", {std::to_string(port)}, -1, PUT);
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
std::ostringstream oss;
|
||||
@ -828,6 +845,14 @@ TEST_CASE("rx_zmqport", "[.cmd][.rx]") {
|
||||
std::to_string(port + i * socketsperdetector) +
|
||||
'\n');
|
||||
}
|
||||
|
||||
test_valid_port("rx_zmqport", {}, -1, PUT);
|
||||
test_valid_port("rx_zmqport", {}, 0, PUT);
|
||||
// should fail for the second module
|
||||
if (det.size() > 1) {
|
||||
REQUIRE_THROWS(proxy.Call("rx_zmqport", {"65535"}, -1, PUT));
|
||||
}
|
||||
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setRxZmqPort(prev_val_zmqport[i], i);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "sls/Detector.h"
|
||||
#include "sls/file_utils.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
#include "test-CmdProxy-global.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <sstream>
|
||||
@ -76,7 +77,13 @@ TEST_CASE("hostname", "[.cmd]") {
|
||||
REQUIRE_NOTHROW(proxy.Call("hostname", {}, -1, GET));
|
||||
}
|
||||
|
||||
// virtual: not testing
|
||||
TEST_CASE("virtual", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
REQUIRE_THROWS(proxy.Call("virtual", {}, -1, GET));
|
||||
test_valid_port("virtual", {"1"}, -1, PUT);
|
||||
REQUIRE_THROWS(proxy.Call("virtual", {"3", "65534"}, -1, PUT));
|
||||
}
|
||||
|
||||
TEST_CASE("versions", "[.cmd]") {
|
||||
Detector det;
|
||||
@ -2693,6 +2700,12 @@ TEST_CASE("udp_dstport", "[.cmd]") {
|
||||
proxy.Call("udp_dstport", {"50084"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "udp_dstport 50084\n");
|
||||
}
|
||||
test_valid_port("udp_dstport", {}, -1, PUT);
|
||||
test_valid_port("udp_dstport", {}, 0, PUT);
|
||||
// should fail for the second module
|
||||
if (det.size() > 1) {
|
||||
REQUIRE_THROWS(proxy.Call("udp_dstport", {"65535"}, -1, PUT));
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setDestinationUDPPort(prev_val[i], {i});
|
||||
}
|
||||
@ -2781,8 +2794,18 @@ TEST_CASE("udp_dstport2", "[.cmd]") {
|
||||
proxy.Call("udp_dstport2", {"50084"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "udp_dstport2 50084\n");
|
||||
}
|
||||
|
||||
test_valid_port("udp_dstport2", {}, -1, PUT);
|
||||
test_valid_port("udp_dstport2", {}, 0, PUT);
|
||||
// should fail for the second module
|
||||
if (det.size() > 1) {
|
||||
REQUIRE_THROWS(proxy.Call("udp_dstport2", {"65535"}, -1, PUT));
|
||||
}
|
||||
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setDestinationUDPPort2(prev_val[i], {i});
|
||||
if (prev_val[i] != 0) {
|
||||
det.setDestinationUDPPort2(prev_val[i], {i});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("udp_dstport2", {}, -1, GET));
|
||||
@ -2976,7 +2999,7 @@ TEST_CASE("zmqport", "[.cmd]") {
|
||||
det.setNumberofUDPInterfaces(2);
|
||||
socketsperdetector *= 2;
|
||||
}
|
||||
int port = 3500;
|
||||
uint16_t port = 3500;
|
||||
auto port_str = std::to_string(port);
|
||||
{
|
||||
std::ostringstream oss;
|
||||
@ -3005,6 +3028,12 @@ TEST_CASE("zmqport", "[.cmd]") {
|
||||
std::to_string(port + i * socketsperdetector) +
|
||||
'\n');
|
||||
}
|
||||
test_valid_port("zmqport", {}, -1, PUT);
|
||||
test_valid_port("zmqport", {}, 0, PUT);
|
||||
// should fail for the second module
|
||||
if (det.size() > 1) {
|
||||
REQUIRE_THROWS(proxy.Call("zmqport", {"65535"}, -1, PUT));
|
||||
}
|
||||
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH) {
|
||||
det.setNumberofUDPInterfaces(prev);
|
||||
}
|
||||
@ -3384,6 +3413,12 @@ TEST_CASE("port", "[.cmd]") {
|
||||
proxy.Call("port", {}, 0, GET, oss);
|
||||
REQUIRE(oss.str() == "port 1942\n");
|
||||
}
|
||||
test_valid_port("port", {}, -1, PUT);
|
||||
test_valid_port("port", {}, 0, PUT);
|
||||
// should fail for the second module
|
||||
if (det.size() > 1) {
|
||||
REQUIRE_THROWS(proxy.Call("port", {"65536"}, -1, PUT));
|
||||
}
|
||||
det.setControlPort(prev_val, {0});
|
||||
}
|
||||
|
||||
@ -3401,6 +3436,12 @@ TEST_CASE("stopport", "[.cmd]") {
|
||||
proxy.Call("stopport", {}, 0, GET, oss);
|
||||
REQUIRE(oss.str() == "stopport 1942\n");
|
||||
}
|
||||
test_valid_port("stopport", {}, -1, PUT);
|
||||
test_valid_port("stopport", {}, 0, PUT);
|
||||
// should fail for the second module
|
||||
if (det.size() > 1) {
|
||||
REQUIRE_THROWS(proxy.Call("stopport", {"65536"}, -1, PUT));
|
||||
}
|
||||
det.setStopPort(prev_val, {0});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user