Hi there,
I have a standalone application (compiled in Visual C++ 2008) that acquires data from an FPGA board and displays real time histograms while the program is running. The histograms are displayed on pads in a single canvas. When running ROOT 5.16 I can click on different windows and when I click back to the TCanvas window, the histograms continue to update. When running ROOT 5.22, after clicking on a different window the canvas goes blank and never redraws, even after clicking back on the canvas.
Here is an example of how the program works:
int main( ) {
Controller *controller = new Controller();
if( controller->Connect() ) {
controller->Run();
}
delete controller;
}
class Controller {
private:
TFile *r_file;
TTree *r_tree;
TRint *r_App;
TCanvas *r_c1;
TPad *r_pad1, *r_pad2;
TH1F *r_h1, *r_h2;
public:
Controller();
~Controller();
int InitializeRoot();
int Connect();
void Run();
void ParseData();
void ParseStats();
}
Controller::Controller() {
r_file = NULL;
}
Controller::~Controller() {
r_App->Run();
r_tree->Write();
if( r_file != NULL ) {
r_file->Write();
r_file->Close();
}
}
int Controller::Connect() {
if( !InitializeRoot() ) {
return 0;
}
// connect to the FPGA...
return 1;
}
int Controller::InitializeRoot() {
r_file = new TFile("out.root", "RECREATE");
r_tree = new TTree("OutTree", "Events");
r_tree->Branch("timestamp", ×tamp, "timestamp/i");
// create other branches...
r_tree->AutoSave();
r_App = new TRint("ROOTapp", NULL, NULL, NULL, NULL, true);
r_c1 = new TCanvas("c1", "canvas", 610, 0, 800, 800);
r_pad1 = new TPad("pad1", "pad1", 0.005, 0.505, 0.995, 0.995);
r_pad2 = new TPad("pad2", "pad2", 0.005, 0.005, 0.995, 0.495);
r_pad1->Draw();
r_pad2->Draw();
r_pad1->cd();
r_h1 = new TH1F("h1", "h1", 100, 1, 100);
r_h1->Draw();
r_pad2->cd();
r_h2 = new TH1F("h2", "h2", 100, 1, 100);
r_h2->Draw();
r_c1->cd();
return 1;
}
void Controller::Run() {
while( [current_time < stop_time] ) { // loop until the time is up (psuedo code)
if( [received data from FPGA] ) {
ParseData();
}
if( [received stats from FPGA] ) {
ParseStats(); // occasionally (every couple seconds) we will receive some stats from the FPGA
}
}
}
void Controller::ParseData() {
this->timestamp = new_timestamp; // put new data into the branch
... // handle other data
r_tree->Fill();
r_h1->Fill(new_timestamp);
r_pad1->Modified();
... // same for other histograms
}
void Controller::ParseStats() {
// because stats come back only occasionally, we will use this time to update the canvas
... // parse the stats
r_c1->Update();
}
I tried to strip out everything unnecessary, but its still quite long… sorry about that.
Thanks in advance for any suggestions regarding this strange problem!
Cheers,
Ford