complete scalar (basic)
This commit is contained in:
parent
e3b16f7694
commit
709f0553b4
|
@ -64,10 +64,10 @@ class Digitizer2Gen {
|
||||||
Digitizer2Gen();
|
Digitizer2Gen();
|
||||||
~Digitizer2Gen();
|
~Digitizer2Gen();
|
||||||
|
|
||||||
unsigned short GetSerialNumber() {return serialNumber;}
|
unsigned short GetSerialNumber() const{return serialNumber;}
|
||||||
|
|
||||||
void SetDummy(unsigned short sn);
|
void SetDummy(unsigned short sn);
|
||||||
bool IsDummy() {return isDummy;}
|
bool IsDummy() const {return isDummy;}
|
||||||
|
|
||||||
int OpenDigitizer(const char * url);
|
int OpenDigitizer(const char * url);
|
||||||
bool IsConnected() const {return isConnected;}
|
bool IsConnected() const {return isConnected;}
|
||||||
|
@ -100,8 +100,10 @@ class Digitizer2Gen {
|
||||||
// 3 = only ch, energy, timestamp, minimum
|
// 3 = only ch, energy, timestamp, minimum
|
||||||
// 15 = raw data
|
// 15 = raw data
|
||||||
int ReadData();
|
int ReadData();
|
||||||
int ReadStat();
|
int ReadStat(); // digitizer update it every 500 msec
|
||||||
void PrintStat();
|
void PrintStat();
|
||||||
|
uint32_t GetTriggerCount(int ch) const {return triggerCount[ch];}
|
||||||
|
uint64_t GetRealTime(int ch) const {return realTime[ch];}
|
||||||
|
|
||||||
void Reset();
|
void Reset();
|
||||||
void ProgramPHA(bool testPulse = false);
|
void ProgramPHA(bool testPulse = false);
|
||||||
|
|
|
@ -43,6 +43,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
|
||||||
scalarLayout->setSpacing(0);
|
scalarLayout->setSpacing(0);
|
||||||
|
|
||||||
leTrigger = NULL;
|
leTrigger = NULL;
|
||||||
|
leAccept = NULL;
|
||||||
|
|
||||||
|
scalarThread = new ScalarThread();
|
||||||
|
connect(scalarThread, &ScalarThread::updataScalar, this, &MainWindow::UpdateScalar);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget * mainLayoutWidget = new QWidget(this);
|
QWidget * mainLayoutWidget = new QWidget(this);
|
||||||
|
@ -203,6 +207,7 @@ MainWindow::~MainWindow(){
|
||||||
printf("- %s\n", __func__);
|
printf("- %s\n", __func__);
|
||||||
|
|
||||||
DeleteTriggerLineEdit();
|
DeleteTriggerLineEdit();
|
||||||
|
delete scalarThread;
|
||||||
CloseDigitizers();
|
CloseDigitizers();
|
||||||
|
|
||||||
//---- need manually delete
|
//---- need manually delete
|
||||||
|
@ -233,6 +238,9 @@ void MainWindow::StartACQ(){
|
||||||
readDataThread[i]->start();
|
readDataThread[i]->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( !scalar->isVisible() ) scalar->show();
|
||||||
|
scalarThread->start();
|
||||||
|
|
||||||
bnStartACQ->setEnabled(false);
|
bnStartACQ->setEnabled(false);
|
||||||
bnStopACQ->setEnabled(true);
|
bnStopACQ->setEnabled(true);
|
||||||
bnOpenScope->setEnabled(false);
|
bnOpenScope->setEnabled(false);
|
||||||
|
@ -252,6 +260,10 @@ void MainWindow::StopACQ(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scalarThread->Stop();
|
||||||
|
scalarThread->quit();
|
||||||
|
scalarThread->wait();
|
||||||
|
|
||||||
LogMsg("Stop Run");
|
LogMsg("Stop Run");
|
||||||
bnStartACQ->setEnabled(true);
|
bnStartACQ->setEnabled(true);
|
||||||
bnStopACQ->setEnabled(false);
|
bnStopACQ->setEnabled(false);
|
||||||
|
@ -260,6 +272,9 @@ void MainWindow::StopACQ(){
|
||||||
runID ++;
|
runID ++;
|
||||||
leRunID->setText(QString::number(runID));
|
leRunID->setText(QString::number(runID));
|
||||||
|
|
||||||
|
//if( scalarThread->isRunning()) printf("Scalar Thread still running.\n");
|
||||||
|
//if( scalarThread->isFinished()) printf("Scalar Thread finsihed.\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//^###################################################################### open and close digitizer
|
//^###################################################################### open and close digitizer
|
||||||
|
@ -380,7 +395,7 @@ void MainWindow::OpenScaler(){
|
||||||
|
|
||||||
void MainWindow::SetUpScalar(){
|
void MainWindow::SetUpScalar(){
|
||||||
|
|
||||||
scalar->setGeometry(0, 0, 10 + nDigi * 100, 1000);
|
scalar->setGeometry(0, 0, 10 + nDigi * 200, 1000);
|
||||||
|
|
||||||
int rowID = 0;
|
int rowID = 0;
|
||||||
for( int ch = 0; ch < MaxNumberOfChannel; ch++){
|
for( int ch = 0; ch < MaxNumberOfChannel; ch++){
|
||||||
|
@ -396,22 +411,30 @@ void MainWindow::SetUpScalar(){
|
||||||
}
|
}
|
||||||
|
|
||||||
leTrigger = new QLineEdit**[nDigi];
|
leTrigger = new QLineEdit**[nDigi];
|
||||||
|
leAccept = new QLineEdit**[nDigi];
|
||||||
for( int iDigi = 0; iDigi < nDigi; iDigi++){
|
for( int iDigi = 0; iDigi < nDigi; iDigi++){
|
||||||
rowID = 0;
|
rowID = 0;
|
||||||
leTrigger[iDigi] = new QLineEdit *[digi[iDigi]->GetNChannels()];
|
leTrigger[iDigi] = new QLineEdit *[digi[iDigi]->GetNChannels()];
|
||||||
|
leAccept[iDigi] = new QLineEdit *[digi[iDigi]->GetNChannels()];
|
||||||
for( int ch = 0; ch < MaxNumberOfChannel; ch++){
|
for( int ch = 0; ch < MaxNumberOfChannel; ch++){
|
||||||
|
|
||||||
if( ch == 0 ){
|
if( ch == 0 ){
|
||||||
QLabel * lbDigi = new QLabel("Digi-" + QString::number(digi[iDigi]->GetSerialNumber()), scalar);
|
QLabel * lbDigi = new QLabel("Digi-" + QString::number(digi[iDigi]->GetSerialNumber()), scalar);
|
||||||
lbDigi->setAlignment(Qt::AlignCenter);
|
lbDigi->setAlignment(Qt::AlignCenter);
|
||||||
scalarLayout->addWidget(lbDigi, rowID, iDigi+1);
|
scalarLayout->addWidget(lbDigi, rowID, 2*iDigi+1, 1, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
rowID ++;
|
rowID ++;
|
||||||
|
|
||||||
leTrigger[iDigi][ch] = new QLineEdit();
|
leTrigger[iDigi][ch] = new QLineEdit();
|
||||||
leTrigger[iDigi][ch]->setReadOnly(true);
|
leTrigger[iDigi][ch]->setReadOnly(true);
|
||||||
scalarLayout->addWidget(leTrigger[iDigi][ch], rowID, iDigi+1);
|
leTrigger[iDigi][ch]->setAlignment(Qt::AlignRight);
|
||||||
|
scalarLayout->addWidget(leTrigger[iDigi][ch], rowID, 2*iDigi+1);
|
||||||
|
|
||||||
|
leAccept[iDigi][ch] = new QLineEdit();
|
||||||
|
leAccept[iDigi][ch]->setReadOnly(true);
|
||||||
|
leAccept[iDigi][ch]->setAlignment(Qt::AlignRight);
|
||||||
|
scalarLayout->addWidget(leAccept[iDigi][ch], rowID, 2*iDigi+2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,19 +442,55 @@ void MainWindow::SetUpScalar(){
|
||||||
|
|
||||||
void MainWindow::DeleteTriggerLineEdit(){
|
void MainWindow::DeleteTriggerLineEdit(){
|
||||||
|
|
||||||
printf("__________ %s \n", __func__);
|
|
||||||
|
|
||||||
if( leTrigger == NULL ) return;
|
if( leTrigger == NULL ) return;
|
||||||
|
|
||||||
for( int i = 0; i < nDigi; i++){
|
for( int i = 0; i < nDigi; i++){
|
||||||
for( int ch = 0; ch < digi[i]->GetNChannels(); ch ++){
|
for( int ch = 0; ch < digi[i]->GetNChannels(); ch ++){
|
||||||
delete leTrigger[i][ch];
|
delete leTrigger[i][ch];
|
||||||
|
delete leAccept[i][ch];
|
||||||
}
|
}
|
||||||
delete [] leTrigger[i];
|
delete [] leTrigger[i];
|
||||||
|
delete [] leAccept[i];
|
||||||
}
|
}
|
||||||
delete [] leTrigger;
|
delete [] leTrigger;
|
||||||
leTrigger = NULL;
|
leTrigger = NULL;
|
||||||
printf("end of ____ %s \n", __func__);
|
leAccept = NULL;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::UpdateScalar(){
|
||||||
|
if( !digi ) return;
|
||||||
|
|
||||||
|
///===== Get trigger for all channel
|
||||||
|
for( int iDigi = 0; iDigi < nDigi; iDigi ++ ){
|
||||||
|
if( digi[iDigi]->IsDummy() ) return;
|
||||||
|
|
||||||
|
//=========== use ReadStat to get the trigger rate
|
||||||
|
//digiMTX.lock();
|
||||||
|
//digi[iDigi]->ReadStat(); // digitizer update it every 500 msec;
|
||||||
|
//digiMTX.unlock();
|
||||||
|
//for( int ch = 0; ch < digi[iDigi]->GetNChannels(); ch ++){
|
||||||
|
// leTrigger[iDigi][ch]->setText(QString::number(digi[iDigi]->GetTriggerCount(ch)*1e9*1.0/ digi[iDigi]->GetRealTime(ch)));
|
||||||
|
//}
|
||||||
|
|
||||||
|
//=========== another method, directly readValue
|
||||||
|
digiMTX.lock();
|
||||||
|
for( int ch = 0; ch < digi[iDigi]->GetNChannels(); ch ++){
|
||||||
|
std::string time = digi[iDigi]->ReadChValue(std::to_string(ch), DIGIPARA::CH::ChannelRealtime); // for refreashing SelfTrgRate and SavedCount
|
||||||
|
std::string haha = digi[iDigi]->ReadChValue(std::to_string(ch), DIGIPARA::CH::SelfTrgRate);
|
||||||
|
leTrigger[iDigi][ch]->setText(QString::fromStdString(haha));
|
||||||
|
std::string kaka = digi[iDigi]->ReadChValue(std::to_string(ch), DIGIPARA::CH::ChannelSavedCount);
|
||||||
|
double acceptRate = atoi(kaka.c_str())*1e9*1.0 / atol(time.c_str());
|
||||||
|
//if( kaka != "0" ) {
|
||||||
|
// printf("%s, %s | %.2f\n", time.c_str(), kaka.c_str(), acceptRate);
|
||||||
|
//}
|
||||||
|
leAccept[iDigi][ch]->setText(QString::number(acceptRate,'f', 1));
|
||||||
|
|
||||||
|
///TODO============== push the trigger, acceptRate rate database
|
||||||
|
|
||||||
|
}
|
||||||
|
digiMTX.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@ private slots:
|
||||||
void OpenScaler();
|
void OpenScaler();
|
||||||
void SetUpScalar();
|
void SetUpScalar();
|
||||||
void DeleteTriggerLineEdit();
|
void DeleteTriggerLineEdit();
|
||||||
|
void UpdateScalar();
|
||||||
|
|
||||||
void ProgramSettings();
|
void ProgramSettings();
|
||||||
bool OpenProgramSettings();
|
bool OpenProgramSettings();
|
||||||
|
@ -59,10 +60,7 @@ private slots:
|
||||||
void CreateRawDataFolderAndLink(const QString newExpName);
|
void CreateRawDataFolderAndLink(const QString newExpName);
|
||||||
|
|
||||||
void closeEvent(QCloseEvent * event){
|
void closeEvent(QCloseEvent * event){
|
||||||
printf("___ %s \n", __func__);
|
|
||||||
printf("+++++++++++++++ digiSetting %p\n", digiSetting);
|
|
||||||
if( digiSetting != NULL ) digiSetting->close();
|
if( digiSetting != NULL ) digiSetting->close();
|
||||||
printf("+++++++++++++++ scope %p\n", scope);
|
|
||||||
if( scope != NULL ) scope->close();
|
if( scope != NULL ) scope->close();
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
@ -90,7 +88,9 @@ private:
|
||||||
QMainWindow * scalar;
|
QMainWindow * scalar;
|
||||||
QPushButton * bnOpenScalar;
|
QPushButton * bnOpenScalar;
|
||||||
QLineEdit *** leTrigger; // need to delete manually
|
QLineEdit *** leTrigger; // need to delete manually
|
||||||
|
QLineEdit *** leAccept; // need to delete manually
|
||||||
QGridLayout * scalarLayout;
|
QGridLayout * scalarLayout;
|
||||||
|
ScalarThread * scalarThread;
|
||||||
|
|
||||||
//@------ ACQ things
|
//@------ ACQ things
|
||||||
QPushButton * bnStartACQ;
|
QPushButton * bnStartACQ;
|
||||||
|
|
30
manyThread.h
30
manyThread.h
|
@ -31,7 +31,7 @@ public:
|
||||||
digi->ErrorMsg("No more data");
|
digi->ErrorMsg("No more data");
|
||||||
break;
|
break;
|
||||||
}else{
|
}else{
|
||||||
digi->ErrorMsg("ReadDataLoop()");
|
//digi->ErrorMsg("ReadDataLoop()");
|
||||||
digi->evt->ClearTrace();
|
digi->evt->ClearTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,4 +83,32 @@ private:
|
||||||
unsigned int waitTime; //100 of milisec
|
unsigned int waitTime; //100 of milisec
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//^#======================================================= Scalar Thread
|
||||||
|
class ScalarThread : public QThread {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ScalarThread(QObject * parent = 0 ) : QThread(parent){
|
||||||
|
waitTime = 20; // 10 x 100 milisec
|
||||||
|
stop = false;
|
||||||
|
}
|
||||||
|
void Stop() { this->stop = true;}
|
||||||
|
unsigned int GetWaitTimeinSec() const {return waitTime/10;}
|
||||||
|
void run(){
|
||||||
|
unsigned int count = 0;
|
||||||
|
stop = false;
|
||||||
|
do{
|
||||||
|
usleep(100000);
|
||||||
|
count ++;
|
||||||
|
if( count % waitTime == 0){
|
||||||
|
emit updataScalar();
|
||||||
|
}
|
||||||
|
}while(!stop);
|
||||||
|
}
|
||||||
|
signals:
|
||||||
|
void updataScalar();
|
||||||
|
private:
|
||||||
|
bool stop;
|
||||||
|
unsigned int waitTime;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
26
scope.cpp
26
scope.cpp
|
@ -334,6 +334,15 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
|
||||||
layout->addWidget(bnScopeStop, rowID, 1);
|
layout->addWidget(bnScopeStop, rowID, 1);
|
||||||
connect(bnScopeStop, &QPushButton::clicked, this, &Scope::StopScope);
|
connect(bnScopeStop, &QPushButton::clicked, this, &Scope::StopScope);
|
||||||
|
|
||||||
|
QLabel * lbTriggerRate = new QLabel("Trigger Rate [Hz] : ", this);
|
||||||
|
lbTriggerRate->setAlignment(Qt::AlignCenter | Qt::AlignRight);
|
||||||
|
layout->addWidget(lbTriggerRate, rowID, 2);
|
||||||
|
|
||||||
|
leTriggerRate = new QLineEdit(this);
|
||||||
|
leTriggerRate->setAlignment(Qt::AlignRight);
|
||||||
|
leTriggerRate->setReadOnly(true);
|
||||||
|
layout->addWidget(leTriggerRate, rowID, 3);
|
||||||
|
|
||||||
QPushButton * bnClose = new QPushButton("Close", this);
|
QPushButton * bnClose = new QPushButton("Close", this);
|
||||||
layout->addWidget(bnClose, rowID, 5);
|
layout->addWidget(bnClose, rowID, 5);
|
||||||
connect(bnClose, &QPushButton::clicked, this, &Scope::close);
|
connect(bnClose, &QPushButton::clicked, this, &Scope::close);
|
||||||
|
@ -458,16 +467,25 @@ void Scope::StopScope(){
|
||||||
void Scope::UpdateScope(){
|
void Scope::UpdateScope(){
|
||||||
|
|
||||||
int iDigi = cbScopeDigi->currentIndex();
|
int iDigi = cbScopeDigi->currentIndex();
|
||||||
|
int ch = cbScopeCh->currentIndex();
|
||||||
int sample2ns = DIGIPARA::TraceStep * (1 << cbWaveRes->currentIndex());
|
int sample2ns = DIGIPARA::TraceStep * (1 << cbWaveRes->currentIndex());
|
||||||
|
|
||||||
if( digi ){
|
if( digi ){
|
||||||
digiMTX.lock();
|
|
||||||
unsigned int traceLength = digi[iDigi]->evt->traceLenght;
|
|
||||||
unsigned int dataLength = dataTrace[0]->count();
|
|
||||||
|
|
||||||
//---- remove all points
|
//---- remove all points
|
||||||
|
unsigned int dataLength = dataTrace[0]->count();
|
||||||
for( int j = 0; j < 6; j++ ) dataTrace[j]->removePoints(0, dataLength);
|
for( int j = 0; j < 6; j++ ) dataTrace[j]->removePoints(0, dataLength);
|
||||||
|
|
||||||
|
digiMTX.lock();
|
||||||
|
std::string time = digi[iDigi]->ReadChValue(std::to_string(ch), DIGIPARA::CH::ChannelRealtime); // for refreashing SelfTrgRate and SavedCount
|
||||||
|
std::string haha = digi[iDigi]->ReadChValue(std::to_string(ch), DIGIPARA::CH::SelfTrgRate);
|
||||||
|
leTriggerRate->setText(QString::fromStdString(haha));
|
||||||
|
if( atoi(haha.c_str()) == 0 ) {
|
||||||
|
digiMTX.unlock();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int traceLength = digi[iDigi]->evt->traceLenght;
|
||||||
|
|
||||||
for( unsigned int i = 0 ; i < traceLength; i++){
|
for( unsigned int i = 0 ; i < traceLength; i++){
|
||||||
for( int j = 0; j < 2; j++) dataTrace[j]->append(sample2ns * i, digi[iDigi]->evt->analog_probes[j][i]);
|
for( int j = 0; j < 2; j++) dataTrace[j]->append(sample2ns * i, digi[iDigi]->evt->analog_probes[j][i]);
|
||||||
for( int j = 2; j < 6; j++) dataTrace[j]->append(sample2ns * i, (j-1)*1000 + 4000 * digi[iDigi]->evt->digital_probes[j-2][i]);
|
for( int j = 2; j < 6; j++) dataTrace[j]->append(sample2ns * i, (j-1)*1000 + 4000 * digi[iDigi]->evt->digital_probes[j-2][i]);
|
||||||
|
|
3
scope.h
3
scope.h
|
@ -8,6 +8,7 @@
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
#include <QLineEdit>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QLineSeries>
|
#include <QLineSeries>
|
||||||
|
@ -164,6 +165,8 @@ private:
|
||||||
QComboBox * cbWaveRes;
|
QComboBox * cbWaveRes;
|
||||||
QComboBox * cbTrapPeakAvg;
|
QComboBox * cbTrapPeakAvg;
|
||||||
|
|
||||||
|
QLineEdit * leTriggerRate;
|
||||||
|
|
||||||
QSpinBox * sbBaselineGuard;
|
QSpinBox * sbBaselineGuard;
|
||||||
QSpinBox * sbPileUpGuard;
|
QSpinBox * sbPileUpGuard;
|
||||||
QComboBox * cbBaselineAvg;
|
QComboBox * cbBaselineAvg;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user