#include #include #include #include #include #include #include #include "ModList.h" #include "MainPanel.h" #include "PixScanPanel.h" #include "RegisterPanel.h" #include "ModList.h" #include "ModGeoView.h" #include "ConfigEdit.h" #include "STControlEngine.h" #include "STRodCrate.h" #include "ToolPanel.h" #include "LogPanel.h" #include "STCLog.h" #include "STCLogContainer.h" #include "SetAll.h" #include "ConfigTableSTC.h" #include "RodEditor.h" #ifndef NOTDAQ #include "BocInfo.h" #include "RodInfo.h" #endif #include "OptionsPanel.h" #include "BocAnalysisPanel.h" #include "PrimlistPanel.h" #include "WaferTestPanel.h" #include "NewDcsDialog.h" #include "MultiboardCfg.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef WIN32 #include #endif using namespace PixLib; using namespace SctPixelRod; MainPanel::MainPanel( STControlEngine &engine_in, STCLogContainer &log_in, QWidget* parent, const char* name, Qt::WFlags fl) : Q3MainWindow( parent,name,fl ), m_engine( engine_in ), m_sTCLogContainer( log_in ) { setupUi(this); QObject::connect(currItemAdd, SIGNAL(activated()), this, SLOT(addItem())); QObject::connect(closePanelAction, SIGNAL(activated()), this, SLOT(checkClose())); QObject::connect(fileCloseAction, SIGNAL(activated()), this, SLOT(closeConfig())); QObject::connect(decremGDAC, SIGNAL(activated()), this, SLOT(decrGDAC())); QObject::connect(decremGDACBy, SIGNAL(activated()), this, SLOT(decrGDACBy())); QObject::connect(decremTDAC, SIGNAL(activated()), this, SLOT(decrTDAC())); QObject::connect(decremTDACBy, SIGNAL(activated()), this, SLOT(decrTDACBy())); QObject::connect(currGroupDelete, SIGNAL(activated()), this, SLOT(deleteGroup())); QObject::connect(currModuleCfgEdit, SIGNAL(activated()), this, SLOT(editCurrentModule())); QObject::connect(fileOpenAction, SIGNAL(activated()), this, SLOT(loadConfig())); QObject::connect(optionsReload_defaultAction, SIGNAL(activated()), this, SLOT(loadOptions())); QObject::connect(actionUSBPix_1_FEI4A_default_config, SIGNAL(activated()), this, SLOT(newConfigUSBFEI4A())); QObject::connect(actionUSBPix_2_FEI4A_default_config, SIGNAL(activated()), this, SLOT(newConfigUSB2FEI4A())); QObject::connect(actionUSBPix_1_FEI4B_default_config, SIGNAL(activated()), this, SLOT(newConfigUSBFEI4B())); QObject::connect(actionUSBPix_2_FEI4B_default_config, SIGNAL(activated()), this, SLOT(newConfigUSB2FEI4B())); QObject::connect(actionUSBPix_multi_board_config, SIGNAL(activated()), this, SLOT(newConfigUSBMB())); QObject::connect(fileReopenAction, SIGNAL(activated()), this, SLOT(reopenConfig())); QObject::connect(fileSaveAsAction, SIGNAL(activated()), this, SLOT(saveAs())); QObject::connect(fileSaveAction, SIGNAL(activated()), this, SLOT(saveConfig())); QObject::connect(optionsSave_as_defaultAction, SIGNAL(activated()), this, SLOT(saveOptions())); QObject::connect(editset_all_FDACs_from_scanAction, SIGNAL(activated()), this, SLOT(setFDACs())); QObject::connect(editset_all_TDACs_from_scanAction, SIGNAL(activated()), this, SLOT(setTDACs())); QObject::connect(actionSet_all_masks_from_scan, SIGNAL(activated()), this, SLOT(setMasks())); QObject::connect(editset_all_VCALs_to_charge_ofAction, SIGNAL(activated()), this, SLOT(setVcal())); QObject::connect(showAboutMen, SIGNAL(activated()), this, SLOT(showAbout())); QObject::connect(showBocAnalysisChoice, SIGNAL(activated()), this, SLOT(showBocAnalysis())); QObject::connect(showDataChoice, SIGNAL(activated()), this, SLOT(showData())); QObject::connect(currShowInfo, SIGNAL(activated()), this, SLOT(showInfo())); QObject::connect(showLogPanelChoice, SIGNAL(activated()), this, SLOT(showLogs())); QObject::connect(showModListChoice, SIGNAL(activated()), this, SLOT(showModList())); QObject::connect(actionDCS_view, SIGNAL(activated()), this, SLOT(showDcsView())); QObject::connect(showGeographicalChoice, SIGNAL(activated()), this, SLOT(showModView())); QObject::connect(optionsShow_PanelAction, SIGNAL(activated()), this, SLOT(showOptions())); QObject::connect(showPixScanChoice, SIGNAL(activated()), this, SLOT(showPixScan())); QObject::connect(showPrimlistPanelChoice, SIGNAL(activated()), this, SLOT(showPrimList())); QObject::connect(showWafertestPanelChoice, SIGNAL(activated()), this, SLOT(showWaferTest())); QObject::connect(showReadmeMen, SIGNAL(activated()), this, SLOT(showReadme())); QObject::connect(showRegisterChoice, SIGNAL(activated()), this, SLOT(showRegister())); QObject::connect(showToolChoice, SIGNAL(activated()), this, SLOT(showTools())); QObject::connect(decrMccDelAction, SIGNAL(activated()), this, SLOT(incrMccDelay())); QObject::connect(single_FE_Action, SIGNAL(activated()), this, SLOT(setSingleFe())); m_scanActive = false; // split main window into two sliding halves m_split = new QSplitter( this ); vboxLayout->add(m_split); //totalLayout->add(m_split); // add set-up viewing panels to the left half if(m_engine.getRDSame()){ m_cmnwid = new QWidget(m_split); QVBoxLayout *vboxLayout2 = new QVBoxLayout(m_cmnwid); m_modList = new ModList( m_engine, m_cmnwid, "modlist", 0 , ModList::DAQList); vboxLayout2->addWidget(m_modList); m_dcsList = new ModList( m_engine, m_cmnwid, "dcslist", 0 , ModList::DCSList); vboxLayout2->addWidget(m_dcsList); m_modView = new ModGeoView( m_engine, m_split,"modview",0, m_modList); } else{ m_cmnwid = 0; m_modList = new ModList( m_engine, m_split, "modlist", 0 , ModList::DAQList); m_dcsList = new ModList( m_engine, m_split, "dcslist", 0 , ModList::DCSList); m_modView = new ModGeoView( m_engine, m_split,"modview",0, m_modList); } connect( m_modList->ModListView, SIGNAL( clicked(Q3ListViewItem*) ), this, SLOT( setCurrentModule(Q3ListViewItem*) ) ); connect( m_dcsList->ModListView, SIGNAL( clicked(Q3ListViewItem*) ), this, SLOT( setCurrentModule(Q3ListViewItem*) ) ); // connect( m_modView, SIGNAL( currentChangedTransl(Q3ListViewItem*) ), this, SLOT( setCurrentModule(Q3ListViewItem*) ) ); connect( m_modList, SIGNAL( listUpdated(Q3ListViewItem*) ), this, SLOT( setCurrentModule(Q3ListViewItem*) ) ); // connect( m_modList, SIGNAL( listUpdated(Q3ListViewItem*) ), m_modView, SLOT( updateList() ) ); // connect( m_modList, SIGNAL( statusChanged() ), m_modView, SLOT( changeStatus() ) ); // other panels to the right half m_pixScanPanel = new PixScanPanel( m_engine, m_split, "scanpanel", 0); m_regPanel = new RegisterPanel(m_engine, m_split,"regpanel",0); m_dataPanel = new DataView(false, m_split, "datapanel", 0, &(m_engine.getApp())); m_dataPanel->topLabel->setText("Data Viewer Panel"); m_toolPanel = new ToolPanel( m_engine, m_split ); m_logPanel = new LogPanel( m_split, "LogPanel" ); m_bocPanel = new BocAnalysisPanel(m_engine,m_split, "bocpanel", 0); m_prlPanel = new PrimlistPanel( m_engine, m_split ); m_prbPanel = new WaferTestPanel( m_engine, m_split ); showModList(); setCurrentModule(0); //showPixScan(); showTools(); m_modList->updateView(); m_dcsList->updateView(); // m_modView->updateList(); // item last clicked on module view m_currentListItem = 0; // manipulated layout of PixScanPanel in constructor, have to fit to new size adjustSize(); // temporary: store MA PDB user and password settings in engine if(m_engine.m_userPDB=="" || m_engine.m_passwdPDB==""){ m_engine.m_userPDB = m_dataPanel->getMA()->options->m_Opts->m_userPDB; m_engine.m_passwdPDB = m_dataPanel->getMA()->options->m_Opts->m_passwdPDB; } else if(m_dataPanel->getMA()->options->m_Opts->m_userPDB=="" || m_dataPanel->getMA()->options->m_Opts->m_passwdPDB==""){ m_dataPanel->getMA()->options->m_Opts->m_userPDB = m_engine.m_userPDB; m_dataPanel->getMA()->options->m_Opts->m_passwdPDB = m_engine.m_passwdPDB; } // QApplication::setOverrideCursor(Qt::waitCursor); // m_modView->loadGeo(); // QApplication::restoreOverrideCursor(); Config &opts = m_engine.getOptions(); std::string logPath = ((ConfString&)opts["paths"]["defLogPath"]).value(); if(logPath!="") m_logPanel->browseLogFolder(logPath.c_str()); // first-time set-up of config type in engine should change this panel's menu(es) and items in tool panel connect( &(m_engine), SIGNAL(configChanged()), this, SLOT(setShowMenues())); connect( &(m_engine), SIGNAL(cfgLabelChanged()),this, SLOT(setMyTitle())); connect( &(m_engine), SIGNAL(configChanged()), dynamic_cast(m_toolPanel), SLOT( setIdle())); // initialize logging connect( &(m_sTCLogContainer.log()) , SIGNAL( added( const QString& ) ), m_logPanel, SLOT( logToSTC( const QString& ) ) ); connect( &(m_sTCLogContainer.buffers()) , SIGNAL( added( const QString& ) ), m_logPanel, SLOT( logToROD( const QString& ) ) ); connect( &(m_sTCLogContainer.errLog()) , SIGNAL( added( const QString& ) ), m_logPanel, SLOT( errorToSTC( const QString& ) ) ); connect( &(m_sTCLogContainer.errBuffers()), SIGNAL( added( const QString& ) ), m_logPanel, SLOT( errorToROD( const QString& ) ) ); connect( m_logPanel, SIGNAL(wantRodBuffers()), &m_engine, SLOT(readRodBuff())); connect( m_bocPanel, SIGNAL( errorMessage(std::string) ),&(m_engine), SLOT ( toErrLog(std::string) )); // scan related signals connect( &(m_engine), SIGNAL(beganScanning()), dynamic_cast(m_dcsList), SLOT( setBusy())); connect( &(m_engine), SIGNAL(finishedScanning()), dynamic_cast(m_dcsList), SLOT( setIdle())); connect( &(m_engine), SIGNAL(beganScanning()), dynamic_cast(m_toolPanel), SLOT( setBusy())); connect( &(m_engine), SIGNAL(finishedScanning()), dynamic_cast(m_toolPanel), SLOT( setIdle())); connect( &(m_engine), SIGNAL(beganScanning()), this, SLOT(setScanBusy())); connect( &(m_engine), SIGNAL(finishedScanning()), this, SLOT(setScanDone())); connect( &(m_engine), SIGNAL(breakloop()), dynamic_cast(m_toolPanel), SLOT( setBreak())); connect( m_bocPanel, SIGNAL( bocConfigChanged() ), m_modList, SLOT( updateBocEditors() ) ); connect( m_bocPanel, SIGNAL( bocScanRunning() ), m_pixScanPanel, SLOT( scanRunning() ) ); connect( m_pixScanPanel, SIGNAL( enableBocAnaScan(bool) ), m_bocPanel, SLOT (enableAnaScan(bool) ) ); connect( &(m_engine), SIGNAL( prlScanStarted(int) ), m_pixScanPanel, SLOT( scanRunning(int) ) ); connect( &(m_engine), SIGNAL( gotPixScanData(const char *) ), m_dataPanel, SLOT( browseFile(const char *) ) ); connect( &(m_engine), SIGNAL( currentModule(int, int, int)), m_regPanel, SLOT( setModule(int, int, int) ) ); connect( &(m_engine), SIGNAL( blockCurrMod(bool)), m_regPanel, SLOT( setCurrModBlock(bool))); connect( m_bocPanel, SIGNAL( sendPixScanStatus(int, int, int, int, int, int, int, int, int) ), m_pixScanPanel, SLOT(updateStatus(int, int, int, int, int, int, int, int, int))); // connect PixScanPanel file name to Data Viewer file m_dataPanel->browseFile(m_pixScanPanel->scanFileName->text().latin1()); connect( m_pixScanPanel, SIGNAL( scanFileChanged(const char*) ), m_dataPanel, SLOT( browseFile(const char *) ) ); //connect( m_prlPanel, SIGNAL( scanFileChanged(const char*) ), m_pixScanPanel, SLOT( browseButton_clicked(const char *) ) ); connect(&(m_engine), SIGNAL( scanFileChanged(const char *) ), m_pixScanPanel, SLOT( browseButton_clicked(const char *) ) ); // connect engine to BOC analysis features of resp. panel connect(&(m_engine), SIGNAL( analyseBoc(const char *, const char *) ), this, SLOT (AnalyseBocData(const char* , const char*)) ); // allow engine to open pop-up windows even though it's not a widget connect(&(m_engine), SIGNAL( popupWin(const char*) ), this, SLOT (showPopupWin(const char*)) ); setMyTitle(); } MainPanel::~MainPanel(){ } void MainPanel::showModList(){ if(m_engine.getRDSame()){ m_cmnwid->show(); } else{ m_modList->show(); m_dcsList->hide(); } m_modView->hide(); showModListChoice->setEnabled(false); actionDCS_view->setEnabled(!m_engine.getRDSame()); showGeographicalChoice->setEnabled(false);// true); setCurrentModule(m_modList->ModListView->firstChild()); } void MainPanel::showModView(){ if(m_engine.getRDSame()){ m_cmnwid->hide(); } else{ m_modList->hide(); m_dcsList->hide(); } m_modView->show(); showModListChoice->setEnabled(true); actionDCS_view->setEnabled(!m_engine.getRDSame()); showGeographicalChoice->setEnabled(false); showDcsChoice->setEnabled(true); } void MainPanel::showDcsView(){ if(m_engine.getRDSame()){ m_cmnwid->show(); } else{ m_modList->hide(); m_dcsList->show(); } m_modView->hide(); showModListChoice->setEnabled(true); actionDCS_view->setEnabled(false); showGeographicalChoice->setEnabled(false);// true); setCurrentModule(m_dcsList->ModListView->firstChild()); } void MainPanel::showPixScan(){ m_pixScanPanel->show(); m_regPanel->hide(); m_dataPanel->hide(); m_toolPanel->hide(); m_logPanel->hide(); m_bocPanel->hide(); m_prlPanel->hide(); m_prbPanel->hide(); showDataChoice->setEnabled(true); showPixScanChoice->setEnabled(false); showRegisterChoice->setEnabled(true); showToolChoice->setEnabled(true); showLogPanelChoice->setEnabled(true); showBocAnalysisChoice->setEnabled(m_engine.whichIFtype()!=tUSBSys); showPrimlistPanelChoice->setEnabled(true); showWafertestPanelChoice->setEnabled(true); } void MainPanel::showData(){ m_pixScanPanel->hide(); m_regPanel->hide(); m_dataPanel->show(); m_toolPanel->hide(); m_logPanel->hide(); m_bocPanel->hide(); m_prlPanel->hide(); m_prbPanel->hide(); showDataChoice->setEnabled(false); showPixScanChoice->setEnabled(true); showRegisterChoice->setEnabled(true); showToolChoice->setEnabled(true); showLogPanelChoice->setEnabled(true); showBocAnalysisChoice->setEnabled(m_engine.whichIFtype()!=tUSBSys); showPrimlistPanelChoice->setEnabled(true); showWafertestPanelChoice->setEnabled(true); // QValueList list = m_split->sizes(); // QValueList::Iterator it = list.begin(); // while( it != list.end() ) { // std::cout<< *it <hide(); m_regPanel->show(); m_dataPanel->hide(); m_toolPanel->hide(); m_logPanel->hide(); m_bocPanel->hide(); m_prlPanel->hide(); m_prbPanel->hide(); showDataChoice->setEnabled(true); showPixScanChoice->setEnabled(true); showRegisterChoice->setEnabled(false); showToolChoice->setEnabled(true); showLogPanelChoice->setEnabled(true); showBocAnalysisChoice->setEnabled(m_engine.whichIFtype()!=tUSBSys); showPrimlistPanelChoice->setEnabled(true); showWafertestPanelChoice->setEnabled(true); } void MainPanel::showTools(){ m_pixScanPanel->hide(); m_regPanel->hide(); m_dataPanel->hide(); m_toolPanel->show(); m_logPanel->hide(); m_bocPanel->hide(); m_prlPanel->hide(); m_prbPanel->hide(); showDataChoice->setEnabled(true); showPixScanChoice->setEnabled(true); showRegisterChoice->setEnabled(true); showToolChoice->setEnabled(false); showLogPanelChoice->setEnabled(true); showBocAnalysisChoice->setEnabled(m_engine.whichIFtype()!=tUSBSys); showPrimlistPanelChoice->setEnabled(true); showWafertestPanelChoice->setEnabled(true); } void MainPanel::showLogs(){ m_pixScanPanel->hide(); m_regPanel->hide(); m_dataPanel->hide(); m_toolPanel->hide(); m_bocPanel->hide(); m_logPanel->show(); m_prlPanel->hide(); m_prbPanel->hide(); showDataChoice->setEnabled(true); showPixScanChoice->setEnabled(true); showRegisterChoice->setEnabled(true); showToolChoice->setEnabled(true); showLogPanelChoice->setEnabled(false); showBocAnalysisChoice->setEnabled(m_engine.whichIFtype()!=tUSBSys); showPrimlistPanelChoice->setEnabled(true); showWafertestPanelChoice->setEnabled(true); } void MainPanel::showBocAnalysis(){ m_pixScanPanel->hide(); m_regPanel->hide(); m_dataPanel->hide(); m_toolPanel->hide(); m_logPanel->hide(); m_bocPanel->show(); m_prlPanel->hide(); m_prbPanel->hide(); showPixScanChoice->setEnabled(true); showDataChoice->setEnabled(true); showPixScanChoice->setEnabled(true); showRegisterChoice->setEnabled(true); showToolChoice->setEnabled(true); showLogPanelChoice->setEnabled(true); showBocAnalysisChoice->setEnabled(false); showPrimlistPanelChoice->setEnabled(true); showWafertestPanelChoice->setEnabled(true); } void MainPanel::showPrimList() { m_pixScanPanel->hide(); m_regPanel->hide(); m_dataPanel->hide(); m_toolPanel->hide(); m_logPanel->hide(); m_bocPanel->hide(); m_prlPanel->show(); m_prbPanel->hide(); showPixScanChoice->setEnabled(true); showDataChoice->setEnabled(true); showPixScanChoice->setEnabled(true); showRegisterChoice->setEnabled(true); showToolChoice->setEnabled(true); showLogPanelChoice->setEnabled(true); showBocAnalysisChoice->setEnabled(m_engine.whichIFtype()!=tUSBSys); showPrimlistPanelChoice->setEnabled(false); showWafertestPanelChoice->setEnabled(true); } void MainPanel::showWaferTest(){ m_pixScanPanel->hide(); m_regPanel->hide(); m_dataPanel->hide(); m_toolPanel->hide(); m_logPanel->hide(); m_bocPanel->hide(); m_prlPanel->hide(); m_prbPanel->show(); showPixScanChoice->setEnabled(true); showDataChoice->setEnabled(true); showPixScanChoice->setEnabled(true); showRegisterChoice->setEnabled(true); showToolChoice->setEnabled(true); showLogPanelChoice->setEnabled(true); showBocAnalysisChoice->setEnabled(m_engine.whichIFtype()!=tUSBSys); showPrimlistPanelChoice->setEnabled(true); showWafertestPanelChoice->setEnabled(false); } void MainPanel::editCurrentModule(){ ModListItem *item = 0; ModList *list=0; if(!showModListChoice->isEnabled()) list = m_modList; else list = m_dcsList; item=list->currentModule(); if(item==0) item=list->currentUSB(); if(item==0) item=list->currentROD(); if(item==0) item=list->currentBOC(); if(item==0) item=list->currentGroup(); if(showModListChoice->isEnabled()) item = dynamic_cast(list->ModListView->currentItem()); list->editModule(item,false); } void MainPanel::addItem(){ // check if a DB item is around if(std::string(m_engine.getPixConfDBFname())==""){ QMessageBox::information(this,"STcontrol: MainPanel::addItem()", "Can't find DB object in memory.\n" "Please load or create a DB file first."); return; } // then do the editing ModListItem *mlitem = m_currentListItem; // if(m_currentListItem!=0) // printf("addiing to item %s\n",m_currentListItem->text(0).latin1()); if(m_engine.cfgEdited()){ QMessageBox overwrite("Overwrite changes?", "Adding objects requires re-loading of the RootDB object - \n" "current modifications to the configuration will be lost!\n" "Do you want to continue?", QMessageBox::Warning,QMessageBox::Yes, QMessageBox::No, QMessageBox::NoButton, this, "overwrite_chg",TRUE,Qt::WType_TopLevel); if(overwrite.exec()==QMessageBox::No) return; } QString cfgPath = m_engine.getPixConfDBFname(); int pos=cfgPath.findRev("/"); if(pos>=0) cfgPath = cfgPath.left(pos+1); if(mlitem==0){ // assume user wants to add a crate QMessageBox::warning(this, "MainPanel::addItem()", "Adding crates not yet implemented."); } else if(mlitem->getType()==ModListItem::tcrate){ // we're on crate level QApplication::restoreOverrideCursor(); STRodCrate *crt = mlitem->getCrate(); if(m_currentListItem->text(1)=="DCS"){ // DCS panel -> add DCS item std::vector grpNames; for( std::vector::iterator crate = m_engine.getSTRodCrates().begin(); crate != m_engine.getSTRodCrates().end(); crate++ ) { for(int iGrp=0; iGrp<(*crate)->nGroups(); iGrp++){ grpNames.push_back((*crate)->getGrpName(iGrp)); } } NewDcsDialog ndd(grpNames, this); if(ndd.exec()){ m_engine.addDcsToCurrDB(ndd.objectLabel->text().latin1(), ndd.objectGenType->currentIndex(), ndd.objectDevType->currentIndex(), ndd.nChannels->value(), ndd.objectAssCtrlName->currentText().latin1(), mlitem->getCrate()->getName().c_str()); } } else { // DAQ panel -> add PixModuleGroup if(m_engine.whichIFtype()!=tUSBSys){ std::vector myGrpData; if(addGroupTable(myGrpData, crt, cfgPath.latin1())==0 && myGrpData.size()!=0){ m_engine.addGroupToCurrDB(myGrpData[0], mlitem->getCrate()->getName().c_str()); myGrpData.clear(); return; } } else { QString tdfname=""; std::string defPath = "."; if(!m_engine.plPath().isEmpty()){ Config &opts = m_engine.getOptions(); defPath = ((ConfString&)opts["paths"]["defCfgPath"]).value(); } QString qpath = QString::null; if(defPath!=".") qpath = defPath.c_str(); QStringList Tfilter; Tfilter += "TurboDAQ config file (*.cfg)"; Tfilter += "Any file (*.*)"; QFileDialog Tfdia(this,"Specify name of TurboDAQ cfg-file (cancel to generate default cfg.)", qpath); Tfdia.setNameFilters(Tfilter); Tfdia.setFileMode(QFileDialog::ExistingFile); if(Tfdia.exec() == QDialog::Accepted){ tdfname = Tfdia.selectedFile(); tdfname.replace("\\", "/"); } std::vector myGrpData; if(addConfigSC(myGrpData, (tdfname==""?0:tdfname.latin1())) && myGrpData.size()!=0){ myGrpData[0].myROD.slot = mlitem->getCrate()->nGroups(); myGrpData[0].myROD.IPfile = ""; myGrpData[0].myROD.IDfile = ""; m_engine.addGroupToCurrDB(myGrpData[0], mlitem->getCrate()->getName().c_str(), tUSBSys); myGrpData.clear(); return; } } } } else if(mlitem->getType()==ModListItem::tmodule || mlitem->getType()==ModListItem::tgroup){ if(m_engine.whichIFtype()!=tUSBSys){ // group or module level -> allow adding of modules to resp. group ModListItem *grpitem = mlitem->parentGroup(); // STPixModuleGroup *pmGroup = grpitem->getGroup(); // STRodCrate *crate = mlitem->getCrate(); std::vector myModData; if(grpitem!=0 && addModulesTable(grpitem, myModData, cfgPath.latin1())==0){ if(myModData.size()!=0){ m_engine.addModulesToCurrDB(mlitem->crateId(), mlitem->grpId(), myModData); return; } } } else QMessageBox::warning(this,"STcontrol: MainPanel::addItem()", "Function currently not implemented"); } else QMessageBox::warning(this, "MainPanel::addItem()", "Action on unknown item type requested."); return; } void MainPanel::setCurrentModule(Q3ListViewItem *in_item){ // Make sure in_item is not 0. ModListItem *item = 0; if(in_item!=0) item = dynamic_cast(in_item); m_currentListItem = item; if(m_scanActive) return; // must not enable edit menu items when scan is running QString label = "current module: "; if(item!=0 && item->getType()==ModListItem::tmodule){ // set register panel label label += item->text(0); m_regPanel->setModule(item->crateId(), item->grpId(),item->modId(),label.latin1()); // add item label label = "Add module to group "; label += item->parent()->text(0); currItemAdd->setText(label); label = "&Add module to group "; label += item->parent()->text(0); currItemAdd->setMenuText(label); currItemAdd->setEnabled( true ); // edit cfg label label = "Edit cfg (module "; label += item->text(0); label += ")"; currModuleCfgEdit->setText(label); label = "Edit &cfg (module "; label += item->text(0); label += ")"; currModuleCfgEdit->setMenuText(label); currModuleCfgEdit->setEnabled( TRUE ); // delete group label label = "Delete group "; label += item->parent()->text(0); currGroupDelete->setText(label); label = "&Delete group "; label += item->parent()->text(0); currGroupDelete->setMenuText(label); currGroupDelete->setEnabled( true ); // HW info label = "Show Info for XXX"; currShowInfo->setText(label); currShowInfo->setMenuText(label); currShowInfo->setEnabled(false); // FE select label = "select single &FE cfg (mod "; label += item->text(0); label += ")"; single_FE_Action->setText(label); single_FE_Action->setMenuText(label); single_FE_Action->setEnabled(true); }else if(item!=0 && item->getType()==ModListItem::tgroup){ // un-set register panel label m_regPanel->setModule(-1,-1,-1); // add item label label = "Add module to group "; label += item->text(0); currItemAdd->setText(label); label = "&Add module to group "; label += item->text(0); currItemAdd->setMenuText(label); currItemAdd->setEnabled( true ); // edit cfg label currModuleCfgEdit->setEnabled(true); label = "Edit cfg (group "; label += item->text(0); label += ")"; currModuleCfgEdit->setText( label ); label = "Edit &cfg (group "; label += item->text(0); label += ")"; currModuleCfgEdit->setMenuText( label ); // delete group label label = "Delete group "; label += item->text(0); currGroupDelete->setText(label); label = "&Delete group "; label += item->text(0); currGroupDelete->setMenuText(label); currGroupDelete->setEnabled( true ); // HW info label = "Show Info for XXX"; currShowInfo->setText(label); currShowInfo->setMenuText(label); currShowInfo->setEnabled(false); // FE select label = "select single &FE cfg (grp "; label += item->text(0); label += ")"; single_FE_Action->setText(label); single_FE_Action->setMenuText(label); single_FE_Action->setEnabled(true); }else if(item!=0 && item->getType()==ModListItem::tUSB){ // un-set register panel label m_regPanel->setModule(-1,-1,-1); // add item label label = "Add"; currItemAdd->setText(label); label = "&Add"; currItemAdd->setMenuText(label); currItemAdd->setEnabled(false); // edit cfg label currModuleCfgEdit->setEnabled( true ); label = "Edit USB-cfg (group "; label += item->parentGroup()->text(0); label += ")"; currModuleCfgEdit->setText( label ); label = "Edit USB-&cfg (group "; label += item->parentGroup()->text(0); label += ")"; currModuleCfgEdit->setMenuText( label ); // delete group label label = "Delete"; currGroupDelete->setText(label); label = "&Delete"; label += item->text(0); currGroupDelete->setMenuText(label); currGroupDelete->setEnabled(false); // NEW: show HW interface instead of delete function label = "Show USB HW Info (group "; label += item->parentGroup()->text(0); label += ")"; currShowInfo->setText(label); label = "&Show USB HW Info (group "; label += item->parentGroup()->text(0); label += ")"; currShowInfo->setMenuText(label); currShowInfo->setEnabled(true); // FE select label = "select single &FE cfg (grp "; label += item->parentGroup()->text(0); label += ")"; single_FE_Action->setText(label); single_FE_Action->setMenuText(label); single_FE_Action->setEnabled(true); }else if(item!=0 && item->getType()==ModListItem::tROD){ // un-set register panel label m_regPanel->setModule(-1,-1,-1); // add item label label = "Add"; currItemAdd->setText(label); label = "&Add"; currItemAdd->setMenuText(label); currItemAdd->setEnabled(false); // edit cfg label currModuleCfgEdit->setEnabled( true ); label = "Edit ROD-cfg (group "; label += item->parentGroup()->text(0); label += ")"; currModuleCfgEdit->setText( label ); label = "Edit ROD-&cfg (group "; label += item->parentGroup()->text(0); label += ")"; currModuleCfgEdit->setMenuText( label ); // delete group label label = "Delete"; currGroupDelete->setText(label); label = "&Delete"; label += item->text(0); currGroupDelete->setMenuText(label); currGroupDelete->setEnabled(false); // NEW: show HW interface instead of delete function label = "Show ROD HW Info (group "; label += item->parentGroup()->text(0); label += ")"; currShowInfo->setText(label); label = "&Show ROD HW Info (group "; label += item->parentGroup()->text(0); label += ")"; currShowInfo->setMenuText(label); currShowInfo->setEnabled(true); // FE select label = "select single &FE cfg (grp "; label += item->parentGroup()->text(0); label += ")"; single_FE_Action->setText(label); single_FE_Action->setMenuText(label); single_FE_Action->setEnabled(true); }else if(item!=0 && item->getType()==ModListItem::tBOC){ // un-set register panel label m_regPanel->setModule(-1,-1,-1); // add item label label = "Add"; currItemAdd->setText(label); label = "&Add"; currItemAdd->setMenuText(label); currItemAdd->setEnabled(false); // edit cfg label currModuleCfgEdit->setEnabled( true ); label = "Edit BOC-cfg (group "; label += item->parentGroup()->text(0); label += ")"; currModuleCfgEdit->setText( label ); label = "&Edit BOC-cfg (group "; label += item->parentGroup()->text(0); label += ")"; currModuleCfgEdit->setMenuText( label ); // delete group label label = "Delete"; currGroupDelete->setText(label); label = "&Delete"; label += item->text(0); currGroupDelete->setMenuText(label); currGroupDelete->setEnabled(false); // NEW: show HW interface instead of delete function label = "Show BOC HW Info (group "; label += item->parentGroup()->text(0); label += ")"; currShowInfo->setText(label); label = "&Show BOC HW Info (group "; label += item->parentGroup()->text(0); label += ")"; currShowInfo->setMenuText(label); currShowInfo->setEnabled(true); // FE select label = "select single &FE cfg (grp "; label += item->parentGroup()->text(0); label += ")"; single_FE_Action->setText(label); single_FE_Action->setMenuText(label); single_FE_Action->setEnabled(true); }else if(item!=0 && item->getType()==ModListItem::tDCS){ // item is DCS device // un-set register panel label m_regPanel->setModule(-1,-1,-1); // add item label label = "Add DCS item to "; label += item->parentCrate()->text(0); currItemAdd->setText(label); label = "&Add DCS-item to "; label += item->parentCrate()->text(0); currItemAdd->setMenuText(label); currItemAdd->setEnabled( false ); currModuleCfgEdit->setEnabled( true ); label = "Edit DCS-cfg ("; label += item->text(0); label += ")"; currModuleCfgEdit->setText(label); label = "&Edit DCS-cfg ("; label += item->text(0); label += ")"; currModuleCfgEdit->setMenuText(label); currGroupDelete->setEnabled( false ); currGroupDelete->setText("Delete"); currGroupDelete->setMenuText("&Delete"); // HW info label = "Update DCS-readings"; currShowInfo->setText(label); currShowInfo->setMenuText(label); currShowInfo->setEnabled(true); // FE select label = "select single &FE cfg"; single_FE_Action->setText(label); single_FE_Action->setMenuText(label); single_FE_Action->setEnabled(false); }else if(item!=0 && item->getType()==ModListItem::tDCSC){ // item is DCS channel // un-set register panel label m_regPanel->setModule(-1,-1,-1); // add item label label = "Add DCS item to "; label += item->parentCrate()->text(0); currItemAdd->setText(label); label = "&Add DCS-item to "; label += item->parentCrate()->text(0); currItemAdd->setMenuText(label); currItemAdd->setEnabled( false ); currModuleCfgEdit->setEnabled( true ); label = "Edit channel-cfg ("; label += item->text(0); label += ")"; currModuleCfgEdit->setText(label); label = "&Edit channel-cfg ("; label += item->text(0); label += ")"; currModuleCfgEdit->setMenuText(label); currGroupDelete->setEnabled( false ); currGroupDelete->setText("Delete"); currGroupDelete->setMenuText("&Delete"); // HW info label = "Update DCS-readings"; currShowInfo->setText(label); currShowInfo->setMenuText(label); currShowInfo->setEnabled(true); // FE select label = "select single &FE cfg"; single_FE_Action->setText(label); single_FE_Action->setMenuText(label); single_FE_Action->setEnabled(false); }else if(item!=0){ // item is crate level // un-set register panel label m_regPanel->setModule(-1,-1,-1); // add item label label = (item->text(1)=="DCS")?"Add DCS item to ":"Add module group to "; label += item->text(0); currItemAdd->setText(label); label = (item->text(1)=="DCS")?"&Add DCS item to ":"&Add module group to "; label += item->text(0); currItemAdd->setMenuText(label); currItemAdd->setEnabled(std::string(m_engine.getPixConfDBFname())!="" ); currModuleCfgEdit->setEnabled( FALSE ); currModuleCfgEdit->setText( trUtf8( "Edit cfg" ) ); currModuleCfgEdit->setMenuText( trUtf8( "Edit &cfg" ) ); currGroupDelete->setEnabled( FALSE ); currGroupDelete->setText("Delete"); currGroupDelete->setMenuText("&Delete"); // HW info label = "Show Info for XXX"; currShowInfo->setText(label); currShowInfo->setMenuText(label); currShowInfo->setEnabled(false); // FE select if(item->text(1)=="DCS") label = "---"; else{ label = "select single &FE cfg ("; label += item->text(0); label += ")"; } single_FE_Action->setText(label); single_FE_Action->setMenuText(label); single_FE_Action->setEnabled(item->text(1)!="DCS"); } else{ // null-item // un-set register panel label m_regPanel->setModule(99999,-1,-1); // disable editing currModuleCfgEdit->setEnabled( false ); currModuleCfgEdit->setText( trUtf8( "Edit cfg" ) ); currModuleCfgEdit->setMenuText( trUtf8( "Edit &cfg" ) ); currGroupDelete->setEnabled( false ); currGroupDelete->setText("Delete"); currGroupDelete->setMenuText("&Delete"); // FE select label = "select single FE cfg (all mods)"; single_FE_Action->setText(label); label = "select single &FE cfg (all mods)"; single_FE_Action->setMenuText(label); single_FE_Action->setEnabled(!showModListChoice->isEnabled()); // add item label if(m_engine.singleCrateMode()){//nothing to do in this mode currItemAdd->setText("Add"); currItemAdd->setMenuText("&Add"); currItemAdd->setEnabled( false ); } else{ //allow to add crates label = "Add crate"; currItemAdd->setText(label); label = "&Add crate"; currItemAdd->setMenuText(label); currItemAdd->setEnabled( TRUE ); } } return; } void MainPanel::checkClose(){ if(b_closeConfig()) close(); } void MainPanel::reopenConfig(){ if(std::string(m_engine.getPixConfDBFname())==""){ QMessageBox::information(this,"STcontrol: MainPanel::reopenConfig()", "Can't find DB object in memory."); return; } //@ to do: do this properly once PixLib can life-update configs QString path = m_engine.getPixConfDBFname(); if(b_closeConfig()) loadConfig(path.latin1()); } void MainPanel::loadConfig(const char *path){ bool do_load=false; QString my_path; if(std::string(m_engine.getPixConfDBFname())!=""){ QMessageBox::warning(this,"STcontrol::loadConfig","There is already a loaded config ("+QString(m_engine.getPixConfDBFname())+ ") in memory.\nPlease close it first before continuing." ); return; } if(path==0){ Config &opts = m_engine.getOptions(); std::string defPath = ((ConfString&)opts["paths"]["defCfgPath"]).value(); QString qpath = QString::null; if(defPath!=".") qpath = defPath.c_str(); QStringList filter; filter += "DB ROOT-config file (*.cfg.root)"; filter += "DB ascii-config file (*.cfg)"; filter += "Any file (*.*)"; Q3FileDialog fdia(qpath,QString::null,this,"select data file",TRUE); fdia.setCaption("Specify name of RootDB config-file"); fdia.setFilters(filter); fdia.setMode(Q3FileDialog::ExistingFile); if(fdia.exec() == QDialog::Accepted){ do_load = true; my_path = fdia.selectedFile(); } } else{ my_path = path; do_load = true; } if(do_load){ m_engine.loadDB(my_path.latin1()); } return; } void MainPanel::saveAs(){ Config &opts = m_engine.getOptions(); std::string defPath = ((ConfString&)opts["paths"]["defCfgPath"]).value(); QString qpath = QString::null; if(defPath!=".") qpath = defPath.c_str(); QStringList filter; filter += "DB ROOT-config file (*.cfg.root)"; filter += "Any file (*.*)"; Q3FileDialog fdia(qpath,QString::null,this,"select data file",TRUE); fdia.setCaption("Specify name of RootDB config-file"); fdia.setFilters(filter); fdia.setMode(Q3FileDialog::AnyFile); if(fdia.exec() == QDialog::Accepted){ QString my_fname = fdia.selectedFile(); if(my_fname.right(9)!=".cfg.root") my_fname += ".cfg.root"; saveConfig(my_fname.latin1()); } return; } void MainPanel::saveConfig(const char *path){ // tell engine to save m_engine.saveDB(path); return; } void MainPanel::newConfig(int type){ // can only start from scratch if(std::string(m_engine.getPixConfDBFname())!=""){ QMessageBox::information(this,"STcontrol: MainPanel::newConfig()", "A DB object already exists in memory, can't proceed."); return; } // get file name from user QString my_fname; Config &opts = m_engine.getOptions(); std::string defPath = ((ConfString&)opts["paths"]["defCfgPath"]).value(); QString qpath = QString::null; if(defPath!=".") qpath = defPath.c_str(); QStringList filter; filter += "DB ROOT-config file (*.cfg.root)"; filter += "Any file (*.*)"; QFileDialog fdia(this,"Specify name of new RootDB cfg-file", qpath); fdia.setNameFilters(filter); fdia.setFileMode(QFileDialog::AnyFile); if(fdia.exec() == QDialog::Accepted){ my_fname = fdia.selectedFile(); my_fname.replace("\\", "/"); if(my_fname.right(9)!=".cfg.root") my_fname += ".cfg.root"; switch(type){ default: case 0: // default USB-style single FE-I4A newConfigSC(my_fname.latin1(), 1, 1); break; case 1: // default USB-style 2xFE-I4A module newConfigSC(my_fname.latin1(), 2, 1); break; case 2: // default USB-style single FE-I4B newConfigSC(my_fname.latin1(), 1, 2); break; case 3: // default USB-style 2xFE-I4B module newConfigSC(my_fname.latin1(), 2, 2); break; case 4:{ // USBPix multi-board wizard // under development! //QMessageBox::warning(this, "MainPanel::newConfig()", "Creation of new multi-USBboard configs not yet fully implemented - there won't be any cfg. file created!"); MultiboardCfg mbcfg(m_engine,this); if(mbcfg.exec() == QDialog::Accepted){ std::vector myGrpDataV; std::vector cfgList = mbcfg.getCfgList(); for(std::vector::iterator it = cfgList.begin(); it!=cfgList.end(); it++){ grpData myGrpData; myGrpData.myROD.slot = (*it).boardID; myGrpData.myBOC.haveBoc = false; myGrpData.cfgType = 1; myGrpData.myROD.IPfile = mbcfg.fpgaFwFile->text().latin1(); myGrpData.myROD.IDfile = mbcfg.uCFwFile->text().latin1(); modData myModD; myModD.fname = (*it).fileName.latin1(); myModD.modname= (*it).newFeName.latin1(); myModD.connName= (*it).modDecName.latin1(); myModD.modID = 0; myModD.grpID = 0; myModD.active = true; myModD.roType = 0; myModD.inLink = 0; for(int olID=0;olID<4;olID++) myModD.outLink[olID] = 0; myModD.slot = 0; myModD.pp0 = -1; myModD.assyType = 1; myModD.assyID = (*it).FEflavour; myModD.pos_on_assy = 0; myGrpData.myMods.push_back(myModD); myGrpDataV.push_back(myGrpData); } m_engine.addCrateToDB("TestApp", myGrpDataV, my_fname.latin1(), tUSBSys, true); m_engine.loadDB(my_fname.latin1()); } break; } } } } void MainPanel::newConfigSC(const char *fname, int nFe, int FEtype){ std::vector myGrpDataV; grpData myGrpData; myGrpData.myROD.slot = 0; myGrpData.myROD.IPfile = ""; myGrpData.myROD.IDfile = ""; myGrpData.myBOC.haveBoc = false; myGrpData.cfgType = -1; modData myModD; myModD.fname = ""; myModD.connName= ""; myModD.modID = 0; myModD.grpID = 0; myModD.active = true; myModD.roType = 0; myModD.inLink = 0; for(int olID=0;olID<4;olID++) myModD.outLink[olID] = 0; myModD.slot = 0; myModD.pp0 = -1; myModD.assyType = nFe; myModD.assyID = FEtype; myModD.pos_on_assy = 0; myModD.connName = ""; RenameWin rnw(this,"rnwin",0); QString label = "Enter name of module"; rnw.EnterLabel->setText(label); rnw.Name->setText(""); rnw.setWindowTitle(label); rnw.exec(); if(!rnw.Name->text().isEmpty()){ myModD.modname = rnw.Name->text().latin1(); myGrpData.myMods.push_back(myModD); myGrpDataV.push_back(myGrpData); m_engine.addCrateToDB("TestApp", myGrpDataV, fname, tUSBSys); m_engine.loadDB(fname); } return; } void MainPanel::newConfigTable(const char *fname){ QString cfgPath = fname; int pos=cfgPath.findRev("/"); if(pos>=0) cfgPath = cfgPath.left(pos+1); int retVal = 0; std::vector myGrpData; if(m_engine.singleCrateMode()){ //if in single crate mode, use this // get crate STRodCrate *crt = m_engine.getSTRodCrates()[0]; try{ retVal = addGroupTable(myGrpData, crt, cfgPath.latin1()); }catch(...){ retVal = -100; m_engine.toErrLog("MainPanel::newConfigTable : exception while launching group/module wizard for crate "+ crt->getName()); } if(retVal==0){ // create file via engine m_engine.addCrateToDB("TestApp", myGrpData, fname,tRCCVME); m_engine.loadDB(fname); } myGrpData.clear(); } else{ bool nextCrate = true; int ncrates=0; while(retVal==0 && nextCrate){ ModWin sbcwin(this,"sbcwin",0); sbcwin.setCaption("New Crate"); sbcwin.buttonBox->button(QDialogButtonBox::Cancel)->setText("Finish"); sbcwin.TextboxLabel->setText("Enter name of next SBC (press finish to stop)"); int answer = sbcwin.exec(); nextCrate = (!sbcwin.ModuleName->text().isEmpty() && answer == QDialog::Accepted); if(nextCrate){ retVal = addGroupTable(myGrpData, 0, cfgPath.latin1()); if(retVal==0){ // create file via engine m_engine.addCrateToDB(sbcwin.ModuleName->text().latin1(), myGrpData, fname, tRCCVME); ncrates++; } myGrpData.clear(); } } if(ncrates>0) m_engine.loadDB(fname); } return; } int MainPanel::addConfigSC(std::vector &inGrpData, const char *TurboDAQ_fname){ grpData myGrpData; myGrpData.myROD.slot = 0; myGrpData.myROD.IPfile = ""; myGrpData.myROD.IDfile = ""; myGrpData.myBOC.haveBoc = false; myGrpData.cfgType = -1; modData myModD; myModD.fname = ""; myModD.connName= ""; myModD.modID = 0; myModD.grpID = 0; myModD.active = true; myModD.roType = 0; myModD.inLink = 0; for(int olID=0;olID<4;olID++) myModD.outLink[olID] = 0; myModD.slot = 0; myModD.pp0 = -1; myModD.assyType = 0; myModD.assyID = 0; myModD.pos_on_assy = 0; myModD.connName = ""; bool userAccept=false; if(TurboDAQ_fname!=0){ myGrpData.cfgType = 0; if(myGrpData.cfgType>=0) myModD.fname = TurboDAQ_fname; userAccept = true; } else{ RenameWin rnw(this,"rnwin",0); rnw.EnterLabel->setText("Enter Module Name"); rnw.Name->setText(""); rnw.setWindowTitle("Enter Module Name"); rnw.exec(); if(!rnw.Name->text().isEmpty()){ myModD.modname = rnw.Name->text().latin1(); userAccept = true; } } if(userAccept){ myGrpData.myMods.push_back(myModD); inGrpData.push_back(myGrpData); } return (int)userAccept; } int MainPanel::addGroupTable(std::vector &inGrpData, STRodCrate *crate, const char *cfgPath){ unsigned int orgSize = inGrpData.size(); int retVal = 11; // special code for requesting another ROD panel int iGroup=0; QString oldPath=""; if(cfgPath!=0) oldPath=cfgPath; while(retVal==11){ // start table GUI ConfigTableSTC cfgtab(m_engine,crate, this,"cfgtab"); if(oldPath!="") cfgtab.configPath->setText(oldPath); retVal = cfgtab.exec(); if(retVal==QDialog::Accepted || retVal==11){ QApplication::setOverrideCursor(Qt::waitCursor); grpData myGrpData; // add group bool isOK; myGrpData.myROD.slot = cfgtab.getRodEditor().loaded_RODslots[cfgtab.getRodEditor().RodSlotBox->currentItem()]; myGrpData.myROD.IPfile = cfgtab.getRodEditor().IpramFile->text().latin1(); myGrpData.myROD.IDfile = cfgtab.getRodEditor().IdramFile->text().latin1(); myGrpData.myROD.Xfile = cfgtab.getRodEditor().ExternFile->text().latin1(); myGrpData.myROD.mode = cfgtab.getRodEditor().SetupBox->currentItem(); for(int fID=0;fID<8;fID++){ for(int linkID=0;linkID<4;linkID++){ myGrpData.myROD.fmtLinkMap[fID][linkID] = cfgtab.getRodEditor().fmtLinks[fID][linkID]->UValue(); } } // load BOC config if requested myGrpData.myBOC.haveBoc = false; if(cfgtab.getRodEditor().haveBOC->isOn()){ myGrpData.myBOC.haveBoc = true; myGrpData.myBOC.mode = myGrpData.myROD.mode; if(myGrpData.myBOC.mode==2) myGrpData.myBOC.mode=3; } myGrpData.cfgType = (int)cfgtab.configRootDB->isChecked(); // load module config oldPath = cfgtab.configPath->text(); modData myModD; for(int i=0;i<(int)cfgtab.moduleTable->numRows();i++){ if(!cfgtab.moduleTable->text(i,10).isEmpty()){ if(cfgtab.configRootDB->isChecked()) myModD.fname = (cfgtab.configPath->text()+"M"+cfgtab.moduleTable->text(i,0)+"/").latin1(); else myModD.fname = (cfgtab.configPath->text()+"M"+cfgtab.moduleTable->text(i,0)+ "/configs/").latin1(); Q3ComboTableItem *tabIt = dynamic_cast(cfgtab.moduleTable->item(i,10)); if(tabIt==0) myModD.fname += cfgtab.moduleTable->text(i,10).latin1(); else myModD.fname += tabIt->currentText().latin1(); myModD.modname = cfgtab.moduleTable->text(i,0).latin1(); myModD.connName= cfgtab.moduleTable->text(i,11).latin1(); myModD.modID = i; myModD.grpID = cfgtab.moduleTable->text(i,3).toInt(&isOK); myModD.active = true; myModD.roType = myGrpData.myROD.mode; // modules and ROD/BOC should have same r/o speed myModD.inLink = cfgtab.moduleTable->text(i,5).toInt(&isOK); unsigned int in_stream= myModD.inLink%12; unsigned int tx_board = myModD.inLink/12; if(tx_board<4) myGrpData.myBOC.used_in_links[tx_board].push_back(in_stream); for(int olID=0;olID<4;olID++){ QString tmpStrg = cfgtab.moduleTable->text(i,6+olID); if(tmpStrg.isEmpty()){ if(olID>0) myModD.outLink[olID] = myModD.outLink[olID-1]; else myModD.outLink[olID] = 0; }else{ tmpStrg.remove(0,2); myModD.outLink[olID] = 16*(cfgtab.moduleTable->text(i,6+olID).left(1).toInt(&isOK))+tmpStrg.toInt(&isOK); } } myModD.slot = cfgtab.moduleTable->text(i,4).toInt(&isOK); myModD.pp0 = cfgtab.PP0Box->currentItem(); if(cfgtab.moduleTable->text(i,1).isEmpty()){ myModD.assyType = 0; // undef myModD.assyID = 0; myModD.pos_on_assy = 0; } else{ myModD.assyID = cfgtab.moduleTable->text(i,1).toInt(&isOK); myModD.pos_on_assy = cfgtab.moduleTable->text(i,2).toInt(&isOK); if(myModD.assyID<9000) myModD.assyType = 1; // stave else myModD.assyType = 2; // sector } myGrpData.myMods.push_back(myModD); } } inGrpData.push_back(myGrpData); QApplication::restoreOverrideCursor(); } iGroup++; } if(inGrpData.size()==orgSize) return 1; return 0; } int MainPanel::addModulesTable(ModListItem *grpitem, std::vector &inModData, const char *cfgPath){ grpData tmpGrp; std::vector modNames; ModListItem *moditem = (ModListItem*)grpitem->firstChild(); int istart=0; while(moditem!=0){ if(moditem->getType()==ModListItem::tmodule){ modNames.push_back(moditem->text(0)); istart++; } moditem = (ModListItem*)moditem->nextSibling(); } QString oldPath=""; if(cfgPath!=0) oldPath=cfgPath; ConfigTableSTC cfgtab(m_engine,0,this,"cfgtab"); cfgtab.loadModules(modNames); if(oldPath!="") cfgtab.configPath->setText(oldPath); if(cfgtab.exec()==QDialog::Accepted){ modData myModD; bool isOK; for(int i=istart;i<(int)cfgtab.moduleTable->numRows();i++){ myModD.fname = (cfgtab.configPath->text()+"M"+cfgtab.moduleTable->text(i,0)+ "/configs/").latin1(); Q3ComboTableItem *tabIt = dynamic_cast(cfgtab.moduleTable->item(i,10)); if(tabIt==0) myModD.fname += cfgtab.moduleTable->text(i,10).latin1(); else myModD.fname += tabIt->currentText().latin1(); myModD.modname = cfgtab.moduleTable->text(i,0).latin1(); myModD.modID = i; myModD.grpID = cfgtab.moduleTable->text(i,3).toInt(&isOK); myModD.active = true; myModD.roType = 3;//myGrpData.myROD.mode; // modules and ROD/BOC should have same r/o speed myModD.inLink = cfgtab.moduleTable->text(i,5).toInt(&isOK); for(int olID=0;olID<4;olID++){ QString tmpStrg = cfgtab.moduleTable->text(i,6+olID); if(tmpStrg.isEmpty()){ if(olID>0) myModD.outLink[olID] = myModD.outLink[olID-1]; else myModD.outLink[olID] = 0; }else{ tmpStrg.remove(0,2); myModD.outLink[olID] = 16*(cfgtab.moduleTable->text(i,6+olID).left(1).toInt(&isOK))+tmpStrg.toInt(&isOK); } } myModD.slot = cfgtab.moduleTable->text(i,4).toInt(&isOK); myModD.pp0 = cfgtab.PP0Box->currentItem(); if(cfgtab.moduleTable->text(i,1).isEmpty()){ myModD.assyType = 0; // undef myModD.assyID = 0; myModD.pos_on_assy = 0; } else{ myModD.assyID = cfgtab.moduleTable->text(i,1).toInt(&isOK); myModD.pos_on_assy = cfgtab.moduleTable->text(i,2).toInt(&isOK); if(myModD.assyID<9000) myModD.assyType = 1; // stave else myModD.assyType = 2; // sector } inModData.push_back(myModD); } return 0; } return -1; } void MainPanel::deleteGroup(){ ModListItem *currGroup = m_modList->currentGroup(); if( currGroup==0 ) return; m_modList->deleteModuleGroup( currGroup ); } /** Close the current configuration file and clear STCEngine. */ bool MainPanel::b_closeConfig(){ if(m_engine.cfgEdited()){ QMessageBox overwrite("cfg. was edited!", "The configuration has been edited\nDo you want to continue?\nThis will erase all changes!", QMessageBox::Warning,QMessageBox::Yes, QMessageBox::No, QMessageBox::NoButton, this, "cfg_edited",TRUE,Qt::WType_TopLevel); if(overwrite.exec()==QMessageBox::No) return false; } m_engine.clear(); m_engine.setPixConfDBFname(""); //close BocEditor-GUIs, otherwise problems with reloading/reopening files if (!(m_modList->getBocEditors()->empty())) { for(std::vector::iterator BEIT = m_modList->getBocEditors()->begin(); BEIT != m_modList->getBocEditors()->end(); BEIT++) { (*BEIT)->close(); } m_modList->getBocEditors()->clear(); } return true; } void MainPanel::decrGDACBy(){ SetAll sti(this); sti.setCaption("Set GDAC increment"); sti.TextLabel1->setText("Set GDAC increment"); sti.SpinBox->setMinValue(-31); sti.SpinBox->setMaxValue(32); if(sti.exec()){ decrGDAC(sti.SpinBox->value()); } } void MainPanel::decrGDAC(int step){ bool cfgOne=false; // loop over crates std::vector myCrates = m_engine.getSTRodCrates(); for(std::vector::iterator crIT = myCrates.begin(); crIT != myCrates.end(); crIT++){ // get groups in current crate and loop over them for(int iGrp=0; iGrp<(*crIT)->nGroups(); iGrp++){ std::vector< std::pair > list; (*crIT)->getModules(iGrp, list); for(int iMod=0; iMod<(int)list.size(); iMod++){ Config* conf[18];// elements 0...15 are FEs, 16 is MCC, 17 is module for(int chipID=0;chipID<17;chipID++) conf[chipID] = &((*crIT)->getPixModuleChipConf(iGrp,iMod, chipID)); conf[17] = &((*crIT)->getPixModuleConf(iGrp,iMod)); ConfigEdit cfged(conf,this,"tmpedit"); for(int i=0;inumRows();i++){ bool isOK; int myval = cfged.GlobalTable->text(i,4).toInt(&isOK); if(isOK){ myval += step; cfged.GlobalTable->setText(i,4,QString::number(myval)); } } cfged.StoreCfg(); // send modified module config to PixController if that's initialised m_engine.editedCfg(); if((*crIT)->getPixCtrlStatus(iGrp)==tOK){ cfgOne = true; try{ (*crIT)->writeConfig(iGrp,iMod); } catch(...){ QMessageBox::warning(this,"MainPanel::decrTDAC()","Error sending edited configuration to PixController!"); } } } } } if(cfgOne) m_engine.readRodBuff("Post-config edit:"); return; } void MainPanel::decrTDACBy(){ SetAll sti(this); sti.setCaption("Set TDAC increment"); sti.TextLabel1->setText("Set TDAC increment"); sti.SpinBox->setMinValue(-127); if(sti.exec()){ decrTDAC(sti.SpinBox->value()); } } void MainPanel::decrTDAC(int step){ bool cfgOne=false; // loop over crates std::vector myCrates = m_engine.getSTRodCrates(); for(std::vector::iterator crIT = myCrates.begin(); crIT != myCrates.end(); crIT++){ // get groups in current crate and loop over them for(int iGrp=0; iGrp<(*crIT)->nGroups(); iGrp++){ std::vector< std::pair > list; (*crIT)->getModules(iGrp, list); for(int iMod=0; iMod<(int)list.size(); iMod++){ Config* conf[18];// elements 0...15 are FEs, 16 is MCC, 17 is module for(int chipID=0;chipID<17;chipID++) conf[chipID] = &((*crIT)->getPixModuleChipConf(iGrp,iMod, chipID)); conf[17] = &((*crIT)->getPixModuleConf(iGrp,iMod)); ConfigEdit cfged(conf,this,"tmpedit"); cfged.ShiftPTable(0,1,step); // send modified module config to PixController if that's initialised m_engine.editedCfg(); if((*crIT)->getPixCtrlStatus(iGrp)==tOK){ cfgOne = true; try{ (*crIT)->writeConfig(iGrp,iMod); } catch(...){ QMessageBox::warning(this,"MainPanel::decrTDAC()","Error sending edited configuration to PixController!"); } } } } } if(cfgOne) m_engine.readRodBuff("Post-config edit:"); return; } void MainPanel::showAbout(){ QString about = "This is the ATLAS Pixel Module/System-Test Control GUI\n\n" "Version " PLGUI_VERSION " built\nwith ROOT version " + QString(gROOT->GetVersion()) + "\nand QT version " + QString(qVersion()) + "." "\n\nCurrently active authors of GUI and libraries:\n" PLGUI_AUTHORS; //QMessageBox::information(this,"STcontrol about",about); QMessageBox habout(QMessageBox::Information,"Pixel DAQ GUI Help About", about, QMessageBox::Ok, this); habout.setIconPixmap(QPixmap(QString::fromUtf8(":/icons/images/GA_Si.jpg"))); habout.exec(); } void MainPanel::showReadme(){ // QString url="https://twiki.cern.ch/twiki/bin/view/Atlas/STControlDocPage"; // @HK // m_dataPanel->getMA()->openUrl(url); QUrl url("http://icwiki.physik.uni-bonn.de/twiki/bin/view/Systems/STcontrolI4"); QDesktopServices::openUrl(url); } void MainPanel::showInfo(){ ModListItem *item = 0; item=m_modList->currentBOC(); if(item==0) item=m_modList->currentROD(); if(item==0) item=m_modList->currentUSB(); if(item==0) item = dynamic_cast(m_dcsList->ModListView->currentItem()); STRodCrate *crt = 0; if(item!=0) crt = item->getCrate(); if(crt==0){ QMessageBox::warning(this,"MainPanel::showInfo()","Can't find crate for this item"); return; } // KEPTOLDCRATE if(item!=0 && item->getType()==ModListItem::tBOC){ if(crt->getPixBocStatus(item->grpId())!=tOK) QMessageBox::warning(this,"MainPanel::showInfo()","BOC hasn't been initialised yet, can't proceed"); else{ #ifndef NOTDAQ STPixModuleGroup *grp = crt->getSTPixModuleGroups()[item->grpId()]; RodPixController *rpc = dynamic_cast(grp->getPixController()); RodModule *rm = 0; if(rpc!=0) rm = rpc->rodMod(); BocInfo *m = new BocInfo(this, rm,"bocinfo" ); m->readBocStatus(); m->exec(); #endif } }else if(item!=0 && item->getType()==ModListItem::tROD){ if(crt->getPixCtrlStatus(item->grpId())!=tOK) QMessageBox::warning(this,"MainPanel::showInfo()","ROD hasn't been initialised yet or is not idle, can't proceed"); else{ #ifndef NOTDAQ STPixModuleGroup *grp = crt->getSTPixModuleGroups()[item->grpId()]; RodPixController *rpc = dynamic_cast(grp->getPixController()); //RodModule *rm = 0; //if(rpc!=0) rm = rpc->rodMod(); RodInfo *ri = new RodInfo(rpc, this, "rodinfo"); ri->exec(); #endif } } else if (item!=0 && item->getType()==ModListItem::tUSB){ if(crt->getPixCtrlStatus(item->grpId())!=tOK) QMessageBox::warning(this,"MainPanel::showInfo()","Controller hasn't been initialised yet or is not idle, can't proceed"); else{ STPixModuleGroup *grp = crt->getSTPixModuleGroups()[item->grpId()]; USBPixController *upc = dynamic_cast(grp->getPixController()); if(upc!=0){ std::string infoTxt; upc->hwInfo(infoTxt); QMessageBox::information(this,"MainPanel::showInfo()",infoTxt.c_str()); } else QMessageBox::warning(this,"MainPanel::showInfo()","Controller has invalid pointer, can't proceed"); } } else if (item!=0 && (item->getType()==ModListItem::tDCS || item->getType()==ModListItem::tDCSC)){ m_dcsList->updateView(); } else QMessageBox::warning(this,"MainPanel::showInfo()","Only implemented for ROD/BOC and DCS."); // end KEPTOLDCRATE } void MainPanel::showOptions(){ //Config &opts = m_engine.getOptions(); //bool getAssyInfoOrg = ((ConfBool&)opts["PDB"]["getAssyInfo"]).value(); //m_engine.getOptions().dump(std::cout); optionsPanel op(m_engine.getOptions(),this,"optPan"); op.exec(); //bool getAssyInfoNew = ((ConfBool&)opts["PDB"]["getAssyInfo"]).value(); // if(getAssyInfoNew && !getAssyInfoOrg){ // QApplication::setOverrideCursor(Qt::waitCursor); // m_modView->loadGeo(); // m_modView->updateList(); // QApplication::restoreOverrideCursor(); // } } void MainPanel::saveOptions(){ m_engine.saveOptions(); } void MainPanel::loadOptions(){ m_engine.loadOptions(); } void MainPanel::setVcal(){ RenameWin rnw(this,"rnwin",0); rnw.EnterLabel->setText("Enter charge (e) that VCAL should be set to"); rnw.optBox->show(); rnw.optBox->setText("Chigh"); rnw.exec(); if(!rnw.Name->text().isEmpty()){ bool isOK; float chargeVcal = rnw.Name->text().toFloat(&isOK); if(isOK) m_engine.setVcal(chargeVcal, rnw.optBox->isChecked()); } } void MainPanel::incrMccDelay() { RenameWin rnw(this,"rnwin",0); rnw.EnterLabel->setText("Enter MCC delay in-/decrement"); rnw.optBox->show(); rnw.optBox->setText("delay/ns(ticked)"); rnw.exec(); if(!rnw.Name->text().isEmpty()){ bool isOK; float delay = rnw.Name->text().toFloat(&isOK); if(isOK) m_engine.incrMccDelay(delay, rnw.optBox->isChecked()); } } void MainPanel::setTFDACs(bool isTDAC) { Config &opts = m_engine.getOptions(); std::string defPath = ((ConfString&)opts["paths"]["defDataPath"]).value(); QString dlabel = isTDAC?"TDAC":"FDAC"; QString qpath = QString::null; if(defPath!=".") qpath = defPath.c_str(); QStringList filter; filter += "DB ROOT file (*.root)"; filter += "Any file (*.*)"; Q3FileDialog fdia(qpath,QString::null,this,"select data file",TRUE); fdia.setCaption("Specify name of RootDB data-file"); fdia.setFilters(filter); fdia.setMode(Q3FileDialog::ExistingFile); if(fdia.exec() == QDialog::Accepted){ RootDB *dfile = new RootDB(fdia.selectedFile().latin1()); DBInquire *root = dfile->readRootRecord(1); RefWin sclist(0, this,"scanlist", 0, 0, 100); sclist.SelectorLabel->hide(); sclist.DatSel->hide(); sclist.FuncselLabel->setText("select a scan:"); sclist.setCaption("Select scans with "+dlabel+" histograms"); disconnect( sclist.OKButt, SIGNAL( clicked() ), &sclist, SLOT( RDAccept() ) ); connect( sclist.OKButt, SIGNAL( clicked() ), &sclist, SLOT( accept() ) ); for(recordIterator it = root->recordBegin(); it!=root->recordEnd(); it++){ if((*it)->getName()=="PixScanResult"){ std::string label = (*it)->getDecName(); // remnove trailing and heading "/" label.erase(label.length()-1,1); label.erase(0,1); sclist.FuncSel->insertItem(label.c_str()); } } delete dfile; if(sclist.FuncSel->count()>0){ if(sclist.exec()){ int not_found = m_engine.setTFDACs((fdia.selectedFile()+":/"+sclist.FuncSel->currentText()).latin1(), isTDAC); if(not_found>0) QMessageBox::warning(this,"MainPanel::setTFDACs","Couldn't find "+dlabel+" entries for "+ QString::number(not_found)+((not_found==1)?" module":" modules")); } } else{ QMessageBox::warning(this,"MainPanel::setTFDACs","No scans found in file "+fdia.selectedFile()); } } } void MainPanel::setMasks(){ int mask = 0; bool keepLoading=true; Config &opts = m_engine.getOptions(); std::string defPath = ((ConfString&)opts["paths"]["defDataPath"]).value(); QString qpath = QString::null; if(defPath!=".") qpath = defPath.c_str(); QStringList filter; filter += "DB ROOT file (*.root)"; filter += "Any file (*.*)"; std::vector files, histos; while(keepLoading){ Q3FileDialog fdia(qpath,QString::null,this,"select data file",TRUE); fdia.setCaption("Specify name of RootDB data-file"); fdia.setFilters(filter); fdia.setMode(Q3FileDialog::ExistingFile); if(fdia.exec() == QDialog::Accepted){ RefWin sclist(0, this,"scanlist", 0, 0, 11,fdia.selectedFile().latin1()); QCheckBox *cben = new QCheckBox("Apply to ENABLE", &sclist); sclist.comboLayout->addWidget(cben); QCheckBox *cbc0 = new QCheckBox("Apply to CAP0", &sclist); sclist.comboLayout->addWidget(cbc0); QCheckBox *cbc1 = new QCheckBox("Apply to CAP1", &sclist); sclist.comboLayout->addWidget(cbc1); QCheckBox *cbil = new QCheckBox("Apply to ILEAK", &sclist); sclist.comboLayout->addWidget(cbil); if(mask!=0){ cben->setEnabled(false); cbc0->setEnabled(false); cbc1->setEnabled(false); cbil->setEnabled(false); cben->setChecked(mask&1); cbc0->setChecked(mask&2); cbc1->setChecked(mask&4); cbil->setChecked(mask&8); } sclist.nextButton->show(); disconnect( sclist.OKButt, SIGNAL( clicked() ), &sclist, SLOT( RDAccept() ) ); connect( sclist.OKButt, SIGNAL( clicked() ), &sclist, SLOT( accept() ) ); if(sclist.FuncSel->count()>0){ if(sclist.exec()){ files.push_back((fdia.selectedFile()+":/"+sclist.FuncSel->currentText()).latin1()); histos.push_back(sclist.DatSel->currentText().latin1()); if(mask==0) mask = (int) cben->isChecked() + (((int) cbc1->isChecked() )<<1) + (((int) cbc0->isChecked() )<<2) + (((int) cbil->isChecked() )<<3); if(!sclist.nextClicked()){ keepLoading = false; int not_found = m_engine.setMasks(files, histos, mask); if(not_found>0) QMessageBox::warning(this,"MainPanel::setMasks","Couldn't find "+sclist.DatSel->currentText()+ " entries for "+QString::number(not_found)+((not_found==1)?" module":" modules")); } } else keepLoading = false; } else{ keepLoading = false; QMessageBox::warning(this,"MainPanel::setMasks","No scans found in file "+fdia.selectedFile()); } } else keepLoading = false; } } void MainPanel::setSingleFe() { ModListItem *item = 0; int modID = -1; int grpID = -1; int crtID = -1; item=m_modList->currentModule(); if(item==0){ item=m_modList->currentGroup(); if(item==0){ item=m_modList->currentCrate(); if(item!=0) crtID = item->crateId(); }else{ grpID = item->grpId(); crtID = item->crateId(); } }else{ modID = item->modId(); grpID = item->grpId(); crtID = item->crateId(); } RenameWin rnw(this,"rnwin",0); rnw.EnterLabel->setText("Enter FE index that should be selected (-1 restores cfg of all FEs)"); rnw.Name->setText("-1"); rnw.exec(); if(!rnw.Name->text().isEmpty()){ bool isOK; int iFE = rnw.Name->text().toInt(&isOK); if(isOK) m_engine.selectFe(iFE, crtID, grpID, modID); } } void MainPanel::AnalyseBocData(const char* filename, const char* scanlabel ) { m_bocPanel->Analyse(filename, scanlabel); m_bocPanel->WriteData(); } void MainPanel::showPopupWin(const char *msg) { QMessageBox::information(this,"STcontrol: MainPanel", msg); } void MainPanel::setShowMenues(){ if(m_pixScanPanel->isVisible()) showPixScan(); if(m_regPanel->isVisible()) showRegister(); if(m_dataPanel->isVisible()) showData(); if(m_toolPanel->isVisible()) showTools(); if(m_logPanel->isVisible()) showLogs(); if(m_bocPanel->isVisible()) { if(m_engine.whichIFtype()!=tRCCVME) showTools(); else showBocAnalysis(); } if(m_prlPanel->isVisible()) showPrimList(); } void MainPanel::setScanBusy(){ // file menu menu_New_cfg->setEnabled(false); fileOpenAction->setEnabled(false); fileCloseAction->setEnabled(false); fileReopenAction->setEnabled(false); fileSaveAsAction->setEnabled(false); fileSaveAction->setEnabled(false); // edit menu currItemAdd->setEnabled(false); currModuleCfgEdit->setEnabled(false); currGroupDelete->setEnabled(false); currShowInfo->setEnabled(false); single_FE_Action->setEnabled(false); decremGDAC->setEnabled(false); decremGDACBy->setEnabled(false); decremTDAC->setEnabled(false); decremTDACBy->setEnabled(false); decrMccDelAction->setEnabled(false); editset_all_FDACs_from_scanAction->setEnabled(false); editset_all_TDACs_from_scanAction->setEnabled(false); editset_all_VCALs_to_charge_ofAction->setEnabled(false); m_scanActive = true; } void MainPanel::setScanDone(){ m_scanActive = false; setCurrentModule(0); // takes care of top part of edit menu // file menu menu_New_cfg->setEnabled(true); fileOpenAction->setEnabled(true); fileCloseAction->setEnabled(true); fileReopenAction->setEnabled(true); fileSaveAsAction->setEnabled(true); fileSaveAction->setEnabled(true); // edit menu - only bottom part decremGDAC->setEnabled(true); decremGDACBy->setEnabled(true); decremTDAC->setEnabled(true); decremTDACBy->setEnabled(true); decrMccDelAction->setEnabled(true); editset_all_FDACs_from_scanAction->setEnabled(true); editset_all_TDACs_from_scanAction->setEnabled(true); editset_all_VCALs_to_charge_ofAction->setEnabled(true); } void MainPanel::setMyTitle(){ QString appAst=""; if(m_engine.cfgEdited()) appAst = "*"; QString myFile = m_engine.getPixConfDBFname(); QString myTitle= "Pixel Test DAQ Control; "; if(myFile=="") myTitle += "no config loaded"; else myTitle += "current configuration: "+QString(TLogFile::GetNameFromPath(myFile, false).c_str())+appAst; setWindowTitle(myTitle); }