/*************************************************************************** ToolPanel.cpp - description ------------------- begin : Wed May 12 2004 copyright : (C) 2004 by Jan Schumacher email : jschumac@physik.uni-bonn.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "ToolPanel.h" #include #include #include #include #ifdef WIN32 #include #else #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include "STRodCrate.h" #include "STControlEngine.h" ToolPanel::ToolPanel( STControlEngine &engine_in, QWidget* parent ): QWidget( parent ), m_engine( engine_in ){ setupUi(this); QObject::connect(sendCommandButton, SIGNAL(clicked()), this, SLOT(sendCommand())); QObject::connect(stopButton, SIGNAL(clicked()), this, SLOT(setBreak())); m_break = false; statusLabel->setText("idle"); setIdle(); } ToolPanel::~ToolPanel(){ } /** Send the chosen command(s) to the module. */ void ToolPanel::sendCommand(){ int repetitions = repetitionSpinBox->value(); if(repetitions>1) stopButton->setEnabled(true); setBusy(); for( int repc=0 ; repc < repetitions ; repc++ ) { m_engine.updateGUI(); if(m_break){ setIdle(); return; } statusLabel->setText("executing command"); iterDisplay->display(repc); repaint(); m_engine.updateGUI(); if( configurationChoiceRadioButton->isChecked() ) { // set wait cursor QApplication::setOverrideCursor(Qt::waitCursor); // tell engine to configure them all m_engine.configModules(); // restore normal cursor QApplication::restoreOverrideCursor(); } if( resetChoiceRadioButton->isChecked() ) { int type = resetOpt->currentIndex(); // set wait cursor QApplication::setOverrideCursor(Qt::waitCursor); // tell engine to configure them all m_engine.resetModules(type); // restore normal cursor QApplication::restoreOverrideCursor(); } if( reinitRODs->isChecked() ) { // set wait cursor QApplication::setOverrideCursor(Qt::waitCursor); // tell the engine to initialise RODs m_engine.initRods(); // restore normal cursor QApplication::restoreOverrideCursor(); } if( resetRODs->isChecked() ) { // set wait cursor QApplication::setOverrideCursor(Qt::waitCursor); // tell the engine to reset RODs m_engine.resetRods(); // restore normal cursor QApplication::restoreOverrideCursor(); } if( resetBOCs->isChecked() ) { // set wait cursor QApplication::setOverrideCursor(Qt::waitCursor); // tell the engine to initialise RODs m_engine.initBocs(); // restore normal cursor QApplication::restoreOverrideCursor(); } if( initDCS->isChecked() ) { // set wait cursor QApplication::setOverrideCursor(Qt::waitCursor); // tell the engine to initialise DCS objects m_engine.initDcs(); // restore normal cursor QApplication::restoreOverrideCursor(); } if( initAll->isChecked() ) { // set wait cursor QApplication::setOverrideCursor(Qt::waitCursor); // tell the engine to initialise all m_engine.initRods(); m_engine.initDcs(); // restore normal cursor QApplication::restoreOverrideCursor(); } if( triggerChoiceRadioButton->isChecked() ) { // set wait cursor QApplication::setOverrideCursor(Qt::waitCursor); // tell engine to trigger them all m_engine.triggerModules(); // restore normal cursor QApplication::restoreOverrideCursor(); } if(getSrvRec->isChecked() ) { QApplication::setOverrideCursor(Qt::waitCursor); // tell engine to trigger them all m_engine.getSrvRec(); // restore normal cursor QApplication::restoreOverrideCursor(); } if(readEPROM->isChecked() ) { QApplication::setOverrideCursor(Qt::waitCursor); // tell engine to trigger them all m_engine.readEPROM(); // restore normal cursor QApplication::restoreOverrideCursor(); } // wait for given time if this is not the last iteration if(delaySpinBox->value()>0 && repc<(repetitions-1)){ QApplication::setOverrideCursor(Qt::waitCursor); for(int k=0;kvalue();k++){ statusLabel->setText("waiting"); repaint(); m_engine.updateGUI(); if(m_break){ setIdle(); QApplication::restoreOverrideCursor(); return; } PixLib::sleep(1000); } QApplication::restoreOverrideCursor(); } } setIdle(); return; } void ToolPanel::setIdle(){ stopButton->setEnabled(false); sendCommandButton->setEnabled(true); triggerChoiceRadioButton->setEnabled(true); getSrvRec->setEnabled(true); readEPROM->setEnabled(true); configurationChoiceRadioButton->setEnabled(true); resetChoiceRadioButton->setEnabled(true); reinitRODs->setEnabled(true); resetRODs->setEnabled(m_engine.whichIFtype()!=tUSBSys); resetBOCs->setEnabled(m_engine.whichIFtype()!=tUSBSys); repetitionSpinBox->setEnabled(true); delaySpinBox->setEnabled(true); initDCS->setEnabled(true); initAll->setEnabled(true); m_break = false; statusLabel->setText("idle"); repaint(); m_engine.updateGUI(); } void ToolPanel::setBusy(){ sendCommandButton->setEnabled(false); triggerChoiceRadioButton->setEnabled(false); getSrvRec->setEnabled(false); readEPROM->setEnabled(false); configurationChoiceRadioButton->setEnabled(false); resetChoiceRadioButton->setEnabled(false); reinitRODs->setEnabled(false); resetRODs->setEnabled(false); resetBOCs->setEnabled(false); repetitionSpinBox->setEnabled(false); delaySpinBox->setEnabled(false); initDCS->setEnabled(false); initAll->setEnabled(false); m_break = false; repaint(); m_engine.updateGUI(); } void ToolPanel::setBreak(){ m_break = true; }