Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4ExampleApplication.h"
00015
00016 #include "Riostream.h"
00017 #include "TRandom.h"
00018
00019 #include "TGo4LockGuard.h"
00020 #include "TGo4Log.h"
00021 #include "TGo4CommandInvoker.h"
00022
00023 TGo4ExampleApplication::TGo4ExampleApplication( TGo4BufferQueue* datq)
00024 : TNamed("My example application","Go4 Taskhandler example")
00025 {
00026 GO4TRACE((15,"TGo4ExampleApplication::TGo4ExampleApplication() constructor",__LINE__, __FILE__));
00027 fxDataQ=datq;
00028 fxDemoHistogram = new TH1D("Test Histogram", "Client Data", 2048, 0, 2047);
00029
00030 TGo4CommandInvoker::Instance();
00031 TGo4CommandInvoker::Register("ExampleApplication",this);
00032 }
00033
00034 TGo4ExampleApplication::~TGo4ExampleApplication()
00035 {
00036 GO4TRACE((15,"TGo4ExampleApplication::TGo4ExampleApplication() destructor",__LINE__, __FILE__));
00037 delete fxDemoHistogram;
00038 TGo4CommandInvoker::UnRegister(this);
00039 }
00040
00041 void TGo4ExampleApplication::SendData(TNamed* data)
00042 {
00043 GO4TRACE((12,"TGo4ExampleApplication::SendData(TNamed*)",__LINE__, __FILE__));
00044 if(fxDataQ)
00045 {
00046 std::cout << "Example Application: Sending data into queue..."<<std::endl;
00047 fxDataQ->AddBufferFromObject(data);
00048 }
00049 else
00050 {
00051 std::cout << "Example Application: Sorry, no data queue present"<<std::endl;
00052
00053 }
00054
00055 }
00056 TH1* TGo4ExampleApplication::GetHistogram()
00057 {
00058 GO4TRACE((12,"TGo4ExampleApplication::GetHistogram",__LINE__, __FILE__));
00059 return fxDemoHistogram;
00060 }
00061 void TGo4ExampleApplication::FillHistograms()
00062 {
00063 GO4TRACE((12,"TGo4ExampleApplication::FillHistograms",__LINE__, __FILE__));
00064 TGo4LockGuard mainlock;
00065 static Int_t counter=0;
00066 counter++;
00067 Double_t peak1= gRandom->Gaus(550,42);
00068 Double_t peak2= gRandom->Gaus(1200,230);
00069
00070 fxDemoHistogram->Fill((Axis_t) peak1);
00071 fxDemoHistogram->Fill((Axis_t) peak2);
00072 if(!(counter%100))
00073 std::cout << "Example Application filled histogram 100 times" <<std::endl;
00074
00075 }
00076 void TGo4ExampleApplication::CommandAction2()
00077 {
00078 GO4TRACE((14,"TGo4ExampleApplication::CommandAction2",__LINE__, __FILE__));
00079 std::cout << "Example Application: executing Action 2"<<std::endl;
00080
00081 }
00082 void TGo4ExampleApplication::CommandAction1()
00083 {
00084 GO4TRACE((14,"TGo4ExampleApplication::CommandAction1",__LINE__, __FILE__));
00085 std::cout << "Example Application: executing Action 1"<<std::endl;
00086 SendData(GetHistogram());
00087 }