some improvements

This commit is contained in:
carina@hades 2022-10-25 16:56:52 -04:00
parent 03b6a03557
commit 02ea0c98f1
5 changed files with 92 additions and 70 deletions

View File

@ -189,7 +189,7 @@ inline void Data::SaveBuffer(const char * fileName){
fwrite(buffer, nByte, 1, haha);
presentFileSizeByte = ftell(haha);
printf("=========== file Size : %u Byte = %.2f MB\n", presentFileSizeByte, presentFileSizeByte/1024./1024.);
///printf("=========== file Size : %u Byte = %.2f MB\n", presentFileSizeByte, presentFileSizeByte/1024./1024.);
fclose(haha);
}

View File

@ -728,7 +728,7 @@ void Digitizer::SaveSettingAsText(std::string fileName){
if( haha.GetType() == RW::ReadWrite ) typeStr = "R/W";
if( haha.GetType() == RW::ReadONLY ) typeStr = "R ";
if( haha.GetType() == RW::WriteONLY ) typeStr = " W";
fprintf( txtFile, "0x%04X %30s 0x%08X %s %d\n", actualAddress,
fprintf( txtFile, "0x%04X %30s 0x%08X %s %u\n", actualAddress,
haha.GetNameChar(),
setting[i],
typeStr.c_str(),

View File

@ -178,6 +178,7 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
chIDEntry = new TGNumberEntry(hfg1, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber); hfg1->AddFrame(chIDEntry, haha);
chIDEntry->SetWidth(50);
chIDEntry->SetState(false);
chIDEntry->Connect("Modified()", "MainWindow", this, "ChangePlot()");
bPlotSingleTrace = new TGTextButton(hfg1,"Plot Trace"); hfg1->AddFrame(bPlotSingleTrace, haha);
bPlotSingleTrace->Connect("Clicked()", "MainWindow", this, "PlotSingleTrace()");
@ -226,8 +227,8 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
LogMsg((char*)"Please \"Open Digitizers\" to start.");
HandleMenu(M_DIGITIZER_OPEN);
HandleMenu(M_BOARD_SETTINGS);
HandleMenu(M_CH_SETTING_PHA);
//HandleMenu(M_BOARD_SETTINGS);
//HandleMenu(M_CH_SETTING_PHA);
//HandleMenu(M_CH_SETTING_PSD);
//HandleMenu(M_REGISTER_SETTING);
//HandleMenu(M_TRIGGER_SUMMARY);
@ -490,6 +491,7 @@ void MainWindow::LoadSettingFromFile(){
void MainWindow::ChangeBoard(){
int boardID = boardIDEntry->GetNumber();
chIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, digi[boardID]->GetNChannel() -1 );
ChangePlot();
}
void MainWindow::GoodBye(){
@ -519,8 +521,10 @@ void MainWindow::StartRun(){
bPlotSingleTrace->SetEnabled(false);
bFitTrace->SetEnabled(false);
if( cbMode->GetSelected() == Mode_DataRun ) cbMode->SetEnabled(false);
if( cbMode->GetSelected() == Mode_DataRun ) {
cbMode->SetEnabled(false);
HandleMenu(M_TRIGGER_SUMMARY);
}
bool threadFlag = false;
for( int i = 0 ; i < nDigi; i++) {
@ -553,6 +557,8 @@ void MainWindow::StopRun(){
bFitTrace->SetEnabled(true);
cbMode->SetEnabled(true);
if( triggerSummary != NULL ) triggerSummary->CloseWindow();
if( cbMode->GetSelected() == Mode_DataRun ){
int runID = runIDEntry->GetNumber();
runIDEntry->SetNumber(runID +1);
@ -598,7 +604,6 @@ void MainWindow::LogMsg(char * msg){
teLog->AddLine(outMsg);
printf("%s\n", outMsg.Data());
//teLog->LineDown();
teLog->ShowBottom();
}
@ -770,7 +775,7 @@ void * MainWindow::RunThread(void * ptr){
uint32_t bdConfig = digi[boardID]->GetSettingFromMemory(Register::DPP::BoardConfiguration);
bool isDualTrace = ( bdConfig >> 11 ) & 0x1;
Data * data = digi[boardID]->GetData();
while(digi[boardID]->IsRunning()){
@ -789,69 +794,74 @@ void * MainWindow::RunThread(void * ptr){
// Rate graph?
data->SaveBuffer(dataFileName.Data());
data->DecodeBuffer(true, 0);
std::string msg = Form("File Size : %.2f MB", data->GetPresentFileSize() / 1024./1024. );
teLog->AddLine(msg.c_str());
teLog->LineDown();
teLog->ShowBottom();
}else{
data->DecodeBuffer(false, 0);
fEcanvas->GetCanvas()->cd();
///Fill trace
if( cbMode->GetSelected() == Mode_Oscilloscope){
unsigned short nData = data->NumEvents[ch];
traceLength = (data->Waveform1[ch][nData-1]).size();
if( traceLength > 0 ){
for( int i = 0; i < traceLength; i++) {
gAnaTrace1->SetPoint(i, i*ch2ns*(1+isDualTrace), (data->Waveform1[ch][nData-1])[i]);
if( isDualTrace) gAnaTrace2->SetPoint(i, i*ch2ns*(1+isDualTrace), (data->Waveform2[ch][nData-1])[i]);
}
if( traceLength <= gAnaTrace1->GetN() ){
for( int i = gAnaTrace1->GetN() -1 ; i >= traceLength ; i--){
gAnaTrace1->RemovePoint(i);
if( isDualTrace) gAnaTrace2->RemovePoint(i);
}
}
gAnaTrace1->GetYaxis()->SetRangeUser(0, 0x3FFF);
gAnaTrace1->Draw("APL");
gAnaTrace2->Draw("L");
}
CurrentTime = get_time();
if( CurrentTime - PreviousTime > 1000 ){
std::string msg = Form("File Size : %.2f MB", data->GetPresentFileSize() / 1024./1024. );
teLog->AddLine(msg.c_str());
teLog->ShowBottom();
PreviousTime = CurrentTime;
}
}else{
data->DecodeBuffer(false, 0);
}
}
CurrentTime = get_time();
ElapsedTime = CurrentTime - PreviousTime; /// milliseconds
if( ElapsedTime > 500 ){
///Fill Channel Count
for( int i = 0 ; i < digi[boardID]->GetNChannel(); i++){
for( int j = 0; j < data->NumEvents[i]; j++) hChannel[boardID]->Fill(i);
}
///Fill Energy histogram
for( int i = 0; i < data->NumEvents[ch]; i++){
hEnergy[boardID][ch]->Fill( data->Energy[ch][i]);
}
if( cbMode->GetSelected() == Mode_EnergyHist ) hEnergy[boardID][ch]->Draw("hist");
if( cbMode->GetSelected() == Mode_CountHist ) hChannel[boardID]->Draw("hist");
data->ClearData();
PreviousTime = CurrentTime;
if( cbMode->GetSelected() != Mode_DataRun){
fEcanvas->GetCanvas()->cd();
///Fill trace
if( cbMode->GetSelected() == Mode_Oscilloscope){
unsigned short nData = data->NumEvents[ch];
traceLength = (data->Waveform1[ch][nData-1]).size();
if( traceLength > 0 ){
for( int i = 0; i < traceLength; i++) {
gAnaTrace1->SetPoint(i, i*ch2ns*(1+isDualTrace), (data->Waveform1[ch][nData-1])[i]);
if( isDualTrace) gAnaTrace2->SetPoint(i, i*ch2ns*(1+isDualTrace), (data->Waveform2[ch][nData-1])[i]);
}
if( traceLength <= gAnaTrace1->GetN() ){
for( int i = gAnaTrace1->GetN() -1 ; i >= traceLength ; i--){
gAnaTrace1->RemovePoint(i);
if( isDualTrace) gAnaTrace2->RemovePoint(i);
}
}
gAnaTrace1->GetYaxis()->SetRangeUser(0, 0x3FFF);
gAnaTrace1->Draw("APL");
gAnaTrace2->Draw("L");
}
}
CurrentTime = get_time();
ElapsedTime = CurrentTime - PreviousTime; /// milliseconds
if( ElapsedTime > 500 ){
///Fill Channel Count
for( int i = 0 ; i < digi[boardID]->GetNChannel(); i++){
for( int j = 0; j < data->NumEvents[i]; j++) hChannel[boardID]->Fill(i);
}
///Fill Energy histogram
for( int i = 0; i < data->NumEvents[ch]; i++){
hEnergy[boardID][ch]->Fill( data->Energy[ch][i]);
}
if( cbMode->GetSelected() == Mode_EnergyHist ) hEnergy[boardID][ch]->Draw("hist");
if( cbMode->GetSelected() == Mode_CountHist ) hChannel[boardID]->Draw("hist");
data->ClearData();
PreviousTime = CurrentTime;
}
fEcanvas->GetCanvas()->Update();
gSystem->ProcessEvents();
}
fEcanvas->GetCanvas()->Update();
gSystem->ProcessEvents();
data->ClearData();
}
return ptr;

View File

@ -83,9 +83,9 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d
TGLabel * lbSettingFile = new TGLabel(hframe1, "Setting file :"); hframe1->AddFrame(lbSettingFile, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5,5,4,2));
txtSettingFile = new TGTextEntry(hframe1, ""); hframe1->AddFrame(txtSettingFile, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5,5,3,3));
txtSettingFile->SetEnabled(false);
txtSettingFile->Resize(650, 20);
txtSettingFile->Resize(550, 20);
if( digi != NULL ) txtSettingFile->SetText( digi[boardID]->GetSettingFileName().c_str());
}
{///============ fixed info
@ -1501,6 +1501,7 @@ void BoardSetting::ProgramBoardFromFile(){
void BoardSetting::SaveSettingFile(){
const char *filetypes[] = { "Setting File", "*.bin",
"Text File", "*.txt",
0, 0};
static TString dir(".");
@ -1514,14 +1515,23 @@ void BoardSetting::SaveSettingFile(){
if( fi.fFilename == NULL) return;
txtSettingFile->SetText(fi.fFilename);
TString temp = fi.fFilename;
int len = temp.Length();
temp.Remove(0, len-3);
if( digi == NULL ) {
if( temp == "bin" ){
txtSettingFile->SetText(fi.fFilename);
if( digi == NULL ) {
}else{
int boardID = boardIDEntry->GetNumber();
digi[boardID]->OpenSettingBinary( fi.fFilename );
}
}else if( temp == "txt") {
int boardID = boardIDEntry->GetNumber();
digi[boardID]->SaveSettingAsText( fi.fFilename );
}else{
int boardID = boardIDEntry->GetNumber();
//TODO saev as same file
digi[boardID]->OpenSettingBinary( fi.fFilename );
LogMsg("Invalid file extension.");
}
}

View File

@ -116,6 +116,8 @@ TriggerSummary::~TriggerSummary(){
updateFlag = false;
thread->Join();
///delete thread; /// Don;t delete the thread, otherwise, thread will not run after close and reopen.
fMain->Cleanup();