mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-29 01:20:02 +02:00
WIP
This commit is contained in:
parent
afb6d6bf3a
commit
e6361c73fc
@ -1,5 +1,6 @@
|
|||||||
#include "qClient.h"
|
#include "qClient.h"
|
||||||
|
|
||||||
|
#include "qDefs.h"
|
||||||
#include "ClientSocket.h"
|
#include "ClientSocket.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "sls_detector_exceptions.h"
|
#include "sls_detector_exceptions.h"
|
||||||
@ -29,7 +30,7 @@ void qClient::executeLine(int narg, char *args[]) {
|
|||||||
|
|
||||||
// validate command structure
|
// validate command structure
|
||||||
if (narg < 1) {
|
if (narg < 1) {
|
||||||
throw sls::RuntimeError("No command parsed. " + printCommands());
|
throw sls::NonCriticalError("No command parsed. " + printCommands());
|
||||||
}
|
}
|
||||||
|
|
||||||
// help
|
// help
|
||||||
@ -48,8 +49,7 @@ void qClient::executeLine(int narg, char *args[]) {
|
|||||||
else if (argument == "stop")
|
else if (argument == "stop")
|
||||||
stopAcquisition();
|
stopAcquisition();
|
||||||
else {
|
else {
|
||||||
throw sls::RuntimeError("Could not parse arguments. " +
|
throw sls::NonCriticalError("Could not parse arguments. " + printCommands());
|
||||||
printCommands());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
retval = getStatus();
|
retval = getStatus();
|
||||||
@ -67,7 +67,7 @@ void qClient::executeLine(int narg, char *args[]) {
|
|||||||
|
|
||||||
// unrecognized command
|
// unrecognized command
|
||||||
else {
|
else {
|
||||||
throw sls::RuntimeError("Unrecognized command. " + printCommands());
|
throw sls::NonCriticalError("Unrecognized command. " + printCommands());
|
||||||
}
|
}
|
||||||
|
|
||||||
// print result
|
// print result
|
||||||
@ -88,36 +88,36 @@ std::string qClient::printCommands() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string qClient::getStatus() {
|
std::string qClient::getStatus() {
|
||||||
int fnum = qDefs::F_GUI_GET_RUN_STATUS;
|
int fnum = qDefs::QF_GET_DETECTOR_STATUS;
|
||||||
int retvals[2] = {static_cast<int>(ERROR), 0};
|
int retvals[2] = {static_cast<int>(slsDetectorDefs::ERROR), 0};
|
||||||
|
|
||||||
auto client = sls::GuiSocket(hostname, controlPort);
|
auto client = sls::GuiSocket(hostname, controlPort);
|
||||||
client.sendCommandThenRead(fnum, nullptr, 0, retvals, sizeof(retvals));
|
client.sendCommandThenRead(fnum, nullptr, 0, retvals, sizeof(retvals));
|
||||||
|
|
||||||
runStatus status = static_cast<runStatus>(retvals[0]);
|
slsDetectorDefs::runStatus status = static_cast<slsDetectorDefs::runStatus>(retvals[0]);
|
||||||
int progress = retvals[1];
|
int progress = retvals[1];
|
||||||
return std::to_string(progress) + std::string("% ") +
|
return std::to_string(progress) + std::string("% ") +
|
||||||
slsDetectorDefs::runStatusType(status);
|
slsDetectorDefs::runStatusType(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
void qClient::startAcquisition(bool blocking) {
|
void qClient::startAcquisition(bool blocking) {
|
||||||
int fnum = qDefs::F_GUI_START_ACQUISITION;
|
int fnum = qDefs::QF_START_ACQUISITION;
|
||||||
if (blocking)
|
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);
|
auto client = sls::GuiSocket(hostname.c_str(), controlPort);
|
||||||
client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
|
client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void qClient::stopAcquisition() {
|
void qClient::stopAcquisition() {
|
||||||
int fnum = qDefs::F_GUI_STOP_ACQUISITION;
|
int fnum = qDefs::QF_STOP_ACQUISITION;
|
||||||
|
|
||||||
auto client = sls::GuiSocket(hostname, stopPort);
|
auto client = sls::GuiSocket(hostname, stopPort);
|
||||||
client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
|
client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void qClient::exitServer() {
|
void qClient::exitServer() {
|
||||||
int fnum = qDefs::F_GUI_EXIT_SERVER;
|
int fnum = qDefs::QF_EXIT_SERVER;
|
||||||
// closes both control and stop server
|
// closes both control and stop server
|
||||||
auto client = sls::GuiSocket(hostname, controlPort);
|
auto client = sls::GuiSocket(hostname, controlPort);
|
||||||
client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
|
client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
|
||||||
|
@ -1,70 +1,23 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "qDefs.h"
|
|
||||||
|
|
||||||
#include "sls_detector_defs.h"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
/**
|
class qClient {
|
||||||
*@short Sets up the gui server
|
|
||||||
*/
|
|
||||||
class qClient : public virtual slsDetectorDefs {
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
|
||||||
* The constructor
|
|
||||||
* @param h hostname
|
|
||||||
*/
|
|
||||||
qClient(char *h);
|
qClient(char *h);
|
||||||
/**
|
|
||||||
* Destructor
|
|
||||||
*/
|
|
||||||
virtual ~qClient();
|
virtual ~qClient();
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute command
|
|
||||||
* @param narg number of arguments
|
|
||||||
* @param args argument list
|
|
||||||
*/
|
|
||||||
void executeLine(int narg, char *args[]);
|
void executeLine(int narg, char *args[]);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
|
||||||
* Print list of commands
|
|
||||||
* @returns string of result
|
|
||||||
*/
|
|
||||||
std::string printCommands();
|
std::string printCommands();
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets run status
|
|
||||||
* @returns status
|
|
||||||
*/
|
|
||||||
std::string getStatus();
|
std::string getStatus();
|
||||||
|
|
||||||
/**
|
|
||||||
* Start Acquisition
|
|
||||||
* @param blocking true if its a blocking acquistion
|
|
||||||
*/
|
|
||||||
void startAcquisition(bool blocking = false);
|
void startAcquisition(bool blocking = false);
|
||||||
|
|
||||||
/**
|
|
||||||
* Stops Acquisition
|
|
||||||
*/
|
|
||||||
void stopAcquisition();
|
void stopAcquisition();
|
||||||
|
|
||||||
/**
|
|
||||||
* Exits Server
|
|
||||||
*/
|
|
||||||
void exitServer();
|
void exitServer();
|
||||||
|
|
||||||
/** hostname */
|
|
||||||
std::string hostname;
|
std::string hostname;
|
||||||
|
|
||||||
/** control port */
|
|
||||||
int controlPort;
|
int controlPort;
|
||||||
|
|
||||||
/** stop port */
|
|
||||||
int stopPort;
|
int stopPort;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user