GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4ExampleApplication.cxx
Go to the documentation of this file.
1 // $Id: TGo4ExampleApplication.cxx 999 2013-07-25 11:58:59Z linev $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4ExampleApplication.h"
15 
16 #include "Riostream.h"
17 #include "TRandom.h"
18 
19 #include "TGo4LockGuard.h"
20 #include "TGo4Log.h"
21 #include "TGo4CommandInvoker.h"
22 
24 : TNamed("My example application","Go4 Taskhandler example")
25  {
26  GO4TRACE((15,"TGo4ExampleApplication::TGo4ExampleApplication() constructor",__LINE__, __FILE__));
27  fxDataQ=datq;
28  fxDemoHistogram = new TH1D("Test Histogram", "Client Data", 2048, 0, 2047);
29 
30  TGo4CommandInvoker::Instance(); // make sure we have an invoker instance!
31  TGo4CommandInvoker::Register("ExampleApplication",this); // register as command receiver at the global invoker
32 }
33 
35 {
36  GO4TRACE((15,"TGo4ExampleApplication::TGo4ExampleApplication() destructor",__LINE__, __FILE__));
37  delete fxDemoHistogram;
39 }
40 
42 {
43  GO4TRACE((12,"TGo4ExampleApplication::SendData(TNamed*)",__LINE__, __FILE__));
44  if(fxDataQ)
45  {
46  std::cout << "Example Application: Sending data into queue..."<<std::endl;
48  }
49  else
50  {
51  std::cout << "Example Application: Sorry, no data queue present"<<std::endl;
52  // no data queue present
53  }
54 
55 }
57 {
58  GO4TRACE((12,"TGo4ExampleApplication::GetHistogram",__LINE__, __FILE__));
59  return fxDemoHistogram;
60 }
62 {
63  GO4TRACE((12,"TGo4ExampleApplication::FillHistograms",__LINE__, __FILE__));
64  TGo4LockGuard mainlock; // protect against socket streaming
65  static Int_t counter=0;
66  counter++;
67  Double_t peak1= gRandom->Gaus(550,42);
68  Double_t peak2= gRandom->Gaus(1200,230);
69  //std::cout << "Example Application random numbers: "<< peak1<<" "<< peak2 << std::endl;
70  fxDemoHistogram->Fill((Axis_t) peak1);
71  fxDemoHistogram->Fill((Axis_t) peak2);
72  if(!(counter%100))
73  std::cout << "Example Application filled histogram 100 times" <<std::endl;
74 
75 }
77 {
78  GO4TRACE((14,"TGo4ExampleApplication::CommandAction2",__LINE__, __FILE__));
79  std::cout << "Example Application: executing Action 2"<<std::endl;
80 
81 }
83 {
84  GO4TRACE((14,"TGo4ExampleApplication::CommandAction1",__LINE__, __FILE__));
85  std::cout << "Example Application: executing Action 1"<<std::endl;
86  SendData(GetHistogram()); // later we get histogram by specified name
87 }
static void UnRegister(TGo4CommandReceiver *p)
static void Register(const char *name, TGo4CommandReceiver *p)
static TGo4CommandInvoker * Instance()
#define GO4TRACE(X)
Definition: TGo4Log.h:26
TGo4ExampleApplication(TGo4BufferQueue *datq=0)
void AddBufferFromObject(TObject *object)