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