many bug fix; added thread sync of ACQ start
This commit is contained in:
parent
3c6985ead0
commit
cad68c2e7c
|
@ -70,7 +70,7 @@ class Data{
|
||||||
|
|
||||||
void PrintStat() const;
|
void PrintStat() const;
|
||||||
|
|
||||||
void PrintAllData(bool tableMode = true) const;
|
void PrintAllData(bool tableMode = true, unsigned int maxRowDisplay = 0) const;
|
||||||
|
|
||||||
//^================= Saving data
|
//^================= Saving data
|
||||||
bool OpenSaveFile(std::string fileNamePrefix); // return false when fail
|
bool OpenSaveFile(std::string fileNamePrefix); // return false when fail
|
||||||
|
@ -268,7 +268,7 @@ inline void Data::PrintStat() const{
|
||||||
printf("---+--------+-----------+-----------+----------\n");
|
printf("---+--------+-----------+-----------+----------\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Data::PrintAllData(bool tableMode) const{
|
inline void Data::PrintAllData(bool tableMode, unsigned int maxRowDisplay) const{
|
||||||
printf("============================= Print Data\n");
|
printf("============================= Print Data\n");
|
||||||
|
|
||||||
if( tableMode ){
|
if( tableMode ){
|
||||||
|
@ -296,6 +296,8 @@ inline void Data::PrintAllData(bool tableMode) const{
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
entry ++;
|
entry ++;
|
||||||
|
|
||||||
|
if( maxRowDisplay > 0 && (unsigned int) entry >= maxRowDisplay ) break;
|
||||||
}while(entry <= MaxEntry);
|
}while(entry <= MaxEntry);
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
@ -305,6 +307,7 @@ inline void Data::PrintAllData(bool tableMode) const{
|
||||||
for( int ev = 0; ev <= (LoopIndex[ch] > 0 ? MaxNData : DataIndex[ch]) ; ev++){
|
for( int ev = 0; ev <= (LoopIndex[ch] > 0 ? MaxNData : DataIndex[ch]) ; ev++){
|
||||||
if( DPPType == V1730_DPP_PHA_CODE ) printf("%4d, %5u, %15llu, %5u \n", ev, Energy[ch][ev], Timestamp[ch][ev], fineTime[ch][ev]);
|
if( DPPType == V1730_DPP_PHA_CODE ) printf("%4d, %5u, %15llu, %5u \n", ev, Energy[ch][ev], Timestamp[ch][ev], fineTime[ch][ev]);
|
||||||
if( DPPType == V1730_DPP_PSD_CODE ) printf("%4d, %5u, %5u, %15llu, %5u \n", ev, Energy[ch][ev], Energy2[ch][ev], Timestamp[ch][ev], fineTime[ch][ev]);
|
if( DPPType == V1730_DPP_PSD_CODE ) printf("%4d, %5u, %5u, %15llu, %5u \n", ev, Energy[ch][ev], Energy2[ch][ev], Timestamp[ch][ev], fineTime[ch][ev]);
|
||||||
|
if( maxRowDisplay > 0 && (unsigned int) ev > maxRowDisplay ) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -408,6 +408,24 @@ void Digitizer::StartACQ(){
|
||||||
printf("\e[1m\e[33m======= Acquisition Started for %d | Board %d, Port %d\e[0m\n", BoardInfo.SerialNumber, boardID, portID);
|
printf("\e[1m\e[33m======= Acquisition Started for %d | Board %d, Port %d\e[0m\n", BoardInfo.SerialNumber, boardID, portID);
|
||||||
AcqRun = true;
|
AcqRun = true;
|
||||||
data->ClearTriggerRate();
|
data->ClearTriggerRate();
|
||||||
|
|
||||||
|
unsigned int acqID = ExtractBits(GetSettingFromMemory(DPP::AcquisitionControl), DPP::Bit_AcquistionControl::StartStopMode);
|
||||||
|
unsigned int trgOutID = ExtractBits(GetSettingFromMemory(DPP::FrontPanelIOControl), DPP::Bit_FrontPanelIOControl::TRGOUTConfig);
|
||||||
|
|
||||||
|
std::string acqStr = "";
|
||||||
|
for( int i = 0; i < (int) DPP::Bit_AcquistionControl::ListStartStopMode.size(); i++){
|
||||||
|
if( DPP::Bit_AcquistionControl::ListStartStopMode[i].second == acqID ){
|
||||||
|
acqStr = DPP::Bit_AcquistionControl::ListStartStopMode[i].first;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::string trgOutStr = "";
|
||||||
|
for( int i = 0; i < (int) DPP::Bit_FrontPanelIOControl::ListTRGOUTConfig.size(); i++){
|
||||||
|
if( DPP::Bit_FrontPanelIOControl::ListTRGOUTConfig[i].second == (trgOutID << 14) ){
|
||||||
|
trgOutStr = DPP::Bit_FrontPanelIOControl::ListTRGOUTConfig[i].first;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf(" ACQ mode : %s (%d), TRG-OUT mode : %s (%d) \n", acqStr.c_str(), acqID, trgOutStr.c_str(), trgOutID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Digitizer::StopACQ(){
|
void Digitizer::StopACQ(){
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
|
#include <QWaitCondition>
|
||||||
|
|
||||||
#include "macro.h"
|
#include "macro.h"
|
||||||
#include "ClassDigitizer.h"
|
#include "ClassDigitizer.h"
|
||||||
|
@ -24,11 +25,30 @@ public:
|
||||||
void Stop() { this->stop = true;}
|
void Stop() { this->stop = true;}
|
||||||
void SetSaveData(bool onOff) {this->isSaveData = onOff;}
|
void SetSaveData(bool onOff) {this->isSaveData = onOff;}
|
||||||
void SetScopeMode(bool onOff) {this->isScope = onOff;}
|
void SetScopeMode(bool onOff) {this->isScope = onOff;}
|
||||||
|
|
||||||
|
void go(){
|
||||||
|
mutex.lock();
|
||||||
|
condition.wakeAll();
|
||||||
|
mutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
void run(){
|
void run(){
|
||||||
|
|
||||||
|
stop = false;
|
||||||
|
|
||||||
|
mutex.lock();
|
||||||
|
condition.wait(&mutex);
|
||||||
|
mutex.unlock();
|
||||||
|
|
||||||
clock_gettime(CLOCK_REALTIME, &t0);
|
clock_gettime(CLOCK_REALTIME, &t0);
|
||||||
|
printf("--- %d, %ld nsec \n", ID, t0.tv_nsec);
|
||||||
ta = t0;
|
ta = t0;
|
||||||
// clock_gettime(CLOCK_REALTIME, &t1);
|
// clock_gettime(CLOCK_REALTIME, &t1);
|
||||||
stop = false;
|
|
||||||
|
digi->StartACQ();
|
||||||
|
|
||||||
|
usleep(1000); // wait for some data;
|
||||||
|
|
||||||
do{
|
do{
|
||||||
|
|
||||||
if( stop) break;
|
if( stop) break;
|
||||||
|
@ -84,7 +104,10 @@ private:
|
||||||
timespec ta, tb, t1, t2, t0;
|
timespec ta, tb, t1, t2, t0;
|
||||||
bool isSaveData;
|
bool isSaveData;
|
||||||
bool isScope;
|
bool isScope;
|
||||||
unsigned long readCount;
|
unsigned long readCount;
|
||||||
|
|
||||||
|
QMutex mutex;
|
||||||
|
QWaitCondition condition;
|
||||||
};
|
};
|
||||||
|
|
||||||
//^#======================================================= Timing Thread
|
//^#======================================================= Timing Thread
|
||||||
|
|
|
@ -7,7 +7,7 @@ void DataReaderScript(){
|
||||||
Data * data = new Data();
|
Data * data = new Data();
|
||||||
data->DPPType = V1730_DPP_PSD_CODE;
|
data->DPPType = V1730_DPP_PSD_CODE;
|
||||||
|
|
||||||
std::string fileName = "data/temp_043_089_PSD_000.fsu";
|
std::string fileName = "data/temp_046_325_PHA_000.fsu";
|
||||||
|
|
||||||
FILE * haha = fopen(fileName.c_str(), "r");
|
FILE * haha = fopen(fileName.c_str(), "r");
|
||||||
fseek(haha, 0L, SEEK_END);
|
fseek(haha, 0L, SEEK_END);
|
||||||
|
@ -49,16 +49,17 @@ void DataReaderScript(){
|
||||||
//if( countBdAgg % 100 == 0) data->PrintStat();
|
//if( countBdAgg % 100 == 0) data->PrintStat();
|
||||||
//data->ClearData();
|
//data->ClearData();
|
||||||
|
|
||||||
if( countBdAgg > 500 ){
|
//if( countBdAgg > 500 ){
|
||||||
data->PrintAllData();
|
// data->PrintAllData();
|
||||||
mb->BuildEventsBackWard(false);
|
// mb->BuildEventsBackWard(false);
|
||||||
break;
|
// break;
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
}while(!feof(haha) && ftell(haha) < inFileSize);
|
}while(!feof(haha) && ftell(haha) < inFileSize);
|
||||||
|
|
||||||
data->PrintStat();
|
data->PrintStat();
|
||||||
|
data->PrintAllData();
|
||||||
|
|
||||||
fclose(haha);
|
fclose(haha);
|
||||||
|
|
||||||
|
|
|
@ -2476,7 +2476,7 @@ void DigiSettingsPanel::UpdatePanelFromMemory(){
|
||||||
|
|
||||||
chkEnableExternalTrigger[ID]->setChecked( ! ( digi[ID]->GetSettingFromMemory(DPP::DisableExternalTrigger) & 0x1) );
|
chkEnableExternalTrigger[ID]->setChecked( ! ( digi[ID]->GetSettingFromMemory(DPP::DisableExternalTrigger) & 0x1) );
|
||||||
|
|
||||||
sbRunDelay[ID]->setValue(digi[ID]->GetSettingFromMemory(DPP::RunStartStopDelay));
|
sbRunDelay[ID]->setValue(digi[ID]->GetSettingFromMemory(DPP::RunStartStopDelay) * DPP::RunStartStopDelay.GetPartialStep() * digi[ID]->GetTick2ns());
|
||||||
|
|
||||||
//*========================================
|
//*========================================
|
||||||
uint32_t anaMonitor = digi[ID]->GetSettingFromMemory(DPP::AnalogMonitorMode);
|
uint32_t anaMonitor = digi[ID]->GetSettingFromMemory(DPP::AnalogMonitorMode);
|
||||||
|
@ -2496,6 +2496,13 @@ void DigiSettingsPanel::UpdatePanelFromMemory(){
|
||||||
sbBufferGain[ID]->setValue(digi[ID]->GetSettingFromMemory(DPP::BufferOccupancyGain));
|
sbBufferGain[ID]->setValue(digi[ID]->GetSettingFromMemory(DPP::BufferOccupancyGain));
|
||||||
sbVoltageLevel[ID]->setValue(digi[ID]->GetSettingFromMemory(DPP::VoltageLevelModeConfig));
|
sbVoltageLevel[ID]->setValue(digi[ID]->GetSettingFromMemory(DPP::VoltageLevelModeConfig));
|
||||||
|
|
||||||
|
//*========================================
|
||||||
|
uint32_t acqCtrl = digi[ID]->GetSettingFromMemory(DPP::AcquisitionControl);
|
||||||
|
|
||||||
|
cbStartStopMode[ID]->setCurrentIndex( Digitizer::ExtractBits(acqCtrl, DPP::Bit_AcquistionControl::StartStopMode) );
|
||||||
|
cbAcqStartArm[ID]->setCurrentIndex( Digitizer::ExtractBits(acqCtrl, DPP::Bit_AcquistionControl::ACQStartArm) );
|
||||||
|
cbPLLRefClock[ID]->setCurrentIndex( Digitizer::ExtractBits(acqCtrl, DPP::Bit_AcquistionControl::PLLRef) );
|
||||||
|
|
||||||
//*========================================
|
//*========================================
|
||||||
uint32_t frontPanel = digi[ID]->GetSettingFromMemory(DPP::FrontPanelIOControl);
|
uint32_t frontPanel = digi[ID]->GetSettingFromMemory(DPP::FrontPanelIOControl);
|
||||||
cbLEMOMode[ID]->setCurrentIndex( ( frontPanel & 0x1 ));
|
cbLEMOMode[ID]->setCurrentIndex( ( frontPanel & 0x1 ));
|
||||||
|
@ -2503,8 +2510,7 @@ void DigiSettingsPanel::UpdatePanelFromMemory(){
|
||||||
if( (frontPanel >> 1 ) & 0x1 ) { // bit-1, TRIG-OUT high impedance, i.e. disable
|
if( (frontPanel >> 1 ) & 0x1 ) { // bit-1, TRIG-OUT high impedance, i.e. disable
|
||||||
cbTRGOUTMode[ID]->setCurrentIndex(0);
|
cbTRGOUTMode[ID]->setCurrentIndex(0);
|
||||||
}else{
|
}else{
|
||||||
unsigned short trgOutBit = ((frontPanel >> 14 ) & 0x3F ) << 14 ;
|
unsigned int trgOutBit = ((frontPanel >> 14 ) & 0x3F ) << 14 ;
|
||||||
|
|
||||||
for( int i = 0; i < cbTRGOUTMode[ID]->count() ; i++ ){
|
for( int i = 0; i < cbTRGOUTMode[ID]->count() ; i++ ){
|
||||||
if( cbTRGOUTMode[ID]->itemData(i).toUInt() == trgOutBit ){
|
if( cbTRGOUTMode[ID]->itemData(i).toUInt() == trgOutBit ){
|
||||||
cbTRGOUTMode[ID]->setCurrentIndex(i);
|
cbTRGOUTMode[ID]->setCurrentIndex(i);
|
||||||
|
@ -3076,6 +3082,8 @@ void DigiSettingsPanel::LoadSetting(){
|
||||||
digi[ID]->ProgramSettingsToBoard();
|
digi[ID]->ProgramSettingsToBoard();
|
||||||
UpdatePanelFromMemory();
|
UpdatePanelFromMemory();
|
||||||
|
|
||||||
|
UpdateOtherPanels();
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
SendLogMsg("Fail to Loaded settings file " + fileName + " for Digi-" + QString::number(digi[ID]->GetSerialNumber()));
|
SendLogMsg("Fail to Loaded settings file " + fileName + " for Digi-" + QString::number(digi[ID]->GetSerialNumber()));
|
||||||
}
|
}
|
||||||
|
|
32
FSUDAQ.cpp
32
FSUDAQ.cpp
|
@ -64,9 +64,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
|
||||||
layout->addWidget(bnCanvas, 1, 2);
|
layout->addWidget(bnCanvas, 1, 2);
|
||||||
connect(bnCanvas, &QPushButton::clicked, this, &MainWindow::OpenCanvas);
|
connect(bnCanvas, &QPushButton::clicked, this, &MainWindow::OpenCanvas);
|
||||||
|
|
||||||
QPushButton * bnSync = new QPushButton("Sync Boards", this);
|
bnSync = new QPushButton("Sync Boards", this);
|
||||||
layout->addWidget(bnSync);
|
layout->addWidget(bnSync);
|
||||||
bnSync->setEnabled(false);
|
connect(bnSync, &QPushButton::clicked, this, &MainWindow::SetSyncMode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -561,6 +561,8 @@ void MainWindow::OpenDigitizers(){
|
||||||
bnStopACQ->setEnabled(false);
|
bnStopACQ->setEnabled(false);
|
||||||
bnStopACQ->setStyleSheet("");
|
bnStopACQ->setStyleSheet("");
|
||||||
|
|
||||||
|
bnSync->setEnabled( nDigi >= 1 );
|
||||||
|
|
||||||
if( rawDataPath == "" ) {
|
if( rawDataPath == "" ) {
|
||||||
chkSaveData->setChecked(false);
|
chkSaveData->setChecked(false);
|
||||||
chkSaveData->setEnabled(false);
|
chkSaveData->setEnabled(false);
|
||||||
|
@ -635,6 +637,8 @@ void MainWindow::WaitForDigitizersOpen(bool onOff){
|
||||||
bnCanvas->setEnabled(!onOff);
|
bnCanvas->setEnabled(!onOff);
|
||||||
bnAnalyzer->setEnabled(!onOff);
|
bnAnalyzer->setEnabled(!onOff);
|
||||||
|
|
||||||
|
bnSync->setEnabled(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************
|
//***************************************************************
|
||||||
|
@ -786,6 +790,8 @@ void MainWindow::UpdateScalar(){
|
||||||
for( unsigned int iDigi = 0; iDigi < nDigi; iDigi++){
|
for( unsigned int iDigi = 0; iDigi < nDigi; iDigi++){
|
||||||
digiMTX[iDigi].lock();
|
digiMTX[iDigi].lock();
|
||||||
|
|
||||||
|
printf("### %d ", iDigi);
|
||||||
|
digi[iDigi]->GetData()->PrintAllData(true, 10);
|
||||||
if( chkSaveData->isChecked() ) totalFileSize += digi[iDigi]->GetData()->GetTotalFileSize();
|
if( chkSaveData->isChecked() ) totalFileSize += digi[iDigi]->GetData()->GetTotalFileSize();
|
||||||
for( int i = 0; i < digi[iDigi]->GetNChannels(); i++){
|
for( int i = 0; i < digi[iDigi]->GetNChannels(); i++){
|
||||||
if( digi[iDigi]->GetChannelOnOff(i) == true ) {
|
if( digi[iDigi]->GetChannelOnOff(i) == true ) {
|
||||||
|
@ -828,7 +834,6 @@ void MainWindow::StartACQ(){
|
||||||
LogMsg("<font style=\"color: orange;\">===================== <b>Start a non-save Run</b></font>");
|
LogMsg("<font style=\"color: orange;\">===================== <b>Start a non-save Run</b></font>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for( unsigned int i = 0; i < nDigi ; i++){
|
for( unsigned int i = 0; i < nDigi ; i++){
|
||||||
if( chkSaveData->isChecked() ) {
|
if( chkSaveData->isChecked() ) {
|
||||||
if( digi[i]->GetData()->OpenSaveFile((rawDataPath + "/" + prefix + "_" + QString::number(runID).rightJustified(3, '0')).toStdString()) == false ) {
|
if( digi[i]->GetData()->OpenSaveFile((rawDataPath + "/" + prefix + "_" + QString::number(runID).rightJustified(3, '0')).toStdString()) == false ) {
|
||||||
|
@ -841,11 +846,15 @@ void MainWindow::StartACQ(){
|
||||||
digi[i]->WriteRegister(DPP::SoftwareClear_W, 1);
|
digi[i]->WriteRegister(DPP::SoftwareClear_W, 1);
|
||||||
digi[i]->GetData()->ClearData();
|
digi[i]->GetData()->ClearData();
|
||||||
|
|
||||||
digi[i]->StartACQ();
|
|
||||||
readDataThread[i]->start();
|
readDataThread[i]->start();
|
||||||
}
|
}
|
||||||
if( chkSaveData->isChecked() ) SaveLastRunFile();
|
if( chkSaveData->isChecked() ) SaveLastRunFile();
|
||||||
|
|
||||||
|
printf("------------ wait for 2 sec \n");
|
||||||
|
usleep(2000*1000);
|
||||||
|
printf("------------ Go! \n");
|
||||||
|
for( unsigned int i = 0; i < nDigi; i++) readDataThread[i]->go();
|
||||||
|
|
||||||
scalarThread->start();
|
scalarThread->start();
|
||||||
|
|
||||||
if( !scalar->isVisible() ) {
|
if( !scalar->isVisible() ) {
|
||||||
|
@ -960,6 +969,19 @@ void MainWindow::StopACQ(){
|
||||||
|
|
||||||
void MainWindow::AutoRun(){ //TODO
|
void MainWindow::AutoRun(){ //TODO
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::SetSyncMode(){
|
||||||
|
|
||||||
|
// No sync
|
||||||
|
|
||||||
|
// using external start ( TRG-OUT (S-IN) --> S-IN )
|
||||||
|
|
||||||
|
// using SW ( TRG-OUT(RUN) --> S-IN)
|
||||||
|
|
||||||
|
// using external Clock ( TRG-OUT(RUN) --> S-IN )
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::CommentDialog(bool isStartRun){
|
bool MainWindow::CommentDialog(bool isStartRun){
|
||||||
|
|
3
FSUDAQ.h
3
FSUDAQ.h
|
@ -74,6 +74,8 @@ private slots:
|
||||||
void WriteElog(QString htmlText, QString subject, QString category, int runNumber);
|
void WriteElog(QString htmlText, QString subject, QString category, int runNumber);
|
||||||
void AppendElog(QString appendHtmlText);
|
void AppendElog(QString appendHtmlText);
|
||||||
|
|
||||||
|
void SetSyncMode();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -95,6 +97,7 @@ private:
|
||||||
QPushButton * bnOpenScaler;
|
QPushButton * bnOpenScaler;
|
||||||
QPushButton * bnStartACQ;
|
QPushButton * bnStartACQ;
|
||||||
QPushButton * bnStopACQ;
|
QPushButton * bnStopACQ;
|
||||||
|
QPushButton * bnSync;
|
||||||
|
|
||||||
QPushButton * bnCanvas;
|
QPushButton * bnCanvas;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user