From e6361c73fc3603cf892f7d9bf861809dd98da265 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Wed, 12 Jun 2019 11:24:05 +0200 Subject: [PATCH] WIP --- slsDetectorGui/client/qClient.cpp | 22 +++++++------- slsDetectorGui/client/qClient.h | 49 +------------------------------ 2 files changed, 12 insertions(+), 59 deletions(-) diff --git a/slsDetectorGui/client/qClient.cpp b/slsDetectorGui/client/qClient.cpp index fee2b0c21..f4ceccd9f 100755 --- a/slsDetectorGui/client/qClient.cpp +++ b/slsDetectorGui/client/qClient.cpp @@ -1,5 +1,6 @@ #include "qClient.h" +#include "qDefs.h" #include "ClientSocket.h" #include "logger.h" #include "sls_detector_exceptions.h" @@ -29,7 +30,7 @@ void qClient::executeLine(int narg, char *args[]) { // validate command structure if (narg < 1) { - throw sls::RuntimeError("No command parsed. " + printCommands()); + throw sls::NonCriticalError("No command parsed. " + printCommands()); } // help @@ -48,8 +49,7 @@ void qClient::executeLine(int narg, char *args[]) { else if (argument == "stop") stopAcquisition(); else { - throw sls::RuntimeError("Could not parse arguments. " + - printCommands()); + throw sls::NonCriticalError("Could not parse arguments. " + printCommands()); } } retval = getStatus(); @@ -67,7 +67,7 @@ void qClient::executeLine(int narg, char *args[]) { // unrecognized command else { - throw sls::RuntimeError("Unrecognized command. " + printCommands()); + throw sls::NonCriticalError("Unrecognized command. " + printCommands()); } // print result @@ -88,36 +88,36 @@ std::string qClient::printCommands() { } std::string qClient::getStatus() { - int fnum = qDefs::F_GUI_GET_RUN_STATUS; - int retvals[2] = {static_cast(ERROR), 0}; + int fnum = qDefs::QF_GET_DETECTOR_STATUS; + int retvals[2] = {static_cast(slsDetectorDefs::ERROR), 0}; auto client = sls::GuiSocket(hostname, controlPort); client.sendCommandThenRead(fnum, nullptr, 0, retvals, sizeof(retvals)); - runStatus status = static_cast(retvals[0]); + slsDetectorDefs::runStatus status = static_cast(retvals[0]); int progress = retvals[1]; return std::to_string(progress) + std::string("% ") + slsDetectorDefs::runStatusType(status); } void qClient::startAcquisition(bool blocking) { - int fnum = qDefs::F_GUI_START_ACQUISITION; + int fnum = qDefs::QF_START_ACQUISITION; if (blocking) - fnum = qDefs::F_GUI_START_AND_READ_ALL; + fnum = qDefs::QF_START_AND_READ_ALL; auto client = sls::GuiSocket(hostname.c_str(), controlPort); client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0); } void qClient::stopAcquisition() { - int fnum = qDefs::F_GUI_STOP_ACQUISITION; + int fnum = qDefs::QF_STOP_ACQUISITION; auto client = sls::GuiSocket(hostname, stopPort); client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0); } void qClient::exitServer() { - int fnum = qDefs::F_GUI_EXIT_SERVER; + int fnum = qDefs::QF_EXIT_SERVER; // closes both control and stop server auto client = sls::GuiSocket(hostname, controlPort); client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0); diff --git a/slsDetectorGui/client/qClient.h b/slsDetectorGui/client/qClient.h index 726be3fbf..18db3fe14 100755 --- a/slsDetectorGui/client/qClient.h +++ b/slsDetectorGui/client/qClient.h @@ -1,70 +1,23 @@ #pragma once -#include "qDefs.h" - -#include "sls_detector_defs.h" - #include #include -/** - *@short Sets up the gui server - */ -class qClient : public virtual slsDetectorDefs { +class qClient { public: - /** - * The constructor - * @param h hostname - */ qClient(char *h); - /** - * Destructor - */ virtual ~qClient(); - - /** - * Execute command - * @param narg number of arguments - * @param args argument list - */ void executeLine(int narg, char *args[]); private: - /** - * Print list of commands - * @returns string of result - */ std::string printCommands(); - - /** - * Gets run status - * @returns status - */ std::string getStatus(); - - /** - * Start Acquisition - * @param blocking true if its a blocking acquistion - */ void startAcquisition(bool blocking = false); - - /** - * Stops Acquisition - */ void stopAcquisition(); - - /** - * Exits Server - */ void exitServer(); - /** hostname */ std::string hostname; - - /** control port */ int controlPort; - - /** stop port */ int stopPort; };