AlcapDAQ  1
Functions | Variables
mainWindow.cpp File Reference
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <vector>
#include <time.h>
#include <stdlib.h>
#include <libgen.h>
#include "TApplication.h"
#include "TGButton.h"
#include "TRootEmbeddedCanvas.h"
#include "TGStatusBar.h"
#include "TCanvas.h"
#include "TROOT.h"
#include "TGTextEntry.h"
#include "TGLabel.h"
#include "TG3DLine.h"
#include "TGFileDialog.h"
#include "TSocket.h"
#include "TMessage.h"
#include "TH1D.h"
#include "TH1.h"
#include "TObjArray.h"
#include "TObjString.h"
#include "getHist.h"
#include "TOnlineFrame.h"

Go to the source code of this file.

Functions

void HelpMessage ()
 
int main (int argc, char **argv)
 

Variables

std::vector< screen_infoscreens
 
int width = 800
 
int height = 600
 

Function Documentation

void HelpMessage ( )

Definition at line 156 of file mainWindow.cpp.

References printf().

Referenced by main().

157 {
158  printf("Default connection is to localhost:9090.\n");
159  printf("To specify another host, use: \n");
160  printf("\t ./online-display -H hostname -p port\n");
161  printf("Or, to open a ROOT file:\n");
162  printf("\t ./online-display -i filename\n");
163 }
int main ( int  argc,
char **  argv 
)

Definition at line 51 of file mainWindow.cpp.

References c, TOnlineFrame::ConnectToServer(), TOnlineFrame::ConsiderAutoupdate(), TOnlineFrame::ConsiderCycling(), TOnlineFrame::getAutoUpdateTime(), TOnlineFrame::GetHist(), TOnlineFrame::GetHistTitles(), gROOT, HelpMessage(), i, TOnlineFrame::OpenRootFile(), printf(), TOnlineFrame::setServerName(), TOnlineFrame::setServerPort(), sprintf(), time, and TOnlineFrame::UpdateDisplay().

52 {
53  int c;
54  std::string server_name = "localhost";
55  int server_port = 9090;
56  std::string root_file_name = "";
57  std::string module_file_name = "";
58 
59  while ((c = getopt(argc, argv, "hH:p:i:M:")) != -1)
60  {
61  switch (c)
62  {
63  case 'h':
64  HelpMessage();
65  return 0;
66  case 'H':
67  server_name = optarg;
68  break;
69  case 'p':
70  server_port = atoi(optarg);
71  break;
72  case 'i':
73  root_file_name = optarg;
74  break;
75  case 'M':
76  module_file_name = optarg;
77  break;
78  default:
79  break;
80  }
81  }
82 
83  int fake_argc = 1;
84  char fake_arg_str[256];
85  sprintf(fake_arg_str,"./online-display");
86  char *fake_argv[] = {fake_arg_str};
87 
88  TApplication theApp("RMidas", &fake_argc, fake_argv);
89 
90  if (gROOT->IsBatch()) {
91  printf("%s: cannot run in batch mode\n", argv[0]);
92  return 1;
93  }
94 
95  std::cout<<module_file_name<<std::endl;
96  TOnlineFrame *onlineFrame = new TOnlineFrame(gClient->GetRoot(),module_file_name);
97 
98  if (root_file_name.length() != 0)
99  onlineFrame->OpenRootFile(root_file_name.c_str());
100  else
101  {
102  onlineFrame->setServerName(server_name.c_str());
103  onlineFrame->setServerPort(server_port);
104  onlineFrame->ConnectToServer();
105  onlineFrame->Print();
106 
107 #if 0
108  // Get list of all histograms, then copy them to the current directory
109  std::vector<TString> vHistTitles = onlineFrame->GetHistTitles();
110  for (unsigned int i = 0; i < vHistTitles.size(); ++i)
111  {
112  //printf("%d: %s\n", i, vHistTitles.at(i).Data());
113  TH1 *hist = onlineFrame->GetHist(vHistTitles.at(i).Data());
114  if(hist)
115  {
116  //hist->Draw();
117  hist->Clone(vHistTitles.at(i).Data());
118  }
119  }
120 #endif
121  }
122 
123  //onlineFrame->runMacro("modules/common/root_init.C");
124 
125  /*
126  TThread *ct = new TThread(cycleThread, onlineFrame);
127  ct->Run();
128  */
129 
130  //theApp.SetIdleTimer(1,".q");
131 
132  onlineFrame->UpdateDisplay();
133  theApp.Run(1);
134 #if 0
135  time_t lastCycleTime = 0;//time(NULL);
136  while(true)
137  {
138  theApp.Run(1);
139  if(time(NULL) > lastCycleTime + onlineFrame->getAutoUpdateTime())
140  {
141  //printf("Considering cycling\n");
142  onlineFrame->ConsiderCycling();
143  onlineFrame->ConsiderAutoupdate();
144  lastCycleTime = time(NULL);
145  }
146  else
147  {
148  usleep(10000);
149  }
150  }
151 #endif
152 
153  return 0;
154 }

Variable Documentation

int height = 600

Definition at line 33 of file mainWindow.cpp.

Referenced by PrePulse::FindPrePulses(), and TOnlineFrame::TOnlineFrame().

std::vector<screen_info> screens
int width = 800

Definition at line 32 of file mainWindow.cpp.

Referenced by TOnlineFrame::TOnlineFrame().