00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4ExampleClient.h"
00015
00016 #include "Riostream.h"
00017
00018 #include "TGo4Log.h"
00019 #include "TGo4TaskHandler.h"
00020 #include "TGo4ThreadHandler.h"
00021
00022 #include "TGo4ExampleClientStatus.h"
00023 #include "TGo4ExampleApplication.h"
00024 #include "TGo4MainRunnable.h"
00025 #include "TGo4WatchRunnable.h"
00026
00027 const char* TGo4ExampleClient::fgcWATCHTHREAD="WATCH-";
00028 const char* TGo4ExampleClient::fgcMAINTHREAD="MAIN-";
00029
00030
00031 TGo4ExampleClient::TGo4ExampleClient(const char* name,
00032 const char* host,
00033 UInt_t negport,
00034 Bool_t blockingmode)
00035 : TGo4ClientTask(name, host, negport , blockingmode, kFALSE)
00036 {
00037 TRACE((15,"TGo4ExampleClient::TGo4ExampleClient(const char*, const char*, Uint_t, Bool_t) constructor",__LINE__, __FILE__));
00038 SetMaster(kFALSE);
00039 TGo4Log::Debug(" ExampleClient ''%s'' started ",GetName());
00040 fxApplication= new TGo4ExampleApplication( (TGo4BufferQueue*) GetTaskHandler()->GetDataQueue());
00041 TGo4MainRunnable* mainrun = new TGo4MainRunnable(Form("MainRunnable of %s",GetName()), this);
00042 TGo4WatchRunnable* watchrun = new TGo4WatchRunnable(Form("WatchRunnable of %s",GetName()), this);
00043
00044 fcMainName.Form("%s%s", fgcMAINTHREAD, GetName());
00045 fxWorkHandler->NewThread(fcMainName.Data(), mainrun);
00046 fcWatchName.Form("%s%s", fgcWATCHTHREAD, GetName());
00047 fxWorkHandler->NewThread(fcWatchName.Data(), watchrun);
00048 Launch();
00049 }
00050
00051 TGo4ExampleClient::~TGo4ExampleClient()
00052 {
00053 TRACE((15,"TGo4ExampleClient::~TGo4ExampleClient() destructor",__LINE__, __FILE__));
00054 fxWorkHandler->CancelAll();
00055 delete fxApplication;
00056 }
00057
00058 TGo4TaskStatus * TGo4ExampleClient::CreateStatus()
00059 {
00060 TRACE((12,"TGo4ExampleClient::CreateStatus()",__LINE__, __FILE__));
00061 TGo4ExampleClientStatus* stat= new TGo4ExampleClientStatus(GetName());
00062 UpdateStatus(stat);
00063 return stat;
00064
00065 }
00066 void TGo4ExampleClient::UpdateStatus(TGo4ClientStatus* state)
00067 {
00068 TRACE((12,"TGo4ExampleClient::UpdateStatus(TGo4ClientStatus*)",__LINE__, __FILE__));
00069 TGo4ClientTask::UpdateStatus(state);
00070 TGo4ExampleClientStatus* exstate= (TGo4ExampleClientStatus*) state;
00071 exstate->SetHistoStatus(GetApplication()->GetHistogram());
00072 exstate->SetNames(fcMainName.Data(), fcWatchName.Data());
00073
00074 }
00075
00076 void TGo4ExampleClient::Stop()
00077 {
00078 TRACE((12,"TGo4ExampleClient::Stop()",__LINE__, __FILE__));
00079 cout << "Stop of example client!"<<endl;
00080
00081 TGo4Log::Debug(" ExampleClient ''%s'' executing Stop(): stop main thread",GetName());
00082 fxWorkHandler->Stop(fcMainName.Data());
00083 }
00084 void TGo4ExampleClient::Start()
00085 {
00086 TRACE((12,"TGo4ExampleClient::Start()",__LINE__, __FILE__));
00087 cout << "Start of example client!"<<endl;
00088
00089 TGo4Log::Debug(" ExampleClient ''%s'' executing Start(): start main thread",GetName());
00090 fxWorkHandler->Start(fcMainName.Data());
00091 }
00092 TGo4ExampleApplication* TGo4ExampleClient::GetApplication()
00093 {
00094 TRACE((12,"TGo4ExampleClient::GetApplication()",__LINE__, __FILE__));
00095 return fxApplication;
00096 }