diff --git a/ClassDigitizer2Gen.cpp b/ClassDigitizer2Gen.cpp index f4b08b9..4de19cf 100644 --- a/ClassDigitizer2Gen.cpp +++ b/ClassDigitizer2Gen.cpp @@ -45,6 +45,9 @@ void Digitizer2Gen::Initialization(){ VGASetting[index] = PHA::VGA::VGAGain; LVDSSettings[index] = PHA::LVDS::AllSettings; } + for( int idx = 0; idx < 16; idx ++){ + InputDelay[idx] = PHA::GROUP::InputDelay; + } //build map for( int i = 0; i < (int) PHA::DIG::AllSettings.size(); i++) boardMap[PHA::DIG::AllSettings[i].GetPara()] = i; @@ -131,7 +134,7 @@ std::string Digitizer2Gen::ReadValue(const Reg para, int ch_index, bool verbose case TYPE::DIG : boardSettings[index].SetValue(ans); break; case TYPE::VGA : VGASetting[ch_index].SetValue(ans); break; case TYPE::LVDS: LVDSSettings[ch_index][index].SetValue(ans);break; - case TYPE::GROUP: break; //^ GROUP is not implemented + case TYPE::GROUP: InputDelay[ch_index].SetValue(ans); break; } //printf("%s | %s | index %d | %s \n", para.GetFullPara(ch_index).c_str(), ans.c_str(), index, chSettings[ch_index][index].GetValue().c_str()); @@ -183,7 +186,7 @@ bool Digitizer2Gen::WriteValue(const Reg para, std::string value, int ch_index){ // boardSettings[index].GetValue().c_str()); }break; case TYPE::LVDS : LVDSSettings[ch_index][index].SetValue(value); break; - case TYPE::GROUP : break; + case TYPE::GROUP : InputDelay[ch_index].SetValue(value); break; } } @@ -255,6 +258,9 @@ int Digitizer2Gen::OpenDigitizer(const char * url){ VGASetting[index] = PHA::VGA::VGAGain; LVDSSettings[index] = PHA::LVDS::AllSettings; } + for( int idx = 0; idx < 16; idx ++ ){ + InputDelay[idx] = PHA::GROUP::InputDelay; + } //build map for( int i = 0; i < (int) PHA::DIG::AllSettings.size(); i++) boardMap[PHA::DIG::AllSettings[i].GetPara()] = i; @@ -271,6 +277,9 @@ int Digitizer2Gen::OpenDigitizer(const char * url){ VGASetting[index] = PSD::VGA::VGAGain; LVDSSettings[index] = PSD::LVDS::AllSettings; } + for( int idx = 0; idx < 16; idx ++ ){ + InputDelay[idx] = PSD::GROUP::InputDelay; + } //build map for( int i = 0; i < (int) PSD::DIG::AllSettings.size(); i++) boardMap[PSD::DIG::AllSettings[i].GetPara()] = i; @@ -1070,6 +1079,12 @@ void Digitizer2Gen::PrintBoardSettings(){ } } + for(int idx = 0; idx < 16 ; idx ++ ){ + printf("%-45s %d %s\n", InputDelay[idx].GetFullPara(idx).c_str(), + InputDelay[idx].ReadWrite(), + InputDelay[idx].GetValue().c_str()); + } + for( int i = 0; i < (int) LVDSSettings[0].size(); i++){ for( int index = 0; index < 4; index++){ if( LVDSSettings[index][i].ReadWrite() == RW::WriteOnly) continue; @@ -1129,6 +1144,8 @@ void Digitizer2Gen::ReadAllSettings(){ if( ModelName == "VX2745") for(int i = 0; i < 4 ; i ++) ReadValue(VGASetting[i], i); + for( int idx = 0; idx < 16; idx++) ReadValue(InputDelay[idx], idx, false); + for( int index = 0; index < 4; index++){ for( int i = 0; i < (int) LVDSSettings[index].size(); i++){ if( LVDSSettings[index][i].ReadWrite() == RW::WriteOnly) continue; @@ -1185,6 +1202,20 @@ int Digitizer2Gen::SaveSettingsToFile(const char * saveFileName, bool setReadOnl count ++; } + for( int idx = 0; idx < 16; idx ++){ + totCount ++; + if( InputDelay[idx].GetValue() == "" ) { + printf(" No value for %s \n", InputDelay[idx].GetPara().c_str()); + continue; + } + fprintf(saveFile, "%-45s!%d!%4d!%s\n", InputDelay[idx].GetFullPara(idx).c_str(), + InputDelay[idx].ReadWrite(), + 9050 + idx, + InputDelay[idx].GetValue().c_str()); + count ++; + + } + if( ModelName == "VX2745" && FPGAType == DPPType::PHA) { for(int i = 0; i < 4 ; i ++){ totCount ++; @@ -1316,8 +1347,10 @@ bool Digitizer2Gen::LoadSettingsFromFile(const char * loadFileName){ //printf("%s|%d|%d|%s\n", boardSettings[id-8000].GetFullPara().c_str(), // boardSettings[id-8000].ReadWrite(), id, // boardSettings[id-8000].GetValue().c_str()); - }else{ // vga + }else if ( 9000 <= id && id < 9050){ // vga VGASetting[id - 9000].SetValue(value); + }else{ // group + InputDelay[id - 9050].SetValue(value); } //printf("%s|%s|%d|%s|\n", para, readWrite, id, value); if( std::strcmp(readWrite, "2") == 0 && isConnected) WriteValue(para, value, false); @@ -1340,10 +1373,11 @@ bool Digitizer2Gen::LoadSettingsFromFile(const char * loadFileName){ std::string Digitizer2Gen::GetSettingValue(const Reg para, unsigned int ch_index) { int index = FindIndex(para); switch (para.GetType()){ - case TYPE::DIG: return boardSettings[index].GetValue(); - case TYPE::CH: return chSettings[ch_index][index].GetValue(); - case TYPE::VGA: return VGASetting[ch_index].GetValue(); - case TYPE::LVDS: return LVDSSettings[ch_index][index].GetValue(); + case TYPE::DIG: return boardSettings[index].GetValue(); + case TYPE::CH: return chSettings[ch_index][index].GetValue(); + case TYPE::VGA: return VGASetting[ch_index].GetValue(); + case TYPE::LVDS: return LVDSSettings[ch_index][index].GetValue(); + case TYPE::GROUP: return InputDelay[ch_index].GetValue(); default : return "invalid"; } return "no such parameter"; diff --git a/ClassDigitizer2Gen.h b/ClassDigitizer2Gen.h index 8c2a5c8..e883228 100644 --- a/ClassDigitizer2Gen.h +++ b/ClassDigitizer2Gen.h @@ -12,6 +12,7 @@ #define MaxOutFileSize 2*1024*1024*1024 //2GB //#define MaxOutFileSize 20*1024*1024 //20MB #define MaxNumberOfChannel 64 +#define MaxNumberOfGroup 16 #include "DigiParameters.h" @@ -62,6 +63,7 @@ class Digitizer2Gen { std::vector chSettings[MaxNumberOfChannel]; std::vector LVDSSettings[4]; Reg VGASetting[4]; + Reg InputDelay[16]; std::map boardMap; std::map LVDSMap; diff --git a/DigiParameters.h b/DigiParameters.h index 702cd2c..f33e4c8 100644 --- a/DigiParameters.h +++ b/DigiParameters.h @@ -70,7 +70,7 @@ class Reg { case TYPE::CH:{ std::string haha = "/par/"; if( isCmd ){ - haha = "/cmd/"; + haha = "/cmd/"; // for SendChSWTrigger, not in GUI } if( ch_index == -1 ){ return "/ch/0..63" + haha + name; @@ -94,7 +94,7 @@ class Reg { }; break; case TYPE::GROUP:{ if( ch_index == -1 ){ - return "/group/0..16/par/" + name; + return "/group/0..15/par/" + name; }else{ return "/group/" + std::to_string(ch_index) + "/par/" + name; } @@ -173,7 +173,6 @@ namespace PHA{ const Reg ErrorFlags ("ErrorFlags", RW::ReadOnly, TYPE::DIG, {}, ANSTYPE::BINARY, "byte"); const Reg BoardReady ("BoardReady", RW::ReadOnly, TYPE::DIG, {{"True", "No Error"}, {"False", "Error"}}); - //^ not impletemented const Reg SPFLinkPresence ("SPFLinkPresence", RW::ReadOnly, TYPE::DIG, {{"True", "Inserted"}, {"False", "Disconnected"}}); const Reg SPFLinkActive ("SPFLinkActive", RW::ReadOnly, TYPE::DIG, {{"True", "Active"}, {"False", "Deactive"}}); const Reg SPFLinkProtocol ("SPFLinkProtocal", RW::ReadOnly, TYPE::DIG, {{"Eth1G", "1 GB/s"}, {"Eth10G", "10 GB/s"}, {"CONET2", "Conet2"}}); @@ -353,6 +352,9 @@ namespace PHA{ SpeedSensFan2 , ErrorFlags , BoardReady , + // SPFLinkPresence , + // SPFLinkActive , + // SPFLinkProtocol , ClockSource , IO_Level , StartSource , @@ -402,7 +404,7 @@ namespace PHA{ } namespace GROUP{ - const Reg InputDelay ("InputDelay", RW::ReadWrite, TYPE::GROUP, {}, ANSTYPE::INTEGER, "S"); //^ Not impletemented. + const Reg InputDelay ("InputDelay", RW::ReadWrite, TYPE::GROUP, {{"0",""}, {"100", ""}, {"0.000001", ""}}, ANSTYPE::INTEGER, "sec"); } namespace VGA{ @@ -427,6 +429,9 @@ namespace PHA{ namespace CH{ + /// ========= command + const Reg SendChSWTrigger ("SendChSWrigger", RW::WriteOnly, TYPE::CH, {}, ANSTYPE::NONE, "", true); + /// ========= red only const Reg SelfTrgRate ("SelfTrgRate", RW::ReadOnly, TYPE::CH, {}, ANSTYPE::INTEGER, "Hz"); const Reg ChannelStatus ("ChStatus", RW::ReadOnly, TYPE::CH, {}, ANSTYPE::STR); @@ -441,8 +446,8 @@ namespace PHA{ /// ======= read write //^ not impletemented - const Reg SelfTriggerWidh ("SelfTriggerWidth", RW::ReadWrite, TYPE::CH, {{"0", ""},{"6000", ""},{"8", ""}}, ANSTYPE::INTEGER, "ns"); // not sure the max - const Reg SignalOffset ("SignalOffset", RW::ReadWrite, TYPE::CH, {{"0", ""},{"1000", ""},{"1", ""}}, ANSTYPE::INTEGER, "uV"); // not sure the max + const Reg SelfTriggerWidth ("SelfTriggerWidth", RW::ReadWrite, TYPE::CH, {{"0", ""},{"6000", ""},{"8", ""}}, ANSTYPE::INTEGER, "ns"); // not sure the max + const Reg SignalOffset ("SignalOffset", RW::ReadWrite, TYPE::CH, {{"0", ""},{"1000", ""},{"1", ""}}, ANSTYPE::INTEGER, "uV"); // not sure the max //^ impletemented @@ -742,6 +747,11 @@ namespace PSD{ const Reg ErrorFlags = PHA::DIG::ErrorFlags; const Reg BoardReady = PHA::DIG::BoardReady; + const Reg SPFLinkPresence = PHA::DIG::SPFLinkPresence; + const Reg SPFLinkActive = PHA::DIG::SPFLinkActive; + const Reg SPFLinkProtocol = PHA::DIG::SPFLinkProtocol; + + ///============= read write //const Reg EnableClockOutBackplane ("EnClockOutP0", RW::ReadWrite, TYPE::DIG); const Reg ClockSource = PHA::DIG::ClockSource; @@ -852,6 +862,9 @@ namespace PSD{ SpeedSensFan2 , ErrorFlags , BoardReady , + // SPFLinkPresence , + // SPFLinkActive , + // SPFLinkProtocol , ClockSource , IO_Level , StartSource , @@ -899,6 +912,10 @@ namespace PSD{ } + namespace GROUP{ + const Reg InputDelay = PHA::GROUP::InputDelay; + } + namespace VGA{ const Reg VGAGain = PHA::VGA::VGAGain; } @@ -917,6 +934,9 @@ namespace PSD{ namespace CH{ + /// ========= command + const Reg SendChSWTrigger ("SendChSWrigger", RW::WriteOnly, TYPE::CH, {}, ANSTYPE::NONE, "", true); + /// ========= red only const Reg SelfTrgRate = PHA::CH::SelfTrgRate; const Reg ChannelStatus = PHA::CH::ChannelStatus; @@ -929,6 +949,11 @@ namespace PSD{ const Reg ChannelWaveCount = PHA::CH::ChannelWaveCount; /// ======= read write + //^ not impletemented + const Reg SelfTriggerWidth = PHA::CH::SelfTriggerWidth; + const Reg SignalOffset = PHA::CH::SignalOffset; + + //^ impletemented const Reg ChannelEnable = PHA::CH::ChannelEnable; const Reg DC_Offset = PHA::CH::DC_Offset; const Reg TriggerThreshold = PHA::CH::TriggerThreshold; diff --git a/digiSettingsPanel.cpp b/digiSettingsPanel.cpp index 4bfadda..ce8de87 100644 --- a/digiSettingsPanel.cpp +++ b/digiSettingsPanel.cpp @@ -107,7 +107,14 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi lab->setAlignment(Qt::AlignRight | Qt::AlignCenter); leInfo[iDigi][j] = new QLineEdit(digiTab[iDigi]); leInfo[iDigi][j]->setReadOnly(true); - leInfo[iDigi][j]->setText(QString::fromStdString(digi[iDigi]->ReadValue(infoIndex[j].second))); + + Reg reg = infoIndex[j].second; + QString text = QString::fromStdString(digi[iDigi]->ReadValue(reg)); + if( reg.GetPara() == PHA::DIG::ADC_SampleRate.GetPara() ) { + short tick2ns = 1000/ text.toInt(); + text += " = " + QString::number(tick2ns, 'f', 1) + " ns" ; + } + leInfo[iDigi][j]->setText(text); infoLayout->addWidget(lab, j%nRow, 2*(j/nRow)); infoLayout->addWidget(leInfo[iDigi][j], j%nRow, 2*(j/nRow) +1); } @@ -781,6 +788,21 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi } + {//^====================== Group = InputDelay + bdGroup[iDigi] = new QWidget(this); + bdTab->addTab(bdGroup[iDigi], "Input Delay"); + QGridLayout * groupLayout = new QGridLayout(bdGroup[iDigi]); + groupLayout->setAlignment(Qt::AlignTop ); + //LVDSLayout->setSpacing(2); + + for(int k = 0; k < MaxNumberOfGroup; k ++){ + SetupSpinBox(spbInputDelay[iDigi][k], PHA::GROUP::InputDelay, k, false, "ch : " + QString::number(4*k) + " - " + QString::number(4*k+3) + " [s] ", groupLayout, k/4, 2*(k%4)); + spbInputDelay[iDigi][k]->setDecimals(6); + } + + + } + } {//^====================== Group channel settings @@ -2588,6 +2610,11 @@ void DigiSettingsPanel::UpdatePanelFromMemory(bool onlyStatus){ sbDACoutChSelect[ID]->setEnabled(false); } + //------------ Group + for( int k = 0 ; k < MaxNumberOfGroup; k++){ + FillSpinBoxValueFromMemory(spbInputDelay[ID][k], PHA::GROUP::InputDelay, k); // PHA = PSD + } + //@============================== Channel setting/ status diff --git a/digiSettingsPanel.h b/digiSettingsPanel.h index 2b17703..7abc727 100644 --- a/digiSettingsPanel.h +++ b/digiSettingsPanel.h @@ -65,6 +65,7 @@ private: QWidget * bdVGA[MaxNumberOfDigitizer]; QWidget * bdLVDS[MaxNumberOfDigitizer]; QWidget * bdITL[MaxNumberOfDigitizer]; + QWidget * bdGroup[MaxNumberOfDigitizer]; QGroupBox * box0[MaxNumberOfDigitizer]; @@ -206,6 +207,9 @@ private: QLineEdit * chGainFactor[MaxNumberOfDigitizer][MaxNumberOfChannel]; QLineEdit * chADCToVolts[MaxNumberOfDigitizer][MaxNumberOfChannel]; + //--------------- Group settings + RSpinBox * spbInputDelay[MaxNumberOfDigitizer][MaxNumberOfGroup]; + //--------------- Channel settings RComboBox * cbChPick[MaxNumberOfDigitizer]; diff --git a/mainwindow.cpp b/mainwindow.cpp index 8467d32..ded1d32 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -952,6 +952,7 @@ bool MainWindow::CheckSOLARISpanelOK(){ return false; } + LogMsg("Found " + file.fileName() + ". Setting up SOLARIS panel."); mapping.clear(); std::vector singleDigiMap; detType.clear();