GSI Object Oriented Online Offline (Go4)  GO4-6.1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4TaskHandler.h
Go to the documentation of this file.
1 // $Id: TGo4TaskHandler.h 2627 2019-10-01 08:02:45Z linev $
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=0);
78 
79 
86  Bool_t DisConnect(Bool_t waitforclient=kTRUE);
87 
89 
97  Int_t WaitGetPort(TGo4Socket* sock);
98 
102  void SetNegotiationPort(UInt_t port){ fuNegPort=port;}
103 
105 
107 
109 
111 
113 
114  TGo4Queue * GetDataQueue() const { return fxDataQueue; }
115 
116  const char* GetHostName() const { return fxHostName.Data(); }
117 
118  const char* GetComName() const { return fxComName.Data(); }
119 
120  const char* GetDatName() const { return fxDatName.Data(); }
121 
122  const char* GetStatName() const { return fxStatName.Data(); }
123 
124  Int_t GetComPort() const { return fiComPort; }
125 
126  Int_t GetDatPort() const { return fiDatPort; }
127 
128  Int_t GetStatPort() const { return fiStatPort; }
129 
131  void SetRole(Go4CommandMode_t role){fiRole=role;}
132 
138 
140  Bool_t IsClientMode() const { return fbClientMode; }
141 
143  Bool_t IsMasterMode() const { return fbMasterMode; }
144 
149  void SetAborting(Bool_t isaborting=kTRUE) { fbIsAborting=isaborting; }
150 
152  Bool_t IsAborting() const { return fbIsAborting; }
153 
159 
167 
174  Bool_t StopTransportThreads(Bool_t wait=kTRUE);
175 
180  void StartTransportThreads();
181 
185  Bool_t WaitThreadStop(const char* name);
186 
190  void CloseChannels(Option_t *opt="");
191 
193  void ClearQueues();
194 
195 
201  static void SetAdminAccount(const char* name, const char* passwd);
202 
208  static void SetCtrlAccount(const char* name, const char* passwd);
209 
215  static void SetObservAccount(const char* name, const char* passwd);
216 
217  static const char* Get_fgcOK();
218 
219  static const char* Get_fgcERROR();
220 
221  static UInt_t Get_fguPORTWAITTIME();
222 
223  static Int_t Get_fgiPORTWAITCYCLES();
224 
225  protected:
226 
228  static const UInt_t fguCONNECTORPORT;
229 
231  static const Int_t fgiTHREADSTOPCYCLES;
232 
234  static const UInt_t fguTHREADSTOPTIME;
235 
237  static const UInt_t fguTRANSPORTCHECKDELAY;
238 
240  static const UInt_t fguSTATUSQUEUESIZE;
241 
243  static const UInt_t fguDATAQUEUESIZE;
244 
246  static const UInt_t fguCOMMANDQUEUESIZE;
247 
249  static const char* fgcCONNECT;
250 
252  static const char* fgcDISCONNECT;
253 
255  static const char* fgcMASTER;
256 
258  static const char* fgcSLAVE;
259 
260 
262  static const char* fgcCOMMANDTHREAD;
263 
265  static const char* fgcSTATUSTHREAD;
266 
268  static const char* fgcDATATHREAD;
269 
270 
271  private:
272  TGo4TaskHandler();
273 
274 
279  static TNamed fgxADMINISTRATORACCOUNT;
280 
281 
286  static TNamed fgxOBSERVERACCOUNT;
287 
292  static TNamed fgxCONTROLLERACCOUNT;
293 
295  static const char* fgcERROR;
296 
298  static const char* fgcOK;
299 
301  static const UInt_t fguPORTWAITTIME;
302 
304  static const Int_t fgiPORTWAITCYCLES;
305 
307  Bool_t fbClientMode;
308 
310  Bool_t fbMasterMode;
311 
313  Bool_t fbIsAborting;
314 
317 
325 
328 
333 
338 
340  TString fxComName;
341 
343  TString fxStatName;
344 
346  TString fxDatName;
347 
349  TString fxHostName;
350 
352  UInt_t fuNegPort;
353 
355  Int_t fiComPort;
356 
358  Int_t fiStatPort;
359 
361  Int_t fiDatPort;
362 
368 
373 
378 
383 
384 };
385 
386 #endif //TGO4TASKHANDLER_H
TGo4Socket * GetCommandTransport() const
static const char * fgcSTATUSTHREAD
const char * GetDatName() const
static const UInt_t fguDATAQUEUESIZE
Bool_t DisConnect(Bool_t waitforclient=kTRUE)
static TNamed fgxADMINISTRATORACCOUNT
static UInt_t Get_fguPORTWAITTIME()
Int_t GetStatPort() const
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
TGo4Queue * GetStatusQueue() const
Bool_t IsAborting() const
static const Int_t fgiPORTWAITCYCLES
static const UInt_t fguTRANSPORTCHECKDELAY
static const char * Get_fgcERROR()
TGo4Socket * GetDataTransport() const
static const char * fgcERROR
static const Int_t fgiTHREADSTOPCYCLES
Int_t GetDatPort() const
static const char * Get_fgcOK()
TGo4DataRunnable * fxDataRun
Bool_t IsClientMode() const
static void SetCtrlAccount(const char *name, const char *passwd)
void SetAborting(Bool_t isaborting=kTRUE)
TGo4Queue * GetCommandQueue() const
static const UInt_t fguSTATUSQUEUESIZE
void SetInvoker(TGo4CommandInvoker *inv)
TGo4Socket * GetStatusTransport() const
TGo4ThreadManager * GetThreadManager() const
Int_t GetComPort() const
TGo4Queue * fxCommandQueue
TGo4StatusRunnable * fxStatusRun
TGo4Socket * fxCommandTransport
Bool_t WaitThreadStop(const char *name)
static const UInt_t fguPORTWAITTIME
TGo4CommandRunnable * fxCommandRun
static const char * fgcCONNECT
Bool_t ConnectServerChannel(const char *name, TGo4Socket *negotiator, TGo4Socket *channel, const char *host)
TGo4Queue * GetDataQueue() const
TGo4Socket * fxStatusTransport
static const char * fgcOK
const char * GetComName() const
const char * GetStatName() const
static const char * fgcCOMMANDTHREAD
static const char * fgcMASTER
TGo4Socket * fxDataTransport
Bool_t ConnectClientChannel(const char *name, TGo4Socket *negotiator, TGo4Socket *channel, const char *host)
const char * GetHostName() const
TGo4ThreadHandler * fxThreadHandler
void SetNegotiationPort(UInt_t port)
virtual TGo4TaskHandlerStatus * CreateStatus()
virtual ~TGo4TaskHandler()
Bool_t IsMasterMode() const
static const UInt_t fguCONNECTORPORT
static TNamed fgxCONTROLLERACCOUNT
Go4CommandMode_t GetRole()
static const char * fgcSLAVE
void SetRole(Go4CommandMode_t role)
TGo4CommandInvoker * GetInvoker() const
static const UInt_t fguTHREADSTOPTIME
static TNamed fgxOBSERVERACCOUNT
static void SetAdminAccount(const char *name, const char *passwd)
static Int_t Get_fgiPORTWAITCYCLES()
static const char * fgcDISCONNECT
TGo4Queue * fxStatusQueue
TGo4CommandInvoker * fxInvoker
TGo4Socket * ServerRequest(const char *host="localhost")
Int_t WaitGetPort(TGo4Socket *sock)
Bool_t Connect(const char *host="localhost", TGo4Socket *negotiator=0)
Bool_t ServerLogin(TGo4Socket *connector, Go4CommandMode_t account)
Go4CommandMode_t fiRole
void CloseChannels(Option_t *opt="")