some buttons is working at the scope

This commit is contained in:
Ryan Tang 2023-02-07 15:55:39 -05:00
parent fb02434c55
commit 898ddfa63c
8 changed files with 272 additions and 37 deletions

1
.gitignore vendored
View File

@ -3,6 +3,7 @@
SOLARIS_DAQ
*.sol
programSettings.txt
test
*~
*.autosave

66
.vscode/settings.json vendored
View File

@ -2,7 +2,71 @@
"files.associations": {
"script.C": "cpp",
"SOLARIS_Qt6_DAQ.pro": "makefile",
"qlineseries": "cpp"
"qlineseries": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"chrono": "cpp",
"codecvt": "cpp",
"compare": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstdint": "cpp",
"deque": "cpp",
"list": "cpp",
"map": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"semaphore": "cpp",
"span": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cinttypes": "cpp",
"typeinfo": "cpp",
"variant": "cpp"
},
"better-comments.multilineComments": true,

View File

@ -97,6 +97,11 @@ std::string Digitizer2Gen::ReadValue(const char * parameter, bool verbose){
return retValue;
}
std::string Digitizer2Gen::ReadChValue(std::string ch, std::string shortPara, bool verbose){
std::string haha = "/ch/" + ch + "/par/" + shortPara;
return ReadValue(haha.c_str(), verbose);
}
void Digitizer2Gen::WriteValue(const char * parameter, std::string value){
if( !isConnected ) return;
printf(" %s| %-45s : %s\n", __func__, parameter, value.c_str());
@ -107,6 +112,11 @@ void Digitizer2Gen::WriteValue(const char * parameter, std::string value){
}
}
void Digitizer2Gen::WriteChValue(std::string ch, std::string shortPara, std::string value){
std::string haha = "/ch/" + ch + "/par/" + shortPara;
WriteValue(haha.c_str(), value);
}
void Digitizer2Gen::SendCommand(const char * parameter){
if( !isConnected ) return;
printf("Send Command : %s \n", parameter);

View File

@ -72,7 +72,9 @@ class Digitizer2Gen {
int CloseDigitizer();
std::string ReadValue(const char * parameter, bool verbose = false);
std::string ReadChValue(std::string ch, std::string shortPara, bool verbose = false);
void WriteValue(const char * parameter, std::string value);
void WriteChValue(std::string ch, std::string shortPara, std::string value);
void SendCommand(const char * parameter);
uint64_t GetHandle(const char * parameter);

View File

@ -170,8 +170,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
if( OpenProgramSettings() ) OpenExpSettings();
bnOpenScope->setEnabled(true);
}
MainWindow::~MainWindow(){
@ -333,44 +331,91 @@ void MainWindow::CloseDigitizers(){
//^###################################################################### Open Scope
void MainWindow::OpenScope(){
cbScopeDigi->clear(); ///thsi will also trigger QComboBox::currentIndexChanged
cbScopeCh->clear();
if( digi ) {
for( int i = 0 ; i < nDigi; i++) {
cbScopeDigi->addItem("Digi-" + QString::number(digi[i]->GetSerialNumber()), i);
}
//*---- set digitizer to take full trace; since in scope mode, no data saving, speed would be fast (How fast?)
//* when the input rate is faster than trigger rate, Digitizer will stop data taking.
//*---- get digi setting
int iDigi = cbScopeDigi->currentIndex();
int ch = cbScopeCh->currentIndex();
if( digi[iDigi]->IsDummy() ) return;
int index;
std::string ans;
std::vector<std::string> haha = {"WaveAnalogProbe0", "WaveAnalogProbe1"};
for( int i = 0 ; i < 2; i++){
ans = digi[iDigi]->ReadChValue(std::to_string(ch), haha[i]);
index = cbAnaProbe[i]->findData(QString::fromStdString(ans));
cbAnaProbe[i]->setCurrentIndex(index);
}
haha.clear();
haha = {"WaveDigitalProbe0", "WaveDigitalProbe1", "WaveDigitalProbe2", "WaveDigitalProbe3"};
for( int i = 0 ; i < 4; i++){
ans = digi[iDigi]->ReadChValue(std::to_string(ch), haha[i]);
index = cbDigProbe[i]->findData(QString::fromStdString(ans));
cbDigProbe[i]->setCurrentIndex(index);
}
ans = digi[iDigi]->ReadChValue(std::to_string(ch), "ChRecordLengthT");
sbRL->setValue(atoi(ans.c_str()));
ans = digi[iDigi]->ReadChValue(std::to_string(ch), "ChPreTriggerT");
sbPT->setValue(atoi(ans.c_str()));
//TODO ===== Reset and ProgramPHA should be removed
digi[iDigi]->Reset();
digi[iDigi]->ProgramPHA(false);
digi[iDigi]->WriteValue("/ch/0..63/par/ChEnable", "false");
digi[iDigi]->WriteValue(("/ch/" + std::to_string(ch) + "/par/ChEnable").c_str(), "true");
digi[iDigi]->WriteChValue("0..63", "ChEnable", "false");
digi[iDigi]->WriteChValue(std::to_string(ch), "ChEnable", "true");
digi[iDigi]->SetPHADataFormat(0);
StartScope();
bnStartACQ->setEnabled(false);
bnStopACQ->setEnabled(false);
}
scope->show();
}
void MainWindow::StartScope(){
if( !digi ) return;
//*---- set digitizer to take full trace; since in scope mode, no data saving, speed would be fast (How fast?)
//* when the input rate is faster than trigger rate, Digitizer will stop data taking.
int iDigi = cbScopeDigi->currentIndex();
digi[iDigi]->StartACQ();
readDataThread[iDigi]->SetScopeRun(true);
readDataThread[iDigi]->start();
updateTraceThread->start();
bnStartACQ->setEnabled(false);
bnStopACQ->setEnabled(false);
}
scope->show();
bnScopeStart->setEnabled(false);
bnScopeStop->setEnabled(true);
sbRL->setEnabled(false);
allowChange = true;
}
void MainWindow::StopScope(){
updateTraceThread->Stop();
@ -380,7 +425,9 @@ void MainWindow::StopScope(){
if(digi){
for(int i = 0; i < nDigi; i++){
if( digi[i]->IsDummy() ) continue;
digiMTX.lock();
digi[i]->StopACQ();
digiMTX.unlock();
readDataThread[i]->quit();
readDataThread[i]->wait();
@ -389,6 +436,11 @@ void MainWindow::StopScope(){
bnStopACQ->setEnabled(true);
}
bnScopeStart->setEnabled(true);
bnScopeStop->setEnabled(false);
sbRL->setEnabled(true);
}
void MainWindow::UpdateScope(){
@ -448,6 +500,17 @@ void MainWindow::ProbeChange(QComboBox * cb[], const int size ){
}
}
digiMTX.lock();
if( size == 2) {// analog probes
dataTrace->setName(cb[0]->currentText());
}
if( size == 4){ // digitial probes
}
digiMTX.unlock();
}
void MainWindow::SetUpPlot(){ //@--- this function run at start up
@ -456,10 +519,13 @@ void MainWindow::SetUpPlot(){ //@--- this function run at start up
scope->setGeometry(0, 0, 1000, 800);
scope->setWindowFlags( scope->windowFlags() & ~Qt::WindowCloseButtonHint );
allowChange = false;
plot = new QChart();
dataTrace = new QLineSeries();
dataTrace->setName("data");
dataTrace->setName("Analog Trace 1");
for(int i = 0; i < 100; i ++) dataTrace->append(i, QRandomGenerator::global()->bounded(10));
plot->addSeries(dataTrace);
plot->createDefaultAxes(); /// this must be after addSeries();
plot->axes(Qt::Vertical).first()->setRange(-1, 11); /// this must be after createDefaultAxes();
@ -491,6 +557,7 @@ void MainWindow::SetUpPlot(){ //@--- this function run at start up
});
//------------ Probe selection
rowID ++;
cbAnaProbe[0] = new QComboBox(scope);
cbAnaProbe[0]->addItem("ADC Input", "ADCInput");
cbAnaProbe[0]->addItem("Time Filter", "TimeFiler");
@ -504,20 +571,22 @@ void MainWindow::SetUpPlot(){ //@--- this function run at start up
connect(cbAnaProbe[0], &QComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbAnaProbe, 2);});
connect(cbAnaProbe[1], &QComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbAnaProbe, 2);});
//connect(cbAnaProbe[0], &QComboBox::currentIndexChanged, this, [=](){
// int iDigi = cbScopeDigi->currentIndex();
// int ch = cbScopeCh->currentIndex();
// char str[200] = ("/ch/" + std::to_string(ch) + "/par/WaveAnalogProbe0").c_str();
// digi[iDigi]->WriteValue(str, (cbAnaProbe[0]->currentData()).toString().toStdString());
//});
cbAnaProbe[0]->setCurrentIndex(1); ///trigger the AnaProbeChange
cbAnaProbe[0]->setCurrentIndex(0);
cbAnaProbe[1]->setCurrentIndex(4);
connect(cbAnaProbe[0], &QComboBox::currentIndexChanged, this, [=](){
int iDigi = cbScopeDigi->currentIndex();
int ch = cbScopeCh->currentIndex();
digiMTX.lock();
digi[iDigi]->WriteChValue(std::to_string(ch), "WaveAnalogProbe0", (cbAnaProbe[0]->currentData()).toString().toStdString());
digiMTX.unlock();
});
cbDigProbe[0] = new QComboBox(scope);
cbDigProbe[0]->addItem("Trigger", "Trigger");
cbDigProbe[0]->addItem("Time Filter Armed", "TimeFilerArmed");
cbDigProbe[0]->addItem("Time Filter Armed", "TimeFilterArmed");
cbDigProbe[0]->addItem("ReTrigger Guard", "ReTriggerGaurd");
cbDigProbe[0]->addItem("Trap. basline Freeze", "EnergyFilterBaselineFreeze");
cbDigProbe[0]->addItem("Peaking", "EnergyFilterPeaking");
@ -550,29 +619,77 @@ void MainWindow::SetUpPlot(){ //@--- this function run at start up
cbDigProbe[2]->setCurrentIndex(5);
cbDigProbe[3]->setCurrentIndex(6);
layout->addWidget(cbAnaProbe[0], rowID, 2);
layout->addWidget(cbAnaProbe[1], rowID, 3);
layout->addWidget(cbAnaProbe[0], rowID, 0);
layout->addWidget(cbAnaProbe[1], rowID, 1);
layout->addWidget(cbDigProbe[0], rowID, 2);
layout->addWidget(cbDigProbe[1], rowID, 3);
layout->addWidget(cbDigProbe[2], rowID, 4);
layout->addWidget(cbDigProbe[3], rowID, 5);
//------------ wave settings
rowID ++;
layout->addWidget(cbDigProbe[0], rowID, 0);
layout->addWidget(cbDigProbe[1], rowID, 1);
layout->addWidget(cbDigProbe[2], rowID, 2);
layout->addWidget(cbDigProbe[3], rowID, 3);
QLabel * lbRL = new QLabel("Record Lenght [ns]",scope);
layout->addWidget(lbRL, rowID, 0);
sbRL = new QSpinBox(scope);
sbRL->setMinimum(32);
sbRL->setMaximum(648000);
sbRL->setSingleStep(8);
layout->addWidget(sbRL, rowID, 1);
connect(sbRL, &QSpinBox::valueChanged, this, [=](){
if( !allowChange ) return;
int iDigi = cbScopeDigi->currentIndex();
digiMTX.lock();
//StopScope();
digi[iDigi]->WriteChValue(std::to_string(cbScopeCh->currentIndex()),
"ChRecordLengthT",
std::to_string(sbRL->value()));
//StartScope();
digiMTX.unlock();
plot->axes(Qt::Horizontal).first()->setRange(0, sbRL->value()/8);
});
QLabel * lbPT = new QLabel("Pre Trigger [ns]",scope);
layout->addWidget(lbPT, rowID, 2);
sbPT = new QSpinBox(scope);
sbPT->setMinimum(32);
sbPT->setMaximum(32000);
sbPT->setSingleStep(8);
layout->addWidget(sbPT, rowID, 3);
QLabel * lbDCOffset = new QLabel("DC offset [%]",scope);
layout->addWidget(lbDCOffset, rowID, 4);
QSpinBox * sbDCOffset = new QSpinBox(scope);
sbDCOffset->setMinimum(0);
sbDCOffset->setMaximum(100);
sbDCOffset->setSingleStep(1);
layout->addWidget(sbDCOffset, rowID, 5);
//------------ plot view
rowID ++;
QChartView * plotView = new QChartView(plot);
plotView->setRenderHints(QPainter::Antialiasing);
layout->addWidget(plotView, rowID, 0, 1, 4);
layout->addWidget(plotView, rowID, 0, 1, 6);
//------------ close button
rowID ++;
QPushButton * bnStop = new QPushButton("Stop", scope);
layout->addWidget(bnStop, rowID, 2);
connect(bnStop, &QPushButton::clicked, this, &MainWindow::StopScope);
bnScopeStart = new QPushButton("Start", scope);
layout->addWidget(bnScopeStart, rowID, 0);
bnScopeStart->setEnabled(false);
connect(bnScopeStart, &QPushButton::clicked, this, &MainWindow::StartScope);
bnScopeStop = new QPushButton("Stop", scope);
layout->addWidget(bnScopeStop, rowID, 1);
connect(bnScopeStop, &QPushButton::clicked, this, &MainWindow::StopScope);
QPushButton * bnClose = new QPushButton("Close", scope);
layout->addWidget(bnClose, rowID, 3);
layout->addWidget(bnClose, rowID, 5);
connect(bnClose, &QPushButton::clicked, this, &MainWindow::StopScope);
connect(bnClose, &QPushButton::clicked, scope, &QMainWindow::close);

View File

@ -114,6 +114,7 @@ private slots:
void CloseDigitizers();
void OpenScope();
void StartScope();
void StopScope();
void SetUpPlot();
void UpdateScope();
@ -155,6 +156,11 @@ private:
QComboBox * cbScopeCh;
QComboBox * cbAnaProbe[2];
QComboBox * cbDigProbe[4];
QSpinBox * sbRL; // record length
QSpinBox * sbPT; // pre trigger
QPushButton * bnScopeStart;
QPushButton * bnScopeStop;
bool allowChange;
void ProbeChange(QComboBox * cb[], const int size);
//@------ ACQ things

28
makeTest.sh Normal file
View File

@ -0,0 +1,28 @@
CC="g++"
COPTS="-fPIC -DLINUX -O2 -std=c++17 -lpthread"
CAENLIBS="-lCAEN_FELib"
CURLLIBS="-lcurl"
OBJS="ClassDigitizer2Gen.o influxdb.o"
#
#ALL = test
#
################################################################
#
#test : test.cpp ClassDigitizer2Gen.o influxdb.o
# $(CC) $(COPTS) $(OBJS) -o test test.cpp $(CAENLIBS) $(CURLLIBS)
#
#ClassDigitizer2Gen.o : ClassDigitizer2Gen.cpp ClassDigitizer2Gen.h Event.h
# $(CC) $(COPTS) -c ClassDigitizer2Gen.cpp $(CAENLIBS)
#
#influxdb.o : influxdb.cpp influxdb.h
# $(CC) $(COPTS) -c influxdb.cpp $(CURLLIBS)
${CC} ${COPTS} -c influxdb.cpp ${CURLLIBS}
${CC} ${COPTS} -c ClassDigitizer2Gen.cpp ${CAENLIBS}
${CC} ${COPTS} ${OBJS} -o test test.cpp ${CAENLIBS} ${CURLLIBS}

View File

@ -92,6 +92,8 @@ int main(int argc, char* argv[]){
digi->Reset();
digi->ProgramPHA(false);
printf("--------%s \n", digi->ReadChValue(0, "WaveAnalogprobe0", true).c_str());
//printf("%s \n", digi->ReadValue("/ch/0/par/ChRealtimeMonitor").c_str());
//printf("%s \n", digi->ReadValue("/ch/0/par/Energy_Nbit").c_str());
//printf("%s \n", digi->ReadValue("/par/MaxRawDataSize").c_str());
@ -120,6 +122,7 @@ int main(int argc, char* argv[]){
printf("%s\n", digi->GetPath(parHandle).c_str());
*/
/*
digi->ReadDigitizerSettings();
digi->SetPHADataFormat(1);
@ -156,6 +159,10 @@ int main(int argc, char* argv[]){
(t1.tv_nsec-t0.tv_nsec + t1.tv_sec*1e+9 - t0.tv_sec*1e+9)*1.0/1e9);
digi->CloseOutFile();
*/
digi->CloseDigitizer();
delete digi;