00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef TGO4TASKHANDLER_H
00017 #define TGO4TASKHANDLER_H
00018
00019 #include "TNamed.h"
00020 #include "Rtypes.h"
00021 #include <TBuffer.h>
00022 #include <Rtypes.h>
00023 #include "Go4CommandsBase/TGo4Command.h"
00024
00025 class TGo4ThreadManager;
00026 class TGo4ThreadHandler;
00027 class TGo4Socket;
00028 class TGo4Queue;
00029 class TGo4CommandInvoker;
00030 class TGo4TaskHandlerStatus;
00031 class TGo4DataRunnable;
00032 class TGo4StatusRunnable;
00033 class TGo4CommandRunnable;
00034
00035
00036
00037
00038
00050 class TGo4TaskHandler : public TNamed {
00051
00052 public:
00053
00054 friend class TGo4TaskManager;
00055
00056 TGo4TaskHandler(const char* name, TGo4ThreadManager* threadmanager, Bool_t clientmode=kFALSE, Bool_t mastermode=kTRUE,UInt_t negotiationport=0);
00057
00058 virtual ~TGo4TaskHandler();
00059
00065 Bool_t ConnectServerChannel(const char* name, TGo4Socket* negotiator, TGo4Socket* channel, const char* host);
00066
00072 Bool_t ConnectClientChannel(const char* name, TGo4Socket * negotiator, TGo4Socket * channel, const char* host);
00073
00077 TGo4Socket* ServerRequest(const char* host="localhost");
00078
00080 Bool_t ServerLogin(TGo4Socket* connector, Go4CommandMode_t account);
00081
00085 Bool_t Connect(const char* host="localhost", TGo4Socket* negotiator=0);
00086
00087
00094 Bool_t DisConnect(Bool_t waitforclient=kTRUE);
00095
00096 TGo4ThreadManager* GetThreadManager() const { return fxThreadManager; }
00097
00105 Int_t WaitGetPort(TGo4Socket* sock);
00106
00110 void SetNegotiationPort(UInt_t port){ fuNegPort=port;}
00111
00112 TGo4Socket* GetCommandTransport() const { return fxCommandTransport; }
00113
00114 TGo4Socket* GetStatusTransport() const { return fxStatusTransport; }
00115
00116 TGo4Socket* GetDataTransport() const { return fxDataTransport; }
00117
00118 TGo4Queue* GetCommandQueue() const { return fxCommandQueue; }
00119
00120 TGo4Queue* GetStatusQueue() const { return fxStatusQueue; }
00121
00122 TGo4Queue * GetDataQueue() const { return fxDataQueue; }
00123
00124 const char* GetHostName() const { return fxHostName.Data(); }
00125
00126 const char* GetComName() const { return fxComName.Data(); }
00127
00128 const char* GetDatName() const { return fxDatName.Data(); }
00129
00130 const char* GetStatName() const { return fxStatName.Data(); }
00131
00132 Int_t GetComPort() const { return fiComPort; }
00133
00134 Int_t GetDatPort() const { return fiDatPort; }
00135
00136 Int_t GetStatPort() const { return fiStatPort; }
00137
00138 Go4CommandMode_t GetRole(){return fiRole;}
00139 void SetRole(Go4CommandMode_t role){fiRole=role;}
00140
00145 TGo4CommandInvoker* GetInvoker() const { return fxInvoker; }
00146
00148 Bool_t IsClientMode() const { return fbClientMode; }
00149
00151 Bool_t IsMasterMode() const { return fbMasterMode; }
00152
00157 void SetAborting(Bool_t isaborting=kTRUE) { fbIsAborting=isaborting; }
00158
00160 Bool_t IsAborting() const { return fbIsAborting; }
00161
00166 void SetInvoker(TGo4CommandInvoker* inv) { fxInvoker=inv; }
00167
00174 virtual TGo4TaskHandlerStatus * CreateStatus();
00175
00182 Bool_t StopTransportThreads(Bool_t wait=kTRUE);
00183
00188 void StartTransportThreads();
00189
00195 Bool_t WaitThreadStop(const char* name);
00196
00197
00199 void CloseChannels();
00201 void ClearQueues();
00202
00203
00209 static void SetAdminAccount(const char* name, const char* passwd);
00210
00211
00217 static void SetCtrlAccount(const char* name, const char* passwd);
00218
00219
00220
00226 static void SetObservAccount(const char* name, const char* passwd);
00227
00228
00229
00230
00232 static const UInt_t fguCONNECTORPORT;
00233
00235 static const Int_t fgiPORTWAITCYCLES;
00236
00238 static const UInt_t fguPORTWAITTIME;
00239
00243 static const Int_t fgiTHREADSTOPCYCLES;
00244
00248 static const UInt_t fguTHREADSTOPTIME;
00249
00250
00252 static const UInt_t fguTRANSPORTCHECKDELAY;
00253
00255 static const UInt_t fguSTATUSQUEUESIZE;
00256
00258 static const UInt_t fguDATAQUEUESIZE;
00259
00261 static const UInt_t fguCOMMANDQUEUESIZE;
00262
00264 static const Text_t fgcCONNECT[];
00265
00267 static const Text_t fgcDISCONNECT[];
00268
00270 static const Text_t fgcOK[];
00271
00273 static const Text_t fgcERROR[];
00274
00276 static const Text_t fgcMASTER[];
00277
00279 static const Text_t fgcSLAVE[];
00280
00281
00283 static const Text_t fgcCOMMANDTHREAD[];
00284
00286 static const Text_t fgcSTATUSTHREAD[];
00287
00289 static const Text_t fgcDATATHREAD[];
00290
00291
00292
00293
00294
00295 private:
00296 TGo4TaskHandler();
00297
00298
00303 static TNamed fgxADMINISTRATORACCOUNT;
00304
00305
00310 static TNamed fgxOBSERVERACCOUNT;
00311
00316 static TNamed fgxCONTROLLERACCOUNT;
00317
00318
00320 Bool_t fbClientMode;
00321
00323 Bool_t fbMasterMode;
00324
00326 Bool_t fbIsAborting;
00327
00329 TGo4ThreadManager* fxThreadManager;
00330
00337 TGo4ThreadHandler* fxThreadHandler;
00338
00340 TGo4CommandInvoker* fxInvoker;
00341
00343 TGo4Queue* fxCommandQueue;
00344 TGo4Queue* fxStatusQueue;
00345 TGo4Queue* fxDataQueue;
00346
00348 TGo4Socket* fxCommandTransport;
00349 TGo4Socket* fxStatusTransport;
00350 TGo4Socket* fxDataTransport;
00351
00353 TString fxComName;
00354
00356 TString fxStatName;
00357
00359 TString fxDatName;
00360
00362 TString fxHostName;
00363
00365 UInt_t fuNegPort;
00366
00368 Int_t fiComPort;
00369
00371 Int_t fiStatPort;
00372
00374 Int_t fiDatPort;
00375
00376
00381 Go4CommandMode_t fiRole;
00382
00386 TGo4StatusRunnable* fxStatusRun;
00387
00391 TGo4DataRunnable* fxDataRun;
00392
00396 TGo4CommandRunnable* fxCommandRun;
00397 ;
00398
00399 };
00400 #endif //TGO4TASKHANDLER_H
00401
00402