00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TGo4ExampleApplication.h"
00017
00018 #include <iostream.h>
00019
00020 #include "TRandom.h"
00021
00022 #include "Go4LockGuard/TGo4LockGuard.h"
00023 #include "Go4Log/TGo4Log.h"
00024 #include "Go4CommandsBase/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 }
00042
00043 void TGo4ExampleApplication::SendData(TNamed* data)
00044 {
00045 TRACE((12,"TGo4ExampleApplication::SendData(TNamed*)",__LINE__, __FILE__));
00046 if(fxDataQ)
00047 {
00048 cout << "Example Application: Sending data into queue..."<<endl;
00049 fxDataQ->AddBufferFromObject(data);
00050 }
00051 else
00052 {
00053 cout << "Example Application: Sorry, no data queue present"<<endl;
00054
00055 }
00056
00057 }
00058 TH1* TGo4ExampleApplication::GetHistogram()
00059 {
00060 TRACE((12,"TGo4ExampleApplication::GetHistogram",__LINE__, __FILE__));
00061 return fxDemoHistogram;
00062 }
00063 void TGo4ExampleApplication::FillHistograms()
00064 {
00065 TRACE((12,"TGo4ExampleApplication::FillHistograms",__LINE__, __FILE__));
00066 TGo4LockGuard mainlock;
00067 static Int_t counter=0;
00068 counter++;
00069 Double_t peak1= gRandom->Gaus(550,42);
00070 Double_t peak2= gRandom->Gaus(1200,230);
00071
00072 fxDemoHistogram->Fill((Axis_t) peak1);
00073 fxDemoHistogram->Fill((Axis_t) peak2);
00074 if(!(counter%100))
00075 cout << "Example Application filled histogram 100 times" <<endl;
00076
00077 }
00078 void TGo4ExampleApplication::CommandAction2()
00079 {
00080 TRACE((14,"TGo4ExampleApplication::CommandAction2",__LINE__, __FILE__));
00081 cout << "Example Application: executing Action 2"<<endl;
00082
00083 }
00084 void TGo4ExampleApplication::CommandAction1()
00085 {
00086 TRACE((14,"TGo4ExampleApplication::CommandAction1",__LINE__, __FILE__));
00087 cout << "Example Application: executing Action 1"<<endl;
00088 SendData(GetHistogram());
00089 }
00090
00091