#include "PixScanPanel.h" #include "STControlEngine.h" #include "STRodCrate.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 #include #include #include PixScanPanel::PixScanPanel( STControlEngine &engine_in, QWidget* parent, const char* , Qt::WFlags fl, bool editor ) : QWidget(parent,fl), m_engine( engine_in ) // : PixScanPanelBase(parent,name,fl), m_engine( engine_in ) { setupUi(this); QObject::connect(scanFileBrowse, SIGNAL(clicked()), this, SLOT(browseButton_clicked())); QObject::connect(rawFileBrowse, SIGNAL(clicked()), this, SLOT(rawBrowseButton_clicked())); QObject::connect(clearCfgButton, SIGNAL(clicked()), this, SLOT(clearConfig())); QObject::connect(clearLabelMem, SIGNAL(clicked()), this, SLOT(clearScanLabelMemory())); QObject::connect(saveFile, SIGNAL(toggled(bool)), this, SLOT(fileEnabled(bool))); QObject::connect(fixedSdelBox, SIGNAL(toggled(bool)), this, SLOT(fixSdelay(bool))); QObject::connect(fixedVCALBox, SIGNAL(toggled(bool)), this, SLOT(fixVCAL(bool))); QObject::connect(loadCfgButton, SIGNAL(clicked()), this, SLOT(loadConfig())); QObject::connect(loop0LoadPoints, SIGNAL(clicked()), this, SLOT(loadLoop0Pts())); QObject::connect(loop1LoadPoints, SIGNAL(clicked()), this, SLOT(loadLoop1Pts())); QObject::connect(loop2LoadPoints, SIGNAL(clicked()), this, SLOT(loadLoop2Pts())); QObject::connect(newCfgButton, SIGNAL(clicked()), this, SLOT(newConfig())); QObject::connect(configParameterTable, SIGNAL(clicked(int,int,int,QPoint)), this, SLOT(openTableMenu(int,int,int))); QObject::connect(configParameterTable, SIGNAL(valueChanged(int,int)), this, SLOT(readFromHandlersFromTable(int,int))); QObject::connect(runButton, SIGNAL(clicked()), this, SLOT(runButton_clicked())); QObject::connect(saveCfgButton, SIGNAL(clicked()), this, SLOT(saveConfig())); QObject::connect(strDelRange, SIGNAL(valueChanged(int)), this, SLOT(SdelayChanged(int))); QObject::connect(showLoopIndex, SIGNAL(valueChanged(int)), this, SLOT(showLoop(int))); QObject::connect(totavfill, SIGNAL(stateChanged(int)), this, SLOT(toggleHitOccupancy())); QObject::connect(hitoccfill, SIGNAL(stateChanged(int)), this, SLOT(toggleToTAverage())); QObject::connect(generSDSPcfg, SIGNAL(toggled(bool)), this, SLOT(updateConfig())); QObject::connect(scanConfigSel, SIGNAL(activated(QString)), this, SLOT(updateConfig())); QObject::connect(setVcal, SIGNAL(valueChanged(int)), this, SLOT(VcalChanged(int))); QObject::connect(saveFile, SIGNAL(toggled(bool)), this, SLOT(enableRawFileStuff(bool))); QObject::connect(appIndRawfile, SIGNAL(toggled(bool)), this, SLOT(enableRawFileStuff(bool))); QObject::connect(toggleClusButton,SIGNAL(clicked()), this, SLOT(toggleClusHis())); QObject::connect(srcEventCount, SIGNAL(activated(QString)), this, SLOT(setEvtLabel(QString))); // not needed anymore, but for the moment just hide this button clearLabelMem->hide(); // create one PixScan object so the user can at least use default scans m_stdScan = new PixScan(PixScan::DIGITAL_TEST); m_scanCfg = m_stdScan; m_currStdScanID = -1; // initialise variables for rem. time estimation m_StatusUpdatesRecieved=0; m_MeasurementStartTime=-1; connect( &m_engine, SIGNAL(configChanged()), this, SLOT(updateFegrSel()) ); connect( &m_engine, SIGNAL(crateListChanged()), this, SLOT(updateCrateGrpSel()) ); connect( &m_engine, SIGNAL(sendPixScanStatus(int,int,int,int,int,int,int,int,int)), this, SLOT(updateStatus(int,int,int,int,int,int,int,int,int))); connect( rodBox, SIGNAL(activated(int)), this , SLOT(observedRodChanged(int))); connect( crateBox, SIGNAL(activated(int)), this , SLOT(observedCrateChanged(int))); // set default data path/name ConfGroup &grp = m_engine.getOptions()["paths"]; std::string dpath, dname; dpath = ((ConfString&)grp["defDataPath"]).value(); dname = ((ConfString&)grp["defDataName"]).value(); bool appDate = ((ConfBool&)grp["addDatetoDataFile"]).value(); if(dname!=""){ QString fullPath = (dpath+"/"+dname).c_str(); if(appDate) fullPath+="_"+QDateTime::currentDateTime().toString("ddMMMyy"); fullPath+=".root"; browseButton_clicked(fullPath.latin1()); } // translates individual loop_i variable names to arrays for(int sci=0;scihide(); ErrorBox->hide(); MCC_ErrorFlag->hide(); MCC_FECheck->hide(); MCC_TimeStampComp->hide(); strDelRange->hide(); delRangeLabel->hide(); superGrpDelay->hide(); delayAB0->hide(); delayAB1->hide(); nAccepts_B0->hide(); nAccepts_A1->hide(); nAccepts_B1->hide(); sgrpLabel->hide(); delg0Label->hide(); delg1Label->hide(); selfTrigger->hide(); generSDSPcfg->hide(); // unused tab tabwidget->setTabEnabled(4,false); // hide until min. thresh. scan is needed again (if ever) minThrGroupBox->hide(); histoBox->hide(); showLoop(0); updateConfigSel(); rodBox->setEnabled(true); crateBox->setEnabled(true); } PixScanPanel::~PixScanPanel(){ delete m_stdScan; // delete fillingLabel; } void PixScanPanel::setStdScanCfg(int type){ m_scanCfg = m_stdScan; QApplication::setOverrideCursor(Qt::waitCursor); PixScan::ScanType st = (PixScan::ScanType) type; try{ m_scanCfg->preset(st); }catch(SctPixelRod::BaseException& exc){ QApplication::restoreOverrideCursor(); std::stringstream msg; msg << exc; QMessageBox::warning(this,"PixScanPanel::setStdScanCfg","Error changing scan cfg: "+ QString(msg.str().c_str())); scanConfigSel->setCurrentItem(0); return; }catch(...){ QApplication::restoreOverrideCursor(); QMessageBox::warning(this,"PixScanPanel::setStdScanCfg","Error changing scan cfg."); scanConfigSel->setCurrentItem(0); return; } QApplication::restoreOverrideCursor(); } void PixScanPanel::newConfig(){ RenameWin rnw(this,"rnwin",0); rnw.EnterLabel->setText("Enter label for new config"); rnw.exec(); if(!rnw.Name->text().isEmpty()){ m_engine.newPixScanCfg(rnw.Name->text().latin1(), m_scanCfg); updateConfigSel(); scanConfigSel->setCurrentItem(scanConfigSel->count()-1); updateConfig(); } return; } void PixScanPanel::loadConfig() { 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,"scanrootfile",TRUE); fdia.setCaption("Specify name of DB file with PixScan entries"); fdia.setFilters(filter); if(fdia.exec() == QDialog::Accepted){ m_engine.loadScanCfg(fdia.selectedFile().latin1()); updateConfigSel(); } return; } void PixScanPanel::clearConfig() { for(std::vector::const_iterator it = m_engine.getPixScanCfg().begin(); it != m_engine.getPixScanCfg().end(); it++) delete (*it); m_engine.getPixScanCfg().clear(); updateConfigSel(); } void PixScanPanel::saveConfig() { 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,"scanrootfile",TRUE); fdia.setCaption("Specify name of DB file to save PixScan entries"); fdia.setFilters(filter); fdia.setMode(Q3FileDialog::AnyFile); if(fdia.exec() == QDialog::Accepted) m_engine.savePixScan(fdia.selectedFile().latin1()); return; } void PixScanPanel::updateConfigSel(){ scanConfigSel->clear(); // load the names of pre-set configs // standard config labels: PixScan *tmpPS = new PixScan(); std::map defScans = tmpPS->getScanTypes(); for(std::map::iterator it = defScans.begin(); it!=defScans.end(); it++){ scanConfigSel->insertItem(("DEFAULT: "+it->first).c_str()); } delete tmpPS; // load the scan config items into combo box for(std::vector::const_iterator it = m_engine.getPixScanCfg().begin(); it != m_engine.getPixScanCfg().end(); it++) { std::string inq_name = TLogFile::GetNameFromPath(m_engine.getPixScanCfgDBName(*it).c_str()); scanConfigSel->insertItem(("USERDEF: "+inq_name).c_str()); } updateConfig(); return; } void PixScanPanel::updateConfig(){ snglfeMode->setChecked(false); int type = scanConfigSel->currentItem(); QString label = scanConfigSel->currentText(); PixScan *tmpPS = new PixScan(); std::map defScans = tmpPS->getScanTypes(); if(label.left(8)=="DEFAULT:"){ label.remove(0,9); setStdScanCfg(defScans[label.latin1()]); m_currStdScanID = defScans[label.latin1()]; }else{ int utype = type-defScans.size(); m_scanCfg = m_engine.getPixScanCfg()[utype]; if(m_scanCfg==0) // selected cfg. doesn't exist somehow, go to default (=digital scan) scanConfigSel->setCurrentItem(0); label.remove(0,9); m_currStdScanID = -1; } if(((ConfBool&)m_engine.getOptions()["autoload"]["doPixScanAutoLabel"]).value()) scanLabel->setText(label); delete tmpPS; updateFegrSel(); updateConfigHandlers(); QString fname = scanFileName->text(); if(m_currStdScanID==PixScan::SOURCE_SCAN){ appIndRawfile->setChecked(true); rawBrowseButton_clicked(fname.left(fname.length()-5).latin1()); } else if(m_currStdScanID>=0){ appIndRawfile->setChecked(false); rawBrowseButton_clicked(""); } } void PixScanPanel::updateFegrSel(){ // test version - not sure this is the best way of doing this // fill names on FE global register combo box PixFeI4AConfig fei4a(0,0, "tmpfe", 0); PixFeI4BConfig fei4b(0,0, "tmpfe", 0); Config &cfga = fei4a.config(); Config &cfgb = fei4b.config(); ConfGroup &grgrpa = cfga.subConfig("GlobalRegister_0/GlobalRegister")["GlobalRegister"]; ConfGroup &grgrpb = cfgb.subConfig("GlobalRegister_0/GlobalRegister")["GlobalRegister"]; std::vector grNames; if(m_engine.currFEFlavour()==2){ for(int j=0;jclear(); loopFERegName[i]->insertItem("unknown"); for(int j=0;j<(int)grNames.size();j++){ loopFERegName[i]->insertItem(grNames[j].c_str()); } } } void PixScanPanel::updateConfigHandlers(){ if(m_scanCfg==0) return; Config &myconf = m_scanCfg->config(); configParameterTable->setNumRows(0); // make sure none of the handles disturbs loading std::map::const_iterator hndlIT; for(hndlIT = m_knownHandles.begin(); hndlIT!=m_knownHandles.end();hndlIT++){ if(dynamic_cast(hndlIT->second) != 0) disconnect( hndlIT->second, SIGNAL( valueChanged(int) ), this, SLOT( readFromHandles() ) ); if(dynamic_cast(hndlIT->second) != 0) disconnect( hndlIT->second, SIGNAL( valueChanged(double) ), this, SLOT( readFromHandles() ) ); if(dynamic_cast(hndlIT->second) != 0) disconnect( hndlIT->second, SIGNAL( activated(int) ), this, SLOT( readFromHandles() ) ); if(dynamic_cast(hndlIT->second) != 0) disconnect( hndlIT->second, SIGNAL( toggled(bool) ), this, SLOT( readFromHandles() ) ); if(dynamic_cast(hndlIT->second) != 0) disconnect( hndlIT->second, SIGNAL( textChanged(const QString&) ), this, SLOT( readFromHandles() ) ); } disconnect(configParameterTable, SIGNAL(valueChanged(int, int)), this, SLOT ( readFromHandlersFromTable (int, int))); // loop over config items and see if it's in our "known" list // Loop over the ConfGroups for (int i=0; i(handle); QCheckBox *tbhandle = dynamic_cast(handle); QComboBox *cbhandle = dynamic_cast(handle); if(sbhandle!=0) sbhandle->setValue(ival); else if(tbhandle!=0) tbhandle->setChecked((bool)ival); else if(cbhandle!=0) cbhandle->setCurrentItem(ival); break;} case ConfObj::LIST : { QComboBox *cbhandle = dynamic_cast(handle); QCheckBox *tbhandle = dynamic_cast(handle); if(cbhandle!=0){ cbhandle->clear(); int currID=0; std::map::const_iterator mapIT; for(mapIT = ((ConfList&)grp[j]).m_symbols.begin(); mapIT != ((ConfList&)grp[j]).m_symbols.end();mapIT++){ cbhandle->insertItem(mapIT->first.c_str()); if(mapIT->first==((ConfList&)grp[j]).sValue()) currID = cbhandle->count()-1; } cbhandle->setCurrentItem(currID); } else if(tbhandle!=0){ tbhandle->setChecked((bool)((ConfList&)grp[j]).getValue()); } break;} case ConfObj::BOOL : { QCheckBox *cbhandle = dynamic_cast(handle); if(cbhandle!=0) cbhandle->setChecked((bool)((ConfBool&)grp[j]).value()); break;} case ConfObj::VECTOR : { Q3ListBox *lbhandle = dynamic_cast(handle); if(lbhandle!=0){ lbhandle->clear(); switch( ((ConfVector&)grp[j]).subtype() ){ case ConfVector::INT:{ std::vector &tmpVec = ((ConfVector&)grp[j]).valueVInt(); for(std::vector::iterator IT = tmpVec.begin(); IT!=tmpVec.end(); IT++) lbhandle->insertItem(QString::number(*IT)); break;} case ConfVector::UINT:{ std::vector &tmpVec = ((ConfVector&)grp[j]).valueVUint(); for(std::vector::iterator IT = tmpVec.begin(); IT!=tmpVec.end(); IT++) lbhandle->insertItem(QString::number(*IT)); break;} case ConfVector::FLOAT:{ std::vector &tmpVec = ((ConfVector&)grp[j]).valueVFloat(); for(std::vector::iterator IT = tmpVec.begin(); IT!=tmpVec.end(); IT++) lbhandle->insertItem(QString::number(*IT, 'f',2)); break;} default: m_engine.toErrLog("PixScanPanel::readFromHandles:\n found unhandled " "config type for item "+grp[j].name()); } } break;} case ConfObj::FLOAT :{ QSpinBox *sbhandle = dynamic_cast(handle); if(sbhandle!=0) sbhandle->setValue((int)((ConfFloat&)grp[j]).value()); QDoubleSpinBox *dsbhandle = dynamic_cast(handle); if(dsbhandle!=0) dsbhandle->setValue((float)((ConfFloat&)grp[j]).value()); break;} case ConfObj::STRING :{ QComboBox *cbhandle = dynamic_cast(handle); QLineEdit *strhandle = dynamic_cast(handle); if(strhandle!=0) strhandle->setText((((ConfString&)grp[j]).value()).c_str()); if(cbhandle!=0){ for(int l=0;lcount();l++){ if(cbhandle->itemText(l)==QString((((ConfString&)grp[j]).value()).c_str())){ cbhandle->setCurrentIndex(l); break; } } } break;} case ConfObj::VOID : default: m_engine.toErrLog("PixScanPanel::updateConfigHandlers:\n found unknown/unhandled " "config type for item "+grp[j].name()); } } else{ // dump info to table if(grp[j].visible() && ( // do not list items that are auto-generated by us: (grp[j].name().find("modGroups_mod")==std::string::npos && grp[j].name().find("modGroups_config")==std::string::npos && grp[j].name().find("modGroups_trigger")==std::string::npos && grp[j].name().find("modGroups_readout")==std::string::npos && grp[j].name().find("modGroups_strobe")==std::string::npos ) || !(generSDSPcfg->isChecked()))){ int k = configParameterTable->numRows(); configParameterTable->insertRows(k,1); configParameterTable->setText( k, 0, grp[j].name().c_str() ); QString typeStr, valStr; switch( grp[j].type() ) { case ConfObj::INT : { typeStr = "INT"; int ival=0; switch( ((ConfInt&)grp[j]).subtype() ){ case ConfInt::S32: ival = (int)((ConfInt&)grp[j]).valueS32(); break; case ConfInt::U32: ival = (int)((ConfInt&)grp[j]).valueU32(); break; case ConfInt::S16: ival = (int)((ConfInt&)grp[j]).valueS16(); break; case ConfInt::U16: ival = (int)((ConfInt&)grp[j]).valueU16(); break; case ConfInt::S8: ival = (int)((ConfInt&)grp[j]).valueS8(); break; case ConfInt::U8: ival = (int)((ConfInt&)grp[j]).valueU8(); break; default: ; } valStr = QString::number(ival); break;} case ConfObj::FLOAT : typeStr = "FLOAT"; valStr = QString::number(((ConfFloat&)grp[j]).value(),'f',3); break; case ConfObj::LIST : typeStr = "LIST"; valStr = ((ConfList&)grp[j]).sValue().c_str(); break; case ConfObj::BOOL : typeStr = "BOOL"; valStr = ((ConfBool&)grp[j]).value()?"true":"false"; break; case ConfObj::STRING : typeStr = "STRING"; valStr = ((ConfString&)grp[j]).value().c_str(); break; case ConfObj::VOID : typeStr = "VOID"; valStr = "void"; break; case ConfObj::VECTOR : typeStr = "VECTOR"; valStr = "vector"; break; default: typeStr = "Unrecognized"; } configParameterTable->setText( k, 1, typeStr ); configParameterTable->setText( k, 2, grp[j].comment().c_str() ); // configParameterTable->setText( k, 3, grp[j].visible()?"true":"false" ); if ( grp[j].type() != ConfObj::LIST && grp[j].type() !=ConfObj::VECTOR ) { configParameterTable->setText( k, 3, valStr ); } else if(grp[j].type() == ConfObj::LIST){ //deal with LIST QStringList stringList; std::map stdmap = ((ConfList&)grp[j]).symbols(); std::map::iterator pos; for(pos = stdmap.begin(); pos != stdmap.end(); pos ++) { stringList << pos->first.c_str(); } Q3ComboTableItem *comboItem = new Q3ComboTableItem ( configParameterTable, stringList ); comboItem->setCurrentItem( ((ConfList&)grp[j]).sValue().c_str() ); configParameterTable->setItem( k, 3, comboItem); } else { // deal with vectors QStringList stringList; switch( ((ConfVector&)grp[j]).subtype() ){ case ConfVector::INT:{ std::vector &tmpVec = ((ConfVector&)grp[j]).valueVInt(); for(std::vector::iterator IT = tmpVec.begin(); IT!=tmpVec.end(); IT++) stringList << QString::number(*IT); configParameterTable->setText( k, 1, "INT VECTOR" ); break;} case ConfVector::UINT:{ std::vector &tmpVec = ((ConfVector&)grp[j]).valueVUint(); for(std::vector::iterator IT = tmpVec.begin(); IT!=tmpVec.end(); IT++) stringList << QString::number(*IT); configParameterTable->setText( k, 1, "UINT VECTOR" ); break;} case ConfVector::FLOAT:{ std::vector &tmpVec = ((ConfVector&)grp[j]).valueVFloat(); for(std::vector::iterator IT = tmpVec.begin(); IT!=tmpVec.end(); IT++) stringList << QString::number(*IT, 'f',2); configParameterTable->setText( k, 1, "FLOAT VECTOR" ); break;} default: configParameterTable->setText( k, 1, "unknown VECTOR" ); stringList << "unknown values"; break; } Q3ComboTableItem *comboItem = new Q3ComboTableItem ( configParameterTable, stringList, true ); comboItem->setCurrentItem( 0 ); configParameterTable->setItem( k, 3, comboItem); } } } } } // set columns for Name, Type, Comment and Visibility read-only; only Value stays editable configParameterTable->setColumnReadOnly( 0, true ); configParameterTable->setColumnReadOnly( 1, true ); configParameterTable->setColumnReadOnly( 2, true ); // configParameterTable->setColumnReadOnly( 3, true ); // make sure all related settings on loop panels are correct for(int sci=0;sci(hndlIT->second) != 0) connect( hndlIT->second, SIGNAL( valueChanged(int) ), this, SLOT( readFromHandles() ) ); if(dynamic_cast(hndlIT->second) != 0) connect( hndlIT->second, SIGNAL( valueChanged(double) ), this, SLOT( readFromHandles() ) ); if(dynamic_cast(hndlIT->second) != 0) connect( hndlIT->second, SIGNAL( activated(int) ), this, SLOT( readFromHandles() ) ); if(dynamic_cast(hndlIT->second) != 0) connect( hndlIT->second, SIGNAL( toggled(bool) ), this, SLOT( readFromHandles() ) ); if(dynamic_cast(hndlIT->second) != 0) connect( hndlIT->second, SIGNAL( textChanged(const QString&) ), this, SLOT( readFromHandles() ) ); } connect(configParameterTable, SIGNAL(valueChanged(int, int)), this, SLOT (readFromHandlersFromTable (int, int))); return; } void PixScanPanel::readFromHandles(){ if(m_scanCfg==0) return; for(int sci=0;sciconfig(); // config was edited -> no longer a std. scan definition m_currStdScanID = -1; // loop over config items and see if it's in our "known" list // Loop over the ConfGroups for (int i=0; i(handle); QCheckBox *tbhandle = dynamic_cast(handle); QComboBox *cbhandle = dynamic_cast(handle); if(sbhandle!=0) read_val = sbhandle->value(); else if(tbhandle!=0) read_val = (int) tbhandle->isChecked(); else if(cbhandle!=0) read_val = (int) cbhandle->currentItem(); else{ m_engine.toErrLog("PixScanPanel::readFromHandles:\n found unhandled " "config type for item "+grp[j].name()); break; } switch( ((ConfInt&)grp[j]).subtype() ){ case ConfInt::S32: *((int *)((ConfInt&)grp[j]).m_value) = (int)read_val; break; case ConfInt::U32: *((unsigned int *)((ConfInt&)grp[j]).m_value) = (unsigned int)read_val; break; case ConfInt::S16: *((short int *)((ConfInt&)grp[j]).m_value) = (short int)read_val; break; case ConfInt::U16: *((unsigned short int *)((ConfInt&)grp[j]).m_value) = (unsigned short int)read_val; break; case ConfInt::S8: *((char *)((ConfInt&)grp[j]).m_value) = (char)read_val; break; case ConfInt::U8: *((unsigned char *)((ConfInt&)grp[j]).m_value) = (unsigned char)read_val; break; default: ; } break;} case ConfObj::LIST :{ int read_val = 0; QComboBox *cbhandle = dynamic_cast(handle); QCheckBox *tbhandle = dynamic_cast(handle); if(cbhandle!=0){ read_val = (int) ((ConfList&)grp[j]).m_symbols[cbhandle->currentText().latin1()]; }else if(tbhandle!=0){ read_val = (int) tbhandle->isChecked(); } else{ m_engine.toErrLog("PixScanPanel::readFromHandles:\n found unhandled " "config type for item "+grp[j].name()); break; } switch( ((ConfList&)grp[j]).subtype() ){ case ConfList::S32: *((int *)((ConfList&)grp[j]).m_value) = (int) read_val; break; case ConfList::U32: *((unsigned int *)((ConfList&)grp[j]).m_value) = (unsigned int) read_val; break; case ConfList::S16: *((short int *)((ConfList&)grp[j]).m_value) = (short int) read_val; break; case ConfList::U16: *((unsigned short int *)((ConfList&)grp[j]).m_value) = (unsigned short int) read_val; break; case ConfList::S8: *((char *)((ConfList&)grp[j]).m_value) = (char) read_val; break; case ConfList::U8: *((unsigned char *)((ConfList&)grp[j]).m_value) = (unsigned char) read_val; break; default: m_engine.toErrLog("PixScanPanel::readFromHandles:\n found unhandled " "config type for item "+grp[j].name()); } break;} case ConfObj::BOOL :{ QCheckBox *tbhandle = dynamic_cast(handle); if(tbhandle!=0) ((ConfBool&)grp[j]).m_value = tbhandle->isChecked(); break;} case ConfObj::VECTOR : { Q3ListBox *lbhandle = dynamic_cast(handle); if(lbhandle!=0){ bool isOK; switch( ((ConfVector&)grp[j]).subtype() ){ case ConfVector::INT:{ int value; std::vector &tmpVec = ((ConfVector&)grp[j]).valueVInt(); tmpVec.clear(); for(unsigned int sci=0;scicount();sci++){ value = lbhandle->text(sci).toInt(&isOK); if(isOK) tmpVec.push_back(value); } break;} case ConfVector::UINT:{ unsigned int value; std::vector &tmpVec = ((ConfVector&)grp[j]).valueVUint(); tmpVec.clear(); for(unsigned int sci=0;scicount();sci++){ value = (unsigned int) lbhandle->text(sci).toInt(&isOK); if(isOK) tmpVec.push_back(value); } break;} case ConfVector::FLOAT:{ float value; std::vector &tmpVec = ((ConfVector&)grp[j]).valueVFloat(); tmpVec.clear(); for(unsigned int sci=0;scicount();sci++){ value = lbhandle->text(sci).toFloat(&isOK); if(isOK) tmpVec.push_back(value); } break;} default: m_engine.toErrLog("PixScanPanel::readFromHandles:\n found unhandled " "config type for item "+grp[j].name()); } } break;} case ConfObj::FLOAT :{ QSpinBox *sbhandle = dynamic_cast(handle); if(sbhandle!=0) ((ConfFloat&)grp[j]).m_value = (float)sbhandle->value(); QDoubleSpinBox *dsbhandle = dynamic_cast(handle); if(dsbhandle!=0) ((ConfFloat&)grp[j]).m_value = (double)dsbhandle->value(); break;} case ConfObj::STRING :{ QComboBox *cbhandle = dynamic_cast(handle); QLineEdit *strhandle = dynamic_cast(handle); if(strhandle!=0){ ((ConfString&)grp[j]).m_value = std::string(strhandle->text().toAscii().data()); } if(cbhandle!=0){ ((ConfString&)grp[j]).m_value = std::string(cbhandle->currentText().latin1()); } break;} case ConfObj::VOID : default: m_engine.toErrLog("PixScanPanel::readFromHandles:\n found unknown " "config type for item "+grp[j].name()); } } } } return; } void PixScanPanel::readFromHandlersFromTable(int row, int){ if(m_scanCfg==0) return; Config &myconf = m_scanCfg->config(); // config was edited -> no longer a std. scan definition m_currStdScanID = -1; // Loop over the ConfGroups for (int i=0; itext( row, 0 )]; // find ConfObj according to its name std::string obj_name = configParameterTable->text( row, 0 ).latin1(); unsigned int pos = (unsigned int)obj_name.find("_"); if(pos!=(unsigned int)std::string::npos) // remove group name from table obj_name.erase(0,pos+1); ConfObj &obj = grp[obj_name]; // find ConfObj according to its name if (obj.name() == "__TrashConfObj__") continue; //not found, try next ConfGroup switch( obj.type() ) { case ConfObj::INT : PixLib::WriteIntConf((ConfInt&) obj, (configParameterTable->text(row,3)).toInt()); break; case ConfObj::FLOAT : ((ConfFloat&)obj).m_value = (configParameterTable->text(row,3)).toFloat(); break; case ConfObj::BOOL : ((ConfBool&)obj).m_value = ((configParameterTable->text(row,3)).lower() == "true") ? true : false; break; case ConfObj::STRING : ((ConfString&)obj).m_value = configParameterTable->text(row,3).ascii(); break; case ConfObj::LIST :{ QString str_val = ((Q3ComboTableItem *)(configParameterTable->item(row,3)))->currentText(); int read_val = (int) ((ConfList&)obj).m_symbols[str_val.latin1()]; switch( ((ConfList&)obj).subtype() ){ case ConfList::S32: *((int *)((ConfList&)obj).m_value) = (int) read_val; break; case ConfList::U32: *((unsigned int *)((ConfList&)obj).m_value) = (unsigned int) read_val; break; case ConfList::S16: *((short int *)((ConfList&)obj).m_value) = (short int) read_val; break; case ConfList::U16: *((unsigned short int *)((ConfList&)obj).m_value) = (unsigned short int) read_val; break; case ConfList::S8: *((char *)((ConfList&)obj).m_value) = (char) read_val; break; case ConfList::U8: *((unsigned char *)((ConfList&)obj).m_value) = (unsigned char) read_val; break; default: ; } } break; case ConfObj::VECTOR :{ Q3ComboTableItem *cb = dynamic_cast(configParameterTable->item(row,3)); bool isOK; if(cb!=0){ int nent = cb->count(); switch( ((ConfVector&)obj).subtype() ){ case ConfVector::UINT:{ std::vector &tmpVec = ((ConfVector&)obj).valueVUint(); tmpVec.clear(); for(int i=0;itext(i).toInt(&isOK); if(isOK){ tmpVec.push_back(value); } } break;} case ConfVector::INT:{ std::vector &tmpVec = ((ConfVector&)obj).valueVInt(); tmpVec.clear(); for(int i=0;itext(i).toInt(&isOK); if(isOK){ tmpVec.push_back(value); } } break;} case ConfVector::FLOAT:{ std::vector &tmpVec = ((ConfVector&)obj).valueVFloat(); tmpVec.clear(); for(int i=0;itext(i).toFloat(&isOK); if(isOK){ tmpVec.push_back(value); } } break;} default: break; } }else m_engine.toErrLog("PixScanPanel::readFromHandlersFromTable:\n "+obj.name()+ "was supposed to have a combo box but doesn't"); break;} case ConfObj::VOID : default: m_engine.toErrLog("PixScanPanel::readFromHandlersFromTable:\n found unknown " "config type "+obj.type()); } } //end of loop over ConfGroups return; } void PixScanPanel::updateLoopSettings(int ID){ if(ID<0 || ID>MAX_LOOPS) return; if(LoopBox[ID]==0) return; if(!loopActive[ID]->isChecked()){ loopStep[ID]->setValue(1); loopStart[ID]->setValue(0); loopStop[ID]->setValue(0); loopRegular[ID]->setChecked(true); loopStart[ID]->setEnabled(false); loopStop[ID]->setEnabled(false); loopStep[ID]->setEnabled(false); loopRegular[ID]->setEnabled(false); loopPtsBox[ID]->setEnabled(false); loopDspProc[ID]->setEnabled(false); loopEndAction[ID]->setEnabled(false); loopOnDsp[ID]->setEnabled(false); loopType[ID]->setEnabled(false); } else{ loopStart[ID]->setEnabled(loopRegular[ID]->isChecked()); loopStop[ID]->setEnabled(loopRegular[ID]->isChecked()); loopStep[ID]->setEnabled(loopRegular[ID]->isChecked()); loopRegular[ID]->setEnabled(true); loopPtsBox[ID]->setEnabled(true); loopDspProc[ID]->setEnabled(true); loopEndAction[ID]->setEnabled(true); loopOnDsp[ID]->setEnabled(true); loopType[ID]->setEnabled(true); } setFeReg(ID); } void PixScanPanel::updateLoopPts(int ID){ if(ID<0 || ID>MAX_LOOPS) return; if(LoopBox[ID]==0) return; if(loopRegular[ID]->isChecked()){ loopPtsBox[ID]->clear(); if(loopStep[ID]->value()>1){ for(int i=0;ivalue();i++){ double scanpt = loopStart[ID]->value() + (loopStop[ID]->value()-loopStart[ID]->value())/ (double)(loopStep[ID]->value()-1)*((double)i); loopPtsBox[ID]->insertItem(QString::number(scanpt)); } }else if(loopStep[ID]->value()==1) loopPtsBox[ID]->insertItem(loopStart[ID]->text()); } else{ // loopPtsBox[ID]->clear(); } return; } void PixScanPanel::showLoop(int ID){ if(ID<0 || ID>MAX_LOOPS) return; if(LoopBox[ID]==0) return; for(int sci=0;scihide(); LoopBox[ID]->show(); return; } void PixScanPanel::runButton_clicked(){ // Just start the scan and return if(runButton->text()=="Start Scan"){ QString new_label; if(STControlEngine::checkScanLabel(m_scanLabels, scanLabel->text(), new_label)){ QMessageBox::StandardButton user_answer = QMessageBox::information(this, "PixScanPanel", "Current scan label has been used before.\n" "RootDB does not support this.\n" "Do you want to use \""+new_label+"\" instead?", QMessageBox::Yes, QMessageBox::No); if(user_answer == QMessageBox::Yes) scanLabel->setText(new_label); else{ QMessageBox::information(this, "PixScanPanel", "Please change scan label manually to something different before " "trying to scan again."); return; } } // change panel view int type = 2*(int)m_scanCfg->getSourceScanFlag(); if(type==2) type += (int)m_scanCfg->getLoopActive(0); // type = 4 foreseen for TB in scanRunning - where do we get that info from? - why was this never implemented? if(type==0 && !m_scanCfg->getDspMaskStaging()) type = 1; scanRunning(type); emit enableBocAnaScan(false); // gather information and actually launch scan STControlEngine::pixScanRunOptions myscopt; myscopt.scanConfig = m_scanCfg; // ok now, engine will make a copy myscopt.loadToAna = 0; myscopt.anaLabel = scanLabel->text().latin1(); myscopt.writeToFile = saveFile->isChecked(); myscopt.fileName = scanFileName->text().latin1(); myscopt.determineSDSPcfg = generSDSPcfg->isChecked(); myscopt.stdTestID = m_currStdScanID; myscopt.runFEbyFE = snglfeMode->isChecked(); myscopt.indexRawFile = appIndRawfile->isChecked(); myscopt.readDcs = dcsReadBox->currentItem(); int nRods = m_engine.CtrlStatusSummary(); // check if none of the controllers has been initialised, unless // scan uses DCS only bool onlyDcsScanned=true; for(int il=0;il<3;il++){ if(m_scanCfg->getLoopActive(il) && m_scanCfg->getLoopParam(il)!=PixLib::PixScan::DCS_VOLTAGE) onlyDcsScanned = false; } onlyDcsScanned &= (m_scanCfg->getDcsChan()!=""); if (nRods == 0 && (m_scanCfg->getDcsChan()=="" || !onlyDcsScanned)) { QMessageBox initRods("PixScanPanel", "Can't find any initialised PixController\nDo you want to initialise all PixControllers?", QMessageBox::Question,QMessageBox::Yes, QMessageBox::No, QMessageBox::NoButton, this, "initrod",TRUE,Qt::WType_TopLevel); if(initRods.exec()==QMessageBox::Yes) { // set wait cursor QApplication::setOverrideCursor(Qt::waitCursor); m_engine.initRods(); // restore normal cursor QApplication::restoreOverrideCursor(); // status = m_engine.pixScan(myscopt); nRods = m_engine.CtrlStatusSummary(); if(nRods<=0) { updateStatus(0,0,0,0,-1,0,0,0,1); QMessageBox::warning(this,"PixScanPanel","Error in initialising PixControllers\n->not scanning."); } } else { updateStatus(0,0,0,0,-1,0,0,0,1); QMessageBox::warning(this,"PixScanPanel","Error in initialising PixControllers\n->not scanning."); } } else if (nRods==-1) { QMessageBox::warning(this,"PixScanPanel","No PixController found.\n->not scanning."); updateStatus(0,0,0,0,0,0,0,0,1); // set state back to idle } else if (nRods<0) { QMessageBox::warning(this,"PixScanPanel","Strange Output from STControlEngine::CtrlStatusSummary().\n->not scanning."); updateStatus(0,0,0,0,0,0,0,0,1); // set state back to idle } if (nRods>0 || (m_scanCfg->getDcsChan()!="" && onlyDcsScanned)) { // only add label if it is really used (if there is a db file to be opened), // and after initialisation of Rods (otherwise label could be added even if scan is not made) if(myscopt.writeToFile && (!myscopt.fileName.empty())) m_scanLabels.push_back(scanLabel->text()); int status = m_engine.pixScan(myscopt); QString errMsg; switch(status) { case -1: errMsg = "Error: no config submitted to scan initialisation\n->not scanning."; break; case -2: errMsg = "Error in processing PixScan configuration\n->not scanning."; break; case -3: errMsg = "Error while sending PixScan configuration to PixControllers\n->not scanning."; break; case -4: errMsg = "Timeout while waiting for PixController to get into scan mode\n->not scanning."; break; default: errMsg = "Unknown error during scan initialisation\n->not scanning."; } return; } } else if(runButton->text()=="Abort" || runButton->text()=="Stop") { runButton->setText("Wait"); runButton->setEnabled(false); m_engine.stopPixScan(); return; } return; } void PixScanPanel::updateStatus(int nSteps0, int nSteps1, int nSteps2, int nMasks, int in_currFe, int sramFillLevel, int triggerRate, int hit_Rate, int status){ if(nMasks<2147483647){// 2147483647 is max. pos. 32-bit int number, not used anywhere else, so should be safe identifier if (eventDisp->isEnabled()) { if (eventLabel->text().left(14)=="Time remaining") { PixLib::PixScan *scanOptions=m_engine.getLastPxScanConfig().scanConfig; // Estimate remaining scantime double percentage=0; double percentage_error=0; if (scanOptions!=NULL) { int ntotstp[3]; double max = 1.; for(int is=0;is<3;is++) { ntotstp[is] = scanOptions->getLoopVarNSteps(is); if(ntotstp[is]==0) ntotstp[is]=1; max *= (double)ntotstp[is]; } if (max>0) { percentage=(double)(nSteps2*ntotstp[1]*ntotstp[0]+nSteps1*ntotstp[0]+nSteps0)/max*100.; percentage_error=100/max; } else percentage=100; if (percentage<0) percentage=0; else if (percentage+percentage_error>100) { percentage=100; percentage_error=0; } } if (percentage!=m_lastPercentage) m_StatusUpdatesRecieved++; if (m_StatusUpdatesRecieved==2) { m_MeasurementStartTime=QDateTime::currentDateTime().toTime_t(); m_MeasurementStartPercentage=percentage; } // First estimation after 1 minute if (percentage>m_lastPercentage && (QDateTime::currentDateTime().toTime_t()-m_MeasurementStartTime>30) && percentage>0 && m_MeasurementStartTime!=-1) { int remaining_minutes=(((100/(percentage-m_MeasurementStartPercentage-percentage_error))-1)*(QDateTime::currentDateTime().toTime_t()-m_MeasurementStartTime)/60)+1; eventLabel->setText("Time remaining (min.):"); eventDisp->display(remaining_minutes); } m_lastPercentage=percentage; } else eventDisp->display(nMasks); } if(usedMem->isEnabled()) usedMem->display(sramFillLevel); if(procEvents0->isEnabled()) procEvents0->display(nSteps0); if(procEvents1->isEnabled()) procEvents1->display(nSteps1); if(procEvents2->isEnabled()) procEvents2->display(nSteps2); if(hitRate->isEnabled()) hitRate->display(hit_Rate); if(trgRate->isEnabled()) trgRate->display(triggerRate); // currFe->setEnabled(in_currFe>=0); // currFeLabel->setEnabled(in_currFe>=0); // if(in_currFe>=0) // currFe->display(in_currFe); // else // currFe->display(0); } switch(status){ case 1: //finished scan runButton->setEnabled(true); runButton->setText("Start Scan"); runButton->setStyleSheet(QString::fromUtf8("background-color: rgb(0, 255, 0);")); scanLabel->setEnabled(true); saveFile->setEnabled(true); rawFileName->setEnabled(saveFile->isChecked() && !appIndRawfile->isChecked()); rawFileBrowse->setEnabled(saveFile->isChecked() && !appIndRawfile->isChecked()); scanFileName->setEnabled(saveFile->isChecked()); scanFileBrowse->setEnabled(saveFile->isChecked()); appIndRawfile->setEnabled(saveFile->isChecked()); statusText->setText("idle"); statusText->repaint(); fileEnabled(saveFile->isChecked()); eventDisp->display(0); repaint(); emit enableBocAnaScan(true); break; case 2: //downloading histos from ROD statusText->setText("downloading data"); statusText->repaint(); repaint(); break; case 3: //writing histos from ROD statusText->setText("writing data"); statusText->repaint(); repaint(); break; case 4: //MAControl is at work statusText->setText("post-scan actions"); statusText->repaint(); repaint(); break; case 5: // fitting/downloading loop 0 statusText->setText("end loop 0"); statusText->repaint(); repaint(); break; case 6: // fitting/downloading loop 1 statusText->setText("end loop 1"); statusText->repaint(); repaint(); break; case 7: // fitting/downloading loop 2 statusText->setText("end loop 2"); statusText->repaint(); repaint(); break; case 8:// for multi-threaded scan mode statusText->setText("wait f. other grps"); statusText->repaint(); repaint(); break; case 9:// needed if observed Rod is not determinded (probl. due to error) statusText->setText("no Rod observed"); statusText->repaint(); repaint(); break; case 10:// rod initialisation statusText->setText("initialising scan"); statusText->repaint(); repaint(); break; case 11:// kept disabled from someone else statusText->setText("waiting..."); statusText->repaint(); repaint(); break; default: // scan on at least one ROD is still running statusText->setText("scanning"); statusText->repaint(); } return; } void PixScanPanel::rawBrowseButton_clicked(const char *in_path){ bool go_for_it = (in_path!=0); QString fname; if(!go_for_it){ QString old_path = QString::null; if(!rawFileName->text().isEmpty()){ old_path = rawFileName->text(); int pos = old_path.findRev("/"); if(pos>=0) old_path.remove(pos,old_path.length()-pos); } else{ // use default data path/name old_path = (((ConfString&)m_engine.getOptions()["paths"]["defDataPath"]).value()).c_str(); } QStringList filter; filter += "Raw data file (*.raw)"; filter += "Any file (*.*)"; Q3FileDialog fdia(old_path,QString::null,this,"newrootfile",TRUE); fdia.setCaption("Specify name of new raw data file"); fdia.setFilters(filter); fdia.setMode(Q3FileDialog::AnyFile); go_for_it = (fdia.exec() == QDialog::Accepted); if(go_for_it) fname = fdia.selectedFile(); } else fname = in_path; if(go_for_it){ if(fname.right(4)!=".raw" && fname!="") fname+=".raw"; disconnect( rawFileName, SIGNAL( textChanged(const QString&) ), this, SLOT( readFromHandles() ) ); rawFileName->setText(fname); ((ConfString&)m_scanCfg->config()["general"]["sourceRawFile"]).m_value = std::string(fname.latin1()); connect( rawFileName, SIGNAL( textChanged(const QString&) ), this, SLOT( readFromHandles() ) ); } return; } void PixScanPanel::browseButton_clicked(const char *in_path){ bool go_for_it = (in_path!=0); QString fname; if(!go_for_it){ QString old_path = QString::null; if(!scanFileName->text().isEmpty()){ old_path = scanFileName->text(); int pos = old_path.findRev("/"); if(pos>=0) old_path.remove(pos,old_path.length()-pos); } else{ // use default data path/name old_path = (((ConfString&)m_engine.getOptions()["paths"]["defDataPath"]).value()).c_str(); } QStringList filter; filter += "DB ROOT file (*.root)"; filter += "Any file (*.*)"; Q3FileDialog fdia(old_path,QString::null,this,"newrootfile",TRUE); fdia.setCaption("Specify name of new RootDB data-file"); fdia.setFilters(filter); fdia.setMode(Q3FileDialog::AnyFile); go_for_it = (fdia.exec() == QDialog::Accepted); if(go_for_it) fname = fdia.selectedFile(); } else fname = in_path; if(go_for_it){ if(fname.right(5)!=".root" && fname!="") fname+=".root"; scanFileName->setText(fname); if(m_currStdScanID==PixScan::SOURCE_SCAN){ appIndRawfile->setChecked(true); rawBrowseButton_clicked(fname.left(fname.length()-5).latin1()); } else if(m_currStdScanID>=0){ appIndRawfile->setChecked(false); rawBrowseButton_clicked(""); } // get list of scan labels and fill local memory of it m_scanLabels.clear(); try{ PixConfDBInterface *myDB = DBEdtEngine::openFile(fname.latin1(), false); DBInquire *root = myDB->readRootRecord(1); for(recordIterator it = root->recordBegin(); it!=root->recordEnd(); it++){ QString scname = (*it)->getDecName().c_str(); scname.remove(0,1); scname.remove(scname.length()-1,1); m_scanLabels.push_back(scname); } delete myDB; } catch(...){ m_scanLabels.clear(); } emit scanFileChanged(fname.latin1()); } return; } void PixScanPanel::fileEnabled(bool ena) { QString fname; if(ena){ fname = scanFileName->text(); browseButton_clicked(fname.latin1()); }else{ m_scanLabels.clear(); fname = ""; } emit scanFileChanged(fname.latin1()); } void PixScanPanel::loadLoopPts(int ID){ if(ID<0 || ID>MAX_LOOPS) return; if(LoopBox[ID]==0) return; int nPts=0; char line[2000]; double testDbl; bool isOK; QStringList filter; filter += "Text file (*.txt)"; filter += "Any file (*.*)"; Q3FileDialog fdia(QString::null,QString::null,this,"scanpts",TRUE); fdia.setCaption("Load ascii-list of scan points"); fdia.setFilters(filter); if(fdia.exec() == QDialog::Accepted){ FILE *in = fopen(fdia.selectedFile().latin1(),"r"); if(in!=0){ loopPtsBox[ID]->clear(); while(fgets(line,2000,in)!=0){ QString tmpstr = line; tmpstr.remove(tmpstr.length()-1,1);//remove trailing '\n' testDbl = tmpstr.toDouble(&isOK); if(isOK){ if(nPts==0) loopStart[ID]->setValue(testDbl); else loopStop[ID]->setValue(testDbl); nPts++; loopPtsBox[ID]->insertItem(tmpstr); } } loopStep[ID]->setValue(nPts); fclose(in); } else QMessageBox::warning(this,"loadInnerPts()","Error opening file "+fdia.selectedFile()); } // update from ListBox seems to fail occaisonally, do so explicitly readFromHandles(); return; } void PixScanPanel::updateCrateGrpSel(){ crateBox->clear(); rodBox->clear(); for(std::vector::iterator crIT = m_engine.getSTRodCrates().begin(); crIT != m_engine.getSTRodCrates().end(); crIT++) crateBox->insertItem((*crIT)->getName().c_str()); if(crateBox->count()==0) return; STRodCrate *crate = m_engine.getSTRodCrates()[crateBox->currentItem()]; for(int i=0; inGroups(); i++) rodBox->insertItem(crate->getGrpName(i).c_str()); } void PixScanPanel::observedRodChanged(int index) { m_engine.setObservedGroup(crateBox->currentItem(), index); } void PixScanPanel::observedCrateChanged(int index) { // show Rods belonging to observed Crate rodBox->clear(); if(crateBox->count()==0) return; STRodCrate *crate = m_engine.getSTRodCrates()[index]; for(int i=0; inGroups(); i++) rodBox->insertItem(crate->getGrpName(i).c_str()); m_engine.setObservedGroup(crateBox->currentItem(), rodBox->currentItem()); } void PixScanPanel::fixVCAL(bool doFix){ if(doFix) setVcal->setValue(0x1fff); else setVcal->setValue(0); } void PixScanPanel::VcalChanged(int value) { bool isFix = (value==0x1fff); disconnect( fixedVCALBox, SIGNAL( toggled(bool) ), this, SLOT( fixVCAL(bool) ) ); fixedVCALBox->setChecked(isFix); connect( fixedVCALBox, SIGNAL( toggled(bool) ), this, SLOT( fixVCAL(bool) ) ); } void PixScanPanel::fixSdelay(bool doFix) { if(doFix) strDelRange->setValue(0x1f); else strDelRange->setValue(5); } void PixScanPanel::SdelayChanged(int value) { bool isFix = (value==0x1f); disconnect( fixedSdelBox, SIGNAL( toggled(bool) ), this, SLOT( fixSdelay(bool) ) ); fixedSdelBox->setChecked(isFix); connect( fixedSdelBox, SIGNAL( toggled(bool) ), this, SLOT( fixSdelay(bool) ) ); } void PixScanPanel::openTableMenu(int row, int col, int button){ if(button==2 && col==3 && configParameterTable->text(row,1).find("VECTOR")){ // right mouse click and last column for VECTORS only Q3ComboTableItem *cb = dynamic_cast(configParameterTable->item(row,col)); QStringList stringList; if(cb!=0){ char line[2000]; QStringList filter; filter += "Text file (*.txt)"; filter += "Any file (*.*)"; Q3FileDialog fdia(QString::null,QString::null,this,"vecpts",TRUE); fdia.setCaption("Load ascii-list of vector entries"); fdia.setFilters(filter); if(fdia.exec() == QDialog::Accepted){ FILE *in = fopen(fdia.selectedFile().latin1(),"r"); if(in!=0){ while(fgets(line,2000,in)!=0){ QString tmpstr = line; tmpstr.remove(tmpstr.length()-1,1);//remove trailing '\n' stringList << tmpstr; } cb->setStringList(stringList); cb->setCurrentItem( 0 ); } readFromHandlersFromTable (row,col); } } } } void PixScanPanel::scanRunning(int type) { // initialise variables for rem. time estimation m_StatusUpdatesRecieved=0; m_MeasurementStartTime=-1; // adjust layout switch(type){ case 4: // test beam mode runButton->setEnabled(false); runButton->setText("TB Mode"); stepsLabel2->setEnabled(false); stepsLabel1->setEnabled(false); stepsLabel0->setEnabled(false); procEvents2->setEnabled(false); procEvents1->setEnabled(false); procEvents0->setEnabled(false); eventLabel->setEnabled(true); eventLabel->setText("Processed Events:"); usedMem->setEnabled(true); usedMemLabel->setEnabled(true); hitRate->setEnabled(true); hitRateLabel->setEnabled(true); trgRate->setEnabled(true); trgRateLabel->setEnabled(true); break; case 3: // source scan mode with scan runButton->setEnabled(true); runButton->setText("Abort"); stepsLabel2->setEnabled(true); stepsLabel1->setEnabled(true); stepsLabel0->setEnabled(true); procEvents2->setEnabled(true); procEvents1->setEnabled(true); procEvents0->setEnabled(true); eventLabel->setEnabled(true); eventLabel->setText("Processed Events:"); usedMem->setEnabled(true); usedMemLabel->setEnabled(true); hitRate->setEnabled(true); hitRateLabel->setEnabled(true); trgRate->setEnabled(true); trgRateLabel->setEnabled(true); break; case 2: // source scan mode w/o scan runButton->setEnabled(true); runButton->setText("Stop"); stepsLabel2->setEnabled(false); stepsLabel1->setEnabled(false); stepsLabel0->setEnabled(false); procEvents2->setEnabled(false); procEvents1->setEnabled(false); procEvents0->setEnabled(false); eventLabel->setEnabled(true); eventLabel->setText("Processed Events:"); usedMem->setEnabled(true); usedMemLabel->setEnabled(true); hitRate->setEnabled(true); hitRateLabel->setEnabled(true); trgRate->setEnabled(true); trgRateLabel->setEnabled(true); break; case 1: // strobe-induced scanning, mask display runButton->setEnabled(true); runButton->setText("Abort"); stepsLabel2->setEnabled(true); stepsLabel1->setEnabled(true); stepsLabel0->setEnabled(true); procEvents2->setEnabled(true); procEvents1->setEnabled(true); procEvents0->setEnabled(true); eventLabel->setEnabled(true); eventLabel->setText("Processed mask steps:"); usedMem->setEnabled(false); usedMemLabel->setEnabled(false); hitRate->setEnabled(false); hitRateLabel->setEnabled(false); trgRate->setEnabled(false); trgRateLabel->setEnabled(false); break; case 0: // strobe-induced scanning, no mask display default: runButton->setEnabled(true); runButton->setText("Abort"); stepsLabel2->setEnabled(true); stepsLabel1->setEnabled(true); stepsLabel0->setEnabled(true); procEvents2->setEnabled(true); procEvents1->setEnabled(true); procEvents0->setEnabled(true); eventLabel->setEnabled(true); eventLabel->setText("Time remaining: initialising..."); usedMem->setEnabled(false); usedMemLabel->setEnabled(false); hitRate->setEnabled(false); hitRateLabel->setEnabled(false); trgRate->setEnabled(false); trgRateLabel->setEnabled(false); break; } runButton->setStyleSheet(QString::fromUtf8("background-color: rgb(255, 0, 0);")); scanLabel->setEnabled(false); saveFile->setEnabled(false); scanFileName->setEnabled(false); scanFileBrowse->setEnabled(false); rawFileName->setEnabled(false); rawFileBrowse->setEnabled(false); appIndRawfile->setEnabled(false); statusText->setText("intialising scan"); statusText->repaint(); m_engine.setObservedGroup(crateBox->currentItem(), rodBox->currentItem()); } void PixScanPanel::toggleHitOccupancy() { if(totavfill->isChecked()) { hitoccfill->setChecked(false); hitocckeep->setChecked(false); } } void PixScanPanel::toggleToTAverage() { if(hitoccfill->isChecked()) { totavfill->setChecked(false); totavkeep->setChecked(false); } } void PixScanPanel::setFeReg(int regId){ if(regId>=0 && regIdsetEnabled(loopActive[regId]->isChecked() && loopType[regId]->currentText()=="FEI4_GR"); } void PixScanPanel::enableRawFileStuff(bool){ bool setEn = saveFile->isChecked() && !(appIndRawfile->isChecked()); rawFileName->setEnabled(setEn); rawFileBrowse->setEnabled(setEn); } void PixScanPanel::toggleClusHis(){ CSdatafill->toggle(); CSdatakeep->toggle(); CTOTdatafill->toggle(); CTOTdatakeep->toggle(); CSTOTdatafill->toggle(); CSTOTdatakeep->toggle(); STOTdatafill->toggle(); STOTdatakeep->toggle(); SLVL1datafill->toggle(); SLVL1datakeep->toggle(); NSeeddatafill->toggle(); NSeeddatakeep->toggle(); hitoccfill->toggle(); hitocckeep->toggle(); } void PixScanPanel::setEvtLabel(QString txt){ if(txt=="seconds") eventsLabel->setText("Seconds per scan point:"); else eventsLabel->setText("Events per scan point:"); }