-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote branch 'slsDetectorGui/2.1' into 2.1
- Loading branch information
Showing
86 changed files
with
26,858 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Makefile.gui | ||
forms/include/ | ||
mocs/ | ||
objs/ | ||
qrc_icons.cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# LEO: Won't compile without libSlsDetector | ||
|
||
include ../Makefile.include | ||
|
||
$(info ) | ||
$(info ##################################) | ||
$(info # Compiling slsDetectorGui #) | ||
$(info ##################################) | ||
$(info ) | ||
|
||
|
||
|
||
PROG = $(DESTDIR)/slsDetectorGui | ||
|
||
DESTDIR ?= ../bin | ||
LIBDIR ?= $(DESTDIR) | ||
DOCDIR ?= docs | ||
|
||
LIBRARYDIR ?= ../slsDetectorSoftware | ||
LIBRARYRXRDIR ?= ../slsReceiverSoftware | ||
INCLUDES ?= $(LIBRARYDIR)/commonFiles -I$(LIBRARYRXRDIR)/MySocketTCP -I$(LIBRARYDIR)/slsReceiverInterface -I$(LIBRARYDIR)/slsDetector -I$(LIBRARYDIR)/slsDetectorAnalysis -I$(LIBRARYDIR)/multiSlsDetector -I$(LIBRARYDIR)/usersFunctions -I$(LIBRARYRXRDIR)/includes | ||
|
||
#ifeq ( $(EIGERSLS), yes) | ||
# LDFLAG += $(EIGERFLAGS) | ||
#else ifeq ( $(ROOTSLS), yes) | ||
# LDFLAG += $(ROOTFLAGS) | ||
#endif | ||
|
||
.PHONY: all lib clean mm doc htmldoc guiclient | ||
|
||
|
||
all: lib $(PROG) Makefile.gui guiclient | ||
|
||
lib: | ||
cd ../ && $(MAKE) lib | ||
|
||
clean: | ||
if test -e Makefile.gui; then $(MAKE) -f Makefile.gui clean; $(MAKE) -f Makefile.gui mocclean; rm Makefile.gui; else $(MAKE) Makefile.gui; $(MAKE) -f Makefile.gui clean; $(MAKE) -f Makefile.gui mocclean; fi | ||
cd client && $(MAKE) clean | ||
# cd manual && make clean | ||
|
||
|
||
Makefile.gui: mm | ||
|
||
mm: | ||
qmake -set QT_INSTALL_PREFIX $(QTDIR) && qmake -o Makefile.gui INCLUDES='$(INCLUDES)' DESTDIR=$(DESTDIR) SLSDETLIB=$(LIBDIR) SUBLIBS='$(LDFLAGDET)' | ||
|
||
doc: | ||
cd manual && $(MAKE) DESTDIR=$(DOCDIR) | ||
|
||
htmldoc: | ||
cd manual && $(MAKE) html DESTDIR=$(DOCDIR) | ||
|
||
$(PROG): Makefile.gui $(DIR) | ||
$(MAKE) -f Makefile.gui SLSDETLIB=$(LIBDIR) DESTDIR=$(DESTDIR) SUBLIBS='$(LDFLAGDET)' INCLUDES='$(INCLUDES)' | ||
|
||
guiclient: | ||
echo $(WD) | ||
cd client && $(MAKE) DESTDIR=$(DESTDIR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
CC = g++ | ||
CLAGS += -DVERBOSE #VERYBOSE | ||
LDLIBS += -lm -lstdc++ -lpthread | ||
|
||
LDIR = ../../slsDetectorSoftware | ||
RDIR = ../../slsReceiverSoftware | ||
|
||
INCLUDES = -I $(LDIR)/commonFiles -I $(LDIR)/slsDetector -I ../include -I $(RDIR)/include | ||
SRC_CLNT = qClient.cpp $(RDIR)/src/MySocketTCP.cpp | ||
|
||
PROGS = gui_client | ||
DESTDIR ?= bin | ||
INSTMODE = 0777 | ||
|
||
FINALDIR = ../../bin | ||
|
||
OBJS = $(SRC_CLNT:.cpp=.o) | ||
|
||
|
||
all: clean $(PROGS) | ||
|
||
boot: $(OBJS) | ||
|
||
$(PROGS): | ||
echo $(OBJS) | ||
mkdir -p $(DESTDIR) | ||
gcc $(SRC_CLNT) $(INCLUDES) $(FLAGS) $(LDLIBS) -o $@ | ||
mv $(PROGS) $(FINALDIR) | ||
|
||
clean: | ||
rm -rf $(DESTDIR)/$(PROGS) *.o $(FINALDIR)/$(PROGS) | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,234 @@ | ||
/* | ||
* qClient.cpp | ||
* | ||
* Created on: Feb 27, 2013 | ||
* Author: Dhanya Maliakal | ||
*/ | ||
// Qt Project Class Headers | ||
#include "qClient.h" | ||
// Project Class Headers | ||
#include "MySocketTCP.h" | ||
#include "slsDetectorBase.h" | ||
|
||
// C++ Include Headers | ||
#include <iostream> | ||
#include <sstream> | ||
using namespace std; | ||
|
||
|
||
|
||
//------------------------------------------------------------------------------------------------------------------------------------------------- | ||
|
||
|
||
int main(int argc, char *argv[]){ | ||
|
||
qClient *cl =new qClient(argv[1]); | ||
cl->executeLine(argc-2, argv+2); | ||
|
||
delete cl; | ||
} | ||
|
||
|
||
//------------------------------------------------------------------------------------------------------------------------------------------------- | ||
|
||
|
||
qClient::qClient(char* hostname){ | ||
//create socket | ||
mySocket = new MySocketTCP(hostname, DEFAULT_GUI_PORTNO); | ||
if (mySocket->getErrorStatus()){ | ||
cout << "Error: could not connect to host:" << hostname << " with port " << DEFAULT_GUI_PORTNO << endl; | ||
delete mySocket; | ||
exit(-1); | ||
} | ||
|
||
//create socket to connect to stop server | ||
myStopSocket = new MySocketTCP(hostname, DEFAULT_GUI_PORTNO+1); | ||
if (myStopSocket->getErrorStatus()){ | ||
cout << "Error: could not connect to host:" << hostname << " with port " << DEFAULT_GUI_PORTNO + 1 << endl; | ||
delete myStopSocket; | ||
exit(-1); | ||
} | ||
|
||
} | ||
|
||
|
||
//------------------------------------------------------------------------------------------------------------------------------------------------- | ||
|
||
qClient::~qClient() { | ||
if(mySocket) delete mySocket; | ||
if(myStopSocket) delete myStopSocket; | ||
} | ||
|
||
|
||
//------------------------------------------------------------------------------------------------------------------------------------------------- | ||
|
||
|
||
int qClient::executeLine(int narg, char *args[]){ | ||
|
||
char arg[MAX_STR_LENGTH] = ""; | ||
int iarg = -1; | ||
char answer[100]; | ||
string retval = ""; | ||
string cmd = args[0]; | ||
string argument; | ||
|
||
|
||
//validate command structure | ||
if(narg<1){ | ||
cout << "Error: no command parsed" << endl; | ||
return FAIL; | ||
} | ||
|
||
|
||
//help | ||
if (cmd == "help"){ | ||
retval = printCommands(); | ||
} | ||
|
||
//file name | ||
else if (cmd == "status"){ | ||
|
||
if(narg>1){ | ||
argument = args[1]; | ||
//start acquisition | ||
if(argument == "start") | ||
startAcquisition(); | ||
else if (argument == "stop") | ||
stopAcquisition(); | ||
else{ | ||
cout << "Error: could not parse arguments: " << argument << endl; | ||
printCommands(); | ||
return FAIL; | ||
} | ||
} | ||
retval = getStatus(); | ||
} | ||
|
||
|
||
else if (cmd == "acquire"){ | ||
startAcquisition(true); | ||
retval = getStatus(); | ||
} | ||
|
||
|
||
else if (cmd == "exit"){ | ||
return exitServer(); | ||
} | ||
|
||
|
||
//unrecognized command | ||
else{ | ||
cout << "Error: unrecognized command" << endl; | ||
return FAIL; | ||
} | ||
|
||
|
||
//print result | ||
cout << cmd << ": " << retval << endl; | ||
|
||
return OK; | ||
} | ||
|
||
//------------------------------------------------------------------------------------------------------------------------------------------------- | ||
|
||
|
||
string qClient::printCommands(){ | ||
ostringstream os; | ||
os << "\nexit \t exits servers 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(){ | ||
int fnum = F_GET_RUN_STATUS; | ||
int ret = FAIL; | ||
runStatus retval=ERROR; | ||
int progress = 0; | ||
char answer[100]; | ||
|
||
if (myStopSocket->Connect() >= 0) { | ||
myStopSocket->SendDataOnly(&fnum,sizeof(fnum)); | ||
myStopSocket->ReceiveDataOnly(&ret,sizeof(ret)); | ||
myStopSocket->ReceiveDataOnly(&retval,sizeof(retval)); | ||
myStopSocket->ReceiveDataOnly(&progress,sizeof(progress)); | ||
myStopSocket->Disconnect(); | ||
}else | ||
exit(-1); | ||
|
||
|
||
sprintf(answer,"%d%% ",progress); | ||
strcat(answer,slsDetectorBase::runStatusType((runStatus)retval).c_str()); | ||
|
||
return string(answer); | ||
} | ||
|
||
|
||
//------------------------------------------------------------------------------------------------------------------------------------------------- | ||
|
||
|
||
int qClient::startAcquisition(bool blocking){ | ||
int fnum = F_START_ACQUISITION; | ||
if(blocking) fnum = F_START_AND_READ_ALL; | ||
int ret = FAIL; | ||
|
||
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; | ||
} | ||
|
||
|
||
//------------------------------------------------------------------------------------------------------------------------------------------------- | ||
|
||
|
||
int qClient::stopAcquisition(){ | ||
int fnum = F_STOP_ACQUISITION; | ||
int ret = FAIL; | ||
|
||
if (myStopSocket->Connect() >= 0) { | ||
myStopSocket->SendDataOnly(&fnum,sizeof(fnum)); | ||
myStopSocket->ReceiveDataOnly(&ret,sizeof(ret)); | ||
if (ret == FAIL){ | ||
myStopSocket->ReceiveDataOnly(mess,sizeof(mess)); | ||
std::cout<< "Gui returned error: " << mess << std::endl; | ||
} | ||
myStopSocket->Disconnect(); | ||
}else | ||
exit(-1); | ||
|
||
return ret; | ||
} | ||
|
||
|
||
//------------------------------------------------------------------------------------------------------------------------------------------------- | ||
|
||
|
||
int qClient::exitServer(){ | ||
int fnum = F_EXIT_SERVER; | ||
int ret = FAIL; | ||
|
||
if (myStopSocket->Connect() >= 0) { | ||
myStopSocket->SendDataOnly(&fnum,sizeof(fnum)); | ||
myStopSocket->ReceiveDataOnly(&ret,sizeof(ret)); | ||
myStopSocket->ReceiveDataOnly(mess,sizeof(mess)); | ||
cout << mess << endl; | ||
myStopSocket->Disconnect(); | ||
}else | ||
exit(-1); | ||
|
||
return ret; | ||
} |
Oops, something went wrong.