2023-03-17 17:08:56 -04:00
|
|
|
#include "SOLARISpanel.h"
|
|
|
|
|
|
|
|
#include <QFile>
|
2023-03-20 15:52:04 -04:00
|
|
|
#include <QLabel>
|
2023-03-17 18:13:36 -04:00
|
|
|
#include <QSet>
|
|
|
|
#include <QList>
|
2023-03-22 12:36:24 -04:00
|
|
|
#include <QFrame>
|
2023-03-27 15:48:41 -04:00
|
|
|
#include <QFileDialog>
|
2023-03-17 17:08:56 -04:00
|
|
|
|
2023-03-20 19:53:47 -04:00
|
|
|
#define NCOL 10 // number of column
|
2023-03-20 15:52:04 -04:00
|
|
|
|
2023-03-31 20:01:27 -04:00
|
|
|
#define ChStartIndex 2 // the index of detIDList for channel
|
|
|
|
|
2023-03-20 15:52:04 -04:00
|
|
|
std::vector<Reg> SettingItems = {PHA::CH::TriggerThreshold, PHA::CH::DC_Offset};
|
|
|
|
|
2023-03-17 17:08:56 -04:00
|
|
|
SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi,
|
2023-03-27 15:48:41 -04:00
|
|
|
QString analysisPath,
|
2023-03-17 17:08:56 -04:00
|
|
|
std::vector<std::vector<int>> mapping,
|
|
|
|
QStringList detType,
|
2023-03-31 20:01:27 -04:00
|
|
|
QStringList detGroupName,
|
|
|
|
std::vector<int> detGroupID,
|
2023-03-17 17:08:56 -04:00
|
|
|
std::vector<int> detMaxID,
|
|
|
|
QWidget *parent) : QWidget(parent){
|
|
|
|
|
|
|
|
setWindowTitle("SOLARIS Settings");
|
2023-03-23 19:57:14 -04:00
|
|
|
setGeometry(0, 0, 1350, 800);
|
2023-03-17 17:08:56 -04:00
|
|
|
|
|
|
|
this->digi = digi;
|
|
|
|
this->nDigi = nDigi;
|
2023-03-27 15:48:41 -04:00
|
|
|
if( this->nDigi > MaxNumberOfDigitizer ) {
|
|
|
|
this->nDigi = MaxNumberOfChannel;
|
|
|
|
qDebug() << "Please increase the MaxNumberOfChannel";
|
|
|
|
}
|
2023-03-17 17:08:56 -04:00
|
|
|
this->mapping = mapping;
|
2023-04-03 12:25:23 -04:00
|
|
|
this->detTypeNameList = detType;
|
2023-03-17 17:08:56 -04:00
|
|
|
this->detMaxID = detMaxID;
|
2023-03-31 20:01:27 -04:00
|
|
|
this->detGroupID = detGroupID;
|
2023-04-03 12:25:23 -04:00
|
|
|
this->detGroupNameList = detGroupName;
|
2023-03-27 15:58:20 -04:00
|
|
|
this->digiSettingPath = analysisPath + "/working/Settings/";
|
2023-03-17 17:08:56 -04:00
|
|
|
|
|
|
|
//Check number of detector type; Array 0-199, Recoil 200-299, other 300-
|
2023-04-03 12:25:23 -04:00
|
|
|
int nDetType = detTypeNameList.size();
|
2023-03-31 20:01:27 -04:00
|
|
|
for( int k = 0 ; k < nDetType; k++) nDetinType.push_back(0);
|
|
|
|
|
|
|
|
std::vector<int> condenGroupID = detGroupID;
|
|
|
|
std::sort(condenGroupID.begin(), condenGroupID.end()); // sort the detGroupID
|
|
|
|
auto last = std::unique(condenGroupID.begin(), condenGroupID.end());
|
|
|
|
condenGroupID.erase(last, condenGroupID.end());
|
|
|
|
int nDetGroup = condenGroupID.size();
|
|
|
|
for( int k = 0 ; k < nDetGroup; k++) nDetinGroup.push_back(0);
|
2023-03-17 17:08:56 -04:00
|
|
|
|
2023-03-17 18:13:36 -04:00
|
|
|
|
2023-03-31 20:01:27 -04:00
|
|
|
QList<QList<int>> detIDListTemp; // store { detGroup, detID, (Digi << 8 ) + ch}, making mapping into 1-D array to be consolidated
|
2023-03-20 15:52:04 -04:00
|
|
|
printf("################################# \n");
|
2023-03-23 16:36:47 -04:00
|
|
|
for( int i = 0; i < (int) mapping.size() ; i++){
|
2023-03-20 19:53:47 -04:00
|
|
|
for( int j = 0; j < (int) mapping[i].size(); j++ ){
|
2023-03-30 13:09:11 -04:00
|
|
|
printf("%4d,", mapping[i][j]);
|
2023-03-31 20:01:27 -04:00
|
|
|
if( mapping[i][j] >= 0 ) {
|
|
|
|
int groupID = FindDetGroup(mapping[i][j]);
|
|
|
|
int typeID = FindDetTypeID(mapping[i][j]);
|
|
|
|
QList<int> haha ;
|
|
|
|
haha << groupID << mapping[i][j] << ((i << 8 ) + j);
|
|
|
|
detIDListTemp << haha;
|
|
|
|
nDetinType[typeID] ++;
|
|
|
|
nDetinGroup[groupID] ++;
|
|
|
|
}
|
2023-03-20 15:52:04 -04:00
|
|
|
if( j % 16 == 15 ) printf("\n");
|
2023-03-17 17:08:56 -04:00
|
|
|
}
|
2023-03-17 18:13:36 -04:00
|
|
|
printf("------------------ \n");
|
2023-03-17 17:08:56 -04:00
|
|
|
}
|
|
|
|
|
2023-03-31 20:01:27 -04:00
|
|
|
//consolidate detIDListTemp --> 2D array of (detID, (Digi << 8) + ch, +.... )
|
|
|
|
//for example, {2, 0, 0}, {2, 100, 1}, {2, 200, 2}--> {2, 0, 0, 1, 2};
|
|
|
|
//for example, {2, 1, 3}, {2, 101, 4}, {2, 201, 5}--> {2, 0, 3, 4, 5};
|
2023-04-03 12:25:23 -04:00
|
|
|
detIDArrayList.clear();
|
2023-03-20 15:52:04 -04:00
|
|
|
bool repeated = false;
|
|
|
|
for( int i = 0; i < detIDListTemp.size(); i++ ){
|
|
|
|
repeated = false;
|
2023-04-03 12:25:23 -04:00
|
|
|
if( detIDArrayList.size() == 0 ){
|
|
|
|
detIDArrayList << detIDListTemp[i];
|
2023-03-22 12:36:24 -04:00
|
|
|
continue;
|
|
|
|
}
|
2023-04-03 12:25:23 -04:00
|
|
|
for( int j = 0; j < detIDArrayList.size() ; j++){
|
|
|
|
if( detIDArrayList[j][0] == detIDListTemp[i][0] ) { // same group
|
2023-03-31 20:01:27 -04:00
|
|
|
|
2023-04-03 12:25:23 -04:00
|
|
|
int type1 = FindDetTypeID(detIDArrayList[j][1]);
|
2023-03-31 20:01:27 -04:00
|
|
|
int type2 = FindDetTypeID(detIDListTemp[i][1]);
|
|
|
|
|
|
|
|
int low1 = (type1 == 0 ? 0 : detMaxID[type1-1]);
|
|
|
|
int low2 = (type2 == 0 ? 0 : detMaxID[type2-1]);
|
|
|
|
|
2023-04-03 12:25:23 -04:00
|
|
|
int detID1 = detIDArrayList[j][1] - low1;
|
2023-03-31 20:01:27 -04:00
|
|
|
int detID2 = detIDListTemp[i][1] - low2;
|
|
|
|
|
|
|
|
if( detID1 == detID2) {
|
|
|
|
repeated = true;
|
2023-04-03 12:25:23 -04:00
|
|
|
detIDArrayList[j] << detIDListTemp[i][2];
|
2023-03-31 20:01:27 -04:00
|
|
|
break;
|
|
|
|
}
|
2023-03-20 15:52:04 -04:00
|
|
|
}
|
|
|
|
}
|
2023-03-22 12:36:24 -04:00
|
|
|
if( !repeated ) {
|
2023-04-03 12:25:23 -04:00
|
|
|
detIDArrayList << detIDListTemp[i];
|
2023-03-22 12:36:24 -04:00
|
|
|
}
|
2023-03-20 15:52:04 -04:00
|
|
|
}
|
2023-03-17 18:13:36 -04:00
|
|
|
|
2023-03-20 19:53:47 -04:00
|
|
|
//---- sort detIDList;
|
2023-04-03 12:25:23 -04:00
|
|
|
std::sort(detIDArrayList.begin(), detIDArrayList.end(), [](const QList<int>& a, const QList<int>& b) {
|
2023-03-31 20:01:27 -04:00
|
|
|
return a.at(1) < b.at(1);
|
2023-03-20 19:53:47 -04:00
|
|
|
});
|
|
|
|
|
2023-03-22 12:36:24 -04:00
|
|
|
//------------- display detector summary
|
2023-03-20 19:53:47 -04:00
|
|
|
//qDebug() << detIDList;
|
2023-03-22 12:36:24 -04:00
|
|
|
printf("---------- num. of det. Type : %d\n", nDetType);
|
|
|
|
for( int i =0; i < nDetType; i ++ ) {
|
2023-03-31 20:01:27 -04:00
|
|
|
detType[i].remove(' ');
|
|
|
|
printf(" Type-%d (%6s) : %3d det. (%3d - %3d)\n", i, detType[i].toStdString().c_str(), nDetinType[i], (i==0 ? 0 : detMaxID[i-1]), detMaxID[i]-1);
|
|
|
|
}
|
|
|
|
printf("---------- num. of det. Group : %d\n", nDetGroup);
|
|
|
|
for( int i =0; i < nDetGroup; i++){
|
|
|
|
printf(" Group-%d (%10s) : %3d det.\n", i, detGroupName[i].toStdString().c_str(), nDetinGroup[i]);
|
2023-03-22 12:36:24 -04:00
|
|
|
}
|
2023-03-20 19:53:47 -04:00
|
|
|
|
2023-03-20 15:52:04 -04:00
|
|
|
//---------- Set Panel
|
2023-03-22 18:16:26 -04:00
|
|
|
QGridLayout * mainLayout = new QGridLayout(this); this->setLayout(mainLayout);
|
2023-03-17 17:08:56 -04:00
|
|
|
|
2023-03-23 19:57:14 -04:00
|
|
|
///=================================
|
2023-03-27 15:48:41 -04:00
|
|
|
int rowIndex = 0 ;
|
2023-03-22 18:16:26 -04:00
|
|
|
QPushButton * bnRefresh = new QPushButton("Refresh Settings", this);
|
2023-03-23 19:57:14 -04:00
|
|
|
connect(bnRefresh, &QPushButton::clicked, this, &SOLARISpanel::RefreshSettings );
|
2023-03-27 15:48:41 -04:00
|
|
|
mainLayout->addWidget(bnRefresh, rowIndex, 0, 1, 2);
|
2023-03-22 18:16:26 -04:00
|
|
|
|
2023-03-23 19:57:14 -04:00
|
|
|
QPushButton * bnSaveSetting = new QPushButton("Save Settings", this);
|
|
|
|
connect(bnSaveSetting, &QPushButton::clicked, this, &SOLARISpanel::SaveSettings);
|
2023-03-27 15:48:41 -04:00
|
|
|
mainLayout->addWidget(bnSaveSetting, rowIndex, 2, 1, 2);
|
2023-03-23 19:57:14 -04:00
|
|
|
|
|
|
|
QPushButton * bnLoadSetting = new QPushButton("Load Settings", this);
|
|
|
|
connect(bnLoadSetting, &QPushButton::clicked, this, &SOLARISpanel::LoadSettings);
|
2023-03-27 15:48:41 -04:00
|
|
|
mainLayout->addWidget(bnLoadSetting, rowIndex, 4, 1, 2);
|
2023-03-23 19:57:14 -04:00
|
|
|
|
2023-03-24 17:23:59 -04:00
|
|
|
QLabel * lbCoinTime = new QLabel("Coin. Time (all ch.) [ns]", this);
|
2023-03-23 19:57:14 -04:00
|
|
|
lbCoinTime->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
2023-03-27 15:48:41 -04:00
|
|
|
mainLayout->addWidget(lbCoinTime, rowIndex, 6, 1, 2);
|
2023-03-23 19:57:14 -04:00
|
|
|
|
2023-03-24 17:23:59 -04:00
|
|
|
sbCoinTime = new RSpinBox(this);
|
|
|
|
sbCoinTime->setMinimum(-1);
|
|
|
|
sbCoinTime->setMaximum(atof(PHA::CH::CoincidenceLength.GetAnswers()[1].first.c_str()));
|
|
|
|
sbCoinTime->setSingleStep(atof(PHA::CH::CoincidenceLength.GetAnswers()[2].first.c_str()));
|
|
|
|
sbCoinTime->setDecimals(0);
|
|
|
|
sbCoinTime->SetToolTip(atof(PHA::CH::CoincidenceLength.GetAnswers()[1].first.c_str()));
|
2023-03-27 15:48:41 -04:00
|
|
|
mainLayout->addWidget(sbCoinTime, rowIndex, 8, 1, 2);
|
2023-03-23 19:57:14 -04:00
|
|
|
|
2023-03-31 20:01:27 -04:00
|
|
|
|
2023-03-24 17:23:59 -04:00
|
|
|
connect(sbCoinTime, &RSpinBox::valueChanged, this, [=](){
|
|
|
|
if( !enableSignalSlot ) return;
|
|
|
|
sbCoinTime->setStyleSheet("color:blue;");
|
|
|
|
});
|
|
|
|
|
|
|
|
connect(sbCoinTime, &RSpinBox::returnPressed, this, [=](){
|
|
|
|
if( !enableSignalSlot ) return;
|
|
|
|
//printf("%s %d %d \n", para.GetPara().c_str(), index, spb->value());
|
|
|
|
if( sbCoinTime->decimals() == 0 && sbCoinTime->singleStep() != 1) {
|
|
|
|
double step = sbCoinTime->singleStep();
|
|
|
|
double value = sbCoinTime->value();
|
|
|
|
sbCoinTime->setValue( (std::round(value/step) * step) );
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int i = 0; i < (int) mapping.size(); i ++){
|
|
|
|
if( i >= nDigi || digi[i]->IsDummy() || !digi[i]->IsConnected() ) return;
|
|
|
|
QString msg;
|
|
|
|
msg = QString::fromStdString(PHA::CH::CoincidenceLength.GetPara()) + "|DIG:"+ QString::number(digi[i]->GetSerialNumber());
|
|
|
|
msg += ",CH:All = " + QString::number(sbCoinTime->value());
|
|
|
|
if( digi[i]->WriteValue(PHA::CH::CoincidenceLength, std::to_string(sbCoinTime->value()))){
|
|
|
|
SendLogMsg(msg + "|OK.");
|
|
|
|
sbCoinTime->setStyleSheet("");
|
|
|
|
}else{
|
|
|
|
SendLogMsg(msg + "|Fail.");
|
|
|
|
sbCoinTime->setStyleSheet("color:red;");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
UpdatePanelFromMemory();
|
|
|
|
});
|
2023-03-31 20:01:27 -04:00
|
|
|
|
2023-03-23 19:57:14 -04:00
|
|
|
///=================================
|
|
|
|
rowIndex ++;
|
2023-03-22 18:16:26 -04:00
|
|
|
QLabel * info = new QLabel("Only simple trigger is avalible. For complex trigger scheme, please use the setting panel.", this);
|
2023-03-23 19:57:14 -04:00
|
|
|
mainLayout->addWidget(info, rowIndex, 0, 1, 4);
|
2023-04-12 13:52:42 -04:00
|
|
|
rowIndex ++;
|
|
|
|
QLabel * info2 = new QLabel("The panel is defined by " + analysisPath + "/working/Mapping.h", this);
|
|
|
|
mainLayout->addWidget(info2, rowIndex, 0, 1, 4);
|
2023-03-22 18:16:26 -04:00
|
|
|
|
2023-03-23 19:57:14 -04:00
|
|
|
///=================================
|
|
|
|
rowIndex ++;
|
2023-03-27 15:48:41 -04:00
|
|
|
QTabWidget * tabWidget = new QTabWidget(this); mainLayout->addWidget(tabWidget, rowIndex, 0, 1, 10);
|
2023-03-31 20:01:27 -04:00
|
|
|
for( int detGroup = 0; detGroup < nDetGroup; detGroup ++ ){
|
2023-03-17 17:08:56 -04:00
|
|
|
|
2023-03-23 16:36:47 -04:00
|
|
|
QTabWidget * tabSetting = new QTabWidget(tabWidget);
|
2023-03-31 20:01:27 -04:00
|
|
|
tabWidget->addTab(tabSetting, detGroupName[detGroup]);
|
2023-03-17 17:08:56 -04:00
|
|
|
|
2023-03-20 15:52:04 -04:00
|
|
|
for( int SettingID = 0; SettingID < (int) SettingItems.size(); SettingID ++){
|
2023-03-17 17:08:56 -04:00
|
|
|
|
2023-03-20 19:53:47 -04:00
|
|
|
QScrollArea * scrollArea = new QScrollArea(this);
|
|
|
|
scrollArea->setWidgetResizable(true);
|
|
|
|
scrollArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
2023-03-23 16:36:47 -04:00
|
|
|
tabSetting->addTab(scrollArea, QString::fromStdString(SettingItems[SettingID]));
|
2023-03-17 17:08:56 -04:00
|
|
|
|
2023-03-23 16:36:47 -04:00
|
|
|
QWidget * tab = new QWidget(tabSetting);
|
2023-03-20 19:53:47 -04:00
|
|
|
scrollArea->setWidget(tab);
|
|
|
|
|
2023-03-20 15:52:04 -04:00
|
|
|
QGridLayout * layout = new QGridLayout(tab);
|
|
|
|
layout->setAlignment(Qt::AlignLeft|Qt::AlignTop);
|
|
|
|
layout->setSpacing(0);
|
2023-03-17 18:13:36 -04:00
|
|
|
|
2023-03-31 20:01:27 -04:00
|
|
|
chkAll[detGroup][SettingID] = new QCheckBox("Set for all", tab);
|
|
|
|
layout->addWidget(chkAll[detGroup][SettingID], 0, 0);
|
|
|
|
|
|
|
|
connect(chkAll[detGroup][SettingID], &QCheckBox::stateChanged, this, [=](bool state){
|
|
|
|
bool found = false;
|
2023-04-03 12:25:23 -04:00
|
|
|
for(int i = 0; i < detIDArrayList.size(); i++){
|
|
|
|
if( detIDArrayList[i][0] != detGroup ) continue;
|
2023-03-31 20:01:27 -04:00
|
|
|
if( found == false ){
|
|
|
|
found = true;
|
|
|
|
continue;
|
|
|
|
}else{
|
2023-04-03 12:25:23 -04:00
|
|
|
groupBox[detGroup][SettingID][detIDArrayList[i][1]]->setEnabled(!state);
|
2023-03-31 20:01:27 -04:00
|
|
|
}
|
2023-03-24 19:23:36 -04:00
|
|
|
}
|
|
|
|
});
|
2023-03-31 20:01:27 -04:00
|
|
|
|
2023-03-22 12:36:24 -04:00
|
|
|
QFrame *line = new QFrame(tab);
|
|
|
|
line->setFrameShape(QFrame::HLine);
|
|
|
|
line->setFrameShadow(QFrame::Sunken);
|
|
|
|
line->setFixedHeight(10);
|
|
|
|
layout->addWidget(line, 1, 0, 1, NCOL);
|
|
|
|
|
2023-04-03 12:25:23 -04:00
|
|
|
for(int i = 0; i < detIDArrayList.size(); i++){
|
|
|
|
if( detIDArrayList[i][0] != detGroup ) continue;
|
|
|
|
CreateDetGroup(SettingID, detIDArrayList[i], layout, i/NCOL + 2, i%NCOL);
|
2023-03-20 15:52:04 -04:00
|
|
|
}
|
2023-03-17 17:08:56 -04:00
|
|
|
|
2023-03-20 15:52:04 -04:00
|
|
|
}
|
|
|
|
}
|
2023-03-17 17:08:56 -04:00
|
|
|
|
2023-03-31 20:01:27 -04:00
|
|
|
enableSignalSlot = true;
|
|
|
|
|
2023-03-17 17:08:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
SOLARISpanel::~SOLARISpanel(){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-03-23 13:08:47 -04:00
|
|
|
//^######################################################################
|
2023-03-31 20:01:27 -04:00
|
|
|
int SOLARISpanel::FindDetTypeID(int detID){
|
2023-04-03 12:25:23 -04:00
|
|
|
for( int i = 0; i < (int) detTypeNameList.size(); i++){
|
2023-03-22 18:16:26 -04:00
|
|
|
int lowID = (i == 0) ? 0 : detMaxID[i-1];
|
2023-03-31 20:01:27 -04:00
|
|
|
if( lowID <= detID && detID < detMaxID[i]) {
|
2023-03-22 18:16:26 -04:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2023-03-31 20:01:27 -04:00
|
|
|
int SOLARISpanel::FindDetGroup(int detID){
|
|
|
|
int typeID = FindDetTypeID(detID);
|
|
|
|
if( typeID == -1) return -999;
|
|
|
|
return detGroupID[typeID];
|
|
|
|
}
|
2023-03-17 17:08:56 -04:00
|
|
|
|
2023-03-31 20:01:27 -04:00
|
|
|
void SOLARISpanel::CreateDetGroup(int SettingID, QList<int> detIDArray, QGridLayout * &layout, int row, int col){
|
|
|
|
|
|
|
|
int detGroup = detIDArray[0];
|
|
|
|
int detID = detIDArray[1];
|
|
|
|
|
|
|
|
groupBox[detGroup][SettingID][detID] = new QGroupBox("Det-" + QString::number(detID), this);
|
|
|
|
groupBox[detGroup][SettingID][detID]->setFixedWidth(130);
|
|
|
|
groupBox[detGroup][SettingID][detID]->setAlignment(Qt::AlignCenter);
|
|
|
|
QGridLayout * layout0 = new QGridLayout(groupBox[detGroup][SettingID][detID]);
|
2023-03-20 19:53:47 -04:00
|
|
|
layout0->setSpacing(0);
|
|
|
|
layout0->setAlignment(Qt::AlignLeft);
|
2023-03-17 18:13:36 -04:00
|
|
|
|
2023-03-23 13:08:47 -04:00
|
|
|
//@======================================== SpinBox and Display
|
2023-03-23 19:57:14 -04:00
|
|
|
bool isDisableDetector = false;
|
2023-03-20 15:52:04 -04:00
|
|
|
|
2023-03-31 20:01:27 -04:00
|
|
|
int nChInGroupBox = 0;
|
|
|
|
for( int ppp = ChStartIndex; ppp < detIDArray.size(); ppp ++){
|
|
|
|
|
|
|
|
int chIndex = ppp - ChStartIndex;
|
2023-03-23 19:57:14 -04:00
|
|
|
isDisableDetector = false;
|
2023-03-31 20:01:27 -04:00
|
|
|
nChInGroupBox ++;
|
2023-03-23 19:57:14 -04:00
|
|
|
|
2023-03-31 20:01:27 -04:00
|
|
|
int digiID = (detIDArray[ppp] >> 8 );
|
|
|
|
int chID = (detIDArray[ppp] & 0xFF);
|
|
|
|
|
|
|
|
int typeID = FindDetTypeID(mapping[digiID][chID]);
|
2023-03-20 15:52:04 -04:00
|
|
|
|
2023-04-03 12:25:23 -04:00
|
|
|
QLabel * lb = new QLabel(detTypeNameList[typeID].remove(' '), this);
|
2023-03-31 20:01:27 -04:00
|
|
|
layout0->addWidget(lb, 2*chIndex, 0, 2, 1);
|
2023-03-20 19:53:47 -04:00
|
|
|
|
|
|
|
chkOnOff[SettingID][digiID][chID] = new QCheckBox(this);
|
2023-03-27 12:46:03 -04:00
|
|
|
layout0->addWidget(chkOnOff[SettingID][digiID][chID], 2*chIndex, 1, 2, 1);
|
2023-03-20 19:53:47 -04:00
|
|
|
|
|
|
|
leDisplay[SettingID][digiID][chID] = new QLineEdit(this);
|
|
|
|
leDisplay[SettingID][digiID][chID]->setFixedWidth(70);
|
2023-03-27 12:46:03 -04:00
|
|
|
layout0->addWidget(leDisplay[SettingID][digiID][chID], 2*chIndex, 2);
|
2023-03-20 15:52:04 -04:00
|
|
|
|
2023-03-20 19:53:47 -04:00
|
|
|
sbSetting[SettingID][digiID][chID] = new RSpinBox(this);
|
|
|
|
if( digiID < nDigi ) sbSetting[SettingID][digiID][chID]->setToolTip( "Digi-" + QString::number(digi[digiID]->GetSerialNumber()) + ", Ch-" + QString::number(chID));
|
|
|
|
sbSetting[SettingID][digiID][chID]->setToolTipDuration(-1);
|
|
|
|
sbSetting[SettingID][digiID][chID]->setFixedWidth(70);
|
2023-03-20 15:52:04 -04:00
|
|
|
|
2023-03-20 19:53:47 -04:00
|
|
|
sbSetting[SettingID][digiID][chID]->setMinimum(atoi(SettingItems[SettingID].GetAnswers()[0].first.c_str()));
|
|
|
|
sbSetting[SettingID][digiID][chID]->setMaximum(atoi(SettingItems[SettingID].GetAnswers()[1].first.c_str()));
|
|
|
|
sbSetting[SettingID][digiID][chID]->setSingleStep(atoi(SettingItems[SettingID].GetAnswers()[2].first.c_str()));
|
2023-03-20 15:52:04 -04:00
|
|
|
|
2023-03-27 12:46:03 -04:00
|
|
|
layout0->addWidget(sbSetting[SettingID][digiID][chID], 2*chIndex+1, 2);
|
2023-03-20 19:53:47 -04:00
|
|
|
|
|
|
|
if( digiID >= nDigi || chID >= digi[digiID]->GetNChannels() ) {
|
|
|
|
leDisplay[SettingID][digiID][chID]->setEnabled(false);
|
|
|
|
sbSetting[SettingID][digiID][chID]->setEnabled(false);
|
2023-03-23 19:57:14 -04:00
|
|
|
chkOnOff[SettingID][digiID][chID]->setEnabled(false);
|
|
|
|
isDisableDetector = true;
|
2023-03-20 19:53:47 -04:00
|
|
|
}
|
|
|
|
|
2023-03-22 18:16:26 -04:00
|
|
|
///========================= for SpinBox
|
2023-03-20 19:53:47 -04:00
|
|
|
RSpinBox * spb = sbSetting[SettingID][digiID][chID];
|
2023-03-20 15:52:04 -04:00
|
|
|
const Reg para = SettingItems[SettingID];
|
|
|
|
|
|
|
|
connect(spb, &RSpinBox::valueChanged, this, [=](){
|
|
|
|
if( !enableSignalSlot ) return;
|
|
|
|
spb->setStyleSheet("color:blue;");
|
|
|
|
});
|
|
|
|
|
|
|
|
connect(spb, &RSpinBox::returnPressed, this, [=](){
|
|
|
|
if( !enableSignalSlot ) return;
|
|
|
|
//printf("%s %d %d \n", para.GetPara().c_str(), index, spb->value());
|
|
|
|
if( spb->decimals() == 0 && spb->singleStep() != 1) {
|
|
|
|
double step = spb->singleStep();
|
|
|
|
double value = spb->value();
|
|
|
|
spb->setValue( (std::round(value/step) * step) );
|
|
|
|
}
|
2023-03-24 19:23:36 -04:00
|
|
|
|
2023-03-31 20:01:27 -04:00
|
|
|
if( chkAll[detGroup][SettingID]->isChecked() ){
|
2023-04-03 12:25:23 -04:00
|
|
|
for(int k = 0; k < detIDArrayList.size() ; k++){
|
|
|
|
if( detGroup == detIDArrayList[k][0] ){
|
|
|
|
for( int h = ChStartIndex; h < detIDArrayList[k].size() ; h++){
|
2023-03-31 20:01:27 -04:00
|
|
|
if( h != chIndex + ChStartIndex) continue;
|
2023-04-03 12:25:23 -04:00
|
|
|
int digiK = (detIDArrayList[k][h] >> 8);
|
2023-03-31 20:01:27 -04:00
|
|
|
if( digiK >= nDigi ) continue;
|
2023-04-03 12:25:23 -04:00
|
|
|
int index = (detIDArrayList[k][h] & 0xFF);
|
2023-03-27 12:46:03 -04:00
|
|
|
|
|
|
|
QString msg;
|
2023-03-31 20:01:27 -04:00
|
|
|
msg = QString::fromStdString(para.GetPara()) + "|DIG:"+ QString::number(digi[digiK]->GetSerialNumber());
|
2023-04-03 12:25:23 -04:00
|
|
|
msg += ",CH:" + QString::number(index) + "(" + detTypeNameList[typeID] + ")";
|
2023-03-27 12:46:03 -04:00
|
|
|
msg += " = " + QString::number(spb->value());
|
|
|
|
|
2023-03-31 20:01:27 -04:00
|
|
|
if( digi[digiK]->WriteValue(para, std::to_string(spb->value()), index)){
|
2023-03-27 12:46:03 -04:00
|
|
|
SendLogMsg(msg + "|OK.");
|
|
|
|
spb->setStyleSheet("");
|
|
|
|
}else{
|
|
|
|
SendLogMsg(msg + "|Fail.");
|
|
|
|
spb->setStyleSheet("color:red;");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-03-20 15:52:04 -04:00
|
|
|
}else{
|
2023-03-27 12:46:03 -04:00
|
|
|
QString msg;
|
|
|
|
msg = QString::fromStdString(para.GetPara()) + "|DIG:"+ QString::number(digi[digiID]->GetSerialNumber());
|
2023-04-03 12:25:23 -04:00
|
|
|
msg += ",CH:" + QString::number(chID) + "(" + detTypeNameList[typeID] + ")";
|
2023-03-27 12:46:03 -04:00
|
|
|
msg += " = " + QString::number(spb->value());
|
|
|
|
if( digi[digiID]->WriteValue(para, std::to_string(spb->value()), chID)){
|
|
|
|
SendLogMsg(msg + "|OK.");
|
|
|
|
spb->setStyleSheet("");
|
|
|
|
}else{
|
|
|
|
SendLogMsg(msg + "|Fail.");
|
|
|
|
spb->setStyleSheet("color:red;");
|
|
|
|
}
|
2023-03-20 15:52:04 -04:00
|
|
|
}
|
2023-03-24 17:23:59 -04:00
|
|
|
UpdatePanelFromMemory();
|
|
|
|
UpdateOtherPanels();
|
2023-03-20 15:52:04 -04:00
|
|
|
});
|
2023-03-20 19:53:47 -04:00
|
|
|
|
2023-03-22 18:16:26 -04:00
|
|
|
///===================== for the OnOff CheckBox
|
|
|
|
connect(chkOnOff[SettingID][digiID][chID], &QCheckBox::stateChanged, this, [=](int state){
|
2023-03-20 19:53:47 -04:00
|
|
|
if( !enableSignalSlot ) return;
|
|
|
|
|
2023-03-31 20:01:27 -04:00
|
|
|
if( chkAll[detGroup][SettingID]->isChecked() ){
|
|
|
|
|
2023-04-03 12:25:23 -04:00
|
|
|
for(int k = 0; k < detIDArrayList.size() ; k++){
|
|
|
|
if( detGroup == detIDArrayList[k][0] ){
|
2023-03-27 12:46:03 -04:00
|
|
|
|
2023-04-03 12:25:23 -04:00
|
|
|
for( int h = ChStartIndex; h < detIDArrayList[k].size() ; h++){
|
2023-03-31 20:01:27 -04:00
|
|
|
if( h != chIndex + ChStartIndex) continue;
|
2023-04-03 12:25:23 -04:00
|
|
|
int digiK = (detIDArrayList[k][h] >> 8);
|
2023-03-31 20:01:27 -04:00
|
|
|
if( digiK >= nDigi ) continue;
|
2023-04-03 12:25:23 -04:00
|
|
|
int index = (detIDArrayList[k][h] & 0xFF);
|
2023-03-27 12:46:03 -04:00
|
|
|
QString msg;
|
2023-03-31 20:01:27 -04:00
|
|
|
msg = QString::fromStdString(PHA::CH::ChannelEnable.GetPara()) + "|DIG:"+ QString::number(digi[digiK]->GetSerialNumber());
|
2023-04-03 12:25:23 -04:00
|
|
|
msg += ",CH:" + QString::number(index) + "(" + detTypeNameList[typeID] + ")";
|
2023-03-27 12:46:03 -04:00
|
|
|
msg += ( state ? " = True" : " = False");
|
|
|
|
|
2023-03-31 20:01:27 -04:00
|
|
|
if( digi[digiK]->WriteValue(PHA::CH::ChannelEnable, state ? "True" : "False", index)){
|
2023-03-27 12:46:03 -04:00
|
|
|
SendLogMsg(msg + "|OK.");
|
|
|
|
enableSignalSlot = false;
|
2023-03-31 20:01:27 -04:00
|
|
|
|
|
|
|
leDisplay[detGroup][digiK][index]->setEnabled(state);
|
|
|
|
sbSetting[detGroup][digiK][index]->setEnabled(state);
|
|
|
|
chkOnOff [detGroup][digiK][index]->setChecked(state);
|
2023-03-27 12:46:03 -04:00
|
|
|
enableSignalSlot = true;
|
|
|
|
}else{
|
|
|
|
SendLogMsg(msg + "|Fail.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-03-31 20:01:27 -04:00
|
|
|
|
2023-03-27 12:46:03 -04:00
|
|
|
}else{
|
|
|
|
QString msg;
|
|
|
|
msg = QString::fromStdString(PHA::CH::ChannelEnable.GetPara()) + "|DIG:"+ QString::number(digi[digiID]->GetSerialNumber());
|
2023-03-31 20:01:27 -04:00
|
|
|
|
2023-04-03 12:25:23 -04:00
|
|
|
msg += ",CH:" + QString::number(chID) + "(" + detTypeNameList[typeID] + ")";
|
2023-03-27 12:46:03 -04:00
|
|
|
msg += ( state ? " = True" : " = False");
|
2023-03-31 20:01:27 -04:00
|
|
|
|
|
|
|
qDebug() << msg;
|
2023-03-27 12:46:03 -04:00
|
|
|
|
|
|
|
if( digi[digiID]->WriteValue(PHA::CH::ChannelEnable, state ? "True" : "False", chID)){
|
|
|
|
SendLogMsg(msg + "|OK.");
|
|
|
|
enableSignalSlot = false;
|
2023-03-31 20:01:27 -04:00
|
|
|
leDisplay[detGroup][digiID][chID]->setEnabled(state);
|
|
|
|
sbSetting[detGroup][digiID][chID]->setEnabled(state);
|
|
|
|
chkOnOff [detGroup][digiID][chID]->setChecked(state);
|
2023-03-27 12:46:03 -04:00
|
|
|
enableSignalSlot = true;
|
|
|
|
}else{
|
|
|
|
SendLogMsg(msg + "|Fail.");
|
|
|
|
}
|
2023-03-22 18:16:26 -04:00
|
|
|
}
|
2023-03-20 19:53:47 -04:00
|
|
|
|
2023-03-24 17:23:59 -04:00
|
|
|
UpdatePanelFromMemory();
|
|
|
|
UpdateOtherPanels();
|
2023-03-20 19:53:47 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
layout0->setColumnStretch(0, 1);
|
|
|
|
layout0->setColumnStretch(1, 1);
|
|
|
|
layout0->setColumnStretch(2, 5);
|
2023-03-20 15:52:04 -04:00
|
|
|
|
2023-03-17 18:13:36 -04:00
|
|
|
}
|
2023-03-17 17:08:56 -04:00
|
|
|
|
2023-03-23 13:08:47 -04:00
|
|
|
//@======================================== Trigger Combox
|
2023-03-22 18:16:26 -04:00
|
|
|
//=================== The Trigger depnds on 5 settings (at least)
|
|
|
|
// EventTriggerSource, WaveTriggerSource, CoincidentMask, AntiCoincidentMask
|
|
|
|
// 1, EventTriggerSource has 8 settings, ITLA, ITLB, GlobalTriggerSource, TRGIN, SWTrigger, ChSelfTrigger, Ch64Trigger, Disabled
|
|
|
|
// 2, WaveTriggerSource has 8 settings, always set to be equal EventTriggerSource
|
|
|
|
// 3, CoincidentMak has 6 Settings, Disabled, Ch64Trigger, TRGIN, GloableTriggerSource, ITLA, ITLB
|
|
|
|
// 4, AntiCoincidentMask has 6 Settings, always disabled
|
|
|
|
// 5, ChannelTriggerMask is a 64-bit
|
|
|
|
// 6, CoincidenceLengthT in ns, set to be 100 ns.
|
2023-03-22 12:36:24 -04:00
|
|
|
|
|
|
|
if( SettingItems[SettingID].GetPara() == PHA::CH::TriggerThreshold.GetPara()){
|
2023-03-31 20:01:27 -04:00
|
|
|
cbTrigger[detGroup][detID] = new RComboBox(this);
|
|
|
|
cbTrigger[detGroup][detID]->addItem("Self Trigger", "ChSelfTrigger"); /// no coincident
|
|
|
|
cbTrigger[detGroup][detID]->addItem("Trigger e", 0x1); // Self-trigger and coincient Ch64Trigger
|
|
|
|
cbTrigger[detGroup][detID]->addItem("Ext. Trigger", "TRGIN"); // with coincident with TRGIN.
|
|
|
|
cbTrigger[detGroup][detID]->addItem("Disabled", "Disabled"); // no Trigger, no coincident, basically channel still alive, but no recording
|
|
|
|
cbTrigger[detGroup][detID]->addItem("Others", -999); // other settings
|
2023-03-22 18:16:26 -04:00
|
|
|
|
2023-03-31 20:01:27 -04:00
|
|
|
layout0->addWidget(cbTrigger[detGroup][detID], 2*nChInGroupBox, 0, 1, 3);
|
2023-03-23 19:57:14 -04:00
|
|
|
|
2023-03-31 20:01:27 -04:00
|
|
|
if( isDisableDetector ) cbTrigger[detGroup][detID]->setEnabled(false);
|
2023-03-22 18:16:26 -04:00
|
|
|
|
2023-03-27 12:46:03 -04:00
|
|
|
//*========== connection
|
2023-03-31 20:01:27 -04:00
|
|
|
connect(cbTrigger[detGroup][detID], &RComboBox::currentIndexChanged, this , [=](int index){
|
2023-03-22 18:16:26 -04:00
|
|
|
if( !enableSignalSlot) return;
|
|
|
|
|
2023-03-31 20:01:27 -04:00
|
|
|
if( chkAll[detGroup][SettingID]->isChecked() ){
|
|
|
|
|
2023-04-03 12:25:23 -04:00
|
|
|
for( int k = 0; k < detIDArrayList.size(); k++){
|
|
|
|
if( detIDArrayList[k][0] != detGroup ) continue;
|
|
|
|
int haha = detIDArrayList[k][1];
|
|
|
|
if( haha == detID )continue;
|
|
|
|
cbTrigger[detGroup][haha]->setCurrentIndex(index);
|
2023-03-27 12:46:03 -04:00
|
|
|
}
|
2023-04-03 12:25:23 -04:00
|
|
|
|
2023-03-27 12:46:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
///----------- single
|
2023-03-31 20:01:27 -04:00
|
|
|
for( int i = ChStartIndex ; i < detIDArray.size(); i++){
|
2023-03-22 18:16:26 -04:00
|
|
|
|
2023-03-31 20:01:27 -04:00
|
|
|
int digiID = (detIDArray[i] >> 8 );
|
|
|
|
if( digiID >= nDigi) continue;
|
|
|
|
int chID = (detIDArray[i] & 0xFF);
|
2023-03-22 18:16:26 -04:00
|
|
|
|
2023-03-23 19:57:14 -04:00
|
|
|
if( digi[digiID]->IsDummy() || !digi[digiID]->IsConnected() ) continue;
|
|
|
|
|
2023-03-22 18:16:26 -04:00
|
|
|
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;
|
2023-03-27 12:46:03 -04:00
|
|
|
case 1 : { /// trigger by energy
|
2023-03-22 18:16:26 -04:00
|
|
|
digi[digiID]->WriteValue(PHA::CH::EventTriggerSource, "ChSelfTrigger", chID);
|
|
|
|
digi[digiID]->WriteValue(PHA::CH::WaveTriggerSource, "ChSelfTrigger", chID);
|
|
|
|
|
2023-03-31 20:01:27 -04:00
|
|
|
if( i == ChStartIndex ){
|
2023-03-23 16:36:47 -04:00
|
|
|
digi[digiID]->WriteValue(PHA::CH::CoincidenceMask, "Disabled", chID);
|
|
|
|
}else {
|
2023-03-22 18:16:26 -04:00
|
|
|
digi[digiID]->WriteValue(PHA::CH::CoincidenceMask, "Ch64Trigger", chID);
|
2023-03-27 15:48:41 -04:00
|
|
|
digi[digiID]->WriteValue(PHA::CH::CoincidenceLength, "100");
|
2023-03-22 18:16:26 -04:00
|
|
|
|
|
|
|
//Form the trigger bit
|
2023-03-31 20:01:27 -04:00
|
|
|
unsigned long mask = 1ULL << (detIDArray[ChStartIndex] & 0xFF ); // trigger by energy
|
2023-03-23 13:08:47 -04:00
|
|
|
QString maskStr = QString::number(mask);
|
2023-03-22 18:16:26 -04:00
|
|
|
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);
|
|
|
|
|
2023-03-27 15:48:41 -04:00
|
|
|
digi[digiID]->WriteValue(PHA::CH::CoincidenceLength, "100");
|
2023-03-22 18:16:26 -04:00
|
|
|
}; 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;
|
|
|
|
}
|
2023-03-27 12:46:03 -04:00
|
|
|
|
2023-03-31 20:01:27 -04:00
|
|
|
SendLogMsg("SOLARIS panel : Set Trigger = " + cbTrigger[detGroup][detID]->itemText(index) + "|Digi:" + QString::number(digi[digiID]->GetSerialNumber()) + ",Det:" + QString::number(detID));
|
2023-03-27 12:46:03 -04:00
|
|
|
|
2023-03-22 18:16:26 -04:00
|
|
|
}
|
2023-03-24 19:23:36 -04:00
|
|
|
UpdatePanelFromMemory();
|
|
|
|
UpdateOtherPanels();
|
2023-03-20 15:52:04 -04:00
|
|
|
|
2023-03-22 18:16:26 -04:00
|
|
|
});
|
2023-03-17 17:08:56 -04:00
|
|
|
|
2023-03-24 17:23:59 -04:00
|
|
|
|
2023-03-22 18:16:26 -04:00
|
|
|
}
|
2023-03-31 20:01:27 -04:00
|
|
|
layout->addWidget(groupBox[detGroup][SettingID][detID], row, col);
|
2023-03-17 17:08:56 -04:00
|
|
|
}
|
|
|
|
|
2023-03-23 19:57:14 -04:00
|
|
|
//^##############################################################
|
|
|
|
void SOLARISpanel::RefreshSettings(){
|
|
|
|
for( int i = 0 ; i < nDigi; i++){
|
|
|
|
if( digi[i]->IsDummy() || !digi[i]->IsConnected()){
|
|
|
|
digi[i]->ReadAllSettings();
|
|
|
|
}
|
|
|
|
}
|
2023-03-24 17:23:59 -04:00
|
|
|
UpdatePanelFromMemory();
|
2023-03-23 19:57:14 -04:00
|
|
|
}
|
2023-03-17 17:08:56 -04:00
|
|
|
|
2023-03-24 17:23:59 -04:00
|
|
|
void SOLARISpanel::UpdatePanelFromMemory(){
|
|
|
|
|
|
|
|
if( !isVisible() ) return;
|
|
|
|
|
2023-03-20 15:52:04 -04:00
|
|
|
enableSignalSlot = false;
|
2023-03-20 19:53:47 -04:00
|
|
|
|
2023-03-24 17:23:59 -04:00
|
|
|
printf("SOLARISpanel::%s\n", __func__);
|
2023-03-23 19:57:14 -04:00
|
|
|
|
2023-03-24 17:23:59 -04:00
|
|
|
//@===================== LineEdit and SpinBox
|
2023-03-20 15:52:04 -04:00
|
|
|
for( int SettingID = 0; SettingID < (int) SettingItems.size() ; SettingID ++){
|
|
|
|
for( int DigiID = 0; DigiID < (int) mapping.size(); DigiID ++){
|
|
|
|
if( DigiID >= nDigi ) continue;;
|
|
|
|
for( int chID = 0; chID < (int) mapping[DigiID].size(); chID++){
|
|
|
|
if( mapping[DigiID][chID] < 0 ) continue;
|
|
|
|
|
|
|
|
std::string haha = digi[DigiID]->GetSettingValue(SettingItems[SettingID], chID);
|
|
|
|
sbSetting[SettingID][DigiID][chID]->setValue( atof(haha.c_str()));
|
|
|
|
|
|
|
|
if( SettingItems[SettingID].GetPara() == PHA::CH::TriggerThreshold.GetPara() ){
|
|
|
|
std::string haha = digi[DigiID]->GetSettingValue(PHA::CH::SelfTrgRate, chID);
|
2023-03-31 20:01:27 -04:00
|
|
|
leDisplay[SettingID][DigiID][chID]->setText(QString::number(atof(haha.c_str()), 'f', 2) );
|
2023-03-20 15:52:04 -04:00
|
|
|
}else{
|
2023-03-31 20:01:27 -04:00
|
|
|
leDisplay[SettingID][DigiID][chID]->setText(QString::number(atof(haha.c_str()), 'f', 2) );
|
2023-03-20 15:52:04 -04:00
|
|
|
}
|
2023-03-20 19:53:47 -04:00
|
|
|
|
|
|
|
haha = digi[DigiID]->GetSettingValue(PHA::CH::ChannelEnable, chID);
|
|
|
|
chkOnOff[SettingID][DigiID][chID]->setChecked( haha == "True" ? true : false);
|
2023-03-24 17:23:59 -04:00
|
|
|
leDisplay[SettingID][DigiID][chID]->setEnabled(haha == "True" ? true : false);
|
|
|
|
sbSetting[SettingID][DigiID][chID]->setEnabled(haha == "True" ? true : false);
|
|
|
|
|
2023-03-31 20:01:27 -04:00
|
|
|
//printf("====== %d %d %d |%s|\n", SettingID, DigiID, chID, haha.c_str());
|
2023-03-20 15:52:04 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-24 17:23:59 -04:00
|
|
|
//@===================== Trigger
|
2023-04-03 12:25:23 -04:00
|
|
|
for( int k = 0; k < detIDArrayList.size() ; k++){
|
|
|
|
if( detIDArrayList[k][1] >= detMaxID[0] || 0 > detIDArrayList[k][1]) continue; //! only for array
|
2023-03-20 19:53:47 -04:00
|
|
|
|
2023-04-03 12:25:23 -04:00
|
|
|
if( detIDArrayList[k][0] != 0 ) continue;
|
2023-03-31 20:01:27 -04:00
|
|
|
|
2023-03-20 19:53:47 -04:00
|
|
|
//if( detIDList[k].size() <= 2) continue;
|
2023-04-03 12:25:23 -04:00
|
|
|
bool skipFlag = false;
|
2023-03-20 19:53:47 -04:00
|
|
|
std::vector<unsigned long> triggerMap;
|
|
|
|
std::vector<std::string> coincidentMask;
|
2023-03-22 18:16:26 -04:00
|
|
|
std::vector<std::string> antiCoincidentMask;
|
2023-03-20 19:53:47 -04:00
|
|
|
std::vector<std::string> eventTriggerSource;
|
2023-03-22 18:16:26 -04:00
|
|
|
std::vector<std::string> waveTriggerSource;
|
2023-03-20 19:53:47 -04:00
|
|
|
|
2023-04-03 12:25:23 -04:00
|
|
|
for( int h = ChStartIndex; h < detIDArrayList[k].size(); h++){
|
|
|
|
int digiID = detIDArrayList[k][h] >> 8;
|
|
|
|
if( digiID >= nDigi) {
|
|
|
|
skipFlag = true;
|
|
|
|
continue;
|
|
|
|
}
|
2023-03-23 19:57:14 -04:00
|
|
|
|
2023-04-03 12:25:23 -04:00
|
|
|
int chID = (detIDArrayList[k][h] & 0xFF);
|
2023-03-23 19:57:14 -04:00
|
|
|
triggerMap.push_back(Utility::TenBase(digi[digiID]->GetSettingValue(PHA::CH::ChannelsTriggerMask, chID)));
|
2023-03-20 19:53:47 -04:00
|
|
|
coincidentMask.push_back(digi[digiID]->GetSettingValue(PHA::CH::CoincidenceMask, chID));
|
2023-03-22 18:16:26 -04:00
|
|
|
antiCoincidentMask.push_back(digi[digiID]->GetSettingValue(PHA::CH::AntiCoincidenceMask, chID));
|
2023-03-20 19:53:47 -04:00
|
|
|
eventTriggerSource.push_back(digi[digiID]->GetSettingValue(PHA::CH::EventTriggerSource, chID));
|
2023-03-22 18:16:26 -04:00
|
|
|
waveTriggerSource.push_back(digi[digiID]->GetSettingValue(PHA::CH::WaveTriggerSource, chID));
|
2023-03-20 19:53:47 -04:00
|
|
|
}
|
|
|
|
|
2023-04-03 12:25:23 -04:00
|
|
|
if(skipFlag) continue;
|
|
|
|
|
2023-03-20 19:53:47 -04:00
|
|
|
//====== only acceptable condition is eventTriggerSource are all ChSelfTrigger
|
|
|
|
// and coincidentMask for e, xf, xn, are at least one for Ch64Trigger
|
2023-03-22 18:16:26 -04:00
|
|
|
// and waveTriggerSource are all ChSelfTrigger
|
|
|
|
|
2023-03-24 19:23:36 -04:00
|
|
|
//====== a stupid way
|
|
|
|
// triggerSource : Other = 0x0, Disabled = 0x1, ChSelfTrigger = 0x2, TRGIN = 0x3
|
|
|
|
// CoinMask : Other = 0x0, Disbaled = 0x1, Ch64Trigger = 0x2, TRGIN = 0x3
|
|
|
|
// for example, SelfTrigger should be, 0x2211, triggerMask does not matter.
|
|
|
|
// |||+-- anti-coin
|
|
|
|
// ||+-- coin
|
|
|
|
// |+-- wave
|
|
|
|
// +-- event
|
|
|
|
|
|
|
|
// comboxIndex 0) SelfTrigger 0x2211, any trigger mask
|
|
|
|
// comboxIndex 2) TRGIN 0x3331, any trigger mask
|
|
|
|
// comboxIndex 3) Disable 0x1111, any trigger mask
|
|
|
|
// comboxIndex 1) Trigger E {0x2211 - e , 0x2221 - xf, 0x2221 - xn },
|
|
|
|
// triggerMask { 0, 0x1, 0x1}
|
|
|
|
// comboxIndex 4) Other settings
|
|
|
|
|
|
|
|
std::vector<unsigned int> stupidIndex;
|
|
|
|
for( int i = 0 ; i < (int) triggerMap.size(); i++){
|
|
|
|
unsigned int index = 0;
|
|
|
|
if(antiCoincidentMask[i] == "Disabled") index += 0x1;
|
|
|
|
if(antiCoincidentMask[i] == "Ch64Trigger") index += 0x2;
|
|
|
|
if(antiCoincidentMask[i] == "TRGIN") index += 0x3;
|
|
|
|
|
|
|
|
if(coincidentMask[i] == "Disabled") index += 0x10;
|
|
|
|
if(coincidentMask[i] == "Ch64Trigger") index += 0x20;
|
|
|
|
if(coincidentMask[i] == "TRGIN") index += 0x30;
|
|
|
|
|
|
|
|
if(waveTriggerSource[i] == "Disabled") index += 0x100;
|
|
|
|
if(waveTriggerSource[i] == "ChSelfTrigger") index += 0x200;
|
|
|
|
if(waveTriggerSource[i] == "TRGIN") index += 0x300;
|
|
|
|
|
|
|
|
if(eventTriggerSource[i] == "Disabled") index += 0x1000;
|
|
|
|
if(eventTriggerSource[i] == "ChSelfTrigger") index += 0x2000;
|
|
|
|
if(eventTriggerSource[i] == "TRGIN") index += 0x3000;
|
|
|
|
|
|
|
|
stupidIndex.push_back(index);
|
|
|
|
}
|
|
|
|
|
2023-04-03 12:25:23 -04:00
|
|
|
//printf("===================== detIDList : %d %d \n", detIDList[k][0], detIDList[k][1]);
|
|
|
|
|
2023-03-24 19:23:36 -04:00
|
|
|
int jaja[5] = {0}; // this store the count for each comboxIndex;
|
|
|
|
for( int i = 0; i < (int) stupidIndex.size(); i++){
|
|
|
|
//printf(" %d | 0x%s \n", i, QString::number(stupidIndex[i], 16).toUpper().toStdString().c_str());
|
|
|
|
if( stupidIndex[i] == 0x2211 ) jaja[0] ++;
|
|
|
|
if( stupidIndex[i] == 0x3331 ) jaja[2] ++;
|
|
|
|
if( stupidIndex[i] == 0x1111 ) jaja[3] ++;
|
|
|
|
if( i == 0 && stupidIndex[i] == 0x2211 ) jaja[1] ++;
|
|
|
|
if( i > 0 && stupidIndex[i] == 0x2221 ) jaja[1] ++;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Search for jaja, see is there any one equal to total number of ch;
|
|
|
|
int comboxIndex = 4;
|
|
|
|
for( int i = 0; i < 5; i++){
|
|
|
|
//printf("%d | %d \n", i, jaja[i]);
|
|
|
|
if( jaja[i] == (int) stupidIndex.size() )comboxIndex = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
//printf("comboxIndex : %d \n", comboxIndex);
|
|
|
|
|
|
|
|
// if Trigger e, need to check the trigger mask;
|
|
|
|
if( comboxIndex == 3){
|
2023-04-03 12:25:23 -04:00
|
|
|
unsigned long ShouldBeMask = 1ULL << (detIDArrayList[k][ChStartIndex] & 0xFF);
|
2023-03-24 19:23:36 -04:00
|
|
|
for( int i = 1; i < (int) triggerMap.size(); i ++){
|
|
|
|
//printf(" %d | %lu =? %lu \n", i, triggerMap[i], ShouldBeMask);
|
|
|
|
if( triggerMap[i] != ShouldBeMask) comboxIndex = 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-03 12:25:23 -04:00
|
|
|
int detGroup = FindDetGroup(detIDArrayList[k][1]);
|
|
|
|
cbTrigger[detGroup][detIDArrayList[k][1]]->setCurrentIndex(comboxIndex);
|
2023-03-24 19:23:36 -04:00
|
|
|
|
2023-03-20 19:53:47 -04:00
|
|
|
}
|
|
|
|
|
2023-03-24 17:23:59 -04:00
|
|
|
//@===================== Coin. time
|
|
|
|
std::vector<int> coinTime;
|
|
|
|
|
2023-04-03 12:25:23 -04:00
|
|
|
for( int i = 0; i < detIDArrayList.size(); i++){
|
|
|
|
for( int j = ChStartIndex; j < detIDArrayList[i].size(); j++){
|
|
|
|
int digiID = detIDArrayList[i][j] >> 8;
|
|
|
|
int chID = (detIDArrayList[i][j] & 0xFF);
|
2023-03-24 17:23:59 -04:00
|
|
|
if( digiID >= nDigi ) continue;
|
|
|
|
if( digi[digiID]->IsDummy() || !digi[digiID]->IsConnected() ) continue;
|
|
|
|
coinTime.push_back( atoi(digi[digiID]->GetSettingValue(PHA::CH::CoincidenceLength, chID).c_str()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isSameCoinTime = true;
|
|
|
|
for( int i = 1; i < (int) coinTime.size(); i++){
|
|
|
|
if( coinTime[i] != coinTime[0]) {
|
|
|
|
isSameCoinTime = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( isSameCoinTime ){
|
|
|
|
sbCoinTime->setValue(coinTime[0]);
|
|
|
|
}else{
|
|
|
|
sbCoinTime->setValue(-1);
|
|
|
|
}
|
|
|
|
|
2023-03-20 15:52:04 -04:00
|
|
|
enableSignalSlot = true;
|
2023-03-24 17:23:59 -04:00
|
|
|
|
2023-03-20 15:52:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void SOLARISpanel::UpdateThreshold(){
|
|
|
|
|
|
|
|
for( int SettingID = 0; SettingID < (int) SettingItems.size() ; SettingID ++){
|
|
|
|
if( SettingItems[SettingID].GetPara() != PHA::CH::TriggerThreshold.GetPara() ) continue;
|
|
|
|
|
|
|
|
for( int DigiID = 0; DigiID < (int) mapping.size(); DigiID ++){
|
|
|
|
if( DigiID >= nDigi ) continue;;
|
|
|
|
|
|
|
|
for( int chID = 0; chID < (int) mapping[DigiID].size(); chID++){
|
|
|
|
|
|
|
|
if( mapping[DigiID][chID] < 0 ) continue;
|
|
|
|
|
|
|
|
std::string haha = digi[DigiID]->GetSettingValue(PHA::CH::SelfTrgRate, chID);
|
|
|
|
leDisplay[SettingID][DigiID][chID]->setText(QString::fromStdString(haha));
|
|
|
|
|
|
|
|
///printf("====== %d %d %d |%s|\n", SettingID, DigiID, chID, haha.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-03-23 19:57:14 -04:00
|
|
|
|
|
|
|
//^#########################################
|
|
|
|
void SOLARISpanel::SaveSettings(){
|
|
|
|
|
2023-03-27 15:48:41 -04:00
|
|
|
for(int i = 0; i < nDigi; i++){
|
|
|
|
|
|
|
|
//*------ search for settings_XXXX.dat
|
|
|
|
|
|
|
|
//Check path exist
|
|
|
|
QDir dir(digiSettingPath);
|
|
|
|
if( !dir.exists() ) dir.mkpath(".");
|
|
|
|
|
|
|
|
QString settingFile = digiSettingPath + "/setting_" + QString::number(digi[i]->GetSerialNumber()) + "_" + QDateTime::currentDateTime().toString("yyyyMMdd_hhmmss") + ".dat";
|
|
|
|
|
|
|
|
|
|
|
|
int flag = digi[i]->SaveSettingsToFile(settingFile.toStdString().c_str());
|
|
|
|
|
|
|
|
switch (flag) {
|
|
|
|
case 1 : {
|
|
|
|
SendLogMsg("Saved setting file <b>" + settingFile + "</b>.");
|
|
|
|
}; break;
|
|
|
|
case 0 : {
|
|
|
|
SendLogMsg("<font style=\"color:red;\"> Fail to write setting file. <b> " + settingFile + " </b></font>");
|
|
|
|
}; break;
|
|
|
|
case -1 : {
|
|
|
|
SendLogMsg("<font style=\"color:red;\"> Fail to save setting file <b> " + settingFile + " </b>, same settings are empty.</font>");
|
|
|
|
}; break;
|
|
|
|
};
|
2023-03-23 19:57:14 -04:00
|
|
|
|
2023-03-27 15:48:41 -04:00
|
|
|
}
|
2023-03-23 19:57:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void SOLARISpanel::LoadSettings(){
|
2023-03-27 15:48:41 -04:00
|
|
|
for(int i = 0; i < nDigi; i++){
|
|
|
|
|
|
|
|
//*------ search for settings_XXXX.dat
|
|
|
|
QString settingFile = digiSettingPath + "/settings_" + QString::number(digi[i]->GetSerialNumber()) + ".dat";
|
|
|
|
if( digi[i]->LoadSettingsFromFile( settingFile.toStdString().c_str() ) ){
|
|
|
|
SendLogMsg("Found setting file <b>" + settingFile + "</b> and loading. please wait.");
|
|
|
|
digi[i]->SetSettingFileName(settingFile.toStdString());
|
|
|
|
SendLogMsg("done settings.");
|
|
|
|
}else{
|
|
|
|
SendLogMsg("<font style=\"color: red;\">Unable to found setting file <b>" + settingFile + "</b>. </font>");
|
|
|
|
digi[i]->SetSettingFileName("");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2023-03-23 19:57:14 -04:00
|
|
|
|
|
|
|
}
|