Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef TGO4TASKHANDLER_H
00015 #define TGO4TASKHANDLER_H
00016
00017 #include "TNamed.h"
00018 #include "TGo4Command.h"
00019
00020 class TGo4ThreadManager;
00021 class TGo4ThreadHandler;
00022 class TGo4Socket;
00023 class TGo4Queue;
00024 class TGo4CommandInvoker;
00025 class TGo4TaskHandlerStatus;
00026 class TGo4DataRunnable;
00027 class TGo4StatusRunnable;
00028 class TGo4CommandRunnable;
00029
00030
00042 class TGo4TaskHandler : public TNamed {
00043
00044 public:
00045
00046 friend class TGo4TaskManager;
00047
00048 TGo4TaskHandler(const char* name, TGo4ThreadManager* threadmanager, Bool_t clientmode=kFALSE, Bool_t mastermode=kTRUE,UInt_t negotiationport=0);
00049
00050 virtual ~TGo4TaskHandler();
00051
00057 Bool_t ConnectServerChannel(const char* name, TGo4Socket* negotiator, TGo4Socket* channel, const char* host);
00058
00064 Bool_t ConnectClientChannel(const char* name, TGo4Socket * negotiator, TGo4Socket * channel, const char* host);
00065
00069 TGo4Socket* ServerRequest(const char* host="localhost");
00070
00072 Bool_t ServerLogin(TGo4Socket* connector, Go4CommandMode_t account);
00073
00077 Bool_t Connect(const char* host="localhost", TGo4Socket* negotiator=0);
00078
00079
00086 Bool_t DisConnect(Bool_t waitforclient=kTRUE);
00087
00088 TGo4ThreadManager* GetThreadManager() const { return fxThreadManager; }
00089
00097 Int_t WaitGetPort(TGo4Socket* sock);
00098
00102 void SetNegotiationPort(UInt_t port){ fuNegPort=port;}
00103
00104 TGo4Socket* GetCommandTransport() const { return fxCommandTransport; }
00105
00106 TGo4Socket* GetStatusTransport() const { return fxStatusTransport; }
00107
00108 TGo4Socket* GetDataTransport() const { return fxDataTransport; }
00109
00110 TGo4Queue* GetCommandQueue() const { return fxCommandQueue; }
00111
00112 TGo4Queue* GetStatusQueue() const { return fxStatusQueue; }
00113
00114 TGo4Queue * GetDataQueue() const { return fxDataQueue; }
00115
00116 const char* GetHostName() const { return fxHostName.Data(); }
00117
00118 const char* GetComName() const { return fxComName.Data(); }
00119
00120 const char* GetDatName() const { return fxDatName.Data(); }
00121
00122 const char* GetStatName() const { return fxStatName.Data(); }
00123
00124 Int_t GetComPort() const { return fiComPort; }
00125
00126 Int_t GetDatPort() const { return fiDatPort; }
00127
00128 Int_t GetStatPort() const { return fiStatPort; }
00129
00130 Go4CommandMode_t GetRole(){return fiRole;}
00131 void SetRole(Go4CommandMode_t role){fiRole=role;}
00132
00137 TGo4CommandInvoker* GetInvoker() const { return fxInvoker; }
00138
00140 Bool_t IsClientMode() const { return fbClientMode; }
00141
00143 Bool_t IsMasterMode() const { return fbMasterMode; }
00144
00149 void SetAborting(Bool_t isaborting=kTRUE) { fbIsAborting=isaborting; }
00150
00152 Bool_t IsAborting() const { return fbIsAborting; }
00153
00158 void SetInvoker(TGo4CommandInvoker* inv) { fxInvoker=inv; }
00159
00166 virtual TGo4TaskHandlerStatus * CreateStatus();
00167
00174 Bool_t StopTransportThreads(Bool_t wait=kTRUE);
00175
00180 void StartTransportThreads();
00181
00185 Bool_t WaitThreadStop(const char* name);
00186
00190 void CloseChannels(Option_t *opt="");
00191
00193 void ClearQueues();
00194
00195
00201 static void SetAdminAccount(const char* name, const char* passwd);
00202
00208 static void SetCtrlAccount(const char* name, const char* passwd);
00209
00215 static void SetObservAccount(const char* name, const char* passwd);
00216
00217 static const char* Get_fgcOK();
00218
00219 static const char* Get_fgcERROR();
00220
00221 static UInt_t Get_fguPORTWAITTIME();
00222
00223 static Int_t Get_fgiPORTWAITCYCLES();
00224
00225 protected:
00226
00228 static const UInt_t fguCONNECTORPORT;
00229
00231 static const Int_t fgiTHREADSTOPCYCLES;
00232
00234 static const UInt_t fguTHREADSTOPTIME;
00235
00237 static const UInt_t fguTRANSPORTCHECKDELAY;
00238
00240 static const UInt_t fguSTATUSQUEUESIZE;
00241
00243 static const UInt_t fguDATAQUEUESIZE;
00244
00246 static const UInt_t fguCOMMANDQUEUESIZE;
00247
00249 static const char* fgcCONNECT;
00250
00252 static const char* fgcDISCONNECT;
00253
00255 static const char* fgcMASTER;
00256
00258 static const char* fgcSLAVE;
00259
00260
00262 static const char* fgcCOMMANDTHREAD;
00263
00265 static const char* fgcSTATUSTHREAD;
00266
00268 static const char* fgcDATATHREAD;
00269
00270
00271 private:
00272 TGo4TaskHandler();
00273
00274
00279 static TNamed fgxADMINISTRATORACCOUNT;
00280
00281
00286 static TNamed fgxOBSERVERACCOUNT;
00287
00292 static TNamed fgxCONTROLLERACCOUNT;
00293
00295 static const char* fgcERROR;
00296
00298 static const char* fgcOK;
00299
00301 static const UInt_t fguPORTWAITTIME;
00302
00304 static const Int_t fgiPORTWAITCYCLES;
00305
00307 Bool_t fbClientMode;
00308
00310 Bool_t fbMasterMode;
00311
00313 Bool_t fbIsAborting;
00314
00316 TGo4ThreadManager* fxThreadManager;
00317
00324 TGo4ThreadHandler* fxThreadHandler;
00325
00327 TGo4CommandInvoker* fxInvoker;
00328
00330 TGo4Queue* fxCommandQueue;
00331 TGo4Queue* fxStatusQueue;
00332 TGo4Queue* fxDataQueue;
00333
00335 TGo4Socket* fxCommandTransport;
00336 TGo4Socket* fxStatusTransport;
00337 TGo4Socket* fxDataTransport;
00338
00340 TString fxComName;
00341
00343 TString fxStatName;
00344
00346 TString fxDatName;
00347
00349 TString fxHostName;
00350
00352 UInt_t fuNegPort;
00353
00355 Int_t fiComPort;
00356
00358 Int_t fiStatPort;
00359
00361 Int_t fiDatPort;
00362
00367 Go4CommandMode_t fiRole;
00368
00372 TGo4StatusRunnable* fxStatusRun;
00373
00377 TGo4DataRunnable* fxDataRun;
00378
00382 TGo4CommandRunnable* fxCommandRun;
00383
00384 };
00385
00386 #endif //TGO4TASKHANDLER_H