#include "RegisterPanel.h" #include "STControlEngine.h" #include "STRodCrate.h" #include "OptionsPanel.h" #include "LogClasses.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include RegisterItem::RegisterItem( QWidget* parent, const char* name, Qt::WFlags fl) : QWidget(parent,name,fl){ m_layout = new QHBoxLayout(); ; m_label = new QLabel( parent, QString(name)+QString("label") ); m_label->setText( name); m_layout->addWidget( m_label ); QSpacerItem* spacer = new QSpacerItem( 10, 2, QSizePolicy::Expanding, QSizePolicy::Expanding ); m_layout->addItem( spacer ); m_button = new QPushButton( parent, QString(name)+QString("button")); m_button->setEnabled( FALSE ); m_button->setText( trUtf8( "details" ) ); m_layout->addWidget( m_button ); // no text initially m_infoText = ""; // connect details button with the text report connect( m_button, SIGNAL( clicked() ), this, SLOT( detailsPressed() ) ); } RegisterItem::~RegisterItem(){ } void RegisterItem::detailsPressed(){ //QMessageBox::information(this,"Register test info",m_infoText); QDialog *infoW = new QDialog(this); infoW->setWindowTitle("Register test info"); infoW->setMinimumSize(300,300); QTextBrowser *txtB = new QTextBrowser(infoW); QVBoxLayout *generalLayout = new QVBoxLayout(infoW); generalLayout->addWidget(txtB); //QSpacerItem* spacer = new QSpacerItem( 2, 20, QSizePolicy::Expanding, QSizePolicy::Expanding ); //generalLayout->addItem( spacer ); QPushButton *pb = new QPushButton("OK", infoW); generalLayout->addWidget(pb); connect( pb, SIGNAL( clicked() ), infoW, SLOT( accept() ) ); // format and set text content QTextCharFormat txtF(txtB->currentCharFormat()); txtF.setFontFixedPitch(true); txtB->setCurrentCharFormat(txtF); txtB->insertPlainText(m_infoText); infoW->exec(); } void RegisterItem::setStatus(StatusTag status, QString infoText){ m_infoText = infoText; switch(status){ case tunknown: // no info default: if(m_button->styleSheet()!=QString::fromUtf8("background-color: rgb(150, 150, 150);")) m_button->setStyleSheet(QString::fromUtf8("background-color: rgb(150, 150, 150);")); m_button->setEnabled(false); break; case tOK: // all OK if(m_button->styleSheet()!=QString::fromUtf8("background-color: rgb(0, 255, 0);")) m_button->setStyleSheet(QString::fromUtf8("background-color: rgb(0, 255, 0);")); m_button->setEnabled(true); break; case tfailed: // error if(m_button->styleSheet()!=QString::fromUtf8("background-color: rgb(255, 0, 0);")) m_button->setStyleSheet(QString::fromUtf8("background-color: rgb(255, 0, 0);")); m_button->setEnabled(true); break; } } void RegisterItem::hide(){ m_button->hide(); m_label->hide(); } void RegisterItem::show(){ m_button->show(); m_label->show(); } RegisterPanel::RegisterPanel(STControlEngine &engine_in, QWidget* parent, const char* name, Qt::WFlags fl) : Q3MainWindow(parent,name,fl), m_engine(engine_in), m_unblocked(true){ setupUi(this); QObject::connect(actionPerform_all_tests, SIGNAL(activated()), this, SLOT(testAll())); QObject::connect(actionPerform_all_tests_current, SIGNAL(activated()), this, SLOT(testCurrent())); QObject::connect(clearAction, SIGNAL(activated()), this, SLOT(clearAll())); Config &cfg = m_engine.chipTestCfg(); for(int i=0; isetObjectName("action_"+QString(cfg.subConfig(i).name().c_str())); act->setText(QApplication::translate("RegisterPanelBase", QString(cfg.subConfig(i).name().c_str()), 0, QApplication::UnicodeUTF8)); m_allActions.push_back(act); popupMenu->addAction(act); switch(i){ case 0: QObject::connect(act, SIGNAL(activated()), this, SLOT(testList0())); break; case 1: QObject::connect(act, SIGNAL(activated()), this, SLOT(testList1())); break; case 2: QObject::connect(act, SIGNAL(activated()), this, SLOT(testList2())); break; default: break; } act = new QAction(this); act->setObjectName("action_current_"+QString(cfg.subConfig(i).name().c_str())); act->setText(QApplication::translate("RegisterPanelBase", QString(cfg.subConfig(i).name().c_str()), 0, QApplication::UnicodeUTF8)); m_currActions.push_back(act); popupMenu_8->addAction(act); switch(i){ case 0: QObject::connect(act, SIGNAL(activated()), this, SLOT(testListCurrent0())); break; case 1: QObject::connect(act, SIGNAL(activated()), this, SLOT(testListCurrent1())); break; case 2: QObject::connect(act, SIGNAL(activated()), this, SLOT(testListCurrent2())); break; default: break; } } // QVBoxLayout *leftLayout = new QVBoxLayout(); // QVBoxLayout *rightLayout = new QVBoxLayout(); // m_regMod = new RegisterItem(mainTabs->page(0),"Module",0); // leftLayout->addLayout( m_regMod->m_layout); // m_regFE.resize(1); // m_regFE[0] = new RegisterItem(mainTabs->page(0),"FE0",0); // rightLayout->addLayout( m_regFE[0]->m_layout); QVBoxLayout *generalLayout = new QVBoxLayout(mainTabs->page(0)); // add config. editor QLabel *edl = new QLabel("Configuration of Chip Tests:", mainTabs->page(0)); generalLayout->addWidget(edl); optionsPanel *op = new optionsPanel(cfg,this,"optPan",false, 0, true, true, false); generalLayout->addWidget(op); op->cancB->hide(); QSpacerItem* Spacer25 = new QSpacerItem( 5, 2, QSizePolicy::Expanding, QSizePolicy::Expanding ); generalLayout->addItem( Spacer25 ); // add result buttons QGroupBox *grpbx = new QGroupBox("Chip Test results:", mainTabs->page(0)); QVBoxLayout *boxLayout = new QVBoxLayout(grpbx); m_regMod = new RegisterItem(grpbx,"Module",0); m_regFE.resize(2); m_regFE[0] = new RegisterItem(grpbx,"FE0",0); m_regFE[1] = new RegisterItem(grpbx,"FE1",0); boxLayout->addLayout(m_regMod->m_layout);// leftLayout); boxLayout->addLayout(m_regFE[0]->m_layout);// rightLayout); boxLayout->addLayout(m_regFE[1]->m_layout);// rightLayout); generalLayout->addWidget(grpbx); QSpacerItem* Spacer24 = new QSpacerItem( 5, 2, QSizePolicy::Expanding, QSizePolicy::Expanding ); generalLayout->addItem( Spacer24 ); // update function for text panel connect( &m_engine, SIGNAL(sendRTStatus(const char*)), this, SLOT(setTextMessg(const char *)) ); connect( &m_engine, SIGNAL(configChanged()), this, SLOT(setActionsEnabled()) ); // en-/dis-able actions when scans are run connect( &m_engine, SIGNAL(finishedScanning()), this, SLOT(setActionsEnabled()) ); connect( &m_engine, SIGNAL(beganScanning()), this, SLOT(setActionsDisabled())); // no current module set m_crateID = -1; m_grpID = -1; m_modID = -1; // clear form clearInfo(); setActions(true); } RegisterPanel::~RegisterPanel(){ } void RegisterPanel::setTextMessg(const char *msg){ m_messageBox->setText(msg); } void RegisterPanel::clearAll(){ m_engine.clearModuleInfo(); clearInfo(); } void RegisterPanel::clearInfo(){ m_regMod->setStatus(tunknown); m_regFE[0]->setStatus(tunknown); m_regFE[1]->setStatus(tunknown); } void RegisterPanel::setModule(int crateID, int grpID, int modID, const char *name) { try{ if(crateID>=0){// || grpID<0){ m_crateID = crateID; m_grpID = grpID; m_modID = modID; } bool isen = actionPerform_all_tests->isEnabled(); STRodCrate *crate = 0; if(m_crateID>=0 && m_crateID<(int)m_engine.getSTRodCrates().size()) crate = m_engine.getSTRodCrates()[m_crateID]; QString myName=""; if(crate!=0 && m_grpID>=0 && m_modID>=0) myName = crate->getModName(m_grpID, m_modID).c_str(); if(myName!=""){ // update status info if(name==0) myName = ("current module: "+TLogFile::GetNameFromPath(myName.latin1())).c_str(); else myName = name; moduleLabel->setText(myName); actionPerform_all_tests_current->setEnabled( isen && m_crateID>=0 ); for(std::vector::iterator it=m_currActions.begin(); it!=m_currActions.end(); it++) (*it)->setEnabled( isen && m_crateID>=0 ); modStatus modS = crate->getPixModuleStatus(m_grpID, m_modID); m_regMod->setStatus(modS.modStat, "Module:\n"+QString(modS.modMsg.c_str())); m_regFE[0]->setStatus(modS.feStat[0], "FE 0\n"+ QString(modS.feMsg[0].c_str())); m_regFE[1]->setStatus(modS.feStat[1], "FE 1\n"+ QString(modS.feMsg[1].c_str())); }else if(m_unblocked){ moduleLabel->setText("no module selected"); clearInfo(); actionPerform_all_tests_current->setEnabled( false ); for(std::vector::iterator it=m_currActions.begin(); it!=m_currActions.end(); it++) (*it)->setEnabled( false ); } }catch(...){ QMessageBox::warning(this,"test panel","unexpected exception: "+QString::number(m_crateID)+" "+QString::number(m_grpID) +" "+QString::number(m_modID)); } return; } void RegisterPanel::testCurrent() { for(int i=0; i<(int)m_allActions.size(); i++) testList(i, true); } void RegisterPanel::testAll() { for(int i=0; i<(int)m_allActions.size(); i++) testList(i, false); } void RegisterPanel::setActions(bool isen) { actionPerform_all_tests_current->setEnabled( isen && m_crateID>=0 ); for(std::vector::iterator it=m_currActions.begin(); it!=m_currActions.end(); it++) (*it)->setEnabled( isen && m_crateID>=0 ); actionPerform_all_tests->setEnabled( isen ); for(std::vector::iterator it=m_allActions.begin(); it!=m_allActions.end(); it++) (*it)->setEnabled( isen ); clearAction->setEnabled( isen ); return; } void RegisterPanel::setLED(QLabel *label, int state) { if(label==0) return; if(label->isEnabled()){ switch(state){ case 0: label->setBackgroundColor(Qt::red); break; case 1: label->setBackgroundColor(Qt::green); break; case -1: default: label->setBackgroundColor(Qt::gray); } } else label->setBackgroundColor(Qt::gray); } void RegisterPanel::editCfg(){ Config &cfg = m_engine.chipTestCfg(); optionsPanel *op = new optionsPanel(cfg,this,"optPan",false, 0, true, false, false); op->exec(); } void RegisterPanel::testList(int type, bool current){ if((unsigned int)type >= m_allActions.size()){ m_messageBox->setText("unknown test type"); return; } setActions(false); m_messageBox->setText("started FE test "+m_allActions[type]->text()); int crateID = m_crateID; int grpID = m_grpID; int modID = m_modID; QString label = moduleLabel->text(); if(current) m_engine.runChipTest(m_allActions[type]->text().latin1(), crateID, grpID, modID); else m_engine.runChipTest(m_allActions[type]->text().latin1()); if(m_crateID>=0) setModule(crateID, grpID, modID, label.latin1()); setActions(true); }