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