SOLARIS panel, chkBox for all

This commit is contained in:
Ryan Tang 2023-03-27 12:46:03 -04:00
parent e21e324f78
commit 31d6346151
2 changed files with 101 additions and 113 deletions

View File

@ -172,7 +172,6 @@ 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======= check all
chkAll[detTypeID][SettingID] = new QCheckBox("Set for all", tab); chkAll[detTypeID][SettingID] = new QCheckBox("Set for all", tab);
layout->addWidget(chkAll[detTypeID][SettingID], 0, 0); layout->addWidget(chkAll[detTypeID][SettingID], 0, 0);
connect(chkAll[detTypeID][SettingID], &QCheckBox::stateChanged, this, [=](bool state){ connect(chkAll[detTypeID][SettingID], &QCheckBox::stateChanged, this, [=](bool state){
@ -183,25 +182,12 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi,
} }
}); });
if( SettingItems[SettingID].GetPara() == PHA::CH::TriggerThreshold.GetPara() && detTypeID == 0){
chkAlle = new QCheckBox("Set for all e", tab);
layout->addWidget(chkAlle, 0, 1);
chkAllxf = new QCheckBox("Set for all xf", tab);
layout->addWidget(chkAllxf, 0, 2);
chkAllxn = new QCheckBox("Set for all xn", tab);
layout->addWidget(chkAllxn, 0, 3);
}
QFrame *line = new QFrame(tab); QFrame *line = new QFrame(tab);
line->setFrameShape(QFrame::HLine); line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken); line->setFrameShadow(QFrame::Sunken);
line->setFixedHeight(10); line->setFixedHeight(10);
layout->addWidget(line, 1, 0, 1, NCOL); layout->addWidget(line, 1, 0, 1, NCOL);
//range of detID //range of detID
int lowID = (detTypeID == 0 ? 0 : detMaxID[detTypeID-1]); int lowID = (detTypeID == 0 ? 0 : detMaxID[detTypeID-1]);
@ -212,9 +198,6 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi,
} }
} }
} }
@ -225,7 +208,7 @@ SOLARISpanel::~SOLARISpanel(){
} }
//^###################################################################### //^######################################################################
int SOLARISpanel::FindDetTypID(QList<int> detIDListElement){ int SOLARISpanel::FindDetTypeID(QList<int> detIDListElement){
for( int i = 0; i < (int) detType.size(); i++){ for( int i = 0; i < (int) detType.size(); i++){
int lowID = (i == 0) ? 0 : detMaxID[i-1]; int lowID = (i == 0) ? 0 : detMaxID[i-1];
if( lowID <= detIDListElement[0] && detIDListElement[0] < detMaxID[i]) { if( lowID <= detIDListElement[0] && detIDListElement[0] < detMaxID[i]) {
@ -247,22 +230,22 @@ void SOLARISpanel::CreateDetGroup(int detTypeID, int SettingID, QList<int> detID
//@======================================== SpinBox and Display //@======================================== SpinBox and Display
bool isDisableDetector = false; bool isDisableDetector = false;
for( int i = 1; i < (int) detID.size(); i ++){ for( int chIndex = 1; chIndex < (int) detID.size(); chIndex ++){
isDisableDetector = false; isDisableDetector = false;
QLabel * lb = new QLabel(arrayLabel[i-1], this); QLabel * lb = new QLabel(arrayLabel[chIndex-1], this);
layout0->addWidget(lb, 2*i, 0, 2, 1); layout0->addWidget(lb, 2*chIndex, 0, 2, 1);
int digiID = (detID[i] >> 8 ); int digiID = (detID[chIndex] >> 8 );
int chID = (detID[i] & 0xFF); int chID = (detID[chIndex] & 0xFF);
chkOnOff[SettingID][digiID][chID] = new QCheckBox(this); chkOnOff[SettingID][digiID][chID] = new QCheckBox(this);
layout0->addWidget(chkOnOff[SettingID][digiID][chID], 2*i, 1, 2, 1); layout0->addWidget(chkOnOff[SettingID][digiID][chID], 2*chIndex, 1, 2, 1);
leDisplay[SettingID][digiID][chID] = new QLineEdit(this); leDisplay[SettingID][digiID][chID] = new QLineEdit(this);
leDisplay[SettingID][digiID][chID]->setFixedWidth(70); leDisplay[SettingID][digiID][chID]->setFixedWidth(70);
layout0->addWidget(leDisplay[SettingID][digiID][chID], 2*i, 2); layout0->addWidget(leDisplay[SettingID][digiID][chID], 2*chIndex, 2);
sbSetting[SettingID][digiID][chID] = new RSpinBox(this); 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)); if( digiID < nDigi ) sbSetting[SettingID][digiID][chID]->setToolTip( "Digi-" + QString::number(digi[digiID]->GetSerialNumber()) + ", Ch-" + QString::number(chID));
@ -274,7 +257,7 @@ void SOLARISpanel::CreateDetGroup(int detTypeID, int SettingID, QList<int> detID
sbSetting[SettingID][digiID][chID]->setSingleStep(atoi(SettingItems[SettingID].GetAnswers()[2].first.c_str())); sbSetting[SettingID][digiID][chID]->setSingleStep(atoi(SettingItems[SettingID].GetAnswers()[2].first.c_str()));
sbSetting[SettingID][digiID][chID]->SetToolTip(); sbSetting[SettingID][digiID][chID]->SetToolTip();
layout0->addWidget(sbSetting[SettingID][digiID][chID], 2*i+1, 2); layout0->addWidget(sbSetting[SettingID][digiID][chID], 2*chIndex+1, 2);
if( digiID >= nDigi || chID >= digi[digiID]->GetNChannels() ) { if( digiID >= nDigi || chID >= digi[digiID]->GetNChannels() ) {
leDisplay[SettingID][digiID][chID]->setEnabled(false); leDisplay[SettingID][digiID][chID]->setEnabled(false);
@ -301,18 +284,40 @@ void SOLARISpanel::CreateDetGroup(int detTypeID, int SettingID, QList<int> detID
spb->setValue( (std::round(value/step) * step) ); spb->setValue( (std::round(value/step) * step) );
} }
int index = (chkAll[detTypeID][SettingID]->isChecked() ? -1 : chID); if( chkAll[detTypeID][SettingID]->isChecked() ){
for(int k = 0; k < detIDList.size() ; k++){
if( detTypeID == FindDetTypeID(detIDList[k]) ){
for( int h = 1; h < detIDList[k].size() ; h++){
if( h != chIndex) continue;
int index = (detIDList[k][h] & 0xFF);
QString msg; QString msg;
msg = QString::fromStdString(para.GetPara()) + "|DIG:"+ QString::number(digi[digiID]->GetSerialNumber()); msg = QString::fromStdString(para.GetPara()) + "|DIG:"+ QString::number(digi[digiID]->GetSerialNumber());
msg += ",CH:" + (index == - 1 ? "All" : QString::number(chID)) ; msg += ",CH:" + QString::number(index) + "(" + arrayLabel[chIndex-1] + ")";
msg += " = " + QString::number(spb->value()); msg += " = " + QString::number(spb->value());
if( digi[digiID]->WriteValue(para, std::to_string(spb->value()), index)){
SendLogMsg(msg + "|OK."); if( digi[digiID]->WriteValue(para, std::to_string(spb->value()), index)){
spb->setStyleSheet(""); SendLogMsg(msg + "|OK.");
spb->setStyleSheet("");
}else{
SendLogMsg(msg + "|Fail.");
spb->setStyleSheet("color:red;");
}
}
}
}
}else{ }else{
SendLogMsg(msg + "|Fail."); QString msg;
spb->setStyleSheet("color:red;"); msg = QString::fromStdString(para.GetPara()) + "|DIG:"+ QString::number(digi[digiID]->GetSerialNumber());
msg += ",CH:" + QString::number(chID) + "(" + arrayLabel[chIndex-1] + ")";
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;");
}
} }
UpdatePanelFromMemory(); UpdatePanelFromMemory();
UpdateOtherPanels(); UpdateOtherPanels();
@ -322,20 +327,55 @@ void SOLARISpanel::CreateDetGroup(int detTypeID, int SettingID, QList<int> detID
connect(chkOnOff[SettingID][digiID][chID], &QCheckBox::stateChanged, this, [=](int state){ connect(chkOnOff[SettingID][digiID][chID], &QCheckBox::stateChanged, this, [=](int state){
if( !enableSignalSlot ) return; if( !enableSignalSlot ) return;
int index = (chkAll[detTypeID][SettingID]->isChecked() ? -1 : chID); if( chkAll[detTypeID][SettingID]->isChecked() ){
digi[digiID]->WriteValue(PHA::CH::ChannelEnable, state ? "True" : "False", index); for(int k = 0; k < detIDList.size() ; k++){
if( detTypeID == FindDetTypeID(detIDList[k]) ){
for( int h = 1; h < detIDList[k].size() ; h++){
if( h != chIndex) continue;
int index = (detIDList[k][h] & 0xFF);
enableSignalSlot = false; QString msg;
for( int i = 0; i < (int) detType.size(); i++){ msg = QString::fromStdString(PHA::CH::ChannelEnable.GetPara()) + "|DIG:"+ QString::number(digi[digiID]->GetSerialNumber());
leDisplay[i][digiID][chID]->setEnabled(state); msg += ",CH:" + QString::number(index) + "(" + arrayLabel[chIndex-1] + ")";
sbSetting[i][digiID][chID]->setEnabled(state); msg += ( state ? " = True" : " = False");
chkOnOff[i][digiID][chID]->setChecked(state);
if( digi[digiID]->WriteValue(PHA::CH::ChannelEnable, state ? "True" : "False", index)){
SendLogMsg(msg + "|OK.");
enableSignalSlot = false;
for( int k = 0; k < (int) detType.size(); k++){
leDisplay[k][digiID][index]->setEnabled(state);
sbSetting[k][digiID][index]->setEnabled(state);
chkOnOff[k][digiID][index]->setChecked(state);
}
enableSignalSlot = true;
}else{
SendLogMsg(msg + "|Fail.");
}
}
}
}
}else{
QString msg;
msg = QString::fromStdString(PHA::CH::ChannelEnable.GetPara()) + "|DIG:"+ QString::number(digi[digiID]->GetSerialNumber());
msg += ",CH:" + QString::number(chID) + "(" + arrayLabel[chIndex-1] + ")";
msg += ( state ? " = True" : " = False");
if( digi[digiID]->WriteValue(PHA::CH::ChannelEnable, state ? "True" : "False", chID)){
SendLogMsg(msg + "|OK.");
enableSignalSlot = false;
for( int k = 0; k < (int) detType.size(); k++){
leDisplay[k][digiID][chID]->setEnabled(state);
sbSetting[k][digiID][chID]->setEnabled(state);
chkOnOff[k][digiID][chID]->setChecked(state);
}
enableSignalSlot = true;
}else{
SendLogMsg(msg + "|Fail.");
}
} }
enableSignalSlot = true;
UpdatePanelFromMemory(); UpdatePanelFromMemory();
UpdateOtherPanels(); UpdateOtherPanels();
}); });
layout0->setColumnStretch(0, 1); layout0->setColumnStretch(0, 1);
@ -366,9 +406,18 @@ void SOLARISpanel::CreateDetGroup(int detTypeID, int SettingID, QList<int> detID
if( isDisableDetector ) cbTrigger[detTypeID][detID[0]]->setEnabled(false); if( isDisableDetector ) cbTrigger[detTypeID][detID[0]]->setEnabled(false);
//*========== connection
connect(cbTrigger[detTypeID][detID[0]], &RComboBox::currentIndexChanged, this , [=](int index){ connect(cbTrigger[detTypeID][detID[0]], &RComboBox::currentIndexChanged, this , [=](int index){
if( !enableSignalSlot) return; if( !enableSignalSlot) return;
if( chkAll[detTypeID][SettingID]->isChecked() ){
for( int gg = 0; gg < nDet[detTypeID]; gg++){
if( gg == detID[0] ) continue;
cbTrigger[detTypeID][gg]->setCurrentIndex(index);
}
}
///----------- single
for( int i = 1; i < detID.size(); i++){ for( int i = 1; i < detID.size(); i++){
int digiID = (detID[i] >> 8 ); int digiID = (detID[i] >> 8 );
@ -384,7 +433,7 @@ void SOLARISpanel::CreateDetGroup(int detTypeID, int SettingID, QList<int> detID
digi[digiID]->WriteValue(PHA::CH::WaveTriggerSource, "ChSelfTrigger", chID); digi[digiID]->WriteValue(PHA::CH::WaveTriggerSource, "ChSelfTrigger", chID);
digi[digiID]->WriteValue(PHA::CH::CoincidenceMask, "Disabled", chID); digi[digiID]->WriteValue(PHA::CH::CoincidenceMask, "Disabled", chID);
}; break; }; break;
case 1 : { // trigger by energy case 1 : { /// trigger by energy
digi[digiID]->WriteValue(PHA::CH::EventTriggerSource, "ChSelfTrigger", chID); digi[digiID]->WriteValue(PHA::CH::EventTriggerSource, "ChSelfTrigger", chID);
digi[digiID]->WriteValue(PHA::CH::WaveTriggerSource, "ChSelfTrigger", chID); digi[digiID]->WriteValue(PHA::CH::WaveTriggerSource, "ChSelfTrigger", chID);
@ -413,6 +462,9 @@ void SOLARISpanel::CreateDetGroup(int detTypeID, int SettingID, QList<int> detID
digi[digiID]->WriteValue(PHA::CH::CoincidenceMask, "Disabled", chID); digi[digiID]->WriteValue(PHA::CH::CoincidenceMask, "Disabled", chID);
}; break; }; break;
} }
SendLogMsg("SOLARIS panel : Set Trigger = " + cbTrigger[detTypeID][detID[0]]->itemText(index) + "|Digi:" + QString::number(digi[digiID]->GetSerialNumber()) + ",Det:" + QString::number(detID[0]));
} }
UpdatePanelFromMemory(); UpdatePanelFromMemory();
UpdateOtherPanels(); UpdateOtherPanels();
@ -497,7 +549,7 @@ void SOLARISpanel::UpdatePanelFromMemory(){
// 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 // and waveTriggerSource are all ChSelfTrigger
int detTypeID = FindDetTypID(detIDList[k]); int detTypeID = FindDetTypeID(detIDList[k]);
//====== a stupid way //====== a stupid way
// triggerSource : Other = 0x0, Disabled = 0x1, ChSelfTrigger = 0x2, TRGIN = 0x3 // triggerSource : Other = 0x0, Disabled = 0x1, ChSelfTrigger = 0x2, TRGIN = 0x3
@ -567,68 +619,6 @@ void SOLARISpanel::UpdatePanelFromMemory(){
cbTrigger[detTypeID][detIDList[k][0]]->setCurrentIndex(comboxIndex); cbTrigger[detTypeID][detIDList[k][0]]->setCurrentIndex(comboxIndex);
//Check the 0-index
/*
bool isAcceptableSetting = true;
bool isTriggerE = false;
if( eventTriggerSource[0] != waveTriggerSource[0] || coincidentMask[0] != antiCoincidentMask[0] ) isAcceptableSetting = false;
if( antiCoincidentMask[0] != "Disabled") isAcceptableSetting = false;
if( !(coincidentMask[0] == "Disabled" || coincidentMask[0] == "TRGIN") ) isAcceptableSetting = false;
//check 0-index settings
if( isAcceptableSetting ){
if( eventTriggerSource[0] == "ChSelfTrigger" && coincidentMask[0] == "Disabled") {
//assume isTriggerE
isTriggerE = true;
unsigned long ShouldBeMask = 1ULL << (detIDList[k][1] & 0xFF);
for( int p = 1; p < (int) triggerMap.size(); p ++){
if( coincidentMask[p] != "Ch64Trigger") isTriggerE = false;
if( triggerMap[p] != ShouldBeMask) isTriggerE = false;
}
if( isTriggerE ){
cbTrigger[detTypeID][detIDList[k][0]]->setCurrentText("Trigger e");
}else{
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{
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( !isTriggerE && 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");
*/
} }
//@===================== Coin. time //@===================== Coin. time

View File

@ -64,14 +64,12 @@ 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 FindDetTypeID(QList<int> detIDListElement);
RSpinBox * sbCoinTime; RSpinBox * sbCoinTime;
QCheckBox * chkAll[MaxDetType][MaxSettingItem]; // checkBox for all setting on that tab; QCheckBox * chkAll[MaxDetType][MaxSettingItem]; // checkBox for all setting on that tab;
QCheckBox * chkAlle;
QCheckBox * chkAllxf;
QCheckBox * chkAllxn;
QGroupBox * groupBox[MaxDetType][MaxSettingItem][MaxDetID]; QGroupBox * groupBox[MaxDetType][MaxSettingItem][MaxDetID];