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