various fixs and improvements duraing Encore run, rate ~ 1k/ch
This commit is contained in:
parent
20c9a8b63d
commit
cd7dfbd76d
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
|
@ -157,6 +157,8 @@
|
|||
"source_location": "cpp",
|
||||
"splitpole.C": "cpp",
|
||||
"forward_list": "cpp",
|
||||
"fstream": "cpp"
|
||||
"fstream": "cpp",
|
||||
"Analyzer.C": "cpp",
|
||||
"process_Run.C": "cpp"
|
||||
}
|
||||
}
|
|
@ -245,8 +245,9 @@ inline void Data::SaveData(){
|
|||
|
||||
}
|
||||
inline void Data::CloseSaveFile(){
|
||||
if( outFile != NULL ){
|
||||
if( outFile != nullptr ){
|
||||
fclose(outFile);
|
||||
outFile = nullptr;
|
||||
int result = chmod(outFileName.c_str(), S_IRUSR | S_IRGRP | S_IROTH);
|
||||
if( result != 0 ) printf("somewrong when set file (%s) to read only.", outFileName.c_str());
|
||||
}
|
||||
|
|
|
@ -194,9 +194,13 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr
|
|||
|
||||
});
|
||||
|
||||
bnClearBuffer = new QPushButton("Clear Buffer/FIFO", this);
|
||||
bnClearBuffer = new QPushButton("Clear Buffer/FIFO/Data", this);
|
||||
buttonLayout->addWidget(bnClearBuffer, rowID, 2);
|
||||
connect(bnClearBuffer, &QPushButton::clicked, this, [=](){ digi[ID]->WriteRegister(DPP::SoftwareClear_W, 1); UpdateBoardAndChannelsStatus();});
|
||||
connect(bnClearBuffer, &QPushButton::clicked, this, [=](){
|
||||
digi[ID]->WriteRegister(DPP::SoftwareClear_W, 1);
|
||||
digi[ID]->GetData()->ClearData();
|
||||
UpdateBoardAndChannelsStatus();
|
||||
});
|
||||
|
||||
bnLoadSettings = new QPushButton("Load Settings", this);
|
||||
buttonLayout->addWidget(bnLoadSettings, rowID, 3);
|
||||
|
|
|
@ -61,11 +61,13 @@ int main(int argc, char **argv) {
|
|||
for( int i = 0; i < nFile; i++) printf("%2d | %s \n", i, inFileName[i].Data());
|
||||
printf("=====================================\n");
|
||||
printf(" Time Window = %u \n", timeWindow);
|
||||
printf("=====================================\n");
|
||||
|
||||
printf("===================================== input files:\n");
|
||||
|
||||
///============= sorting file by the serial number & order
|
||||
int ID[nFile]; /// serial+ order*1000;
|
||||
int type[nFile];
|
||||
unsigned int fileSize[nFile];
|
||||
for( int i = 0; i < nFile; i++){
|
||||
int snPos = inFileName[i].Index("_"); // first "_"
|
||||
//snPos = inFileName[i].Index("_", snPos + 1);
|
||||
|
@ -79,12 +81,22 @@ int main(int argc, char **argv) {
|
|||
int order = atoi(&inFileName[i][snPos+13]);
|
||||
ID[i] = sn + order * 1000;
|
||||
|
||||
FILE * temp = fopen(inFileName[i].Data(), "rb");
|
||||
if( temp == NULL ) {
|
||||
fileSize[i] = 0;
|
||||
}else{
|
||||
fseek(temp, 0, SEEK_END);
|
||||
fileSize[i] = ftell(temp);
|
||||
}
|
||||
fclose(temp);
|
||||
|
||||
|
||||
//printf("sn:%d, type:%d (%s), order:%d \n", sn, type[i], typeStr.Data(), order);
|
||||
|
||||
}
|
||||
quickSort(&(ID[0]), &(type[0]), &(inFileName[0]), 0, nFile-1);
|
||||
for( int i = 0 ; i < nFile; i++){
|
||||
printf("%d | %6d | %3d | %s \n", i, ID[i], type[i], inFileName[i].Data());
|
||||
printf("%d | %6d | %3d | %s | %u\n", i, ID[i], type[i], inFileName[i].Data(), fileSize[i]);
|
||||
}
|
||||
|
||||
//*======================================= Sort files in to group
|
||||
|
@ -107,7 +119,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
int nGroup = snList.size();
|
||||
printf("===================================== nGroup %d.\n", nGroup);
|
||||
printf("===================================== number of file Group by digitizer %d.\n", nGroup);
|
||||
for( int i = 0; i < nGroup; i++){
|
||||
printf("............ %d \n", snList[i]);
|
||||
for( int j = 0; j< (int) fileList[i].size(); j++){
|
||||
|
@ -170,6 +182,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
|
||||
//*====================================== build events
|
||||
printf("================= Building events....\n");
|
||||
MultiBuilder * mb = new MultiBuilder(data, typeList, snList);
|
||||
mb->SetTimeWindow(timeWindow);
|
||||
|
||||
|
@ -177,16 +190,23 @@ int main(int argc, char **argv) {
|
|||
char * buffer = nullptr;
|
||||
unsigned int word[1]; // 4 byte = 32 bit
|
||||
|
||||
|
||||
do{
|
||||
|
||||
/// fill the data class with some agg;
|
||||
bool earlyTermination = false;
|
||||
int aggCount = 0;
|
||||
do{
|
||||
|
||||
for ( int i = 0; i < nGroup; i++){
|
||||
if( inFile[i] == nullptr ) continue;
|
||||
size_t dummy = fread(word, 4, 1, inFile[i]);
|
||||
if( dummy != 1) printf("fread error, should read 4 bytes, but read %ld x 4 byte, file pos: %ld byte (%s)\n", dummy, ftell(inFile[i]), fileList[i][inFileIndex[i]].Data());
|
||||
if( dummy != 1) {
|
||||
printf("fread error, should read 4 bytes, but read %ld x 4 byte, file pos: %ld byte (%s)\n", dummy, ftell(inFile[i]), fileList[i][inFileIndex[i]].Data());
|
||||
earlyTermination = true;
|
||||
}
|
||||
|
||||
if( earlyTermination == false){
|
||||
fseek(inFile[i], -4, SEEK_CUR); // rool back
|
||||
|
||||
short header = ((word[0] >> 28 ) & 0xF);
|
||||
|
@ -195,12 +215,18 @@ int main(int argc, char **argv) {
|
|||
|
||||
buffer = new char[aggSize];
|
||||
dummy = fread(buffer, aggSize, 1, inFile[i]);
|
||||
if( dummy != 1) printf("fread error, should read %d bytes, but read %ld x %d byte, file pos: %ld byte (%s)\n", aggSize, dummy, aggSize, ftell(inFile[i]), fileList[i][inFileIndex[i]].Data());
|
||||
if( dummy != 1) {
|
||||
printf("fread error, should read %d bytes, but read %ld x %d byte, file pos: %ld byte (%s)\n", aggSize, dummy, aggSize, ftell(inFile[i]), fileList[i][inFileIndex[i]].Data());
|
||||
earlyTermination = true;
|
||||
}
|
||||
|
||||
if( earlyTermination == false){
|
||||
data[i]->DecodeBuffer(buffer, aggSize, false, 0);
|
||||
data[i]->ClearBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
if( feof(inFile[i]) ){
|
||||
if( feof(inFile[i]) || earlyTermination ){
|
||||
fclose(inFile[i]);
|
||||
inFile[i] = fopen(fileList[i][inFileIndex[i]+1], "r");
|
||||
if( inFile[i] ){
|
||||
|
@ -210,7 +236,6 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
aggCount++;
|
||||
|
||||
}while(aggCount < 10); // get 10 agg
|
||||
|
@ -219,11 +244,13 @@ int main(int argc, char **argv) {
|
|||
|
||||
///----------- save to tree;
|
||||
long startIndex = mb->eventIndex - mb->eventBuilt + 1;
|
||||
if( startIndex < 0 ) startIndex += MaxNEvent;
|
||||
while( startIndex < 0 ) startIndex += MaxNEvent;
|
||||
//printf("startIndex : %ld, %ld\n", startIndex, mb->eventIndex);
|
||||
for( long i = startIndex; i <= mb->eventIndex; i++){
|
||||
evID ++;
|
||||
|
||||
multi = mb->events[i].size();
|
||||
if( multi > MAX_MULTI) break;
|
||||
evID ++;
|
||||
for( int j = 0; j < multi; j ++){
|
||||
bd[j] = mb->events[i][j].bd;
|
||||
ch[j] = mb->events[i][j].ch;
|
||||
|
@ -262,6 +289,7 @@ int main(int argc, char **argv) {
|
|||
for( long i = startIndex; i <= mb->eventIndex; i++){
|
||||
evID ++;
|
||||
multi = mb->events[i].size();
|
||||
if( multi > MAX_MULTI) break;
|
||||
for( int j = 0; j < multi; j ++){
|
||||
bd[j] = mb->events[i][j].bd;
|
||||
ch[j] = mb->events[i][j].ch;
|
||||
|
|
|
@ -214,6 +214,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
|
|||
cbAutoRun->addItem("Single 1 min", 1);
|
||||
cbAutoRun->addItem("Single 30 mins", 30);
|
||||
cbAutoRun->addItem("Single 60 mins", 60);
|
||||
cbAutoRun->addItem("Single 120 mins", 120);
|
||||
cbAutoRun->addItem("Repeat 1 mins", -1);
|
||||
cbAutoRun->addItem("Repeat 60 mins", -60);
|
||||
cbAutoRun->addItem("Repeat 120 mins", -120);
|
||||
|
@ -1079,11 +1080,11 @@ void MainWindow::StopACQ(){
|
|||
|
||||
void MainWindow::AutoRun(){ //TODO
|
||||
|
||||
runTimer->disconnect(runTimerConnection);
|
||||
if( chkSaveData->isChecked() == false){
|
||||
StartACQ();
|
||||
return;
|
||||
}
|
||||
|
||||
if( cbAutoRun->currentData().toInt() == 0 ){
|
||||
StartACQ();
|
||||
//disconnect(runTimer, runTimerConnection);
|
||||
|
@ -1095,6 +1096,7 @@ void MainWindow::AutoRun(){ //TODO
|
|||
|
||||
runTimerConnection = connect( runTimer, &QTimer::timeout, this, [=](){
|
||||
needManualComment = false;
|
||||
LogMsg("Time Up, Stopping ACQ...");
|
||||
StopACQ();
|
||||
if( cbAutoRun->currentData().toInt() < 0 ){
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataTh
|
|||
xaxis->setTitleText("Time [ns]");
|
||||
|
||||
updateTraceThread = new TimingThread();
|
||||
updateTraceThread->SetWaitTimeinSec(0.5);
|
||||
updateTraceThread->SetWaitTimeinSec(ScopeUpdateMiliSec / 1000.);
|
||||
connect(updateTraceThread, &TimingThread::timeUp, this, &Scope::UpdateScope);
|
||||
|
||||
|
||||
|
@ -355,6 +355,9 @@ void Scope::UpdateScope(){
|
|||
|
||||
int index = data->DataIndex[ch];
|
||||
int traceLength = data->Waveform1[ch][index].size();
|
||||
if( digi[ID]->GetDPPType() == V1730_DPP_PSD_CODE ) traceLength = data->DigiWaveform1[ch][index].size();
|
||||
|
||||
if( traceLength > MaxDisplayTraceDataLength) traceLength = MaxDisplayTraceDataLength;
|
||||
|
||||
// printf("--- %s| %d, %d, %d | %d | %d, %d\n", __func__, ch, data->LoopIndex[ch], index, traceLength, factor, tick2ns );
|
||||
if( data->TriggerRate[ch] > 0 ){
|
||||
|
@ -370,7 +373,7 @@ void Scope::UpdateScope(){
|
|||
}
|
||||
|
||||
if( digi[ID]->GetDPPType() == V1730_DPP_PSD_CODE ) {
|
||||
for( int i = 0; i < (int) (data->DigiWaveform1[ch][index]).size() ; i++ ) {
|
||||
for( int i = 0; i < traceLength ; i++ ) {
|
||||
points[0].append(QPointF(tick2ns * i * factor, (data->Waveform1[ch][index])[i]));
|
||||
if( i < (int) data->Waveform2[ch][index].size() ) points[1].append(QPointF(tick2ns * i * factor, (data->Waveform2[ch][index])[i]));
|
||||
if( i < (int) data->DigiWaveform1[ch][index].size() ) points[2].append(QPointF(tick2ns * i, (data->DigiWaveform1[ch][index])[i] * 1000));
|
||||
|
|
3
macro.h
3
macro.h
|
@ -10,7 +10,8 @@
|
|||
#define MaxRecordLength 0x3fff * 8
|
||||
#define MaxSaveFileSize 1024 * 1024 * 1024 * 2
|
||||
|
||||
#define MaxDisplayTraceDataLength 2000 //data point,
|
||||
#define MaxDisplayTraceDataLength 1250 //data point,
|
||||
#define ScopeUpdateMiliSec 200 // msec
|
||||
#define MaxNumberOfTrace 4 // in an event
|
||||
|
||||
#define SETTINGSIZE 2048
|
||||
|
|
Loading…
Reference in New Issue
Block a user