Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

TGo4ExampleApplication.cxx

Go to the documentation of this file.
00001 //-------------------------------------------------------------
00002 //        Go4 Release Package v3.04-01 (build 30401)
00003 //                      28-November-2008
00004 //---------------------------------------------------------------
00005 //   The GSI Online Offline Object Oriented (Go4) Project
00006 //   Experiment Data Processing at EE 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 "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(); // 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    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          // no data queue present
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; // protect against socket streaming
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    //cout << "Example Application random numbers: "<< peak1<<" "<< peak2 <<endl;
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()); // later we get histogram by specified name
00090 }
00091 
00092 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Fri Nov 28 12:59:30 2008 for Go4-v3.04-1 by  doxygen 1.4.2