I am not sure what I did today... fell not good...

This commit is contained in:
Ryan Tang 2023-03-22 18:16:26 -04:00
parent 7a8065f285
commit 8ba54cefc1
4 changed files with 187 additions and 61 deletions

View File

@ -125,9 +125,16 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi,
} }
} }
//---------- Set Panel //---------- Set Panel
QVBoxLayout * mainLayout = new QVBoxLayout(this); this->setLayout(mainLayout); QGridLayout * mainLayout = new QGridLayout(this); this->setLayout(mainLayout);
QTabWidget * tabWidget = new QTabWidget(this); mainLayout->addWidget(tabWidget);
QPushButton * bnRefresh = new QPushButton("Refresh Settings", this);
connect(bnRefresh, &QPushButton::clicked, this, &SOLARISpanel::UpdatePanel );
mainLayout->addWidget(bnRefresh, 0, 0);
QLabel * info = new QLabel("Only simple trigger is avalible. For complex trigger scheme, please use the setting panel.", this);
mainLayout->addWidget(info, 0, 1, 1, 4);
QTabWidget * tabWidget = new QTabWidget(this); mainLayout->addWidget(tabWidget, 1, 0, 1, 5);
for( int detTypeID = 0; detTypeID < nDetType; detTypeID ++ ){ for( int detTypeID = 0; detTypeID < nDetType; detTypeID ++ ){
QTabWidget * tab2 = new QTabWidget(tabWidget); QTabWidget * tab2 = new QTabWidget(tabWidget);
@ -147,6 +154,8 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi,
layout->setAlignment(Qt::AlignLeft|Qt::AlignTop); layout->setAlignment(Qt::AlignLeft|Qt::AlignTop);
layout->setSpacing(0); layout->setSpacing(0);
//TODO======= coincident Time window
//TODO======= check all //TODO======= check all
chkAll = new QCheckBox("Set for all", tab); chkAll = new QCheckBox("Set for all", tab);
layout->addWidget(chkAll, 0, 0); layout->addWidget(chkAll, 0, 0);
@ -215,6 +224,16 @@ SOLARISpanel::~SOLARISpanel(){
} }
int SOLARISpanel::FindDetTypID(QList<int> detIDListElement){
for( int i = 0; i < (int) detType.size(); i++){
int lowID = (i == 0) ? 0 : detMaxID[i-1];
if( lowID <= detIDListElement[0] && detIDListElement[0] < detMaxID[i]) {
return i;
}
}
return -1;
}
void SOLARISpanel::CreateDetGroup(int SettingID, QList<int> detID, QGridLayout * &layout, int row, int col){ void SOLARISpanel::CreateDetGroup(int SettingID, QList<int> detID, QGridLayout * &layout, int row, int col){
QGroupBox * groupbox = new QGroupBox("Det-" + QString::number(detID[0]), this); QGroupBox * groupbox = new QGroupBox("Det-" + QString::number(detID[0]), this);
@ -256,6 +275,7 @@ void SOLARISpanel::CreateDetGroup(int SettingID, QList<int> detID, QGridLayout *
chkOnOff[SettingID][digiID][chID]->setEnabled(false); chkOnOff[SettingID][digiID][chID]->setEnabled(false);
} }
///========================= for SpinBox
RSpinBox * spb = sbSetting[SettingID][digiID][chID]; RSpinBox * spb = sbSetting[SettingID][digiID][chID];
const Reg para = SettingItems[SettingID]; const Reg para = SettingItems[SettingID];
@ -285,19 +305,20 @@ void SOLARISpanel::CreateDetGroup(int SettingID, QList<int> detID, QGridLayout *
} }
}); });
///===================== for the OnOff CheckBox
connect(chkOnOff[SettingID][digiID][chID], &QCheckBox::stateChanged, this, [=](){ connect(chkOnOff[SettingID][digiID][chID], &QCheckBox::stateChanged, this, [=](int state){
if( !enableSignalSlot ) return; if( !enableSignalSlot ) return;
bool haha = chkOnOff[SettingID][digiID][chID]->isChecked(); digi[digiID]->WriteValue(PHA::CH::ChannelEnable, state ? "True" : "False", chID);
if( haha ) { enableSignalSlot = false;
digi[digiID]->WriteValue(PHA::CH::ChannelEnable, "True", chID); for( int i = 0; i < (int) detType.size(); i++){
}else{ leDisplay[i][digiID][chID]->setEnabled(state);
digi[digiID]->WriteValue(PHA::CH::ChannelEnable, "False", chID); sbSetting[i][digiID][chID]->setEnabled(state);
chkOnOff[i][digiID][chID]->setChecked(state);
} }
leDisplay[SettingID][digiID][chID]->setEnabled(haha); enableSignalSlot = true;
sbSetting[SettingID][digiID][chID]->setEnabled(haha);
}); });
layout0->setColumnStretch(0, 1); layout0->setColumnStretch(0, 1);
@ -306,32 +327,75 @@ void SOLARISpanel::CreateDetGroup(int SettingID, QList<int> detID, QGridLayout *
} }
int detTypeID = 0; //=================== The Trigger depnds on 5 settings (at least)
for( int i = 0; i < (int) detType.size(); i++){ // EventTriggerSource, WaveTriggerSource, CoincidentMask, AntiCoincidentMask
int lowID = (i == 0) ? 0 : detMaxID[i-1]; // 1, EventTriggerSource has 8 settings, ITLA, ITLB, GlobalTriggerSource, TRGIN, SWTrigger, ChSelfTrigger, Ch64Trigger, Disabled
if( lowID <= detID[0] && detID[0] < detMaxID[i]) { // 2, WaveTriggerSource has 8 settings, always set to be equal EventTriggerSource
detTypeID = i; // 3, CoincidentMak has 6 Settings, Disabled, Ch64Trigger, TRGIN, GloableTriggerSource, ITLA, ITLB
break; // 4, AntiCoincidentMask has 6 Settings, always disabled
} // 5, ChannelTriggerMask is a 64-bit
} // 6, CoincidenceLengthT in ns, set to be 100 ns.
int detTypeID = FindDetTypID(detID);
if( SettingItems[SettingID].GetPara() == PHA::CH::TriggerThreshold.GetPara()){ if( SettingItems[SettingID].GetPara() == PHA::CH::TriggerThreshold.GetPara()){
cbTrigger[detTypeID][detID[0]] = new RComboBox(this); cbTrigger[detTypeID][detID[0]] = new RComboBox(this);
cbTrigger[detTypeID][detID[0]]->addItem("Non-Trigger", 0x0); cbTrigger[detTypeID][detID[0]]->addItem("Self Trigger", "ChSelfTrigger"); /// no coincident
cbTrigger[detTypeID][detID[0]]->addItem("Self Trigger", -1); cbTrigger[detTypeID][detID[0]]->addItem("Trigger e", 0x1); // Self-trigger and coincient Ch64Trigger
cbTrigger[detTypeID][detID[0]]->addItem("Trigger all", 0x7); cbTrigger[detTypeID][detID[0]]->addItem("Ext. Trigger", "TRGIN"); // with coincident with TRGIN.
cbTrigger[detTypeID][detID[0]]->addItem("Trigger (e)", 0x1); cbTrigger[detTypeID][detID[0]]->addItem("Disabled", "Disabled"); // no Trigger, no coincident, basically channel still alive, but no recording
cbTrigger[detTypeID][detID[0]]->addItem("Trigger (xf)", 0x2); cbTrigger[detTypeID][detID[0]]->addItem("Others", -999); // other settings
cbTrigger[detTypeID][detID[0]]->addItem("Trigger (xn)", 0x4);
cbTrigger[detTypeID][detID[0]]->addItem("Trigger 011", 0x3);
cbTrigger[detTypeID][detID[0]]->addItem("Trigger 110", 0x6);
cbTrigger[detTypeID][detID[0]]->addItem("Trigger 101", 0x5);
cbTrigger[detTypeID][detID[0]]->addItem("Oops....", -999);
layout0->addWidget(cbTrigger[detTypeID][detID[0]], 8, 0, 1, 3); layout0->addWidget(cbTrigger[detTypeID][detID[0]], 8, 0, 1, 3);
connect(cbTrigger[detTypeID][detID[0]], &RComboBox::currentIndexChanged, this , [=](int index){
if( !enableSignalSlot) return;
for( int i = 1; i < detID.size(); i++){
int digiID = (detID[i] >> 8 );
int chID = (detID[i] & 0xFF);
digi[digiID]->WriteValue(PHA::CH::AntiCoincidenceMask, "Disabled", chID);
switch(index){
case 0 : { /// Self Trigger
digi[digiID]->WriteValue(PHA::CH::EventTriggerSource, "ChSelfTrigger", chID);
digi[digiID]->WriteValue(PHA::CH::WaveTriggerSource, "ChSelfTrigger", chID);
digi[digiID]->WriteValue(PHA::CH::CoincidenceMask, "Disabled", chID);
}; break;
case 1 : { // trigger by energy
digi[digiID]->WriteValue(PHA::CH::EventTriggerSource, "ChSelfTrigger", chID);
digi[digiID]->WriteValue(PHA::CH::WaveTriggerSource, "ChSelfTrigger", chID);
if( i > 1 ) {
digi[digiID]->WriteValue(PHA::CH::CoincidenceMask, "Ch64Trigger", chID);
digi[digiID]->WriteValue(PHA::CH::CoincidenceLength, "100", chID);
//Form the trigger bit
unsigned long mask = 1 << (detID[1] & 0xFF ); // trigger by energy
QString maskStr = "0x"+QString::number(mask, 16);
digi[digiID]->WriteValue(PHA::CH::ChannelsTriggerMask, maskStr.toStdString() , chID);
}
}; break;
case 2 : { /// TRGIN, when the whole board is trigger by TRG-IN
digi[digiID]->WriteValue(PHA::CH::EventTriggerSource, "TRGIN", chID);
digi[digiID]->WriteValue(PHA::CH::WaveTriggerSource, "TRGIN", chID);
digi[digiID]->WriteValue(PHA::CH::CoincidenceMask, "TRGIN", chID);
digi[digiID]->WriteValue(PHA::CH::CoincidenceLength, "100", chID);
}; break;
case 3 : { /// disbaled
digi[digiID]->WriteValue(PHA::CH::EventTriggerSource, "Disabled", chID);
digi[digiID]->WriteValue(PHA::CH::WaveTriggerSource, "Disabled", chID);
digi[digiID]->WriteValue(PHA::CH::CoincidenceMask, "Disabled", chID);
}; break;
}
}
});
} }
layout->addWidget(groupbox, row, col); layout->addWidget(groupbox, row, col);
} }
@ -370,19 +434,73 @@ void SOLARISpanel::UpdatePanel(){
//if( detIDList[k].size() <= 2) continue; //if( detIDList[k].size() <= 2) continue;
std::vector<unsigned long> triggerMap; std::vector<unsigned long> triggerMap;
std::vector<std::string> coincidentMask; std::vector<std::string> coincidentMask;
std::vector<std::string> antiCoincidentMask;
std::vector<std::string> eventTriggerSource; std::vector<std::string> eventTriggerSource;
std::vector<std::string> waveTriggerSource;
for( int h = 1; h < detIDList[k].size(); h++){ for( int h = 1; h < detIDList[k].size(); h++){
int digiID = detIDList[k][h] >> 8; int digiID = detIDList[k][h] >> 8;
int chID = (detIDList[k][h] & 0xFF); int chID = (detIDList[k][h] & 0xFF);
triggerMap.push_back(std::stoul(digi[digiID]->GetSettingValue(PHA::CH::ChannelsTriggerMask, chID).c_str())); bool ok;
triggerMap.push_back( QString::fromStdString(digi[digiID]->GetSettingValue(PHA::CH::ChannelsTriggerMask, chID)).toULong(&ok, 16));
coincidentMask.push_back(digi[digiID]->GetSettingValue(PHA::CH::CoincidenceMask, chID)); coincidentMask.push_back(digi[digiID]->GetSettingValue(PHA::CH::CoincidenceMask, chID));
antiCoincidentMask.push_back(digi[digiID]->GetSettingValue(PHA::CH::AntiCoincidenceMask, chID));
eventTriggerSource.push_back(digi[digiID]->GetSettingValue(PHA::CH::EventTriggerSource, chID)); eventTriggerSource.push_back(digi[digiID]->GetSettingValue(PHA::CH::EventTriggerSource, chID));
waveTriggerSource.push_back(digi[digiID]->GetSettingValue(PHA::CH::WaveTriggerSource, chID));
} }
//====== only acceptable condition is eventTriggerSource are all ChSelfTrigger //====== only acceptable condition is eventTriggerSource are all ChSelfTrigger
// and coincidentMask for e, xf, xn, are at least one for Ch64Trigger // and coincidentMask for e, xf, xn, are at least one for Ch64Trigger
// and waveTriggerSource are all ChSelfTrigger
int detTypeID = FindDetTypID(detIDList[k]);
//Check the 0-index
bool isAcceptableSetting = true;
if( eventTriggerSource[0] != waveTriggerSource[0] || coincidentMask[0] != antiCoincidentMask[0] ) isAcceptableSetting = false;
//check 0-index settings
if( isAcceptableSetting ){
if( eventTriggerSource[0] == "ChSelfTrigger" && coincidentMask[0] == "Disabled") {
cbTrigger[detTypeID][detIDList[k][0]]->setCurrentText("Self Trigger");
}else if( eventTriggerSource[0] == "Disabled" && coincidentMask[0] == "Disabled" ) {
cbTrigger[detTypeID][detIDList[k][0]]->setCurrentText("Disabled");
}else if( eventTriggerSource[0] == "TRGIN" && coincidentMask[0] == "TRGIN") {
cbTrigger[detTypeID][detIDList[k][0]]->setCurrentText("Ext. Trigger");
}else if( eventTriggerSource[0] == "ChSelfTrigger" && coincidentMask[0] == "Ch64Trigger") {
//Check trigger map
//TODO;
for( int p = 0; p < (int) triggerMap.size(); p ++ ){
printf("ch-%d, trigger : 0x%s \n", detIDList[k][p+1] & 0xFF, QString::number(triggerMap[p], 16).toStdString().c_str() );
}
cbTrigger[detTypeID][detIDList[k][0]]->setCurrentText("Trigger e");
}else{
isAcceptableSetting = false;
}
}
if( isAcceptableSetting ){
//Check if eventTriggerSource or coincidentMask compare to the 0-index
for( int h = 2; h < detIDList[k].size(); h++){
if( eventTriggerSource[h-1] != eventTriggerSource[0]){
isAcceptableSetting = false;
break;
}
if( waveTriggerSource[h-1] != waveTriggerSource[0]){
isAcceptableSetting = false;
break;
}
if( coincidentMask[h-1] != coincidentMask[0]){
isAcceptableSetting = false;
break;
}
if( antiCoincidentMask[h-1] != antiCoincidentMask[0]){
isAcceptableSetting = false;
break;
}
}
}
if( !isAcceptableSetting ) cbTrigger[detTypeID][detIDList[k][0]]->setCurrentText("Others");
} }
enableSignalSlot = true; enableSignalSlot = true;

View File

@ -43,6 +43,9 @@ public slots:
signals: signals:
//TODO
void UpdateSettingsPanel();
void UpdateScopePanel();
void SendLogMsg(const QString str); void SendLogMsg(const QString str);
private: private:
@ -56,6 +59,8 @@ private:
std::vector<int> detMaxID; std::vector<int> detMaxID;
QList<QList<int>> detIDList; // 1-D array of { detID, (Digi << 8 ) + ch} QList<QList<int>> detIDList; // 1-D array of { detID, (Digi << 8 ) + ch}
int FindDetTypID(QList<int> detIDListElement);
int nDigiMapping; /// mapping.size() int nDigiMapping; /// mapping.size()
std::vector<int> nChMapping; /// mapping[i].size(), NON -1 std::vector<int> nChMapping; /// mapping[i].size(), NON -1

View File

@ -761,10 +761,8 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
layout->addWidget(chADCToVolts[iDigi][ch], 1 + ch/2, ch%2*12 + 11); layout->addWidget(chADCToVolts[iDigi][ch], 1 + ch/2, ch%2*12 + 11);
} }
} }
{//@============== input tab {//@============== input tab
inputTab[iDigi] = new QTabWidget(tab); inputTab[iDigi] = new QTabWidget(tab);
chTabWidget->addTab(inputTab[iDigi], "Input"); chTabWidget->addTab(inputTab[iDigi], "Input");

View File

@ -64,6 +64,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
scalarThread = new ScalarThread(); scalarThread = new ScalarThread();
connect(scalarThread, &ScalarThread::updataScalar, this, &MainWindow::UpdateScalar); connect(scalarThread, &ScalarThread::updataScalar, this, &MainWindow::UpdateScalar);
solarisSetting = nullptr;
} }
QWidget * mainLayoutWidget = new QWidget(this); QWidget * mainLayoutWidget = new QWidget(this);
@ -254,15 +256,27 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
MainWindow::~MainWindow(){ MainWindow::~MainWindow(){
//---- may be no need to delete as thay are child of this
//delete bnProgramSettings;
//delete bnOpenDigitizers;
//delete bnCloseDigitizers;
//delete bnDigiSettings;
//delete bnNewExp;
//delete logInfo;
printf("- %s\n", __func__); printf("- %s\n", __func__);
printf("-------- remove %s\n", DAQLockFile);
remove(DAQLockFile);
printf("-------- delete Solaris panel\n");
if( solarisSetting != NULL ) {
delete solarisSetting;
solarisSetting = nullptr;
}
printf("-------- delete scope\n");
if( scope != NULL ) {
delete scope;
scope = nullptr;
}
printf("-------- delete digiSetting\n");
if( digiSetting != NULL ) {
delete digiSetting;
digiSetting = nullptr;
}
printf("-------- Delete readData Thread\n"); printf("-------- Delete readData Thread\n");
if( digi ){ if( digi ){
for( int i = 0; i < nDigi ; i++){ for( int i = 0; i < nDigi ; i++){
@ -271,22 +285,12 @@ MainWindow::~MainWindow(){
if( readDataThread[i]->isRunning()) StopACQ(); if( readDataThread[i]->isRunning()) StopACQ();
} }
} }
CloseDigitizers(); CloseDigitizers(); // SOlaris panel, digiSetting, scope are also deleted.
printf("-------- Delete scalar Thread\n"); printf("-------- Delete scalar Thread\n");
DeleteTriggerLineEdit(); DeleteTriggerLineEdit();
delete scalarThread; delete scalarThread;
//---- need manually delete
printf("-------- delete scope\n");
if( scope != NULL ) delete scope;
printf("-------- delete digiSetting\n");
if( digiSetting != NULL ) delete digiSetting;
printf("-------- delete Solaris panel\n");
if( solarisSetting != NULL ) delete solarisSetting;
printf("-------- delete influx\n"); printf("-------- delete influx\n");
if( influx != NULL ) { if( influx != NULL ) {
influx->ClearDataPointsBuffer(); influx->ClearDataPointsBuffer();
@ -295,7 +299,7 @@ MainWindow::~MainWindow(){
delete influx; delete influx;
} }
remove(DAQLockFile); printf("--- end of %s\n", __func__);
} }
@ -646,6 +650,12 @@ void MainWindow::CloseDigitizers(){
digiSetting = NULL; digiSetting = NULL;
} }
if( solarisSetting ){
solarisSetting->close();
delete solarisSetting;
solarisSetting = NULL;
}
for( int i = 0; i < nDigi; i++){ for( int i = 0; i < nDigi; i++){
if( digi[i] == NULL) return; if( digi[i] == NULL) return;
digi[i]->CloseDigitizer(); digi[i]->CloseDigitizer();
@ -667,11 +677,6 @@ void MainWindow::CloseDigitizers(){
digi = NULL; digi = NULL;
readDataThread = NULL; readDataThread = NULL;
if( solarisSetting ){
solarisSetting->close();
delete solarisSetting;
solarisSetting = NULL;
}
bnOpenDigitizers->setEnabled(true); bnOpenDigitizers->setEnabled(true);
bnOpenDigitizers->setFocus(); bnOpenDigitizers->setFocus();