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

TGo4ExampleClient.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 "TGo4ExampleClient.h"
00017 
00018 #include "Riostream.h"
00019 
00020 #include "TGo4Log.h"
00021 #include "TGo4TaskHandler.h"
00022 #include "TGo4ThreadHandler.h"
00023 #include "snprintf.h"
00024 
00025 #include "TGo4ExampleClientStatus.h"
00026 #include "TGo4ExampleApplication.h"
00027 #include "TGo4MainRunnable.h"
00028 #include "TGo4WatchRunnable.h"
00029 
00030 const Text_t TGo4ExampleClient::fgcWATCHTHREAD[]="WATCH-";
00031 const Text_t TGo4ExampleClient::fgcMAINTHREAD[]="MAIN-";
00032 
00033 
00034 TGo4ExampleClient::TGo4ExampleClient(const char* name,
00035                                      const char* host,
00036                                      UInt_t negport,
00037                                      Bool_t blockingmode)
00038 : TGo4ClientTask(name, host, negport , blockingmode, kFALSE)
00039 {
00040    TRACE((15,"TGo4ExampleClient::TGo4ExampleClient(Text_t*, Bool_t) constructor",__LINE__, __FILE__));
00041    SetMaster(kFALSE);
00042    TGo4Log::Debug(" ExampleClient ''%s'' started ",GetName());
00043    fcMainName= new Text_t[TGo4ThreadManager::fguTEXTLENGTH];
00044    fcWatchName= new Text_t[TGo4ThreadManager::fguTEXTLENGTH];
00045    Text_t namebuffer[TGo4ThreadManager::fguTEXTLENGTH];
00046    fxApplication= new TGo4ExampleApplication( (TGo4BufferQueue*) GetTaskHandler()->GetDataQueue());
00047    snprintf(namebuffer,TGo4ThreadManager::fguTEXTLENGTH-1,"MainRunnable of %s",GetName());
00048    TGo4MainRunnable* mainrun= new TGo4MainRunnable(namebuffer, this);
00049    snprintf(namebuffer,TGo4ThreadManager::fguTEXTLENGTH-1,"WatchRunnable of %s",GetName());
00050    TGo4WatchRunnable* watchrun= new TGo4WatchRunnable(namebuffer, this);
00051       // adding runnables to thread handler who takes over the responsibility...:
00052    snprintf(fcMainName,TGo4ThreadManager::fguTEXTLENGTH-1,"%s%s",fgcMAINTHREAD,GetName());
00053    fxWorkHandler->NewThread(fcMainName,mainrun);
00054    snprintf(fcWatchName,TGo4ThreadManager::fguTEXTLENGTH-1,"%s%s",fgcWATCHTHREAD,GetName());
00055    fxWorkHandler->NewThread(fcWatchName,watchrun);
00056    Launch();
00057 }
00058 
00059 TGo4ExampleClient::~TGo4ExampleClient()
00060 {
00061    TRACE((15,"TGo4ExampleClient::~TGo4ExampleClient() destructor",__LINE__, __FILE__));
00062    delete [] fcMainName;
00063    delete [] fcWatchName;
00064    fxWorkHandler->CancelAll(); // make sure threads wont work on application when its deleted
00065    delete fxApplication;
00066 }
00067 
00068 TGo4TaskStatus * TGo4ExampleClient::CreateStatus()
00069 {
00070    TRACE((12,"TGo4ExampleClient::CreateStatus()",__LINE__, __FILE__));
00071    TGo4ExampleClientStatus* stat= new TGo4ExampleClientStatus(GetName());
00072    UpdateStatus(stat); // set the internals
00073    return stat;
00074 
00075 }
00076 void TGo4ExampleClient::UpdateStatus(TGo4ClientStatus* state)
00077 {
00078    TRACE((12,"TGo4ExampleClient::UpdateStatus(TGo4ClientStatus*)",__LINE__, __FILE__));
00079    TGo4ClientTask::UpdateStatus(state); // fill superclass attributes
00080    TGo4ExampleClientStatus* exstate= (TGo4ExampleClientStatus*) state;
00081    exstate->SetHistoStatus(GetApplication()->GetHistogram());
00082    exstate->SetNames(fcMainName, fcWatchName);
00083 
00084 }
00085 
00086 void TGo4ExampleClient::Stop()
00087 {
00088    TRACE((12,"TGo4ExampleClient::Stop()",__LINE__, __FILE__));
00089     cout << "Stop of example client!"<<endl;
00090 
00091    TGo4Log::Debug(" ExampleClient ''%s'' executing Stop(): stop main thread",GetName());
00092    fxWorkHandler->Stop(fcMainName);
00093 }
00094 void TGo4ExampleClient::Start()
00095 {
00096    TRACE((12,"TGo4ExampleClient::Start()",__LINE__, __FILE__));
00097     cout << "Start of example client!"<<endl;
00098 
00099    TGo4Log::Debug(" ExampleClient ''%s'' executing Start(): start main thread",GetName());
00100    fxWorkHandler->Start(fcMainName);
00101 }
00102 TGo4ExampleApplication* TGo4ExampleClient::GetApplication()
00103 {
00104   TRACE((12,"TGo4ExampleClient::GetApplication()",__LINE__, __FILE__));
00105    return fxApplication;
00106 }
00107 
00108 //----------------------------END OF GO4 SOURCE FILE ---------------------

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