Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4TaskHandlerExample/TGo4ExampleApplication.cxx

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
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(); // make sure we have an invoker instance!
00034    TGo4CommandInvoker::Register("ExampleApplication",this); // register as command receiver at the global invoker
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          // no data queue present
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; // protect against socket streaming
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    //cout << "Example Application random numbers: "<< peak1<<" "<< peak2 <<endl;
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()); // later we get histogram by specified name
00089 }
00090 
00091 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:56:07 2005 for Go4-v2.10-5 by doxygen1.2.15