fix soem display bugs, fix 2D historgram mergin

This commit is contained in:
splitPoleDAQ 2023-11-21 15:34:29 -05:00
parent 6652416901
commit a34bf75d5f
6 changed files with 60 additions and 7 deletions

View File

@ -94,7 +94,7 @@ class Digitizer{
int ReadData();
bool IsRunning() const {return AcqRun;}
Data * GetData() const {return data;}
uint32_t GetACQStatus() const {return acqStatus;}
uint32_t GetACQStatusFromMemory() const {return acqStatus;}
void ReadAndPrintACQStatue();
void ReadACQStatus() { acqStatus = ReadRegister(DPP::AcquisitionStatus_R); }

View File

@ -130,6 +130,7 @@ public:
void Stop() { this->stop = true;}
void SetWaitTimeinSec(float sec) {waitTime = sec * 10 ;}
float GetWaitTimeinSec() const {return waitTime/10.;}
void DoOnce() {emit timeUp();};
void run(){
unsigned int count = 0;
stop = false;

View File

@ -979,9 +979,7 @@ void MainWindow::UpdateScalar(){
for( unsigned int iDigi = 0; iDigi < nDigi; iDigi++){
if( digi[iDigi]->IsBoardDisabled() ) continue;
digiMTX[iDigi].lock();
uint32_t acqStatus = digi[iDigi]->GetACQStatus();
uint32_t acqStatus = digi[iDigi]->GetACQStatusFromMemory();
//printf("Digi-%d : acq on/off ? : %d \n", digi[iDigi]->GetSerialNumber(), (acqStatus >> 2) & 0x1 );
if( ( acqStatus >> 2 ) & 0x1 ){
runStatus[iDigi]->setStyleSheet("background-color : green;");
@ -989,6 +987,7 @@ void MainWindow::UpdateScalar(){
runStatus[iDigi]->setStyleSheet("");
}
digiMTX[iDigi].lock();
// printf("### %d ", iDigi);
// digi[iDigi]->GetData()->PrintAllData(true, 10);
if( chkSaveData->isChecked() ) totalFileSize += digi[iDigi]->GetData()->GetTotalFileSize();
@ -1612,6 +1611,18 @@ void MainWindow::UpdateAllPanels(int panelID){
if( panelID == 1 ){ // from scope
if( digiSettings && digiSettings->isVisible() ) digiSettings->UpdatePanelFromMemory();
if( scalar ) {
for( unsigned int iDigi = 0; iDigi < nDigi; iDigi++){
if( digi[iDigi]->IsBoardDisabled() ) continue;
uint32_t acqStatus = digi[iDigi]->GetACQStatusFromMemory();
if( ( acqStatus >> 2 ) & 0x1 ){
runStatus[iDigi]->setStyleSheet("background-color : green;");
}else{
runStatus[iDigi]->setStyleSheet("");
}
}
}
}
if( panelID == 2 ){

View File

@ -27,6 +27,9 @@ public:
}
}
isChannelMap = false;
tickStep = 1; // only used when isChannelMap = true
axisRect()->setupFullAxesBox(true);
xAxis->setLabel(xLabel);
yAxis->setLabel(yLabel);
@ -183,6 +186,8 @@ public:
void SetYTitle(QString yTitle) { yAxis->setLabel(yTitle); }
void Rebin(int xbin, double xmin, double xmax, int ybin, double ymin, double ymax);
void SetChannelMap(bool onOff, int tickStep = 1) { isChannelMap = onOff; this->tickStep = tickStep;}
void UpdatePlot(){
QCPColorGradient color;
color.clearColorStops();
@ -196,6 +201,7 @@ public:
colorMap->setGradient(color);
colorMap->rescaleDataRange();
replot();
}
@ -211,10 +217,20 @@ public:
QList<QString> GetCutNameList() const { return cutNameList;}
void PrintCutEntry() const;
double GetXNBin() const {return xBin;}
double GetXMin() const {return xMin;}
double GetXMax() const {return xMax;}
double GetYNBin() const {return yBin;}
double GetYMin() const {return yMin;}
double GetYMax() const {return yMax;}
private:
double xMin, xMax, yMin, yMax;
int xBin, yBin;
bool isChannelMap;
int tickStep;
QCPColorMap * colorMap;
QCPColorScale *colorScale;
@ -281,13 +297,19 @@ inline void Histogram2D::Rebin(int xbin, double xmin, double xmax, int ybin, do
xMax = xmax;
yMin = ymin;
yMax = ymax;
xBin = xbin;
yBin = ybin;
xBin = xbin + 2;
yBin = ybin + 2;
colorMap->data()->clear();
colorMap->data()->setSize(xBin, yBin);
colorMap->data()->setRange(QCPRange(xMin, xMax), QCPRange(yMin, yMax));
if( isChannelMap ){
QCPAxis * xAxis = colorMap->keyAxis();
xAxis->ticker()->setTickCount(xbin/tickStep);
xAxis->ticker()->setTickOrigin(0);
}
for( int i = 0; i < 3; i ++){
for( int j = 0; j < 3; j ++){
entry[i][j] = 0;

View File

@ -422,6 +422,7 @@ void Scope::StopScope(){
}
digiMTX[iDigi].lock();
digi[iDigi]->StopACQ();
digi[iDigi]->ReadACQStatus();
//digi[iDigi]->GetData()->PrintAllData();
digiMTX[iDigi].unlock();

View File

@ -108,6 +108,8 @@ SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawD
}
}
hist2D[i] = new Histogram2D("Digi-" + QString::number(digi[i]->GetSerialNumber()), "Channel", "Raw Energy [ch]", digi[i]->GetNumInputCh(), 0, digi[i]->GetNumInputCh(), nBin, eMin, eMax);
hist2D[i]->SetChannelMap(true, digi[i]->GetNumInputCh() < 20 ? 1 : 4);
hist2D[i]->Rebin(digi[i]->GetNumInputCh(), -0.5, digi[i]->GetNumInputCh()+0.5, nBin, eMin, eMax);
}
LoadSetting();
@ -244,6 +246,15 @@ void SingleSpectra::SaveSetting(){
QString d = QString::number(hist[i][ch]->GetXMax()).rightJustified(6, ' ');
file.write( QString("%1 %2 %3 %4\n").arg(a).arg(b).arg(c).arg(d).toStdString().c_str() );
}
QString a = QString::number(digi[i]->GetNumInputCh()).rightJustified(2, ' ');
QString b = QString::number(hist2D[i]->GetXNBin()).rightJustified(6, ' ');
QString c = QString::number(hist2D[i]->GetXMin()).rightJustified(6, ' ');
QString d = QString::number(hist2D[i]->GetXMax()).rightJustified(6, ' ');
QString e = QString::number(hist2D[i]->GetYNBin()).rightJustified(6, ' ');
QString f = QString::number(hist2D[i]->GetYMin()).rightJustified(6, ' ');
QString g = QString::number(hist2D[i]->GetYMax()).rightJustified(6, ' ');
file.write( QString("%1 %2 %3 %4 %5 %6 %7\n").arg(a).arg(b).arg(c).arg(d).arg(e).arg(f).arg(g).toStdString().c_str() );
}
file.write("//========== End of file\n");
@ -291,8 +302,15 @@ void SingleSpectra::LoadSetting(){
for( int i = 0; i < list.count(); i++){
data.push_back(list[i].toInt());
}
if( 0 <= data[0] && data[0] < digi[digiID]->GetNumInputCh() ){
hist[digiID][data[0]]->Rebin(data[1], data[2], data[3]);
}
if( data[0] == digi[digiID]->GetNumInputCh() && data.size() == 7 ){
hist2D[digiID]->Rebin(data[1], data[2], data[3], data[4], data[5], data[6]);
}
hist[digiID][data[0]]->Rebin(data[1], data[2], data[3]);
}
line = in.readLine();