GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4TaskHandler.h
Go to the documentation of this file.
1 // $Id$
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #ifndef TGO4TASKHANDLER_H
15 #define TGO4TASKHANDLER_H
16 
17 #include "TNamed.h"
18 #include "TGo4Command.h"
19 
20 class TGo4ThreadManager;
21 class TGo4ThreadHandler;
22 class TGo4Socket;
23 class TGo4Queue;
24 class TGo4CommandInvoker;
26 class TGo4DataRunnable;
27 class TGo4StatusRunnable;
29 
30 
42 class TGo4TaskHandler : public TNamed {
43 
44  public:
45 
46  friend class TGo4TaskManager;
47 
48  TGo4TaskHandler(const char *name, TGo4ThreadManager *threadmanager, Bool_t clientmode = kFALSE, Bool_t mastermode = kTRUE, UInt_t negotiationport = 0);
49 
50  virtual ~TGo4TaskHandler();
51 
57  Bool_t ConnectServerChannel(const char *name, TGo4Socket *negotiator, TGo4Socket *channel, const char *host);
58 
64  Bool_t ConnectClientChannel(const char *name, TGo4Socket *negotiator, TGo4Socket *channel, const char *host);
65 
69  TGo4Socket *ServerRequest(const char *host = "localhost");
70 
72  Bool_t ServerLogin(TGo4Socket *connector, Go4CommandMode_t account);
73 
77  Bool_t Connect(const char *host="localhost", TGo4Socket *negotiator = nullptr);
78 
85  Bool_t DisConnect(Bool_t waitforclient = kTRUE);
86 
88 
96  Int_t WaitGetPort(TGo4Socket *sock);
97 
101  void SetNegotiationPort(UInt_t port){ fuNegPort=port;}
102 
104 
106 
108 
110 
112 
113  TGo4Queue *GetDataQueue() const { return fxDataQueue; }
114 
115  const char *GetHostName() const { return fxHostName.Data(); }
116 
117  const char *GetComName() const { return fxComName.Data(); }
118 
119  const char *GetDatName() const { return fxDatName.Data(); }
120 
121  const char *GetStatName() const { return fxStatName.Data(); }
122 
123  Int_t GetComPort() const { return fiComPort; }
124 
125  Int_t GetDatPort() const { return fiDatPort; }
126 
127  Int_t GetStatPort() const { return fiStatPort; }
128 
130  void SetRole(Go4CommandMode_t role){fiRole=role;}
131 
137 
139  Bool_t IsClientMode() const { return fbClientMode; }
140 
142  Bool_t IsMasterMode() const { return fbMasterMode; }
143 
148  void SetAborting(Bool_t isaborting=kTRUE) { fbIsAborting=isaborting; }
149 
151  Bool_t IsAborting() const { return fbIsAborting; }
152 
158 
166 
173  Bool_t StopTransportThreads(Bool_t wait=kTRUE);
174 
179  void StartTransportThreads();
180 
184  Bool_t WaitThreadStop(const char *name);
185 
189  void CloseChannels(Option_t *opt = "");
190 
192  void ClearQueues();
193 
194 
200  static void SetAdminAccount(const char *name, const char *passwd);
201 
207  static void SetCtrlAccount(const char *name, const char *passwd);
208 
214  static void SetObservAccount(const char *name, const char *passwd);
215 
216  static const char *Get_fgcOK();
217 
218  static const char *Get_fgcERROR();
219 
220  static UInt_t Get_fguPORTWAITTIME();
221 
222  static Int_t Get_fgiPORTWAITCYCLES();
223 
224  protected:
225 
227  static const UInt_t fguCONNECTORPORT;
228 
230  static const Int_t fgiTHREADSTOPCYCLES;
231 
233  static const UInt_t fguTHREADSTOPTIME;
234 
236  static const UInt_t fguTRANSPORTCHECKDELAY;
237 
239  static const UInt_t fguSTATUSQUEUESIZE;
240 
242  static const UInt_t fguDATAQUEUESIZE;
243 
245  static const UInt_t fguCOMMANDQUEUESIZE;
246 
248  static const char *fgcCONNECT;
249 
251  static const char *fgcDISCONNECT;
252 
254  static const char *fgcMASTER;
255 
257  static const char *fgcSLAVE;
258 
260  static const char *fgcCOMMANDTHREAD;
261 
263  static const char *fgcSTATUSTHREAD;
264 
266  static const char *fgcDATATHREAD;
267 
268 
269  private:
270  TGo4TaskHandler();
271 
276  static TNamed fgxADMINISTRATORACCOUNT;
277 
282  static TNamed fgxOBSERVERACCOUNT;
283 
288  static TNamed fgxCONTROLLERACCOUNT;
289 
291  static const char *fgcERROR;
292 
294  static const char *fgcOK;
295 
297  static const UInt_t fguPORTWAITTIME;
298 
300  static const Int_t fgiPORTWAITCYCLES;
301 
303  Bool_t fbClientMode{kFALSE};
304 
306  Bool_t fbMasterMode{kFALSE};
307 
309  Bool_t fbIsAborting{kFALSE};
310 
313 
321 
324 
328  TGo4Queue *fxDataQueue{nullptr};
329 
334 
336  TString fxComName;
337 
339  TString fxStatName;
340 
342  TString fxDatName;
343 
345  TString fxHostName;
346 
348  UInt_t fuNegPort{0};
349 
351  Int_t fiComPort{0};
352 
354  Int_t fiStatPort{0};
355 
357  Int_t fiDatPort{0};
358 
364 
369 
374 
379 
380 };
381 
382 #endif //TGO4TASKHANDLER_H
static const char * fgcSTATUSTHREAD
static const UInt_t fguDATAQUEUESIZE
Bool_t DisConnect(Bool_t waitforclient=kTRUE)
static TNamed fgxADMINISTRATORACCOUNT
Bool_t Connect(const char *host="localhost", TGo4Socket *negotiator=nullptr)
static UInt_t Get_fguPORTWAITTIME()
static const char * fgcDATATHREAD
Bool_t StopTransportThreads(Bool_t wait=kTRUE)
TGo4Queue * fxDataQueue
Go4CommandMode_t
Definition: TGo4Command.h:27
static const UInt_t fguCOMMANDQUEUESIZE
static void SetObservAccount(const char *name, const char *passwd)
TGo4ThreadManager * fxThreadManager
static const Int_t fgiPORTWAITCYCLES
static const UInt_t fguTRANSPORTCHECKDELAY
static const char * Get_fgcERROR()
static const char * fgcERROR
static const Int_t fgiTHREADSTOPCYCLES
TGo4Socket * GetDataTransport() const
static const char * Get_fgcOK()
TGo4DataRunnable * fxDataRun
TGo4Socket * GetCommandTransport() const
static void SetCtrlAccount(const char *name, const char *passwd)
void SetAborting(Bool_t isaborting=kTRUE)
static const UInt_t fguSTATUSQUEUESIZE
void SetInvoker(TGo4CommandInvoker *inv)
Int_t GetStatPort() const
TGo4Queue * fxCommandQueue
TGo4StatusRunnable * fxStatusRun
Bool_t IsClientMode() const
TGo4Socket * fxCommandTransport
Bool_t WaitThreadStop(const char *name)
static const UInt_t fguPORTWAITTIME
TGo4CommandRunnable * fxCommandRun
const char * GetDatName() const
static const char * fgcCONNECT
const char * GetHostName() const
Bool_t ConnectServerChannel(const char *name, TGo4Socket *negotiator, TGo4Socket *channel, const char *host)
TGo4Socket * fxStatusTransport
TGo4ThreadManager * GetThreadManager() const
static const char * fgcOK
static const char * fgcCOMMANDTHREAD
Bool_t IsAborting() const
Int_t GetComPort() const
static const char * fgcMASTER
TGo4Socket * fxDataTransport
Bool_t ConnectClientChannel(const char *name, TGo4Socket *negotiator, TGo4Socket *channel, const char *host)
Int_t GetDatPort() const
TGo4Queue * GetStatusQueue() const
TGo4ThreadHandler * fxThreadHandler
void SetNegotiationPort(UInt_t port)
virtual TGo4TaskHandlerStatus * CreateStatus()
virtual ~TGo4TaskHandler()
Bool_t IsMasterMode() const
TGo4Queue * GetCommandQueue() const
const char * GetStatName() const
static const UInt_t fguCONNECTORPORT
static TNamed fgxCONTROLLERACCOUNT
Go4CommandMode_t GetRole()
static const char * fgcSLAVE
void SetRole(Go4CommandMode_t role)
static const UInt_t fguTHREADSTOPTIME
static TNamed fgxOBSERVERACCOUNT
static void SetAdminAccount(const char *name, const char *passwd)
TGo4Socket * GetStatusTransport() const
static Int_t Get_fgiPORTWAITCYCLES()
TGo4Queue * GetDataQueue() const
TGo4CommandInvoker * GetInvoker() const
static const char * fgcDISCONNECT
TGo4Queue * fxStatusQueue
TGo4CommandInvoker * fxInvoker
TGo4Socket * ServerRequest(const char *host="localhost")
Int_t WaitGetPort(TGo4Socket *sock)
const char * GetComName() const
Bool_t ServerLogin(TGo4Socket *connector, Go4CommandMode_t account)
Go4CommandMode_t fiRole
void CloseChannels(Option_t *opt="")