add some code to prevent out of memeory frozen

This commit is contained in:
Ryan Tang 2023-11-20 12:10:36 -05:00
parent b396eef66e
commit 649cb1554a
5 changed files with 28 additions and 3 deletions

View File

@ -26,6 +26,19 @@
"cppStandard": "gnu++17",
"intelliSenseMode": "linux-gcc-x64"
},
{
"name": "Anasen",
"includePath": [
"${workspaceFolder}/**",
"/usr/include/x86_64-linux-gnu/qt6/**",
"/opt/root/include/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c17",
"cppStandard": "gnu++17",
"intelliSenseMode": "linux-gcc-x64"
},
{
"name": "Splitpole",
"includePath": [

View File

@ -587,12 +587,15 @@ int Digitizer::ReadData(){
//uint32_t EventSize = ReadRegister(DPP::EventSize); // Is it as same as data->nByte?
// if( data->nByte > 0 ) printf("Read Buffer size %d byte \n", data->nByte);
if (ret || data->nByte == 0) {
if (ret != CAEN_DGTZ_Success || data->nByte == 0) {
ErrorMsg(__func__);
if( ret == CAEN_DGTZ_OutOfMemory) {
printf("Abort ReadData.\n");
return ret;
}
}
acqStatus = ReadRegister(DPP::AcquisitionStatus_R);
ReadACQStatus();
return ret;
}

View File

@ -96,6 +96,7 @@ class Digitizer{
Data * GetData() const {return data;}
uint32_t GetACQStatus() const {return acqStatus;}
void ReadAndPrintACQStatue();
void ReadACQStatus() { acqStatus = ReadRegister(DPP::AcquisitionStatus_R); }
unsigned int CalByteForBuffer();

View File

@ -78,7 +78,14 @@ public:
printf("ReadDataThread::%s------------ ret : %d \n", __func__, ret);
digiMTX[ID].lock();
digi->StopACQ();
if( ret == CAEN_DGTZ_OutOfMemory ){
digi->WriteRegister(DPP::SoftwareClear_W, 1);
digi->GetData()->ClearData();
}
digi->ReadACQStatus();
digiMTX[ID].unlock();
emit sendMsg("Digi-" + QString::number(digi->GetSerialNumber()) + " ACQ off.");
stop = true;
break;
}

View File

@ -982,6 +982,7 @@ void MainWindow::UpdateScalar(){
digiMTX[iDigi].lock();
uint32_t acqStatus = digi[iDigi]->GetACQStatus();
//printf("Digi-%d : acq on/off ? : %d \n", digi[iDigi]->GetSerialNumber(), (acqStatus >> 2) & 0x1 );
if( ( acqStatus >> 2 ) & 0x1 ){
runStatus[iDigi]->setStyleSheet("background-color : green;");
}else{