added TriggerMask in Setting

This commit is contained in:
Ryan Tang 2023-03-23 19:57:14 -04:00
parent 38f6cc41cb
commit 7b237fabcb
6 changed files with 148 additions and 20 deletions

View File

@ -6,6 +6,7 @@
#include <QDoubleSpinBox>
#include <QComboBox>
#include <QWheelEvent>
#include <QString>
//^=======================================
class RComboBox : public QComboBox{

View File

@ -18,7 +18,7 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi,
QWidget *parent) : QWidget(parent){
setWindowTitle("SOLARIS Settings");
setGeometry(0, 0, 1400, 800);
setGeometry(0, 0, 1350, 800);
printf("%s\n", __func__);
@ -91,14 +91,35 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi,
//---------- Set Panel
QGridLayout * mainLayout = new QGridLayout(this); this->setLayout(mainLayout);
///=================================
int rowIndex = 0;
QPushButton * bnRefresh = new QPushButton("Refresh Settings", this);
connect(bnRefresh, &QPushButton::clicked, this, &SOLARISpanel::UpdatePanel );
mainLayout->addWidget(bnRefresh, 0, 0);
connect(bnRefresh, &QPushButton::clicked, this, &SOLARISpanel::RefreshSettings );
mainLayout->addWidget(bnRefresh, rowIndex, 0);
QPushButton * bnSaveSetting = new QPushButton("Save Settings", this);
connect(bnSaveSetting, &QPushButton::clicked, this, &SOLARISpanel::SaveSettings);
mainLayout->addWidget(bnSaveSetting, rowIndex, 1);
QPushButton * bnLoadSetting = new QPushButton("Load Settings", this);
connect(bnLoadSetting, &QPushButton::clicked, this, &SOLARISpanel::LoadSettings);
mainLayout->addWidget(bnLoadSetting, rowIndex, 2);
QLabel * lbCoinTime = new QLabel("Coin. Time [ns]", this);
lbCoinTime->setAlignment(Qt::AlignRight | Qt::AlignCenter);
mainLayout->addWidget(lbCoinTime, rowIndex, 3);
RSpinBox * sbCoinTime = new RSpinBox(this);
mainLayout->addWidget(sbCoinTime, rowIndex, 4);
///=================================
rowIndex ++;
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);
mainLayout->addWidget(info, rowIndex, 0, 1, 4);
QTabWidget * tabWidget = new QTabWidget(this); mainLayout->addWidget(tabWidget, 1, 0, 1, 5);
///=================================
rowIndex ++;
QTabWidget * tabWidget = new QTabWidget(this); mainLayout->addWidget(tabWidget, rowIndex, 0, 1, 5);
for( int detTypeID = 0; detTypeID < nDetType; detTypeID ++ ){
QTabWidget * tabSetting = new QTabWidget(tabWidget);
@ -183,8 +204,11 @@ void SOLARISpanel::CreateDetGroup(int SettingID, QList<int> detID, QGridLayout *
layout0->setAlignment(Qt::AlignLeft);
//@======================================== SpinBox and Display
bool isDisableDetector = false;
for( int i = 1; i < (int) detID.size(); i ++){
isDisableDetector = false;
QLabel * lb = new QLabel(arrayLabel[i-1], this);
layout0->addWidget(lb, 2*i, 0, 2, 1);
@ -212,7 +236,8 @@ void SOLARISpanel::CreateDetGroup(int SettingID, QList<int> detID, QGridLayout *
if( digiID >= nDigi || chID >= digi[digiID]->GetNChannels() ) {
leDisplay[SettingID][digiID][chID]->setEnabled(false);
sbSetting[SettingID][digiID][chID]->setEnabled(false);
chkOnOff[SettingID][digiID][chID]->setEnabled(false);
chkOnOff[SettingID][digiID][chID]->setEnabled(false);
isDisableDetector = true;
}
///========================= for SpinBox
@ -290,6 +315,8 @@ void SOLARISpanel::CreateDetGroup(int SettingID, QList<int> detID, QGridLayout *
cbTrigger[detTypeID][detID[0]]->addItem("Others", -999); // other settings
layout0->addWidget(cbTrigger[detTypeID][detID[0]], 8, 0, 1, 3);
if( isDisableDetector ) cbTrigger[detTypeID][detID[0]]->setEnabled(false);
connect(cbTrigger[detTypeID][detID[0]], &RComboBox::currentIndexChanged, this , [=](int index){
if( !enableSignalSlot) return;
@ -299,6 +326,8 @@ void SOLARISpanel::CreateDetGroup(int SettingID, QList<int> detID, QGridLayout *
int digiID = (detID[i] >> 8 );
int chID = (detID[i] & 0xFF);
if( digi[digiID]->IsDummy() || !digi[digiID]->IsConnected() ) continue;
digi[digiID]->WriteValue(PHA::CH::AntiCoincidenceMask, "Disabled", chID);
switch(index){
@ -346,10 +375,21 @@ void SOLARISpanel::CreateDetGroup(int SettingID, QList<int> detID, QGridLayout *
layout->addWidget(groupbox, row, col);
}
//^##############################################################
void SOLARISpanel::RefreshSettings(){
for( int i = 0 ; i < nDigi; i++){
if( digi[i]->IsDummy() || !digi[i]->IsConnected()){
digi[i]->ReadAllSettings();
}
}
UpdatePanel();
}
void SOLARISpanel::UpdatePanel(){
enableSignalSlot = false;
printf("%s\n", __func__);
for( int SettingID = 0; SettingID < (int) SettingItems.size() ; SettingID ++){
for( int DigiID = 0; DigiID < (int) mapping.size(); DigiID ++){
if( DigiID >= nDigi ) continue;;
@ -389,8 +429,8 @@ void SOLARISpanel::UpdatePanel(){
for( int h = 1; h < detIDList[k].size(); h++){
int digiID = detIDList[k][h] >> 8;
int chID = (detIDList[k][h] & 0xFF);
bool ok;
triggerMap.push_back( QString::fromStdString(digi[digiID]->GetSettingValue(PHA::CH::ChannelsTriggerMask, chID)).toULong(&ok, 16));
triggerMap.push_back(Utility::TenBase(digi[digiID]->GetSettingValue(PHA::CH::ChannelsTriggerMask, 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));
@ -414,12 +454,8 @@ void SOLARISpanel::UpdatePanel(){
//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] == "Disabled") {
unsigned long mask = 1ULL << (detIDList[k][1] & 0xFF);
@ -431,6 +467,12 @@ void SOLARISpanel::UpdatePanel(){
cbTrigger[detTypeID][detIDList[k][0]]->setCurrentText("Trigger e");
isTriggerE = true;
}
}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{
isAcceptableSetting = false;
}
@ -483,3 +525,14 @@ void SOLARISpanel::UpdateThreshold(){
}
}
}
//^#########################################
void SOLARISpanel::SaveSettings(){
}
void SOLARISpanel::LoadSettings(){
}

View File

@ -40,6 +40,9 @@ public:
private slots:
void RefreshSettings();
void SaveSettings();
void LoadSettings();
public slots:
void UpdatePanel();

View File

@ -591,7 +591,10 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
FillComboBoxValueFromMemory(cbbAntiCoinMask[ID][ch], PHA::CH::AntiCoincidenceMask, index);
FillSpinBoxValueFromMemory(spbCoinLength[ID][ch], PHA::CH::CoincidenceLength, index);
FillSpinBoxValueFromMemory(spbADCVetoWidth[ID][ch], PHA::CH::ADCVetoWidth, index);
unsigned long mask = Utility::TenBase(digi[ID]->GetSettingValue(PHA::CH::ChannelsTriggerMask, cbChPick[ID]->currentData().toInt()));
leTriggerMask[ID][ch]->setText("0x" + QString::number(mask, 16));
enableSignalSlot = true;
}
});
@ -691,6 +694,39 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
rowID ++;
SetupComboBox(cbbChVetoSrc[iDigi][ch], PHA::CH::ChannelVetoSource, -1, true, "Veto Source", layout5, rowID, 0);
QLabel * lbTrgMsk = new QLabel("Trigger Mask :");
lbTrgMsk->setAlignment(Qt::AlignRight | Qt::AlignCenter);
layout5->addWidget(lbTrgMsk, rowID, 2);
leTriggerMask[iDigi][ch] = new QLineEdit(this);
layout5->addWidget(leTriggerMask[iDigi][ch], rowID, 3);
connect(leTriggerMask[iDigi][ch], &QLineEdit::textChanged, this, [=](){
if( !enableSignalSlot ) return;
leTriggerMask[iDigi][ch]->setStyleSheet("color:blue;");
});
connect(leTriggerMask[iDigi][ch], &QLineEdit::returnPressed, this, [=](){
if( !enableSignalSlot ) return;
int index = cbChPick[ID]->currentData().toInt();
QString SixteenBaseValue = "0x" + QString::number(Utility::TenBase(leTriggerMask[ID][ch]->text().toStdString()), 16);
leTriggerMask[ID][ch]->setText(SixteenBaseValue);
QString msg;
msg = QString::fromStdString(PHA::CH::ChannelsTriggerMask.GetPara()) + "|DIG:"+ QString::number(digi[ID]->GetSerialNumber());
msg += ",CH:" + (index == -1 ? "All" : QString::number(index));
msg += " = " + SixteenBaseValue;
if( digi[ID]->WriteValue(PHA::CH::ChannelsTriggerMask, SixteenBaseValue.toStdString(), index)){
SendLogMsg(msg + "|OK.");
leTriggerMask[ID][ch]->setStyleSheet("");
ShowSettingsToPanel();
}else{
SendLogMsg(msg + "|Fail.");
leTriggerMask[ID][ch]->setStyleSheet("color:red;");
}
});
//------------------------------
rowID ++;
SetupComboBox(cbbCoinMask[iDigi][ch], PHA::CH::CoincidenceMask, -1, true, "Coin. Mask", layout5, rowID, 0);
@ -1494,9 +1530,7 @@ void DigiSettingsPanel::ReadTriggerMap(){
for( int ch = 0; ch < (int) digi[ID]->GetNChannels(); ch ++){
std::string ans = digi[ID]->GetSettingValue(PHA::CH::ChannelsTriggerMask, ch);
bool ok;
unsigned long mask = QString::fromStdString(ans).toULong(&ok, 10);
unsigned long mask = Utility::TenBase(digi[ID]->GetSettingValue(PHA::CH::ChannelsTriggerMask, ch));
//printf("Trigger Mask of ch-%2d : 0x%s |%s| \n", ch, QString::number(mask, 16).toStdString().c_str(), ans.c_str());
for( int k = 0; k < (int) digi[ID]->GetNChannels(); k ++ ){
@ -1773,8 +1807,27 @@ void DigiSettingsPanel::ShowSettingsToPanel(){
}
//------ Trigger Mask
if( cbChPick[ID]->currentData().toInt() < 0 ) {
unsigned long mask = Utility::TenBase(digi[ID]->GetSettingValue(PHA::CH::ChannelsTriggerMask, 0));
bool isSame = true;
for(int ch = 1; ch < digi[ID]->GetNChannels() ; ch ++){
unsigned long haha = Utility::TenBase(digi[ID]->GetSettingValue(PHA::CH::ChannelsTriggerMask, ch));
if( mask != haha) {
isSame = false;
leTriggerMask[ID][MaxNumberOfChannel]->setText("Diff. value");
break;
}
}
if( isSame ) leTriggerMask[ID][MaxNumberOfChannel]->setText("0x" + QString::number(mask, 16));
}
enableSignalSlot = true;
ReadTriggerMap();
if( cbChPick[ID]->currentData().toInt() >= 0 ) return;
SyncComboBox(cbbOnOff, -1);
@ -1817,8 +1870,6 @@ void DigiSettingsPanel::ShowSettingsToPanel(){
SyncSpinBox(spbCoinLength , -1);
SyncSpinBox(spbADCVetoWidth , -1);
ReadTriggerMap();
}
//^###########################################################################

View File

@ -18,7 +18,6 @@
#include <QFrame>
#include <QSignalMapper>
#include "ClassDigitizer2Gen.h"
#include "CustomWidgets.h"
#include "macro.h"
@ -217,6 +216,8 @@ private:
RComboBox * cbbCoinMask[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbAntiCoinMask[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
QLineEdit * leTriggerMask[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbCoinLength[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbADCVetoWidth[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];

19
macro.h
View File

@ -5,4 +5,23 @@
#define DAQLockFile "DAQLock.dat"
#define PIDFile "pid.dat"
//^=================================
namespace Utility{
/// either haha is "0xFFF" or "12435", convert to 10-base
static unsigned long TenBase(std::string haha){
QString ans = QString::fromStdString(haha);
unsigned long mask = 0 ;
if( ans.contains("0x")){
bool ok;
mask = ans.toULong(&ok, 16);
}else{
mask = ans.toULong();
}
return mask;
}
}
//just to get rip of the warning;
const unsigned long ksjaldja = Utility::TenBase("0");
#endif