From d3467432a9db2775f9ba352fd52497986eef15e2 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Tue, 11 Jun 2019 15:43:24 +0200 Subject: [PATCH] WIP --- slsDetectorGui/include/qServer.h | 79 +------------------------------- slsDetectorGui/src/qServer.cpp | 16 +++---- 2 files changed, 9 insertions(+), 86 deletions(-) diff --git a/slsDetectorGui/include/qServer.h b/slsDetectorGui/include/qServer.h index 8ffebe3ab..c33b91da9 100755 --- a/slsDetectorGui/include/qServer.h +++ b/slsDetectorGui/include/qServer.h @@ -1,119 +1,42 @@ #pragma once -#include "qDefs.h" -#include "sls_detector_defs.h" class qDetectorMain; class multiSlsDetector; class ServerSocket; -#include - #include -/** - *@short Sets up the gui server - */ class qServer : public QWidget, public virtual slsDetectorDefs { Q_OBJECT public: - /** - * The constructor - */ qServer(qDetectorMain *t); - /** - * Destructor - */ ~qServer(); - - /** - * Create (Control and Stop) Gui Servers - */ void CreateServers(); - - /** - * Destroy (Control and Stop) Gui Servers - */ void DestroyServers(); private: - /** - * Assigns functions to the fnum enum - */ void FunctionTable(); - - /** - * Decodes Function - * @param sock control or stop socket - * @returns OK or FAIL - */ int DecodeFunction(ServerSocket *sock); - - /** - * Shut down Sockets - */ void ShutDownSockets(); - - /** - * Server thread - * @param pointer to control or stop socket - */ void ServerThread(ServerSocket* sock); - - /** - * Get Detector Status - * @returns success of operation - */ int GetStatus(ServerSocket* sock); - - /** - * Starts Acquisition - * @returns success of operation - */ int StartAcquisition(ServerSocket* sock); - - /** - * Stops Acquisition - * @returns success of operation - */ int StopsAcquisition(ServerSocket* sock); - - /** - * Acquire - blocking - * @returns success of operation - */ int Acquire(ServerSocket* sock); - - /** - * Exit Server - * @returns GOODBYE - */ int ExitServer(ServerSocket* sock); /** function list */ typedef int (qServer::*some_func_t)(ServerSocket*); typedef std::vector sflist; - - /** if the gui server thread is running*/ - bool threadRunning; - - /** if thread started */ + bool guiServerRunning; bool threadStarted; - /**The measurement tab object*/ qDetectorMain *mainTab; - - /** control port */ int controlPort; - - /** stop port */ int stopPort; - - /** control socket */ ServerSocket *controlSocket; - - /** stop socket */ ServerSocket *stopSocket; signals: diff --git a/slsDetectorGui/src/qServer.cpp b/slsDetectorGui/src/qServer.cpp index e8c13747d..018ff46e3 100755 --- a/slsDetectorGui/src/qServer.cpp +++ b/slsDetectorGui/src/qServer.cpp @@ -1,8 +1,8 @@ #include "qServer.h" +#include "qDefs.h" #include "qDetectorMain.h" #include "ServerSocket.h" -#include "multiSlsDetector.h" #include "string_utils.h" #include @@ -10,7 +10,7 @@ #include qServer::qServer(qDetectorMain *t) - : threadRunning(false), threadStarted(false), mainTab(t), + : guiServerRunning(false), threadStarted(false), mainTab(t), controlPort(DEFAULT_GUI_PORTNO), stopPort(DEFAULT_GUI_PORTNO + 1), controlSocket(nullptr), stopSocket(nullptr) { FILE_LOG(logDEBUG) << "Client Server ready"; @@ -52,7 +52,7 @@ int qServer::DecodeFunction(ServerSocket *sock) { } void qServer::ShutDownSockets() { - threadRunning = false; + guiServerRunning = false; if (controlSocket) { controlSocket->shutDownSocket(); delete controlSocket; @@ -66,9 +66,9 @@ void qServer::ShutDownSockets() { } void qServer::CreateServers() { - if (!threadRunning) { + if (!guiServerRunning) { FILE_LOG(logINFO) << "Starting Gui Servers"; - threadRunning = true; + guiServerRunning = true; try { // start control server @@ -91,7 +91,7 @@ void qServer::CreateServers() { } void qServer::DestroyServers() { - if (threadRunning) { + if (guiServerRunning) { FILE_LOG(logINFO) << "Stopping Gui Servers"; ShutDownSockets(); FILE_LOG(logDEBUG) << "Server threads stopped successfully."; @@ -101,11 +101,11 @@ void qServer::DestroyServers() { void qServer::ServerThread(ServerSocket* sock) { FILE_LOG(logDEBUG) << "Starting Gui Server at port " << sock->getPort(); - while (threadRunning)) { + while (guiServerRunning)) { try{ sock->accept(); if (DecodeFunction(sock) == GOODBYE) { - threadRunning = false; + guiServerRunning = false; } sock->close(); }