mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-06 10:00:40 +02:00
client connecting to gui serveR done
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@150 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
parent
863b662c6b
commit
22b51032dd
@ -11,6 +11,7 @@
|
|||||||
#include "slsDetectorBase.h"
|
#include "slsDetectorBase.h"
|
||||||
// C++ Include Headers
|
// C++ Include Headers
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
@ -49,55 +50,129 @@ int qClient::executeLine(int narg, char *args[]){
|
|||||||
char answer[100];
|
char answer[100];
|
||||||
string retval = "";
|
string retval = "";
|
||||||
string cmd = args[0];
|
string cmd = args[0];
|
||||||
|
string argument;
|
||||||
|
|
||||||
|
|
||||||
//validate command structure
|
//validate command structure
|
||||||
if(narg<1){
|
if(narg<1){
|
||||||
cout << "Error: no command parsed" << endl;
|
cout << "Error: no command parsed" << endl;
|
||||||
return slsDetectorDefs::FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//help
|
||||||
|
if (cmd == "help"){
|
||||||
|
retval = printCommands();
|
||||||
|
}
|
||||||
|
|
||||||
//file name
|
//file name
|
||||||
if (cmd == "status"){
|
else if (cmd == "status"){
|
||||||
|
|
||||||
|
if(narg>1){
|
||||||
|
argument = args[1];
|
||||||
|
//start acquisition
|
||||||
|
if(argument == "start")
|
||||||
|
sendToGuiServer(F_START_ACQUISITION);
|
||||||
|
else if (argument == "stop")
|
||||||
|
sendToGuiServer(F_STOP_ACQUISITION);
|
||||||
|
else{
|
||||||
|
cout << "Error: could not parse arguments: " << argument << endl;
|
||||||
|
printCommands();
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
retval = getStatus();
|
retval = getStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
else if (cmd == "acquire"){
|
||||||
|
sendToGuiServer(F_START_AND_READ_ALL);
|
||||||
|
retval = getStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
else if (cmd == "exit"){
|
||||||
|
if (sendToGuiServer(F_EXIT_SERVER) == OK)
|
||||||
|
retval = "Gui Server Exited successfully.";
|
||||||
|
else
|
||||||
|
retval = "Gui Server could not exit successfully";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//unrecognized command
|
//unrecognized command
|
||||||
else{
|
else{
|
||||||
cout << "Error: unrecognized command" << endl;
|
cout << "Error: unrecognized command" << endl;
|
||||||
return slsDetectorDefs::FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//print result
|
//print result
|
||||||
cout << cmd << ": " << retval << endl;
|
cout << cmd << ": " << retval << endl;
|
||||||
|
|
||||||
return slsDetectorDefs::OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
string qClient::printCommands(){
|
||||||
|
ostringstream os;
|
||||||
|
os << "\nexit \t exits server in gui" << std::endl;
|
||||||
|
os << "status \t gets status of acquisition in gui. - can be running or idle" << std::endl;
|
||||||
|
os << "status i starts/stops acquistion in gui-non blocking. i is start or stop" << std::endl;
|
||||||
|
os << "acquire starts acquistion in gui-blocking" << std::endl;
|
||||||
|
return os.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
string qClient::getStatus(){
|
string qClient::getStatus(){
|
||||||
int fnum = slsDetectorDefs::F_GET_RUN_STATUS;
|
int fnum = F_GET_RUN_STATUS;
|
||||||
int ret = slsDetectorDefs::FAIL;
|
int ret = FAIL;
|
||||||
int retval = -1;
|
runStatus retval=ERROR;
|
||||||
slsDetectorDefs::runStatus s=slsDetectorDefs::ERROR;
|
int progress = 0;
|
||||||
|
char answer[100];
|
||||||
|
|
||||||
if (mySocket->Connect() >= 0) {
|
if (mySocket->Connect() >= 0) {
|
||||||
mySocket->SendDataOnly(&fnum,sizeof(fnum));
|
mySocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||||
mySocket->ReceiveDataOnly(&ret,sizeof(ret));
|
mySocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||||
mySocket->ReceiveDataOnly(&retval,sizeof(retval));
|
mySocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||||
}
|
mySocket->ReceiveDataOnly(&progress,sizeof(progress));
|
||||||
mySocket->Disconnect();
|
mySocket->Disconnect();
|
||||||
|
}else
|
||||||
|
exit(-1);
|
||||||
|
|
||||||
if(retval==-1)
|
|
||||||
retval=slsDetectorDefs::ERROR;
|
|
||||||
|
|
||||||
return slsDetectorBase::runStatusType((slsDetectorDefs::runStatus)retval);
|
sprintf(answer,"%d%% ",progress);
|
||||||
|
strcat(answer,slsDetectorBase::runStatusType((runStatus)retval).c_str());
|
||||||
|
|
||||||
|
return string(answer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
int qClient::sendToGuiServer(int fnum){
|
||||||
|
int ret = FAIL;
|
||||||
|
char mess[100] = "";
|
||||||
|
|
||||||
|
if (mySocket->Connect() >= 0) {
|
||||||
|
mySocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||||
|
mySocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||||
|
if (ret == FAIL){
|
||||||
|
mySocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||||
|
std::cout<< "Gui returned error: " << mess << std::endl;
|
||||||
|
}
|
||||||
|
mySocket->Disconnect();
|
||||||
|
}else
|
||||||
|
exit(-1);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
|
|
||||||
/** Qt Project Class Headers */
|
/** Qt Project Class Headers */
|
||||||
//#include "qDefs.h"
|
|
||||||
/** Project Class Headers */
|
/** Project Class Headers */
|
||||||
class MySocketTCP;
|
class MySocketTCP;
|
||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
@ -34,6 +33,12 @@ public:
|
|||||||
int executeLine(int narg, char *args[]);
|
int executeLine(int narg, char *args[]);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/** Print list of commands */
|
||||||
|
string printCommands();
|
||||||
|
|
||||||
|
/** Send to Gui Server */
|
||||||
|
int sendToGuiServer(int fnum);
|
||||||
|
|
||||||
/** Gets run status */
|
/** Gets run status */
|
||||||
string getStatus();
|
string getStatus();
|
||||||
|
|
||||||
|
@ -12,8 +12,8 @@
|
|||||||
/** Form Header */
|
/** Form Header */
|
||||||
#include "ui_form_detectormain.h"
|
#include "ui_form_detectormain.h"
|
||||||
/** Qt Project Class Headers */
|
/** Qt Project Class Headers */
|
||||||
class qDrawPlot;
|
#include "qDrawPlot.h"
|
||||||
class qTabMeasurement;
|
#include "qTabMeasurement.h"
|
||||||
class qTabDataOutput;
|
class qTabDataOutput;
|
||||||
class qTabPlot;
|
class qTabPlot;
|
||||||
class qTabActions;
|
class qTabActions;
|
||||||
@ -64,6 +64,22 @@ public:
|
|||||||
* */
|
* */
|
||||||
~qDetectorMain();
|
~qDetectorMain();
|
||||||
|
|
||||||
|
/** Starts or stops Acquisition From gui client
|
||||||
|
* @param start 1 for start and 0 to stop
|
||||||
|
/returns success or fail
|
||||||
|
*/
|
||||||
|
int StartStopAcquisitionFromClient(bool start);
|
||||||
|
|
||||||
|
/** Returns if plot is running
|
||||||
|
*/
|
||||||
|
bool isPlotRunning(){return myPlot->isRunning();};
|
||||||
|
|
||||||
|
/** Returns progress bar value */
|
||||||
|
int GetProgress(){return tab_measurement->GetProgress();};
|
||||||
|
|
||||||
|
/** Uncheck the Listen to Gui Client mode when server has exited using exit command */
|
||||||
|
void GuiServerExited(){actionListenGuiClient->setChecked(false);};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** The Qt Application */
|
/** The Qt Application */
|
||||||
QApplication *theApp;
|
QApplication *theApp;
|
||||||
|
@ -11,8 +11,7 @@
|
|||||||
/** Qt Project Class Headers */
|
/** Qt Project Class Headers */
|
||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
#include "qDefs.h"
|
#include "qDefs.h"
|
||||||
class qDrawPlot;
|
class qDetectorMain;
|
||||||
class qTabMeasurement;
|
|
||||||
|
|
||||||
/** Project Class Headers */
|
/** Project Class Headers */
|
||||||
class multiSlsDetector;
|
class multiSlsDetector;
|
||||||
@ -28,7 +27,7 @@ class qServer: public virtual slsDetectorDefs{
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
/** \short The constructor */
|
/** \short The constructor */
|
||||||
qServer(multiSlsDetector*& detector, qTabMeasurement* m, qDrawPlot *d);
|
qServer(multiSlsDetector*& detector, qDetectorMain *t);
|
||||||
/** Destructor */
|
/** Destructor */
|
||||||
~qServer();
|
~qServer();
|
||||||
|
|
||||||
@ -39,10 +38,10 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/** assigns functions to the fnum enum */
|
/** assigns functions to the fnum enum */
|
||||||
int function_table();
|
int FunctionTable();
|
||||||
|
|
||||||
/** Decodes Function */
|
/** Decodes Function */
|
||||||
int decode_function();
|
int DecodeFunction();
|
||||||
|
|
||||||
/** Unrecognized Function */
|
/** Unrecognized Function */
|
||||||
int M_nofunc();
|
int M_nofunc();
|
||||||
@ -62,19 +61,27 @@ private:
|
|||||||
*/
|
*/
|
||||||
int StartServer();
|
int StartServer();
|
||||||
|
|
||||||
/** Get Detector Status */
|
/** Exit Server */
|
||||||
int get_status();
|
int ExitServer();
|
||||||
|
|
||||||
|
/** Get Detector Status */
|
||||||
|
int GetStatus();
|
||||||
|
|
||||||
|
/** Starts Acquisition */
|
||||||
|
int StartAcquisition();
|
||||||
|
|
||||||
|
/** Stops Acquisition */
|
||||||
|
int StopsAcquisition();
|
||||||
|
|
||||||
|
/** Acquire - blocking */
|
||||||
|
int Acquire();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** The multi detector object */
|
/** The multi detector object */
|
||||||
multiSlsDetector *myDet;
|
multiSlsDetector *myDet;
|
||||||
/**The measurement tab object*/
|
/**The measurement tab object*/
|
||||||
qTabMeasurement *tab_measurement;
|
qDetectorMain *myMainTab;
|
||||||
/**The plot widget object*/
|
|
||||||
qDrawPlot *myPlot;
|
|
||||||
|
|
||||||
|
|
||||||
/** tcp socket to gui client */
|
/** tcp socket to gui client */
|
||||||
MySocketTCP *mySocket;
|
MySocketTCP *mySocket;
|
||||||
|
@ -48,6 +48,17 @@ public:
|
|||||||
*/
|
*/
|
||||||
void SetExpertMode(bool enable);
|
void SetExpertMode(bool enable);
|
||||||
|
|
||||||
|
/** Returns the status of the Start/Stop Acquisition button
|
||||||
|
*/
|
||||||
|
bool GetStartStatus(){return btnStartStop->isChecked();};
|
||||||
|
|
||||||
|
/** Click the Start/Stop Acquisition button
|
||||||
|
* This is used if this command came from gui client
|
||||||
|
*/
|
||||||
|
void ClickStartStop(){btnStartStop->click();};
|
||||||
|
|
||||||
|
/** Returns progress bar value */
|
||||||
|
int GetProgress(){return progressBar->value();};
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
* ********************************************************************/
|
* ********************************************************************/
|
||||||
// Qt Project Class Headers
|
// Qt Project Class Headers
|
||||||
#include "qDetectorMain.h"
|
#include "qDetectorMain.h"
|
||||||
#include "qDrawPlot.h"
|
|
||||||
#include "qTabMeasurement.h"
|
|
||||||
#include "qTabDataOutput.h"
|
#include "qTabDataOutput.h"
|
||||||
#include "qTabPlot.h"
|
#include "qTabPlot.h"
|
||||||
#include "qTabActions.h"
|
#include "qTabActions.h"
|
||||||
@ -113,7 +111,7 @@ void qDetectorMain::SetUpWidgetWindow(){
|
|||||||
tab_debugging = new qTabDebugging (this, myDet); cout<<"Debugging ready"<<endl;
|
tab_debugging = new qTabDebugging (this, myDet); cout<<"Debugging ready"<<endl;
|
||||||
tab_developer = new qTabDeveloper (this, myDet); cout<<"Developer ready"<<endl;
|
tab_developer = new qTabDeveloper (this, myDet); cout<<"Developer ready"<<endl;
|
||||||
|
|
||||||
myServer = new qServer(myDet, tab_measurement, myPlot);
|
myServer = new qServer(myDet, this);
|
||||||
|
|
||||||
// creating the scroll area widgets for the tabs
|
// creating the scroll area widgets for the tabs
|
||||||
for(int i=0;i<NumberOfTabs;i++){
|
for(int i=0;i<NumberOfTabs;i++){
|
||||||
@ -719,4 +717,31 @@ void qDetectorMain::SetZoomToolTip(bool disable){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
int qDetectorMain::StartStopAcquisitionFromClient(bool start){
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "Start/Stop Acquisition From Client:" << start << endl;
|
||||||
|
#endif
|
||||||
|
int ret = slsDetectorDefs::FAIL;
|
||||||
|
|
||||||
|
if (tab_measurement->GetStartStatus() != start){
|
||||||
|
if(start){
|
||||||
|
//refresh all the required tabs
|
||||||
|
tab_actions->Refresh();
|
||||||
|
tab_measurement->Refresh();
|
||||||
|
tab_plot->Refresh();
|
||||||
|
}
|
||||||
|
//click start/stop
|
||||||
|
tab_measurement->ClickStartStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (myPlot->isRunning() == start)
|
||||||
|
ret = slsDetectorDefs::OK;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -6,8 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
// Qt Project Class Headers
|
// Qt Project Class Headers
|
||||||
#include "qServer.h"
|
#include "qServer.h"
|
||||||
#include "qTabMeasurement.h"
|
#include "qDetectorMain.h"
|
||||||
#include "qDrawPlot.h"
|
|
||||||
// Project Class Headers
|
// Project Class Headers
|
||||||
#include "slsDetector.h"
|
#include "slsDetector.h"
|
||||||
#include "multiSlsDetector.h"
|
#include "multiSlsDetector.h"
|
||||||
@ -27,10 +26,10 @@ int qServer::gui_server_thread_running(0);
|
|||||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
qServer::qServer(multiSlsDetector*& detector, qTabMeasurement* m, qDrawPlot *d):
|
qServer::qServer(multiSlsDetector*& detector, qDetectorMain *t):
|
||||||
myDet(detector),tab_measurement(m),myPlot(d),mySocket(NULL),port_no(DEFAULT_GUI_PORTNO),lockStatus(0){
|
myDet(detector), myMainTab(t), mySocket(NULL),port_no(DEFAULT_GUI_PORTNO),lockStatus(0){
|
||||||
|
|
||||||
function_table();
|
FunctionTable();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,8 +39,7 @@ qServer::qServer(multiSlsDetector*& detector, qTabMeasurement* m, qDrawPlot *d):
|
|||||||
|
|
||||||
qServer::~qServer(){
|
qServer::~qServer(){
|
||||||
delete myDet;
|
delete myDet;
|
||||||
delete tab_measurement;
|
delete myMainTab;
|
||||||
delete myPlot;
|
|
||||||
if(mySocket) delete mySocket;
|
if(mySocket) delete mySocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,16 +47,16 @@ qServer::~qServer(){
|
|||||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
int qServer::function_table(){
|
int qServer::FunctionTable(){
|
||||||
|
|
||||||
for (int i=0;i<NUMBER_OF_FUNCTIONS;i++)
|
for (int i=0;i<NUMBER_OF_FUNCTIONS;i++)
|
||||||
flist[i]=&qServer::M_nofunc;
|
flist[i]=&qServer::M_nofunc;
|
||||||
|
|
||||||
flist[F_GET_RUN_STATUS] = &qServer::get_status;
|
flist[F_GET_RUN_STATUS] = &qServer::GetStatus;
|
||||||
flist[F_START_ACQUISITION] = &qServer::get_status;
|
flist[F_START_ACQUISITION] = &qServer::StartAcquisition;
|
||||||
flist[F_STOP_ACQUISITION] = &qServer::get_status;
|
flist[F_STOP_ACQUISITION] = &qServer::StopsAcquisition;
|
||||||
flist[F_START_AND_READ_ALL] = &qServer::get_status;
|
flist[F_START_AND_READ_ALL] = &qServer::Acquire;
|
||||||
flist[F_EXIT_SERVER] = &qServer::get_status;
|
flist[F_EXIT_SERVER] = &qServer::ExitServer;
|
||||||
|
|
||||||
return qDefs::OK;
|
return qDefs::OK;
|
||||||
}
|
}
|
||||||
@ -67,7 +65,7 @@ int qServer::function_table(){
|
|||||||
//------------------------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
int qServer::decode_function(){
|
int qServer::DecodeFunction(){
|
||||||
int ret = qDefs::FAIL;
|
int ret = qDefs::FAIL;
|
||||||
int n,fnum;
|
int n,fnum;
|
||||||
#ifdef VERYVERBOSE
|
#ifdef VERYVERBOSE
|
||||||
@ -92,7 +90,7 @@ int qServer::decode_function(){
|
|||||||
if (fnum<0 || fnum>NUMBER_OF_FUNCTIONS-1)
|
if (fnum<0 || fnum>NUMBER_OF_FUNCTIONS-1)
|
||||||
fnum = NUMBER_OF_FUNCTIONS-1;
|
fnum = NUMBER_OF_FUNCTIONS-1;
|
||||||
//calling function
|
//calling function
|
||||||
(this->*flist[fnum])();
|
ret = (this->*flist[fnum])();
|
||||||
if (ret==qDefs::FAIL)
|
if (ret==qDefs::FAIL)
|
||||||
cout << "Error executing the function = " << fnum << endl;
|
cout << "Error executing the function = " << fnum << endl;
|
||||||
|
|
||||||
@ -159,11 +157,13 @@ int qServer::StartStopServer(int start){
|
|||||||
cout << "Stopping gui server thread ...." << endl;
|
cout << "Stopping gui server thread ...." << endl;
|
||||||
#endif
|
#endif
|
||||||
gui_server_thread_running=0;
|
gui_server_thread_running=0;
|
||||||
mySocket->Disconnect();
|
if(mySocket)
|
||||||
mySocket->ShutDownSocket();
|
mySocket->ShutDownSocket();
|
||||||
pthread_join(gui_server_thread,NULL);
|
pthread_join(gui_server_thread,NULL);
|
||||||
delete mySocket;
|
if(mySocket){
|
||||||
mySocket = NULL;
|
delete mySocket;
|
||||||
|
mySocket = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "Server stopped successfully." << endl;
|
cout << "Server stopped successfully." << endl;
|
||||||
@ -212,7 +212,7 @@ int qServer::StartServer(){
|
|||||||
#ifdef VERYVERBOSE
|
#ifdef VERYVERBOSE
|
||||||
cout << "Conenction accepted" << endl;
|
cout << "Conenction accepted" << endl;
|
||||||
#endif
|
#endif
|
||||||
ret = decode_function();
|
ret = DecodeFunction();
|
||||||
#ifdef VERYVERBOSE
|
#ifdef VERYVERBOSE
|
||||||
cout << "function executed" << endl;
|
cout << "function executed" << endl;
|
||||||
#endif
|
#endif
|
||||||
@ -226,6 +226,13 @@ int qServer::StartServer(){
|
|||||||
cout << "Stopped gui server thread" << endl;
|
cout << "Stopped gui server thread" << endl;
|
||||||
#endif
|
#endif
|
||||||
gui_server_thread_running = 0;
|
gui_server_thread_running = 0;
|
||||||
|
//delete socket(via exit server)
|
||||||
|
if(mySocket){
|
||||||
|
delete mySocket;
|
||||||
|
mySocket = NULL;
|
||||||
|
}
|
||||||
|
//uncheck the server in modes(via exit server)
|
||||||
|
myMainTab->GuiServerExited();
|
||||||
return qDefs::OK;
|
return qDefs::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,20 +240,24 @@ int qServer::StartServer(){
|
|||||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
int qServer::get_status(){
|
int qServer::GetStatus(){
|
||||||
|
|
||||||
int ret = qDefs::OK;
|
int ret = qDefs::OK;
|
||||||
enum slsDetectorDefs::runStatus retval;
|
enum slsDetectorDefs::runStatus retval;
|
||||||
|
int progress = 0;
|
||||||
|
|
||||||
// execute action if the arguments correctly arrived
|
// execute action if the arguments correctly arrived
|
||||||
if(myPlot->isRunning())
|
if(myMainTab->isPlotRunning())
|
||||||
retval = slsDetectorDefs::RUNNING;
|
retval = slsDetectorDefs::RUNNING;
|
||||||
else
|
else
|
||||||
retval = slsDetectorDefs::IDLE;
|
retval = slsDetectorDefs::IDLE;
|
||||||
|
|
||||||
|
progress = myMainTab->GetProgress();
|
||||||
|
|
||||||
// send answer
|
// send answer
|
||||||
mySocket->SendDataOnly(&ret,sizeof(ret));
|
mySocket->SendDataOnly(&ret,sizeof(ret));
|
||||||
mySocket->SendDataOnly(&retval,sizeof(retval));
|
mySocket->SendDataOnly(&retval,sizeof(retval));
|
||||||
|
mySocket->SendDataOnly(&progress,sizeof(progress));
|
||||||
//return ok/fail
|
//return ok/fail
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -254,3 +265,70 @@ int qServer::get_status(){
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
int qServer::StartAcquisition(){
|
||||||
|
|
||||||
|
strcpy(mess,"Could not start acquisition in gui. \n");
|
||||||
|
|
||||||
|
int ret = myMainTab->StartStopAcquisitionFromClient(true);
|
||||||
|
mySocket->SendDataOnly(&ret,sizeof(ret));
|
||||||
|
if(ret==FAIL)
|
||||||
|
mySocket->SendDataOnly(mess,sizeof(mess));
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
int qServer::StopsAcquisition(){
|
||||||
|
|
||||||
|
strcpy(mess,"Could not stop acquisition in gui. \n");
|
||||||
|
|
||||||
|
int ret = myMainTab->StartStopAcquisitionFromClient(false);
|
||||||
|
mySocket->SendDataOnly(&ret,sizeof(ret));
|
||||||
|
if(ret==FAIL)
|
||||||
|
mySocket->SendDataOnly(mess,sizeof(mess));
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
int qServer::Acquire(){
|
||||||
|
|
||||||
|
strcpy(mess,"Could not start blocking acquisition in gui. \n");
|
||||||
|
|
||||||
|
int ret = myMainTab->StartStopAcquisitionFromClient(true);
|
||||||
|
|
||||||
|
if(ret == OK)
|
||||||
|
while(myMainTab->isPlotRunning());
|
||||||
|
|
||||||
|
mySocket->SendDataOnly(&ret,sizeof(ret));
|
||||||
|
if(ret==FAIL)
|
||||||
|
mySocket->SendDataOnly(mess,sizeof(mess));
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
int qServer::ExitServer(){
|
||||||
|
|
||||||
|
int ret = OK;
|
||||||
|
strcpy(mess,"closing gui server");
|
||||||
|
|
||||||
|
mySocket->SendDataOnly(&ret,sizeof(ret));
|
||||||
|
mySocket->SendDataOnly(mess,sizeof(mess));
|
||||||
|
cout << mess << endl;
|
||||||
|
|
||||||
|
return GOODBYE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -324,25 +324,6 @@ void qTabMeasurement::startStopAcquisition(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/*
|
|
||||||
int qTabMeasurement::GetAcquisitionStarted(){
|
|
||||||
|
|
||||||
cout<<" acquisition started call back"<<endl;
|
|
||||||
//if the acquisition started from client, the button wont be checked
|
|
||||||
if(!btnStartStop->isChecked()){cout<<" hasnt started, so from client"<<endl;
|
|
||||||
myPlot->SetAcqFromClient();
|
|
||||||
btnStartStop->click();
|
|
||||||
//wait till the gui is ready to execute the acquire(), but doesnt execute it
|
|
||||||
//acqFromClient is reset when it is ready
|
|
||||||
while(myPlot->GetAcqFromClient());
|
|
||||||
}else
|
|
||||||
cout<<" has started, so from gui"<<endl;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user