mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-21 17:18:00 +02:00
created messages tab-not working completely yet
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@15 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
@ -10,6 +10,7 @@
|
||||
#include "qTabSettings.h"
|
||||
#include "qTabDebugging.h"
|
||||
#include "qTabDeveloper.h"
|
||||
#include "qTabMessages.h"
|
||||
/** Project Class Headers */
|
||||
#include "slsDetector.h"
|
||||
#include "multiSlsDetector.h"
|
||||
@ -93,6 +94,7 @@ void qDetectorMain::SetUpWidgetWindow(){
|
||||
tab_advanced = new qTabAdvanced (this, myDet);
|
||||
tab_debugging = new qTabDebugging (this, myDet);
|
||||
tab_developer = new qTabDeveloper (this, myDet);
|
||||
tab_messages = new qTabMessages (this, myDet);
|
||||
/** creating the scroll area widgets for the tabs */
|
||||
for(int i=0;i<NumberOfTabs;i++){
|
||||
scroll[i] = new QScrollArea;
|
||||
@ -118,6 +120,8 @@ void qDetectorMain::SetUpWidgetWindow(){
|
||||
tabs->insertTab(Advanced, scroll[Advanced], "Advanced");
|
||||
tabs->insertTab(Debugging, scroll[Debugging], "Debugging");
|
||||
tabs->insertTab(Developer, scroll[Developer], "Developer");
|
||||
/** Prefer this to expand and not have scroll buttons*/
|
||||
tabs->insertTab(Messages, tab_messages, "Messages");
|
||||
|
||||
/** mode setup - to set up the tabs initially as disabled, not in form so done here */
|
||||
SetDebugMode(false);
|
||||
@ -404,6 +408,7 @@ void qDetectorMain::EnableTabs(){
|
||||
tabs->setTabEnabled(DataOutput,enable);
|
||||
tabs->setTabEnabled(Actions,enable);
|
||||
tabs->setTabEnabled(Settings,enable);
|
||||
tabs->setTabEnabled(Messages,enable);
|
||||
|
||||
/** special tabs */
|
||||
if(enable==false){
|
||||
|
@ -12,9 +12,8 @@
|
||||
/** Project Class Headers */
|
||||
#include "slsDetector.h"
|
||||
#include "multiSlsDetector.h"
|
||||
|
||||
/** Qt Include Headers */
|
||||
#include <QStandardItemModel>
|
||||
|
||||
/** C++ Include Headers */
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
@ -63,8 +62,15 @@ void qTabMeasurement::SetupWidgetWindow(){
|
||||
progressBar->setValue(0);
|
||||
|
||||
/** timing mode*/
|
||||
SetupTimingMode();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qTabMeasurement::SetupTimingMode(){
|
||||
/** Get timing mode from detector*/
|
||||
slsDetectorDefs::externalCommunicationMode mode = myDet->setExternalCommunicationMode();
|
||||
|
||||
/** To be able to index items on a combo box */
|
||||
QStandardItemModel* model = qobject_cast<QStandardItemModel*>(comboTimingMode->model());
|
||||
QModelIndex index[NumTimingModes];
|
||||
@ -112,15 +118,15 @@ void qTabMeasurement::SetupWidgetWindow(){
|
||||
* then the timing mode is 'None'.
|
||||
* This is for the inexperienced user */
|
||||
if(mode==slsDetectorDefs::AUTO_TIMING){
|
||||
int frames = (int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1);
|
||||
int triggers = (int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1);
|
||||
if((frames==1)&&(triggers==1)){
|
||||
comboTimingMode->setCurrentIndex((int)None);
|
||||
setTimingMode((int)None);
|
||||
}else{
|
||||
comboTimingMode->setCurrentIndex((int)Auto);
|
||||
setTimingMode((int)Auto);
|
||||
}
|
||||
int frames = (int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1);
|
||||
int triggers = (int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1);
|
||||
if((frames==1)&&(triggers==1)){
|
||||
comboTimingMode->setCurrentIndex((int)None);
|
||||
setTimingMode((int)None);
|
||||
}else{
|
||||
comboTimingMode->setCurrentIndex((int)Auto);
|
||||
setTimingMode((int)Auto);
|
||||
}
|
||||
}else{
|
||||
/** mode +1 since the detector class has no timingmode as "None" */
|
||||
comboTimingMode->setCurrentIndex((int)mode+1);
|
||||
@ -128,7 +134,7 @@ void qTabMeasurement::SetupWidgetWindow(){
|
||||
}
|
||||
}
|
||||
/** Mode NOT ENABLED.
|
||||
* This should not happen only if the server and gui has a mismatch
|
||||
* This should not happen -only if the server and gui has a mismatch
|
||||
* on which all modes are allowed in detectors */
|
||||
else{
|
||||
qDefs::ErrorMessage("ERROR: Unknown Timing Mode detected from detector."
|
||||
|
129
slsDetectorGui/src/qTabMessages.cpp
Normal file
129
slsDetectorGui/src/qTabMessages.cpp
Normal file
@ -0,0 +1,129 @@
|
||||
/*
|
||||
* qTabMessages.cpp
|
||||
*
|
||||
* Created on: Jun 26, 2012
|
||||
* Author: l_maliakal_d
|
||||
*/
|
||||
|
||||
#include "qTabMessages.h"
|
||||
/** Project Class Headers */
|
||||
#include "slsDetector.h"
|
||||
#include "multiSlsDetector.h"
|
||||
/** Qt Include Headers */
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QSpacerItem>
|
||||
#include <QDir>
|
||||
#include <QProcess>
|
||||
#include <QStringList>
|
||||
/** C++ Include Headers */
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
qTabMessages::qTabMessages(QWidget *parent,slsDetectorUtils*& detector):
|
||||
QWidget(parent),myDet(detector){
|
||||
SetupWidgetWindow();
|
||||
Initialization();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
qTabMessages::~qTabMessages(){
|
||||
delete myDet;
|
||||
delete dispLog;
|
||||
delete dispCommand;
|
||||
delete dispPath;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qTabMessages::SetupWidgetWindow(){
|
||||
/** Layout */
|
||||
QGridLayout *gridLayout = new QGridLayout(this);
|
||||
QLabel *lblCommand = new QLabel("System Command:",this);
|
||||
QLabel *lblPath = new QLabel("Working Directory:",this);
|
||||
QSpacerItem *hSpacer= new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Minimum);
|
||||
dispLog = new QTextEdit(this);
|
||||
dispCommand = new QLineEdit(this);
|
||||
dispPath = new QLineEdit(this);
|
||||
dispLog->setReadOnly(true);
|
||||
dispPath->setReadOnly(true);
|
||||
dispLog->setFocusPolicy(Qt::NoFocus);
|
||||
dispPath->setFocusPolicy(Qt::NoFocus);
|
||||
gridLayout->addWidget(dispLog, 0, 0, 1, 3);
|
||||
gridLayout->addWidget(lblCommand, 1, 0, 1, 1);
|
||||
gridLayout->addItem(hSpacer, 1, 1, 1, 1);
|
||||
gridLayout->addWidget(dispCommand, 1, 2, 1, 1);
|
||||
gridLayout->addWidget(lblPath, 2, 0, 1, 1);
|
||||
gridLayout->addWidget(dispPath, 2, 2, 1, 1);
|
||||
|
||||
/** Command & Path*/
|
||||
dispCommand->setText("Insert your command here");
|
||||
dispPath->setText(QDir("./").absolutePath());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qTabMessages::Initialization(){
|
||||
connect(dispCommand,SIGNAL(returnPressed()),this,SLOT(executeCommand()));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qTabMessages::executeCommand(){
|
||||
#ifdef VERBOSE
|
||||
cout<<"Calling: "<< dispCommand->text().toAscii().constData()<<endl;
|
||||
#endif
|
||||
QProcess proc(this);
|
||||
#ifdef VERBOSE
|
||||
//std::cout <<"working directory would be " << proc.workingDirectory().absPath() << std::endl;
|
||||
cout<<"Original Working Directory: "<< proc.workingDirectory().toAscii().constData()<<endl;
|
||||
#endif
|
||||
proc.setWorkingDirectory(QDir(dispPath->text()).absolutePath());
|
||||
#ifdef VERBOSE
|
||||
//std::cout <<"working directory is " << proc.workingDirectory().absPath() << std::endl;
|
||||
cout<<"Current Working Directory: "<<proc.workingDirectory().toAscii().constData()<<endl;
|
||||
#endif
|
||||
proc.setArguments(QStringList::split(' ',dispCommand->text()));
|
||||
#ifdef VERBOSE
|
||||
/* QStringList list = proc.arguments();
|
||||
QStringList::Iterator it = list.begin();
|
||||
while( it != list.end() ) {
|
||||
cout<<*it<<endl;
|
||||
++it;
|
||||
}*/
|
||||
#endif
|
||||
//if (!proc.start()) {
|
||||
if(!(proc.state()==QProcess::Running)){
|
||||
// error handling
|
||||
cout<<"Could not launch process"<<endl;
|
||||
} else {
|
||||
//while(proc.isRunning()) {
|
||||
while(proc.state()==QProcess::Running){
|
||||
;
|
||||
#ifdef VERBOSE
|
||||
cout<<"Process running "<< proc.exitStatus()<< endl;
|
||||
#endif
|
||||
}
|
||||
//if (proc.normalExit()) {
|
||||
if(proc.exitStatus()==QProcess::NormalExit){
|
||||
;
|
||||
#ifdef VERBOSE
|
||||
cout<<" process returned OK"<<endl;
|
||||
#endif
|
||||
} else
|
||||
cout<<" process returned error"<<endl;
|
||||
while (proc.canReadLineStdout()) {//readAllStandardOutput ()
|
||||
cout<<proc.readLineStdout() <<endl;
|
||||
}
|
||||
while (proc.canReadLineStderr()) {
|
||||
cout<<"Error: "<<proc.readLineStderr() <<endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
@ -14,41 +14,132 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
qTabSettings::qTabSettings(QWidget *parent,slsDetectorUtils*& detector,int detID):
|
||||
QWidget(parent),myDet(detector),detID(detID){
|
||||
|
||||
setupUi(this);
|
||||
SetupWidgetWindow();
|
||||
Initialization();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
qTabSettings::~qTabSettings(){
|
||||
delete myDet;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qTabSettings::SetupWidgetWindow(){
|
||||
/** Detector Type*/
|
||||
detType=myDet->getDetectorsType();
|
||||
|
||||
/** Settings */
|
||||
SetupDetectorSettings();
|
||||
comboSettings->setCurrentIndex(myDet->getSettings(detID));
|
||||
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qTabSettings::SetupDetectorSettings(){
|
||||
/** Get detector settings from detector*/
|
||||
slsDetectorDefs::detectorSettings sett = myDet->getSettings(detID);
|
||||
|
||||
/** To be able to index items on a combo box */
|
||||
model = qobject_cast<QStandardItemModel*>(comboSettings->model());
|
||||
if (model) {
|
||||
for(int i=0;i<NumSettings;i++){
|
||||
index[i] = model->index(i, comboSettings->modelColumn(), comboSettings->rootModelIndex());
|
||||
item[i] = model->itemFromIndex(index[i]);
|
||||
}
|
||||
/** Enabling/Disabling depending on the detector type
|
||||
Undefined and uninitialized are enabled for all detectors*/
|
||||
if(sett==slsDetectorDefs::UNDEFINED)
|
||||
item[(int)Uninitialized]->setEnabled(false);
|
||||
else if(sett==slsDetectorDefs::UNINITIALIZED)
|
||||
item[(int)Undefined]->setEnabled(false);
|
||||
else{
|
||||
item[(int)Uninitialized]->setEnabled(false);
|
||||
item[(int)Undefined]->setEnabled(false);
|
||||
}
|
||||
switch(detType){
|
||||
case slsDetectorDefs::MYTHEN:
|
||||
item[(int)Standard]->setEnabled(true);
|
||||
item[(int)Fast]->setEnabled(true);
|
||||
item[(int)HighGain]->setEnabled(true);
|
||||
item[(int)DynamicGain]->setEnabled(false);
|
||||
item[(int)LowGain]->setEnabled(false);
|
||||
item[(int)MediumGain]->setEnabled(false);
|
||||
item[(int)VeryHighGain]->setEnabled(false);
|
||||
break;
|
||||
case slsDetectorDefs::EIGER:
|
||||
item[(int)Standard]->setEnabled(false);
|
||||
item[(int)Fast]->setEnabled(false);
|
||||
item[(int)HighGain]->setEnabled(false);
|
||||
item[(int)DynamicGain]->setEnabled(false);
|
||||
item[(int)LowGain]->setEnabled(false);
|
||||
item[(int)MediumGain]->setEnabled(false);
|
||||
item[(int)VeryHighGain]->setEnabled(false);
|
||||
break;
|
||||
case slsDetectorDefs::GOTTHARD:
|
||||
item[(int)Standard]->setEnabled(false);
|
||||
item[(int)Fast]->setEnabled(false);
|
||||
item[(int)HighGain]->setEnabled(true);
|
||||
item[(int)DynamicGain]->setEnabled(true);
|
||||
item[(int)LowGain]->setEnabled(true);
|
||||
item[(int)MediumGain]->setEnabled(true);
|
||||
item[(int)VeryHighGain]->setEnabled(true);
|
||||
break;
|
||||
default:
|
||||
qDefs::ErrorMessage("ERROR: Unknown detector type.","Settings: ERROR");
|
||||
exit(-1);
|
||||
break;
|
||||
}
|
||||
/** detector settings selected NOT ENABLED.
|
||||
* This should not happen -only if the server and gui has a mismatch
|
||||
* on which all modes are allowed in detectors */
|
||||
if(!(item[(int)sett]->isEnabled())){
|
||||
qDefs::ErrorMessage("ERROR: Unknown Detector Settings retrieved from detector. "
|
||||
"Exiting GUI.","Settings: ERROR");
|
||||
#ifdef VERBOSE
|
||||
cout<<"ERROR: Unknown Detector Settings retrieved from detector."<<endl;
|
||||
#endif
|
||||
exit(-1);
|
||||
}
|
||||
/** Setting the detector settings */
|
||||
else {
|
||||
comboSettings->setCurrentIndex((int)sett);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qTabSettings::Initialization(){
|
||||
/** Settings */
|
||||
connect(comboSettings,SIGNAL(currentIndexChanged(int)),this,SLOT(setSettings(int)));
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qTabSettings::setSettings(int index){
|
||||
/** The first time settings is changed from undefined or uninitialized to a proper setting,
|
||||
* then undefined/uninitialized should be disabled */
|
||||
if(item[(int)Undefined]->isEnabled()){
|
||||
/**Do not disable it if this wasnt selected again by mistake*/
|
||||
if(index!=(int)Undefined)
|
||||
item[(int)Undefined]->setEnabled(false);
|
||||
}else if(item[(int)Uninitialized]->isEnabled()){
|
||||
/**Do not disable it if this wasnt selected again by mistake*/
|
||||
if(index!=(int)Uninitialized)
|
||||
item[(int)Uninitialized]->setEnabled(false);
|
||||
}
|
||||
slsDetectorDefs::detectorSettings sett = myDet->setSettings((slsDetectorDefs::detectorSettings)index,detID);
|
||||
#ifdef VERBOSE
|
||||
cout<<"Settings have been set to "<<myDet->slsDetectorBase::getDetectorSettings(sett)<<endl;
|
||||
@ -56,3 +147,4 @@ void qTabSettings::setSettings(int index){
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user