Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4ExampleServer.h"
00015
00016 #include "TGo4Log.h"
00017 #include "TGo4Status.h"
00018 #include "TGo4BufferQueue.h"
00019 #include "TGo4ThreadHandler.h"
00020
00021 #include "TGo4LoggingRunnable.h"
00022 #include "TGo4ControllerRunnable.h"
00023 #include "TGo4ExampleCommandList.h"
00024
00025 const char* TGo4ExampleServer::fgcLOGGINGTHREAD="LOGGER-";
00026 const char* TGo4ExampleServer::fgcCONTROLTHREAD="CONTROL-";
00027
00028 TGo4ExampleController* TGo4ExampleServer::GetController()
00029 {
00030 GO4TRACE((12,"TGo4ExampleServer::GetController()",__LINE__, __FILE__));
00031
00032 return fxController;
00033 }
00034 TGo4ExampleServer::~TGo4ExampleServer()
00035 {
00036 GO4TRACE((15,"TGo4ExampleServer::~TGo4ExampleServer() destructor",__LINE__, __FILE__));
00037
00038 fxWorkHandler->CancelAll();
00039 delete fxController;
00040
00041 }
00042 TGo4ExampleServer::TGo4ExampleServer(const char* name,
00043 UInt_t negotiationport,
00044 Bool_t blockingmode)
00045 : TGo4ServerTask(name, negotiationport, blockingmode,kFALSE)
00046 {
00047 GO4TRACE((15,"TGo4ExampleServer::TGo4ExampleServer(const char*, Bool_t) constructor",__LINE__, __FILE__));
00048
00049 TGo4Log::Debug(" ExampleServer ''%s'' started ",GetName());
00050
00051 fxController = new TGo4ExampleController();
00052
00053 TGo4ControllerRunnable* controlrun= new TGo4ControllerRunnable(Form("ControllerRunnable of %s",GetName()), this);
00054
00055 TGo4LoggingRunnable* logrun = new TGo4LoggingRunnable(Form("LoggerRunnable of %s",GetName()), this);
00056
00057
00058
00059 fcControlName.Form("%s%s",fgcCONTROLTHREAD,GetName());
00060 fxWorkHandler->NewThread(fcControlName.Data(), controlrun);
00061
00062 fcLoggingName.Form("%s%s",fgcLOGGINGTHREAD,GetName());
00063 fxWorkHandler->NewThread(fcLoggingName.Data(),logrun);
00064
00065 Launch();
00066 }
00067
00068 TGo4TaskHandlerCommandList* TGo4ExampleServer::CreateCommandList()
00069 {
00070 return (new TGo4ExampleCommandList);
00071 }
00072
00073 Int_t TGo4ExampleServer::StopWorkThreads()
00074 {
00075
00076 TGo4Log::Debug(" Example Server is stopping work threads ");
00077 Int_t rev=0;
00078 TGo4ThreadHandler* threadhandler= GetWorkHandler();
00079 TGo4BufferQueue* dataq=GetDataQueue();
00080 TGo4BufferQueue* statusq=GetStatusQueue();
00081
00082 threadhandler->Stop(fcControlName.Data());
00083 if(dataq)
00084 {
00085 dataq->AddBufferFromObject(new TNamed("StopObject","dummy"));
00086
00087 }
00088 else
00089 {
00090
00091 }
00092 threadhandler->Stop(fcLoggingName.Data());
00093 if(statusq)
00094 {
00095 statusq->AddBufferFromObject(new TGo4Status("StopStatus"));
00096
00097 }
00098 else
00099 {
00100
00101 }
00102 rev=TGo4ServerTask::StopWorkThreads();
00103 return rev;
00104 }
00105
00106
00107 Int_t TGo4ExampleServer::StartWorkThreads()
00108 {
00109
00110 TGo4Log::Debug(" Example Server is starting work threads ");
00111 Int_t rev=0;
00112
00113 TGo4ThreadHandler* threadhandler= GetWorkHandler();
00114 threadhandler->Start(fcControlName.Data());
00115 threadhandler->Start(fcLoggingName.Data());
00116 rev=TGo4ServerTask::StartWorkThreads();
00117 return rev;
00118
00119 }