mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-05-22 22:14:20 +02:00
cleaned up logs
This commit is contained in:
@@ -29,7 +29,6 @@ void TCPInterface::startTCPServer() {
|
||||
|
||||
int function_id{}; // TODO should it be an enum type
|
||||
while (true) {
|
||||
LOG(logDEBUG1) << "Start accept loop";
|
||||
try {
|
||||
auto socket = server.accept();
|
||||
try {
|
||||
|
||||
@@ -174,20 +174,17 @@ Result<std::string> Detector::getHostname(Positions pos) const {
|
||||
}
|
||||
|
||||
void Detector::setHostname(const std::vector<std::string> &hostname) {
|
||||
LOG(logINFORED) << "test";
|
||||
LOG(logDEBUG) << "Checking if hostname is already in shared memory";
|
||||
if (pimpl->hasModulesInSharedMemory()) {
|
||||
LOG(logWARNING) << "There are already module(s) in shared memory."
|
||||
"Freeing Shared memory now.";
|
||||
auto numChannels = getDetectorSize();
|
||||
LOG(logDEBUG) << "Current detector size: " << numChannels;
|
||||
auto initialChecks = getInitialChecks();
|
||||
freeSharedMemory(getShmId());
|
||||
pimpl = make_unique<DetectorImpl>(getShmId());
|
||||
setDetectorSize(numChannels);
|
||||
setInitialChecks(initialChecks);
|
||||
}
|
||||
LOG(logDEBUG) << "not in shared memory yet, setting hostname";
|
||||
LOG(logDEBUG3) << "not in shared memory yet, setting hostname";
|
||||
pimpl->setHostname(hostname);
|
||||
}
|
||||
|
||||
|
||||
@@ -193,8 +193,6 @@ void DetectorImpl::setHostname(const std::vector<std::string> &name) {
|
||||
}
|
||||
ctb_shm.createSharedMemory();
|
||||
}
|
||||
|
||||
LOG(logDEBUG) << "created shared memory";
|
||||
}
|
||||
|
||||
void DetectorImpl::addModule(const std::string &name) {
|
||||
@@ -206,9 +204,6 @@ void DetectorImpl::addModule(const std::string &name) {
|
||||
// get type by connecting
|
||||
detectorType type = Module::getTypeFromDetector(hostname, port);
|
||||
|
||||
LOG(logDEBUG) << "Detector type of module " << name << " is "
|
||||
<< std::to_string(type);
|
||||
|
||||
// gotthard2 cannot have more than 2 modules (50um=1, 25um=2
|
||||
if (type == GOTTHARD2 && modules.size() > 2) {
|
||||
throw RuntimeError("GotthardII cannot have more than 2 modules. Please "
|
||||
|
||||
@@ -85,20 +85,17 @@ std::string Module::getControlServerLongVersion() const {
|
||||
// throw with old server version (sends 8 bytes)
|
||||
catch (RuntimeError &e) {
|
||||
std::string emsg = std::string(e.what());
|
||||
LOG(logDEBUG) << "Error message: " << emsg;
|
||||
|
||||
/*
|
||||
if (emsg.find(F_GET_SERVER_VERSION) && emsg.find("8 bytes")) {
|
||||
throwDeprecatedServerVersion();
|
||||
}
|
||||
*/
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void Module::throwDeprecatedServerVersion() const {
|
||||
LOG(logDEBUG1) << "throw deprecated version error";
|
||||
LOG(logDEBUG3) << "throw deprecated version error";
|
||||
uint64_t res = sendToDetectorStop<int64_t>(F_GET_SERVER_VERSION);
|
||||
std::cout << std::endl;
|
||||
std::ostringstream os;
|
||||
@@ -108,7 +105,6 @@ void Module::throwDeprecatedServerVersion() const {
|
||||
}
|
||||
|
||||
std::string Module::getStopServerLongVersion() const {
|
||||
LOG(logDEBUG1) << "Getting Stop Server Version";
|
||||
char retval[MAX_STR_LENGTH]{};
|
||||
sendToDetectorStop(F_GET_SERVER_VERSION, nullptr, retval);
|
||||
return retval;
|
||||
@@ -152,8 +148,6 @@ std::string Module::getReceiverSoftwareVersion() const {
|
||||
slsDetectorDefs::detectorType
|
||||
Module::getTypeFromDetector(const std::string &hostname, uint16_t cport) {
|
||||
LOG(logDEBUG1) << "Getting Module type ";
|
||||
LOG(logDEBUG1) << "ClientSocket: Hostname: " << hostname
|
||||
<< " Port: " << cport;
|
||||
ClientSocket socket("Detector", hostname, cport);
|
||||
socket.Send(F_GET_DETECTOR_TYPE);
|
||||
socket.setFnum(F_GET_DETECTOR_TYPE);
|
||||
@@ -3062,10 +3056,7 @@ void Module::sendToDetector(int fnum, const void *args, size_t args_size,
|
||||
// the other versions use templates to deduce sizes and create
|
||||
// the return type
|
||||
checkArgs(args, args_size, retval, retval_size);
|
||||
LOG(logDEBUG1) << "Creating DetectorSocket on: " << shm()->hostname << ":"
|
||||
<< shm()->controlPort;
|
||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||
LOG(logDEBUG1) << "sending command then read to DetectorSocket";
|
||||
client.sendCommandThenRead(fnum, args, args_size, retval, retval_size);
|
||||
client.close();
|
||||
}
|
||||
@@ -3177,10 +3168,8 @@ void Module::sendToDetectorStop(int fnum, const void *args, size_t args_size,
|
||||
// This is the only function that actually sends data to the detector stop
|
||||
// the other versions use templates to deduce sizes and create
|
||||
// the return type
|
||||
LOG(logINFORED) << "Sending command to Detector Stop Socket";
|
||||
checkArgs(args, args_size, retval, retval_size);
|
||||
auto stop = DetectorSocket(shm()->hostname, shm()->stopPort);
|
||||
LOG(logDEBUG1) << "sending command then read to Detector Stop Socket";
|
||||
stop.sendCommandThenRead(fnum, args, args_size, retval, retval_size);
|
||||
stop.close();
|
||||
}
|
||||
@@ -3303,7 +3292,6 @@ void Module::sendToReceiver(int fnum, const void *args, size_t args_size,
|
||||
}
|
||||
checkArgs(args, args_size, retval, retval_size);
|
||||
auto receiver = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort);
|
||||
LOG(logDEBUG1) << "sending command then read to ReceiverSocket";
|
||||
receiver.sendCommandThenRead(fnum, args, args_size, retval, retval_size);
|
||||
receiver.close();
|
||||
}
|
||||
@@ -3485,7 +3473,7 @@ void Module::checkDetectorVersionCompatibility() {
|
||||
LOG(logDEBUG) << "Checking detector version compatibility with client...";
|
||||
std::string detServers[2] = {getControlServerLongVersion(),
|
||||
getStopServerLongVersion()};
|
||||
LOG(logINFO)
|
||||
LOG(logDEBUG1)
|
||||
<< "Checking detector version compatibility with client version "
|
||||
<< detServers[0] << " and " << detServers[1];
|
||||
for (int i = 0; i != 2; ++i) {
|
||||
|
||||
@@ -85,7 +85,6 @@ void ClientInterface::startTCPServer() {
|
||||
<< '\n';
|
||||
|
||||
while (!killTcpThread) {
|
||||
LOG(logDEBUG1) << "Start accept loop";
|
||||
try {
|
||||
auto socket = server.accept();
|
||||
try {
|
||||
|
||||
@@ -67,9 +67,7 @@ int ClientSocket::sendCommandThenRead(int fnum, const void *args,
|
||||
int ret = slsDetectorDefs::FAIL;
|
||||
Send(&fnum, sizeof(fnum));
|
||||
setFnum(fnum);
|
||||
LOG(logDEBUG1) << "Sent command fnum: " << fnum << " to " << socketType;
|
||||
Send(args, args_size);
|
||||
LOG(logDEBUG1) << "About to read reply";
|
||||
readReply(ret, retval, retval_size);
|
||||
return ret;
|
||||
}
|
||||
@@ -78,7 +76,6 @@ void ClientSocket::readReply(int &ret, void *retval, size_t retval_size) {
|
||||
|
||||
try {
|
||||
Receive(&ret, sizeof(ret));
|
||||
// Receive<int>()
|
||||
if (ret == slsDetectorDefs::FAIL) {
|
||||
std::string mess = readErrorMessage();
|
||||
// Do we need to know hostname here?
|
||||
|
||||
@@ -50,8 +50,6 @@ int DataSocket::Receive(void *buffer, size_t size) {
|
||||
// TODO!(Erik) Add sleep? how many reties?
|
||||
int bytes_expected = static_cast<int>(size); // signed size
|
||||
int bytes_read = 0;
|
||||
LOG(logDEBUG1) << "Should receive " << bytes_expected
|
||||
<< " bytes on socket ";
|
||||
while (bytes_read < bytes_expected) {
|
||||
auto this_read =
|
||||
::read(getSocketId(), reinterpret_cast<char *>(buffer) + bytes_read,
|
||||
@@ -82,7 +80,6 @@ std::string DataSocket::Receive(size_t length) {
|
||||
int DataSocket::Send(const void *buffer, size_t size) {
|
||||
int bytes_sent = 0;
|
||||
int data_size = static_cast<int>(size); // signed size
|
||||
LOG(logDEBUG1) << "Sending " << data_size << " bytes on socket ";
|
||||
while (bytes_sent < (data_size)) {
|
||||
auto this_send = ::write(getSocketId(), buffer, size);
|
||||
if (this_send <= 0)
|
||||
@@ -149,8 +146,6 @@ void DataSocket::close() {
|
||||
} else {
|
||||
throw std::runtime_error("Socket ERROR: close called on bad socket\n");
|
||||
}
|
||||
|
||||
LOG(logDEBUG1) << "Closed socket with id: " << getSocketId();
|
||||
}
|
||||
|
||||
void DataSocket::shutDownSocket() {
|
||||
|
||||
@@ -44,7 +44,6 @@ ServerSocket::ServerSocket(int port)
|
||||
}
|
||||
|
||||
ServerInterface ServerSocket::accept() {
|
||||
LOG(logDEBUG1) << "In accept function, waiting for client to connect...";
|
||||
lastClient = thisClient; // update from previous connection
|
||||
struct sockaddr_in clientAddr;
|
||||
socklen_t addr_size = sizeof clientAddr;
|
||||
@@ -57,7 +56,7 @@ ServerInterface ServerSocket::accept() {
|
||||
char tc[INET_ADDRSTRLEN]{};
|
||||
inet_ntop(AF_INET, &(clientAddr.sin_addr), tc, INET_ADDRSTRLEN);
|
||||
thisClient = IpAddr{tc};
|
||||
LOG(logDEBUG1) << "Accepted connection from: " << tc << ":"
|
||||
LOG(logDEBUG3) << "Accepted connection from: " << tc << ":"
|
||||
<< ntohs(clientAddr.sin_port);
|
||||
// Set socket buffer size
|
||||
return ServerInterface(newSocket);
|
||||
|
||||
Reference in New Issue
Block a user