GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4ExampleApplication.cxx
Go to the documentation of this file.
1 // $Id$
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 fuer 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 <iostream>
17 
18 #include "TRandom.h"
19 
20 #include "TGo4LockGuard.h"
21 #include "TGo4Log.h"
22 #include "TGo4CommandInvoker.h"
23 
25 : TNamed("My example application","Go4 Taskhandler example")
26  {
27  GO4TRACE((15,"TGo4ExampleApplication::TGo4ExampleApplication() constructor",__LINE__, __FILE__));
28  fxDataQ = datq;
29  fxDemoHistogram = new TH1D("Test Histogram", "Client Data", 2048, 0, 2047);
30 
31  TGo4CommandInvoker::Instance(); // make sure we have an invoker instance!
32  TGo4CommandInvoker::Register("ExampleApplication",this); // register as command receiver at the global invoker
33 }
34 
36 {
37  GO4TRACE((15,"TGo4ExampleApplication::TGo4ExampleApplication() destructor",__LINE__, __FILE__));
38  delete fxDemoHistogram;
40 }
41 
43 {
44  GO4TRACE((12,"TGo4ExampleApplication::SendData(TNamed*)",__LINE__, __FILE__));
45  if(fxDataQ)
46  {
47  std::cout << "Example Application: Sending data into queue..."<<std::endl;
49  }
50  else
51  {
52  std::cout << "Example Application: Sorry, no data queue present"<<std::endl;
53  // no data queue present
54  }
55 
56 }
58 {
59  GO4TRACE((12,"TGo4ExampleApplication::GetHistogram",__LINE__, __FILE__));
60  return fxDemoHistogram;
61 }
62 
64 {
65  GO4TRACE((12,"TGo4ExampleApplication::FillHistograms",__LINE__, __FILE__));
66  TGo4LockGuard mainlock; // protect against socket streaming
67  static Int_t counter = 0;
68  counter++;
69  Double_t peak1= gRandom->Gaus(550,42);
70  Double_t peak2= gRandom->Gaus(1200,230);
71  fxDemoHistogram->Fill((Axis_t) peak1);
72  fxDemoHistogram->Fill((Axis_t) peak2);
73  if(!(counter%100))
74  std::cout << "Example Application filled histogram 100 times" <<std::endl;
75 
76 }
78 {
79  GO4TRACE((14,"TGo4ExampleApplication::CommandAction2",__LINE__, __FILE__));
80  std::cout << "Example Application: executing Action 2"<<std::endl;
81 }
82 
84 {
85  GO4TRACE((14,"TGo4ExampleApplication::CommandAction1",__LINE__, __FILE__));
86  std::cout << "Example Application: executing Action 1"<<std::endl;
87  SendData(GetHistogram()); // later we get histogram by specified name
88 }
static void UnRegister(TGo4CommandReceiver *p)
static void Register(const char *name, TGo4CommandReceiver *p)
TGo4ExampleApplication(TGo4BufferQueue *datq=nullptr)
static TGo4CommandInvoker * Instance()
#define GO4TRACE(X)
Definition: TGo4Log.h:25
void AddBufferFromObject(TObject *object)