mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-04 09:00:41 +02:00
changing ports only in shared memory and not going to detector/receiver server to change current tcp port
This commit is contained in:
parent
fcfbb7040a
commit
34fb823675
@ -87,7 +87,6 @@ int set_roi(int);
|
||||
int get_roi(int);
|
||||
int lock_server(int);
|
||||
int get_last_client_ip(int);
|
||||
int set_port(int);
|
||||
int calibrate_pedestal(int);
|
||||
int enable_ten_giga(int);
|
||||
int validateAndSetAllTrimbits(int arg);
|
||||
|
@ -230,7 +230,6 @@ void function_table() {
|
||||
flist[F_GET_ROI] = &get_roi;
|
||||
flist[F_LOCK_SERVER] = &lock_server;
|
||||
flist[F_GET_LAST_CLIENT_IP] = &get_last_client_ip;
|
||||
flist[F_SET_PORT] = &set_port;
|
||||
flist[F_ENABLE_TEN_GIGA] = &enable_ten_giga;
|
||||
flist[F_SET_ALL_TRIMBITS] = &set_all_trimbits;
|
||||
flist[F_SET_PATTERN_IO_CONTROL] = &set_pattern_io_control;
|
||||
@ -2880,43 +2879,6 @@ int get_last_client_ip(int file_des) {
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
int set_port(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int p_number = -1;
|
||||
uint32_t oldLastClientIP = 0;
|
||||
|
||||
if (receiveData(file_des, &p_number, sizeof(p_number), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
|
||||
// set only
|
||||
int sd = -1;
|
||||
if ((Server_VerifyLock() == OK)) {
|
||||
// port number too low
|
||||
if (p_number < 1024) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "%s port Number (%d) too low\n",
|
||||
(isControlServer ? "control" : "stop"), p_number);
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
LOG(logINFO, ("Setting %s port to %d\n",
|
||||
(isControlServer ? "control" : "stop"), p_number));
|
||||
oldLastClientIP = lastClientIP;
|
||||
sd = bindSocket(p_number);
|
||||
}
|
||||
}
|
||||
|
||||
Server_SendResult(file_des, INT32, &p_number, sizeof(p_number));
|
||||
// delete old socket
|
||||
if (ret != FAIL) {
|
||||
closeConnection(file_des);
|
||||
exitServer(sockfd);
|
||||
sockfd = sd;
|
||||
lastClientIP = oldLastClientIP;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int enable_ten_giga(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
|
@ -1215,12 +1215,7 @@ int Module::getReceiverPort() const { return shm()->rxTCPPort; }
|
||||
|
||||
int Module::setReceiverPort(int port_number) {
|
||||
if (port_number >= 0 && port_number != shm()->rxTCPPort) {
|
||||
if (shm()->useReceiverFlag) {
|
||||
shm()->rxTCPPort =
|
||||
sendToReceiver<int>(F_SET_RECEIVER_PORT, port_number);
|
||||
} else {
|
||||
shm()->rxTCPPort = port_number;
|
||||
}
|
||||
shm()->rxTCPPort = port_number;
|
||||
}
|
||||
return shm()->rxTCPPort;
|
||||
}
|
||||
@ -2567,21 +2562,13 @@ void Module::setADCInvert(uint32_t value) {
|
||||
int Module::getControlPort() const { return shm()->controlPort; }
|
||||
|
||||
void Module::setControlPort(int port_number) {
|
||||
if (strlen(shm()->hostname) > 0) {
|
||||
shm()->controlPort = sendToDetector<int>(F_SET_PORT, port_number);
|
||||
} else {
|
||||
shm()->controlPort = port_number;
|
||||
}
|
||||
shm()->controlPort = port_number;
|
||||
}
|
||||
|
||||
int Module::getStopPort() const { return shm()->stopPort; }
|
||||
|
||||
void Module::setStopPort(int port_number) {
|
||||
if (strlen(shm()->hostname) > 0) {
|
||||
shm()->stopPort = sendToDetectorStop<int>(F_SET_PORT, port_number);
|
||||
} else {
|
||||
shm()->stopPort = port_number;
|
||||
}
|
||||
shm()->stopPort = port_number;
|
||||
}
|
||||
|
||||
bool Module::getLockDetector() const {
|
||||
|
@ -190,7 +190,6 @@ TEST_CASE("rx_tcpport", "[.cmd][.rx]") {
|
||||
proxy.Call("rx_tcpport", {}, i, GET, oss);
|
||||
REQUIRE(oss.str() == "rx_tcpport " + std::to_string(port + i) + '\n');
|
||||
}
|
||||
REQUIRE_THROWS(proxy.Call("rx_tcpport", {"15"}, -1, PUT));
|
||||
port = 5754;
|
||||
proxy.Call("rx_tcpport", {std::to_string(port)}, -1, PUT);
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
|
@ -113,7 +113,6 @@ void ClientInterface::startTCPServer() {
|
||||
int ClientInterface::functionTable(){
|
||||
flist[F_LOCK_RECEIVER] = &ClientInterface::lock_receiver;
|
||||
flist[F_GET_LAST_RECEIVER_CLIENT_IP] = &ClientInterface::get_last_client_ip;
|
||||
flist[F_SET_RECEIVER_PORT] = &ClientInterface::set_port;
|
||||
flist[F_GET_RECEIVER_VERSION] = &ClientInterface::get_version;
|
||||
flist[F_SETUP_RECEIVER] = &ClientInterface::setup_receiver;
|
||||
flist[F_RECEIVER_SET_ROI] = &ClientInterface::set_roi;
|
||||
@ -302,21 +301,6 @@ int ClientInterface::get_last_client_ip(Interface &socket) {
|
||||
return socket.sendResult(server.getLastClient());
|
||||
}
|
||||
|
||||
int ClientInterface::set_port(Interface &socket) {
|
||||
auto p_number = socket.Receive<int>();
|
||||
if (p_number < 1024)
|
||||
throw RuntimeError("Port Number: " + std::to_string(p_number) +
|
||||
" is too low (<1024)");
|
||||
|
||||
LOG(logINFO) << "TCP port set to " << p_number << std::endl;
|
||||
sls::ServerSocket new_server(p_number);
|
||||
new_server.setLockedBy(server.getLockedBy());
|
||||
new_server.setLastClient(server.getThisClient());
|
||||
server = std::move(new_server);
|
||||
socket.sendResult(p_number);
|
||||
return OK;
|
||||
}
|
||||
|
||||
int ClientInterface::get_version(Interface &socket) {
|
||||
return socket.sendResult(getReceiverVersion());
|
||||
}
|
||||
|
@ -62,7 +62,6 @@ class ClientInterface : private virtual slsDetectorDefs {
|
||||
|
||||
int lock_receiver(sls::ServerInterface &socket);
|
||||
int get_last_client_ip(sls::ServerInterface &socket);
|
||||
int set_port(sls::ServerInterface &socket);
|
||||
int get_version(sls::ServerInterface &socket);
|
||||
int setup_receiver(sls::ServerInterface &socket);
|
||||
void setDetectorType(detectorType arg);
|
||||
|
@ -69,7 +69,6 @@ enum detFuncs {
|
||||
F_GET_ROI,
|
||||
F_LOCK_SERVER,
|
||||
F_GET_LAST_CLIENT_IP,
|
||||
F_SET_PORT,
|
||||
F_ENABLE_TEN_GIGA,
|
||||
F_SET_ALL_TRIMBITS,
|
||||
F_SET_PATTERN_IO_CONTROL,
|
||||
@ -258,7 +257,6 @@ enum detFuncs {
|
||||
F_EXEC_RECEIVER_COMMAND,
|
||||
F_LOCK_RECEIVER,
|
||||
F_GET_LAST_RECEIVER_CLIENT_IP,
|
||||
F_SET_RECEIVER_PORT,
|
||||
F_GET_RECEIVER_VERSION,
|
||||
F_RECEIVER_SET_ROI,
|
||||
F_RECEIVER_SET_NUM_FRAMES,
|
||||
@ -427,7 +425,6 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
||||
case F_GET_ROI: return "F_GET_ROI";
|
||||
case F_LOCK_SERVER: return "F_LOCK_SERVER";
|
||||
case F_GET_LAST_CLIENT_IP: return "F_GET_LAST_CLIENT_IP";
|
||||
case F_SET_PORT: return "F_SET_PORT";
|
||||
case F_ENABLE_TEN_GIGA: return "F_ENABLE_TEN_GIGA";
|
||||
case F_SET_ALL_TRIMBITS: return "F_SET_ALL_TRIMBITS";
|
||||
case F_SET_PATTERN_IO_CONTROL: return "F_SET_PATTERN_IO_CONTROL";
|
||||
@ -614,7 +611,6 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
||||
case F_EXEC_RECEIVER_COMMAND: return "F_EXEC_RECEIVER_COMMAND";
|
||||
case F_LOCK_RECEIVER: return "F_LOCK_RECEIVER";
|
||||
case F_GET_LAST_RECEIVER_CLIENT_IP: return "F_GET_LAST_RECEIVER_CLIENT_IP";
|
||||
case F_SET_RECEIVER_PORT: return "F_SET_RECEIVER_PORT";
|
||||
case F_GET_RECEIVER_VERSION: return "F_GET_RECEIVER_VERSION";
|
||||
case F_RECEIVER_SET_ROI: return "F_RECEIVER_SET_ROI";
|
||||
case F_RECEIVER_SET_NUM_FRAMES: return "F_RECEIVER_SET_NUM_FRAMES";
|
||||
|
Loading…
x
Reference in New Issue
Block a user