#include #include #include #include #include "Pixel/pixelConfigStructures.h" #include "PixFe/PixFeI4A.h" #include "PixFe/PixFeI4B.h" #include "ConfigEditI4.h" #include "CfgMap.h" #include "SetAll.h" #include "ColPairSwitch.h" #include "RefWin.h" #include #include #include #include #include using namespace std; ConfigEditI4::ConfigEditI4(PixLib::Config* conf_in[3], QWidget* parent, Qt::WFlags fl) : QDialog(parent, fl) { setupUi(this); QObject::connect(tableGlobal_1, SIGNAL(cellPressed(int,int)), this, SLOT(globPressed1(int,int))); QObject::connect(tableGlobal_2, SIGNAL(cellPressed(int,int)), this, SLOT(globPressed2(int,int))); QObject::connect(tableGlobal_3, SIGNAL(cellPressed(int,int)), this, SLOT(globPressed3(int,int))); QObject::connect(tablePixel, SIGNAL(cellPressed(int,int)), this, SLOT(pixelPressed(int,int))); QObject::connect(tableColMask, SIGNAL(cellPressed(int,int)), this, SLOT(colMaskPressed(int,int))); QObject::connect(tableErrMask, SIGNAL(cellPressed(int,int)), this, SLOT(errMaskPressed(int,int))); int i,j,k; // store config and create FE to get mor info on reg. items for(i=0;i<3;i++) m_conf[i] = conf_in[i]; if(((ConfList&)(*m_conf[2])["general"]["FE_Flavour"]).sValue()=="FE_I4B") m_Fe = new PixFeI4B(0,0,"dummy",0); else m_Fe = new PixFeI4A(0,0,"dummy",0); // better access to global register tables m_nGtab=3; m_tableGlobal[0] = tableGlobal_1; m_tableGlobal[1] = tableGlobal_2; m_tableGlobal[2] = tableGlobal_3; // count valid FEs m_nFEs=0; for(int chip=0;chip<2;chip++){ Config &feconf = *(m_conf[chip]); Config &globreg = feconf.subConfig("GlobalRegister_0/GlobalRegister"); if(globreg["GlobalRegister"].name()!="__TrashConfGroup__") m_nFEs++; } // set up rest of GUI // set up global DAC table if(m_nFEs<=0) return; Config &feconf = *(m_conf[0]); ConfGroup &grgrp = feconf.subConfig("GlobalRegister_0/GlobalRegister")["GlobalRegister"]; int nreg = (int)(grgrp.size()-4)/3; // leave col masks (3x normal, 3x SELB) out, // this is dealt with separately, add two for GA and Config-flag QStringList hLabels; int istop=nreg-2, offs=2; const int widthFact=10; hLabels << " GA "; tableGlobal_1->setColumnWidth(0,widthFact*string(" GA ").length()); hLabels << "Config"; tableGlobal_1->setColumnWidth(1,widthFact*string("Config").length()); for(i=0;isetColumnWidth(i+offs,widthFact*grname.length()); }else{ istop++; offs--; } } tableGlobal_1->setColumnCount(hLabels.size()); tableGlobal_1->setHorizontalHeaderLabels(hLabels); hLabels.clear(); offs=istop; istop += nreg; for(i=offs;isetColumnWidth(i-offs,widthFact*grname.length()); }else{ istop++; offs--; } } tableGlobal_2->setColumnCount(hLabels.size()); tableGlobal_2->setHorizontalHeaderLabels(hLabels); hLabels.clear(); offs = istop; for(i=istop;i<(int)grgrp.size();i++){ std::string grname = grgrp[i].name(); grname.erase(0,std::string("GlobalRegister_").length()); if(grname.find("DisableColumnCnfg")==std::string::npos && grname.find("SELB")==std::string::npos && grname.find("ErrMask")==std::string::npos){ hLabels << grname.c_str(); tableGlobal_3->setColumnWidth(i-offs,widthFact*grname.length()); } else offs--; } tableGlobal_3->setColumnCount(hLabels.size()); tableGlobal_3->setHorizontalHeaderLabels(hLabels); for(k=0;ksetRowCount(m_nFEs); QStringList vLabels; for(i=0;isetVerticalHeaderLabels(vLabels); for(k=0;kcolumnCount();i++){ for(j=0;jrowCount();j++){ m_tableGlobal[k]->setItem(j,i,new QTableWidgetItem("???")); } } } // set up pixel DAC tables ConfGroup &trimgrp = feconf.subConfig("Trim_0/Trim")["Trim"]; ConfGroup &maskgrp = feconf.subConfig("PixelRegister_0/PixelRegister")["PixelRegister"]; nreg = (int)(trimgrp.size()+maskgrp.size()); tablePixel->setColumnCount(nreg); hLabels.clear(); for(i=0;i<(int)trimgrp.size();i++){ std::string prname = trimgrp[i].name(); prname.erase(0,std::string("Trim_").length()); hLabels << prname.c_str(); #ifdef WIN32 tablePixel->setColumnWidth(i,(int)__max(120.,(float)(widthFact*prname.length()))); #else tablePixel->setColumnWidth(i,(int)fmax(120.,(float)(widthFact*prname.length()))); #endif } for(i=0;i<(int)maskgrp.size();i++){ std::string prname = maskgrp[i].name(); prname.erase(0,std::string("PixelRegister_").length()); hLabels << prname.c_str(); #ifdef WIN32 tablePixel->setColumnWidth(i+trimgrp.size(),(int)__max(120.,(float)(widthFact*prname.length()))); #else tablePixel->setColumnWidth(i+trimgrp.size(),(int)fmax(120.,(float)(widthFact*prname.length()))); #endif } tablePixel->setHorizontalHeaderLabels(hLabels); tablePixel->setRowCount(m_nFEs); tablePixel->setVerticalHeaderLabels(vLabels); for(i=0;icolumnCount();i++){ for(j=0;jrowCount();j++){ tablePixel->setItem(j,i,new QTableWidgetItem("???")); } } tableColMask->setColumnCount(2); hLabels.clear(); hLabels << "DisableColumnCnfg"; hLabels << "SELB"; tableColMask->setHorizontalHeaderLabels(hLabels); tableColMask->setColumnWidth(0,400); tableColMask->setColumnWidth(1,400); tableColMask->setRowCount(m_nFEs); tableColMask->setVerticalHeaderLabels(vLabels); for(i=0;icolumnCount();i++){ for(j=0;jrowCount();j++){ tableColMask->setItem(j,i,new QTableWidgetItem("???")); } } tableErrMask->setColumnCount(1); hLabels.clear(); hLabels << "ErrMask"; tableErrMask->setHorizontalHeaderLabels(hLabels); tableErrMask->setColumnWidth(0,400); tableErrMask->setColumnWidth(1,400); tableErrMask->setRowCount(m_nFEs); tableErrMask->setVerticalHeaderLabels(vLabels); for(i=0;icolumnCount();i++){ for(j=0;jrowCount();j++){ tableErrMask->setItem(j,i,new QTableWidgetItem("???")); } } // set up calib table tableCalib->setColumnCount(11); hLabels.clear(); hLabels << "C_low"; hLabels << "C_med."; hLabels << "C_high"; hLabels << "VCAL grad."; hLabels << "VCAL offs."; hLabels << "VCAL quad."; hLabels << "VCAL cub."; hLabels << "CAL_low"; hLabels << "CAL_med."; hLabels << "CAL_high"; hLabels << "Delay cal."; tableCalib->setHorizontalHeaderLabels(hLabels); for(i=0;icolumnCount();i++) tableCalib->setColumnWidth(i,100); tableCalib->setRowCount(m_nFEs); tableCalib->setVerticalHeaderLabels(vLabels); for(i=0;icolumnCount();i++){ for(j=0;jrowCount();j++){ tableCalib->setItem(j,i,new QTableWidgetItem("???")); } } m_calNames.push_back("CInjLo"); m_calNames.push_back("CInjMed"); m_calNames.push_back("CInjHi"); m_calNames.push_back("VcalGradient1"); m_calNames.push_back("VcalGradient0"); m_calNames.push_back("VcalGradient2"); m_calNames.push_back("VcalGradient3"); m_calNames.push_back("skip"); m_calNames.push_back("skip"); m_calNames.push_back("skip"); m_calNames.push_back("DelayCalib"); // read values from config reset(); } ConfigEditI4::~ConfigEditI4(){ delete m_Fe; emit cfgDone(); } void ConfigEditI4::reset(){ QObject::disconnect(moduleID, SIGNAL(valueChanged(int)), this, SLOT(storeCfg())); QObject::disconnect(isActive, SIGNAL(toggled(bool)), this, SLOT(storeCfg())); QObject::disconnect(tableGlobal_1, SIGNAL(cellChanged(int,int)),this, SLOT(storeCfg())); QObject::disconnect(tableGlobal_2, SIGNAL(cellChanged(int,int)),this, SLOT(storeCfg())); QObject::disconnect(tableGlobal_3, SIGNAL(cellChanged(int,int)),this, SLOT(storeCfg())); QObject::disconnect(tablePixel, SIGNAL(cellChanged(int,int)),this, SLOT(storeCfg())); QObject::disconnect(tableColMask, SIGNAL(cellChanged(int,int)),this, SLOT(storeCfg())); QObject::disconnect(tableErrMask, SIGNAL(cellChanged(int,int)),this, SLOT(storeCfg())); QObject::disconnect(tableCalib, SIGNAL(cellChanged(int,int)),this, SLOT(storeCfg())); // get the module config Config &conf = *(m_conf[2]); if(conf["general"].name()!="__TrashConfGroup__"){ // read module ID if(conf["general"]["ModuleId"].name()!="__TrashConfObj__"){ moduleID->setValue((((ConfInt&)conf["general"]["ModuleId"]).getValue())); } // module is active? if(conf["general"]["Active"].name()!="__TrashConfObj__"){ isActive->setChecked(((ConfList&)conf["general"]["Active"]).sValue()=="TRUE"); } if(conf["general"]["FE_Flavour"].name()!="__TrashConfObj__"){ int currID=0; ConfList &cl = (ConfList&)conf["general"]["FE_Flavour"]; std::map::const_iterator mapIT; for(mapIT = cl.m_symbols.begin(); mapIT != cl.m_symbols.end();mapIT++){ feFlavour->insertItem(mapIT->first.c_str()); if(mapIT->first==cl.sValue()) currID = feFlavour->count()-1; } feFlavour->setCurrentItem(currID); } } // FE config via their tabs fillGlobTab(); fillPixlTab(); fillCalbTab(); QObject::connect(moduleID, SIGNAL(valueChanged(int)), this, SLOT(storeCfg())); QObject::connect(isActive, SIGNAL(toggled(bool)), this, SLOT(storeCfg())); QObject::connect(tableGlobal_1, SIGNAL(cellChanged(int,int)),this, SLOT(storeCfg())); QObject::connect(tableGlobal_2, SIGNAL(cellChanged(int,int)),this, SLOT(storeCfg())); QObject::connect(tableGlobal_3, SIGNAL(cellChanged(int,int)),this, SLOT(storeCfg())); QObject::connect(tablePixel, SIGNAL(cellChanged(int,int)),this, SLOT(storeCfg())); QObject::connect(tableColMask, SIGNAL(cellChanged(int,int)),this, SLOT(storeCfg())); QObject::connect(tableCalib, SIGNAL(cellChanged(int,int)),this, SLOT(storeCfg())); } void ConfigEditI4::storeCfg(){ // get the module config Config &conf = *(m_conf[2]); // set module ID if(conf["general"]["ModuleId"].name()!="__TrashConfObj__"){ ((ConfInt&)conf["general"]["ModuleId"]).setValue(moduleID->value()); } // set module active state if(conf["general"]["Active"].name()!="__TrashConfObj__"){ if(isActive->isChecked()) *((int *)((ConfList&)conf["general"]["Active"]).m_value)= (int)((ConfList&)conf["general"]["Active"]).m_symbols["TRUE"]; else *((int *)((ConfList&)conf["general"]["Active"]).m_value)= (int)((ConfList&)conf["general"]["Active"]).m_symbols["FALSE"]; } // FE config via their tabs storeGlobTab(); storePixlTab(); storeCalbTab(); // signal that the config. was altered emit cfgSaved((int) moduleID->value()); // refresh display reset(); } void ConfigEditI4::fillGlobTab(){ for (int Chip = 0; Chip < m_tableGlobal[0]->rowCount(); Chip++){ Config &feconf = *(m_conf[Chip]); if(feconf["Misc"]["Address"].name()!="__TrashConfObj__" && feconf["Misc"]["Address"].type()==ConfObj::INT) tableGlobal_1->item(Chip,0)->setText(QString::number(((ConfInt&)feconf["Misc"]["Address"]).getValue())); if(feconf["Misc"]["ConfigEnable"].name()!="__TrashConfObj__" && feconf["Misc"]["ConfigEnable"].type()==ConfObj::BOOL) tableGlobal_1->item(Chip,1)->setText((((ConfBool&)feconf["Misc"]["ConfigEnable"]).value() ? "ON":"OFF")); Config &globreg = feconf.subConfig("GlobalRegister_0/GlobalRegister"); for(int k=0;kcolumnCount();i++){ string objName = m_tableGlobal[k]->horizontalHeaderItem(i)->text().latin1(); int length; if(!m_Fe->getGlobRegisterLength(objName,length)) length=8; if(globreg["GlobalRegister"][objName].name()!="__TrashConfObj__" && globreg["GlobalRegister"][objName].type()==ConfObj::INT){ if(length==1) // 1-bit DAC, store as ON/OFF switch m_tableGlobal[k]->item(Chip,i)->setText((((ConfInt&)globreg["GlobalRegister"][objName]).getValue()==1)?"ON":"OFF"); else m_tableGlobal[k]->item(Chip,i)->setText(QString::number(((ConfInt&)globreg["GlobalRegister"][objName]).getValue())); } } } } } void ConfigEditI4::fillPixlTab(){ for (int Chip = 0; Chip < tablePixel->rowCount(); Chip++){ Config &feconf = *(m_conf[Chip]); // ColMask table // DisableColumnCnfg entry Config &globreg = feconf.subConfig("GlobalRegister_0/GlobalRegister"); QString CMstrg; int itot=0; for(int i=0;i<3;i++){ // have 3 ColMask registers QString cmName="DisableColumnCnfg"+QString::number(i); if(globreg["GlobalRegister"][cmName.latin1()].name()!="__TrashConfObj__" && globreg["GlobalRegister"][cmName.latin1()].type()==ConfObj::INT){ int val = ((ConfInt&)globreg["GlobalRegister"][cmName.latin1()]).getValue(); int length; if(!m_Fe->getGlobRegisterLength(string(cmName.latin1()),length)) length=16; for(int k=0;k>k)&0x1); itot++; if((itot%5)==0) CMstrg += " "; } } } tableColMask->item(Chip,0)->setText(CMstrg); // SELB entry itot=0; CMstrg=""; for(int i=0;i<3;i++){ // have 3 ColMask registers QString cmName="SELB"+QString::number(i); if(globreg["GlobalRegister"][cmName.latin1()].name()!="__TrashConfObj__" && globreg["GlobalRegister"][cmName.latin1()].type()==ConfObj::INT){ int val = ((ConfInt&)globreg["GlobalRegister"][cmName.latin1()]).getValue(); int length; if(!m_Fe->getGlobRegisterLength(string(cmName.latin1()),length)) length=16; for(int k=0;k>k)&0x1); itot++; if((itot%5)==0) CMstrg += " "; } } } tableColMask->item(Chip,1)->setText(CMstrg); // ErrMask entry itot=0; CMstrg=""; for(int i=0;i<2;i++){ // have 2 ErrMask registers QString cmName="ErrMask"+QString::number(i); if(globreg["GlobalRegister"][cmName.latin1()].name()!="__TrashConfObj__" && globreg["GlobalRegister"][cmName.latin1()].type()==ConfObj::INT){ int val = ((ConfInt&)globreg["GlobalRegister"][cmName.latin1()]).getValue(); int length; if(!m_Fe->getGlobRegisterLength(string(cmName.latin1()),length)) length=16; for(int k=0;k>k)&0x1); itot++; if((itot%4)==0) CMstrg += " "; } } } tableErrMask->item(Chip,0)->setText(CMstrg); // tablePixel ConfGroup &trimgrp = feconf.subConfig("Trim_0/Trim")["Trim"]; ConfGroup &maskgrp = feconf.subConfig("PixelRegister_0/PixelRegister")["PixelRegister"]; for(int i=0;icolumnCount();i++){ string objName = tablePixel->horizontalHeaderItem(i)->text().latin1(); if(trimgrp[objName].name()!="__TrashConfObj__" && trimgrp[objName].type()==ConfObj::MATRIX && ((ConfMatrix&)trimgrp[objName]).subtype()==ConfMatrix::U16){ // read trims ConfMatrix &mapobj = (ConfMatrix&)trimgrp[objName]; std::vector temp; ((ConfMask *)mapobj.m_value)->get(temp); std::vector::iterator it, itEnd=temp.end(); int cont=-999; for(it=temp.begin(); it!=itEnd; it++){ if(cont==-999) cont = (int) (*it); else if(cont!=(int)(*it)) cont=-1; } if(cont<0) tablePixel->item(Chip,i)->setText("map"); else tablePixel->item(Chip,i)->setText("ALL="+QString::number(cont)); } if(maskgrp[objName].name()!="__TrashConfObj__" && maskgrp[objName].type()==ConfObj::MATRIX && ((ConfMatrix&)maskgrp[objName]).subtype()==ConfMatrix::U1){ // read mask ConfMatrix &mapobj = (ConfMatrix&)maskgrp[objName]; std::vector temp; ((ConfMask *)mapobj.m_value)->get(temp); std::vector::iterator it, itEnd=temp.end(); int cont=-999; for(it=temp.begin(); it!=itEnd; it++){ if(cont==-999) cont = (int) (*it); else if(cont!=(int)(*it)) cont=-1; } if(cont<0) tablePixel->item(Chip,i)->setText("map"); else tablePixel->item(Chip,i)->setText("ALL="+QString::number(cont)); } } } } void ConfigEditI4::fillCalbTab(){ QString Calstr; float cfac, readVal; int i; bool isOK; for (int Chip = 0; Chip < tableCalib->rowCount(); Chip++){ Config &feconf = *(m_conf[Chip]); if(feconf["Misc"].name()!="__TrashConfGroup__"){ for(i=0;i<(int)m_calNames.size();i++){ if(m_calNames[i]!="skip"){ readVal = -1; if(feconf["Misc"][m_calNames[i]].name()!="__TrashConfObj__" && feconf["Misc"][m_calNames[i]].type()==ConfObj::FLOAT) readVal = ((ConfFloat&)feconf["Misc"][m_calNames[i]]).value(); if(fabs(readVal)>.01) Calstr.sprintf("%.4f",readVal); else if(readVal!=0) Calstr.sprintf("%.3e",readVal); else Calstr = "0"; tableCalib->item(Chip,i)->setText(Calstr); } } } cfac = tableCalib->item(Chip,3)->text().toFloat(&isOK)*tableCalib->item(Chip,0)->text().toFloat(&isOK) / 0.160218; Calstr.sprintf("%.2f",cfac); tableCalib->item(Chip,7)->setText(Calstr); cfac = tableCalib->item(Chip,3)->text().toFloat(&isOK)*tableCalib->item(Chip,1)->text().toFloat(&isOK) / 0.160218; Calstr.sprintf("%.2f",cfac); tableCalib->item(Chip,8)->setText(Calstr); cfac = tableCalib->item(Chip,3)->text().toFloat(&isOK)*tableCalib->item(Chip,2)->text().toFloat(&isOK) / 0.160218; Calstr.sprintf("%.2f",cfac); tableCalib->item(Chip,9)->setText(Calstr); } } void ConfigEditI4::storeGlobTab(){ for (int Chip = 0; Chip < m_tableGlobal[0]->rowCount(); Chip++){ Config &feconf = *(m_conf[Chip]); if(feconf["Misc"]["Address"].name()!="__TrashConfObj__" && feconf["Misc"]["Address"].type()==ConfObj::INT) ((ConfInt&)feconf["Misc"]["Address"]).setValue(tableGlobal_1->item(Chip,0)->text().toInt()); if(feconf["Misc"]["ConfigEnable"].name()!="__TrashConfObj__" && feconf["Misc"]["ConfigEnable"].type()==ConfObj::BOOL) ((ConfBool&)feconf["Misc"]["ConfigEnable"]).m_value = (tableGlobal_1->item(Chip,1)->text()=="ON"); Config &globreg = feconf.subConfig("GlobalRegister_0/GlobalRegister"); for(int k=0;kcolumnCount();i++){ string objName = m_tableGlobal[k]->horizontalHeaderItem(i)->text().latin1(); if(globreg["GlobalRegister"][objName].name()!="__TrashConfObj__" && globreg["GlobalRegister"][objName].type()==ConfObj::INT){ if(m_tableGlobal[k]->item(Chip,i)->text()=="ON") ((ConfInt&)globreg["GlobalRegister"][objName]).setValue(1); else if(m_tableGlobal[k]->item(Chip,i)->text()=="OFF") ((ConfInt&)globreg["GlobalRegister"][objName]).setValue(0); else ((ConfInt&)globreg["GlobalRegister"][objName]).setValue(m_tableGlobal[k]->item(Chip,i)->text().toInt()); } } } } } void ConfigEditI4::storePixlTab(){ // store col masks for (int Chip = 0; Chip < tableColMask->rowCount(); Chip++){ Config &feconf = *(m_conf[Chip]); Config &globreg = feconf.subConfig("GlobalRegister_0/GlobalRegister"); QString DACstr; int itot=0, offs=0; for(int i=0;i<3;i++){ // have 3 ColMask registers QString cmName="DisableColumnCnfg"+QString::number(i); if(globreg["GlobalRegister"][cmName.latin1()].name()!="__TrashConfObj__" && globreg["GlobalRegister"][cmName.latin1()].type()==ConfObj::INT){ int length; if(!m_Fe->getGlobRegisterLength(string(cmName.latin1()),length)) length=16; int val=0; for(int k=0;kitem(Chip,0)->text()[ichar]; int bitval = DACstr.toInt(); val += (bitval << k); itot++; } ((ConfInt&)globreg["GlobalRegister"][cmName.latin1()]).setValue(val); offs += length; } } } for (int Chip = 0; Chip < tableColMask->rowCount(); Chip++){ Config &feconf = *(m_conf[Chip]); Config &globreg = feconf.subConfig("GlobalRegister_0/GlobalRegister"); QString DACstr; int itot=0, offs=0; for(int i=0;i<3;i++){ // have 3 ColMask registers QString cmName="SELB"+QString::number(i); if(globreg["GlobalRegister"][cmName.latin1()].name()!="__TrashConfObj__" && globreg["GlobalRegister"][cmName.latin1()].type()==ConfObj::INT){ int length; if(!m_Fe->getGlobRegisterLength(string(cmName.latin1()),length)) length=16; int val=0; for(int k=0;kitem(Chip,1)->text()[ichar]; int bitval = DACstr.toInt(); val += (bitval << k); itot++; } ((ConfInt&)globreg["GlobalRegister"][cmName.latin1()]).setValue(val); offs += length; } } } // store error mask for (int Chip = 0; Chip < tableErrMask->rowCount(); Chip++){ Config &feconf = *(m_conf[Chip]); Config &globreg = feconf.subConfig("GlobalRegister_0/GlobalRegister"); QString DACstr; int itot=0, offs=0; for(int i=0;i<2;i++){ // have 2 ErrMask registers QString cmName="ErrMask"+QString::number(i); if(globreg["GlobalRegister"][cmName.latin1()].name()!="__TrashConfObj__" && globreg["GlobalRegister"][cmName.latin1()].type()==ConfObj::INT){ int length; if(!m_Fe->getGlobRegisterLength(string(cmName.latin1()),length)) length=16; int val=0; for(int k=0;kitem(Chip,0)->text()[ichar]; int bitval = DACstr.toInt(); val += (bitval << k); itot++; } ((ConfInt&)globreg["GlobalRegister"][cmName.latin1()]).setValue(val); offs += length; } } } // pixel registers already stored right after editing } void ConfigEditI4::storeCalbTab(){ for (int Chip = 0; Chip < tableCalib->rowCount(); Chip++){ Config &feconf = *(m_conf[Chip]); for(int i=0;i<(int)m_calNames.size();i++){ if(m_calNames[i]!="skip" && feconf["Misc"][m_calNames[i]].name()!="__TrashConfObj__" && feconf["Misc"][m_calNames[i]].type()==ConfObj::FLOAT) ((ConfFloat&)feconf["Misc"][m_calNames[i]]).m_value = tableCalib->item(Chip,i)->text().toFloat(); } } } void ConfigEditI4::globPressed(int row, int col, int table){ if(QApplication::mouseButtons()!=Qt::RightButton) return; // only process right clicks QTableWidget *GlobalTable = m_tableGlobal[table]; int i; if(GlobalTable->item(row,col)->text()=="ON" || GlobalTable->item(row,col)->text()=="OFF"){ // Q3PopupMenu tablemenu(this,"Table menu"); // tablemenu.insertItem("Toggle",0); // tablemenu.insertItem("All ON",1); // tablemenu.insertItem("All OFF",2); switch(0){//tablemenu.exec(QCursor::pos())){ case 0: default: if(GlobalTable->item(row,col)->text()=="ON") GlobalTable->item(row,col)->setText("OFF"); else GlobalTable->item(row,col)->setText("ON"); break; case 1: for(i=0;irowCount();i++) GlobalTable->item(i,col)->setText("ON"); break; case 2: for(i=0;irowCount();i++) GlobalTable->item(i,col)->setText("OFF"); break; } } else if(table==0 && col==0){ SetAll getval(this); getval.SpinBox->setMinValue(0); getval.SpinBox->setMaxValue(15); getval.SpinBox->setValue(GlobalTable->item(row,col)->text().toInt()); getval.LineEdit->hide(); if(getval.exec()) GlobalTable->item(row,col)->setText(QString::number(getval.SpinBox->value())); } else{ // Q3PopupMenu tablemenu(this,"Table menu"); // tablemenu.insertItem("Set to value",0); // tablemenu.insertItem("Set entire column",1); // tablemenu.insertItem("Increment (all chips)",2); // tablemenu.insertItem("Decrement (all chips)",3); SetAll getval(this); int length; string objName = GlobalTable->horizontalHeaderItem(col)->text().latin1(); if(m_Fe->getGlobRegisterLength(objName,length)) getval.SpinBox->setMaxValue((int)(pow(2,(double)length)-1.)); else getval.SpinBox->setMaxValue(255); getval.SpinBox->setValue(GlobalTable->item(row,col)->text().toInt()); getval.LineEdit->hide(); int incr_val = 1; int choice=0;//tablemenu.exec(QCursor::pos()); switch(choice){ case 0:{ if(getval.exec()) GlobalTable->item(row,col)->setText(QString::number(getval.SpinBox->value())); break;} case 1:{ if(getval.exec()){ for(int i=0;irowCount();i++) GlobalTable->item(i,col)->setText(QString::number(getval.SpinBox->value())); } break;} case 3: incr_val = -1; case 2:{ for(int i=0;irowCount();i++){ bool isOK; int myval = GlobalTable->item(i,col)->text().toInt(&isOK); if(isOK){ myval+=incr_val; GlobalTable->item(i,col)->setText(QString::number(myval)); } } break;} default: break; } } storeCfg(); } void ConfigEditI4::pixelPressed(int row, int col){ if(QApplication::mouseButtons()!=Qt::RightButton) return; // only process right clicks Config &feconf = *(m_conf[0]); ConfGroup &trimgrp = feconf.subConfig("Trim_0/Trim")["Trim"]; Q3PopupMenu tablemenu(this,"Table menu"); tablemenu.insertItem("Set this chip to value",0); tablemenu.insertItem("Set all chips to value",1); tablemenu.insertItem("Load file (this chip)",2); tablemenu.insertItem("Load file (all chips)",3); // tablemenu.insertItem("Increment (all chips)",4); // tablemenu.insertItem("Decrement (all chips)",5); // tablemenu.insertItem("Inecrement by...(all chips)",6); tablemenu.insertItem("Display/Edit",7); if(col>=trimgrp.size()){ tablemenu.insertItem("Copy from other mask",8); tablemenu.insertItem("Invert",9); } switch(tablemenu.exec(QCursor::pos())){ case 0: SetConstPix(row,col, false); break; case 1: SetConstPix(row,col,true); break; case 2: LoadPTableFile(row,col,false); break; case 3: LoadPTableFile(row,col,true); break; case 4: ShiftPTable(row,col,1); break; case 5: ShiftPTable(row,col,-1); break; case 6:{ SetAll sti(this); sti.setCaption("Set T/FDAC increment"); sti.TextLabel1->setText("Set T/FDAC increment"); sti.SpinBox->setMinValue(-127); if(sti.exec()){ ShiftPTable(row,col,sti.SpinBox->value()); } break;} case 7: DisplayMap(row,col); break; case 8: CopyMap(row,col); break; case 9: InvertMap(row,col); break; default: break; } //storeCfg(); reset(); } void ConfigEditI4::colMaskPressed(int row, int col){ if(QApplication::mouseButtons()!=Qt::RightButton) return; // only process right clicks const int nbut=40; QString DACstr; ColPairSwitch cps(this,0, nbut); std::vector buttons = cps.getButtons(); for(int i=0;iitem(row,col)->text()[i+2*(i/5)]; bool isOK; bool CPsw= (bool)DACstr.toInt(&isOK); buttons[i]->setOn(CPsw); buttons[i]->setState(); } if(cps.exec()==1){ DACstr=""; for(int i=0;iisOn())); if(((i+1)%5)==0) DACstr += " "; } tableColMask->item(row,col)->setText(DACstr); } storeCfg(); } void ConfigEditI4::errMaskPressed(int row, int col){ if(QApplication::mouseButtons()!=Qt::RightButton) return; // only process right clicks const int nbut=32; QString DACstr; ColPairSwitch cps(this,0, nbut); std::vector buttons = cps.getButtons(); for(int i=0;iitem(row,col)->text()[i+2*(i/4)]; bool isOK; bool CPsw= (bool)DACstr.toInt(&isOK); buttons[i]->setOn(CPsw); buttons[i]->setState(); } if(cps.exec()==1){ DACstr=""; for(int i=0;iisOn())); if(((i+1)%4)==0) DACstr += " "; } tableErrMask->item(row,col)->setText(DACstr); } storeCfg(); } void ConfigEditI4::LoadPTableFile(int, int, bool){//int row, int col, bool all){ QMessageBox::warning(this,"ConfigEditI4::LoadPTableFile","Function not yet implemented"); } void ConfigEditI4::ShiftPTable(int, int, int){//int row, int col, int amount){ QMessageBox::warning(this,"ConfigEditI4::ShiftPTable","Function not yet implemented"); } void ConfigEditI4::DisplayMap(int row, int col){ string objName = tablePixel->horizontalHeaderItem(col)->text().latin1(); // maximum setting int maxval=1; if(col<2 && !m_Fe->getTrimMax(objName,maxval)) maxval=31; // variable to transfer data to CfgMap unsigned int nCol = 1; unsigned int nRow = 1; uint **mydata = 0; Config &feconf = *(m_conf[row]); if(col<2){ // trim DACs Config &trimreg = feconf.subConfig("Trim_0/Trim"); if(trimreg["Trim"].name()!="__TrashConfGroup__" && trimreg["Trim"][objName].name()!="__TrashConfObj__" && trimreg["Trim"][objName].type()==ConfObj::MATRIX && ((ConfMatrix&)trimreg["Trim"][objName]).subtype()==ConfMatrix::U16){ ConfMatrix &mapobj = (ConfMatrix&)trimreg["Trim"][objName]; std::vector temp; ((ConfMask *)mapobj.m_value)->get(temp); nCol = ((ConfMask *)mapobj.m_value)->get().size(); nRow = ((ConfMask *)mapobj.m_value)->get().front().size(); mydata = new uint*[nCol]; for(uint k=0;k::iterator it, itEnd=temp.end(); int i=0; for(it=temp.begin(); it!=itEnd; it++){ mydata[i%nCol][nRow-1-i/nCol] = (uint)(*it); i++; } } } else { // masks Config &pixreg = feconf.subConfig("PixelRegister_0/PixelRegister"); if(pixreg["PixelRegister"].name()!="__TrashConfGroup__" && pixreg["PixelRegister"][objName].name()!="__TrashConfObj__" && pixreg["PixelRegister"][objName].type()==ConfObj::MATRIX && ((ConfMatrix&)pixreg["PixelRegister"][objName]).subtype()==ConfMatrix::U1){ ConfMatrix &mapobj = (ConfMatrix&)pixreg["PixelRegister"][objName]; std::vector temp; ((ConfMask *)mapobj.m_value)->get(temp); nCol = ((ConfMask *)mapobj.m_value)->get().size(); nRow = ((ConfMask *)mapobj.m_value)->get().front().size(); mydata = new uint*[nCol]; for(uint k=0;k::iterator it, itEnd=temp.end(); int i=0; for(it=temp.begin(); it!=itEnd; it++){ mydata[i%nCol][nRow-1-i/nCol] = (uint)(*it); i++; } } } if(mydata!=0){ CfgMap MapToShow(mydata, maxval, nCol, nRow, this, 0, 0, ModName->text().latin1(), row, 6, 2); MapToShow.setGangedButton->hide(); MapToShow.setIntGangedButton->hide(); MapToShow.setLongButton->hide(); if(MapToShow.exec()==QDialog::Accepted){ // store changes in config objects if(col<2){ // trim DACs Config &trimreg = feconf.subConfig("Trim_0/Trim"); if(trimreg["Trim"].name()!="__TrashConfGroup__" && trimreg["Trim"][objName].name()!="__TrashConfObj__" && trimreg["Trim"][objName].type()==ConfObj::MATRIX && ((ConfMatrix&)trimreg["Trim"][objName]).subtype()==ConfMatrix::U16){ ConfMatrix &mapobj = (ConfMatrix&)trimreg["Trim"][objName]; std::vector temp; ((ConfMask *)mapobj.m_value)->get(temp); std::vector::iterator it, itEnd=temp.end(); int i=0; for(it=temp.begin(); it!=itEnd; it++){ (*it) = (unsigned short int)mydata[i%nCol][nRow-1-i/nCol]; i++; } ((ConfMask *)mapobj.m_value)->set(temp); } } else { // masks Config &pixreg = feconf.subConfig("PixelRegister_0/PixelRegister"); if(pixreg["PixelRegister"].name()!="__TrashConfGroup__" && pixreg["PixelRegister"][objName].name()!="__TrashConfObj__" && pixreg["PixelRegister"][objName].type()==ConfObj::MATRIX && ((ConfMatrix&)pixreg["PixelRegister"][objName]).subtype()==ConfMatrix::U1){ ConfMatrix &mapobj = (ConfMatrix&)pixreg["PixelRegister"][objName]; std::vector temp; ((ConfMask *)mapobj.m_value)->get(temp); std::vector::iterator it, itEnd=temp.end(); int i=0; for(it=temp.begin(); it!=itEnd; it++){ (*it) = (bool)mydata[i%nCol][nRow-1-i/nCol]; i++; } ((ConfMask *)mapobj.m_value)->set(temp); } } emit cfgSaved((int) moduleID->value()); fillPixlTab(); } for(uint k=0;khorizontalHeaderItem(col)->text().latin1(); SetAll getval(this); // maximum setting int maxval=1; if(col<2 && !m_Fe->getTrimMax(objName,maxval)) maxval=31; getval.SpinBox->setMaxValue(maxval); // if all pixels set to same value already propose this as starting point int pos; bool isOK; QString tabtxt = tablePixel->item(row,col)->text(); getval.SpinBox->setValue(0); if((pos=tabtxt.find("ALL="))==0){ tabtxt.remove(0,4); int value = tabtxt.toInt(&isOK); if(isOK) getval.SpinBox->setValue(value); } // show user the panel if(getval.exec()){ int rmin = row, rmax=row+1; if(all){ rmin=0; rmax=m_nFEs; } for(int myrow=rmin;myrow temp; ((ConfMask *)mapobj.m_value)->get(temp); std::vector::iterator it, itEnd=temp.end(); for(it=temp.begin(); it!=itEnd; it++) (*it) = (unsigned short int)getval.SpinBox->value(); ((ConfMask *)mapobj.m_value)->set(temp); } } else { // masks Config &pixreg = feconf.subConfig("PixelRegister_0/PixelRegister"); if(pixreg["PixelRegister"].name()!="__TrashConfGroup__" && pixreg["PixelRegister"][objName].name()!="__TrashConfObj__" && pixreg["PixelRegister"][objName].type()==ConfObj::MATRIX && ((ConfMatrix&)pixreg["PixelRegister"][objName]).subtype()==ConfMatrix::U1){ ConfMatrix &mapobj = (ConfMatrix&)pixreg["PixelRegister"][objName]; std::vector temp; ((ConfMask *)mapobj.m_value)->get(temp); std::vector::iterator it, itEnd=temp.end(); for(it=temp.begin(); it!=itEnd; it++) (*it) = (bool)getval.SpinBox->value(); ((ConfMask *)mapobj.m_value)->set(temp); } } } emit cfgSaved((int) moduleID->value()); } reset(); } void ConfigEditI4::CopyMap(int row,int col){ Config &feconf = *(m_conf[row]); Config &trimreg = feconf.subConfig("Trim_0/Trim"); Config &pixreg = feconf.subConfig("PixelRegister_0/PixelRegister"); if(colhorizontalHeaderItem(col)->text().latin1(); // select mask from which to copy RefWin mlist(0, this,"masklist", 0, 0, 100); mlist.SelectorLabel->hide(); mlist.DatSel->hide(); mlist.FuncselLabel->setText("select a mask to copy from:"); mlist.setCaption(("Select a mask to be copied into "+objName).c_str()); disconnect( mlist.OKButt, SIGNAL( clicked() ), &mlist, SLOT( RDAccept() ) ); connect( mlist.OKButt, SIGNAL( clicked() ), &mlist, SLOT( accept() ) ); for(int i=0;i<(int)pixreg["PixelRegister"].size();i++){ std::string prname = pixreg["PixelRegister"][i].name(); prname.erase(0,std::string("PixelRegister_").length()); if(prname != objName) mlist.FuncSel->insertItem(prname.c_str()); } if(mlist.FuncSel->count()>0){ if(mlist.exec()){ std::string prname = (mlist.FuncSel->currentText()).latin1(); int rmin = row, rmax=row+1; if(1){//all){ rmin=0; rmax=m_nFEs; } for(int myrow=rmin;myrow tovec, fromvec; ((ConfMask *)frommap.m_value)->get(fromvec); ((ConfMask *)tomap.m_value)->get(tovec); std::vector::iterator itf, itt, itEnd=fromvec.end(); for(itf=fromvec.begin(), itt=tovec.begin(); itf!=itEnd; itf++, itt++) (*itt) = (*itf); ((ConfMask *)tomap.m_value)->set(tovec); } } } } emit cfgSaved((int) moduleID->value()); reset(); } void ConfigEditI4::InvertMap(int row,int col){ Config &feconf = *(m_conf[row]); Config &trimreg = feconf.subConfig("Trim_0/Trim"); if(colhorizontalHeaderItem(col)->text().latin1(); int rmin = row, rmax=row+1; if(1){//all){ rmin=0; rmax=m_nFEs; } for(int myrow=rmin;myrow temp; ((ConfMask *)mapobj.m_value)->get(temp); std::vector::iterator it, itEnd=temp.end(); for(it=temp.begin(); it!=itEnd; it++) (*it) = !(*it); ((ConfMask *)mapobj.m_value)->set(temp); } } emit cfgSaved((int) moduleID->value()); reset(); }