GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4Task.h
Go to the documentation of this file.
1 // $Id: TGo4Task.h 1457 2015-05-28 14:59:14Z 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 für 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 TGO4TASK_H
15 #define TGO4TASK_H
16 
17 #include "TGo4ThreadManager.h"
18 #include "TGo4CommandReceiver.h"
19 #include "Go4EmergencyCommands.h"
20 
21 #include "TString.h"
22 
23 class TMutex;
24 class TGo4TaskOwner;
25 class TGo4Slave;
26 class TGo4Master;
27 class TGo4BufferQueue;
28 class TGo4ObjectQueue;
29 class TGo4TaskHandler;
32 class TGo4Command;
33 class TGo4Status;
34 class TGo4TaskStatus;
35 
37 
38 public:
39  friend class TGo4LocalCommandRunnable; // access to command queue
40  friend class TGo4Slave; // access to UpdateStatus
41  friend class TGo4TaskOwner; // set workisstopped flag
42 
43  TGo4Task(const char* name, Bool_t blockingmode,
44  Bool_t autostart=kFALSE,
45  Bool_t autocreate=kTRUE,
46  Bool_t ismaster=kFALSE);
47 
48  virtual ~TGo4Task();
49 
54  virtual void Start();
55 
60  virtual void Stop();
61 
67  virtual void Quit();
68 
74  virtual void KillMain();
75 
81  virtual void RestartMain();
82 
83  virtual void Terminate (Bool_t termapp=kTRUE);
84 
86  virtual void TerminateFast ();
87 
92  virtual void ExecuteString(const char* command);
93 
94  Bool_t IsMaster() { return fbCommandMaster; }
95 
98  void SetOwner(TGo4TaskOwner* owner);
99 
100  virtual TGo4TaskHandler* GetTaskHandler();
101 
102  virtual TGo4BufferQueue* GetCommandQueue(const char* task=0);
103 
104  virtual TGo4BufferQueue* GetStatusQueue(const char* task=0);
105 
106  virtual TGo4BufferQueue* GetDataQueue(const char* task=0);
107 
113  void AddUserCommand(TGo4Command* com);
114 
120 
127  TGo4Status* NextStatus(Bool_t wait=kTRUE);
128 
135  TObject * NextObject(Bool_t wait=kTRUE);
136 
138  virtual TGo4Command* NextCommand();
139 
143  void SendObject(TObject * obj, const char* receiver=0);
144 
148  virtual void SendStatus(TGo4Status * stat, const char* receiver=0);
149 
151  virtual void SendStatusBuffer();
152 
156 
163  void SendStatusMessage(Int_t level, Bool_t printout, const char* text, ...);
164 
171  void UpdateStatusBuffer();
172 
177  virtual Int_t Initialization();
178 
185  virtual TGo4TaskStatus* CreateStatus();
186 
190  Bool_t SubmitCommand(const char* name);
191 
196 
201  Bool_t SubmitEmergencyData(Go4EmergencyCommand_t val, const char* receiver=0);
202 
203 
206  Bool_t SubmitLocalCommand(TGo4Command* com);
207 
210  Bool_t SubmitCommand(TGo4Command* com);
211 
216  TGo4Command* MakeCommand(const char* name);
217 
226  void WakeCommandQueue(Int_t id=0);
227 
234  virtual Int_t StartWorkThreads();
235 
241  virtual Int_t StopWorkThreads();
242 
243  Bool_t IsWorkStopped(){return fbWorkIsStopped;}
244 
250  virtual void GetStatus();
251 
252  const char* GetCommanderName() const { return fxCommanderName.Data(); }
253 
255 
256  TGo4Slave* GetSlave() { return fxSlave; }
257 
265  void SendStopBuffers(const char* taskname=0);
266 
269  TBuffer* GetAbortBuffer(){return fxAbortBuffer;}
270 
271  static Int_t Get_fgiTERMID();
272 
273  protected:
274 
277 
280 
287  virtual void UpdateStatus(TGo4TaskStatus* state);
288 
290 
291  void SetMaster(Bool_t on=kTRUE) { fbCommandMaster=on; }
292 
293  void SetWorkIsStopped(Bool_t on) { fbWorkIsStopped=on; }
294 
296  TMutex * fxStatusMutex;
297 
299  TBuffer* fxStatusBuffer;
300 
301  private:
302 
303  void SetMaster(TGo4Master* m);
304 
305  void SetSlave(TGo4Slave* s);
306 
309 
312 
317 
320 
323 
326 
329 
332 
333 
335  TBuffer* fxStopBuffer;
336 
338  TBuffer* fxQuitBuffer;
339 
341  TBuffer* fxAbortBuffer;
342 
344  static const Int_t fgiTERMID;
345 
346  ClassDef(TGo4Task,1)
347 };
348 
349 #endif //TGO4TASK_H
virtual void UpdateStatus(TGo4TaskStatus *state)
Definition: TGo4Task.cxx:424
virtual void ExecuteString(const char *command)
Definition: TGo4Task.cxx:146
Go4EmergencyCommand_t
Bool_t IsWorkStopped()
Definition: TGo4Task.h:243
virtual Int_t StartWorkThreads()
Definition: TGo4Task.cxx:589
const char * GetCommanderName() const
Definition: TGo4Task.h:252
TBuffer * fxAbortBuffer
Definition: TGo4Task.h:341
TGo4Command * MakeCommand(const char *name)
Definition: TGo4Task.cxx:540
virtual void Stop()
Definition: TGo4Task.cxx:110
Bool_t SubmitLocalCommand(TGo4Command *com)
Definition: TGo4Task.cxx:546
TGo4Master * fxMaster
Definition: TGo4Task.h:322
void WakeCommandQueue(Int_t id=0)
Definition: TGo4Task.cxx:560
void SetSlave(TGo4Slave *s)
Definition: TGo4Task.cxx:92
virtual Int_t Initialization()
Definition: TGo4Task.cxx:393
void SetWorkIsStopped(Bool_t on)
Definition: TGo4Task.h:293
virtual ~TGo4Task()
Definition: TGo4Task.cxx:71
virtual TGo4Command * NextCommand()
Definition: TGo4Task.cxx:357
TGo4TaskOwner * fxOwner
Definition: TGo4Task.h:328
TGo4ObjectQueue * fxLocalCommandQueue
Definition: TGo4Task.h:311
TGo4TaskHandlerCommandList * fxCommandPrototype
Definition: TGo4Task.h:308
TBuffer * fxStopBuffer
Definition: TGo4Task.h:335
TBuffer * fxQuitBuffer
Definition: TGo4Task.h:338
TGo4ObjectQueue * GetLocalCommandQueue()
Definition: TGo4Task.h:289
virtual TGo4TaskHandler * GetTaskHandler()
Definition: TGo4Task.cxx:154
void SendStopBuffers(const char *taskname=0)
Definition: TGo4Task.cxx:601
virtual void RestartMain()
Definition: TGo4Task.cxx:125
TGo4Slave * fxSlave
Definition: TGo4Task.h:325
virtual Int_t StopWorkThreads()
Definition: TGo4Task.cxx:595
static const Int_t fgiTERMID
Definition: TGo4Task.h:344
virtual void TerminateFast()
Definition: TGo4Task.cxx:138
virtual void SendStatusBuffer()
Definition: TGo4Task.cxx:294
TGo4Slave * GetSlave()
Definition: TGo4Task.h:256
virtual void GetStatus()
Definition: TGo4Task.cxx:576
virtual TGo4BufferQueue * GetDataQueue(const char *task=0)
Definition: TGo4Task.cxx:168
void SendObject(TObject *obj, const char *receiver=0)
Definition: TGo4Task.cxx:253
virtual void SendStatus(TGo4Status *stat, const char *receiver=0)
Definition: TGo4Task.cxx:277
Bool_t SubmitCommand(const char *name)
Definition: TGo4Task.cxx:440
TGo4Master * GetMaster()
Definition: TGo4Task.h:254
virtual TGo4BufferQueue * GetCommandQueue(const char *task=0)
Definition: TGo4Task.cxx:159
Bool_t fbWorkIsStopped
Definition: TGo4Task.h:331
TMutex * fxStatusMutex
Definition: TGo4Task.h:296
Bool_t SubmitEmergencyCommand(Go4EmergencyCommand_t val)
Definition: TGo4Task.cxx:469
TMutex * GetStatusBufferMutex()
Definition: TGo4Task.h:155
void SetOwner(TGo4TaskOwner *owner)
Definition: TGo4Task.cxx:98
void AddUserCommandList(TGo4CommandProtoList *comlist)
Definition: TGo4Task.cxx:242
virtual TGo4TaskHandlerCommandList * CreateCommandList()
Definition: TGo4Task.cxx:535
TGo4Task(const char *name, Bool_t blockingmode, Bool_t autostart=kFALSE, Bool_t autocreate=kTRUE, Bool_t ismaster=kFALSE)
Definition: TGo4Task.cxx:38
TString fxCommanderName
Definition: TGo4Task.h:319
TBuffer * fxStatusBuffer
Definition: TGo4Task.h:299
void SendStatusMessage(Int_t level, Bool_t printout, const char *text,...)
Definition: TGo4Task.cxx:303
void SetMaster(Bool_t on=kTRUE)
Definition: TGo4Task.h:291
TObject * NextObject(Bool_t wait=kTRUE)
Definition: TGo4Task.cxx:217
Bool_t fbCommandMaster
Definition: TGo4Task.h:316
virtual TGo4BufferQueue * GetStatusQueue(const char *task=0)
Definition: TGo4Task.cxx:164
virtual void Terminate(Bool_t termapp=kTRUE)
Definition: TGo4Task.cxx:130
void AddUserCommand(TGo4Command *com)
Definition: TGo4Task.cxx:237
virtual TGo4TaskStatus * CreateStatus()
Definition: TGo4Task.cxx:433
void UpdateStatusBuffer()
Definition: TGo4Task.cxx:340
virtual void KillMain()
Definition: TGo4Task.cxx:120
virtual void Start()
Definition: TGo4Task.cxx:105
TGo4TaskHandlerCommandList * GetPrototype()
Definition: TGo4Task.cxx:173
virtual void Quit()
Definition: TGo4Task.cxx:115
TGo4Status * NextStatus(Bool_t wait=kTRUE)
Definition: TGo4Task.cxx:179
static Int_t Get_fgiTERMID()
Definition: TGo4Task.cxx:635
TBuffer * GetAbortBuffer()
Definition: TGo4Task.h:269
Bool_t SubmitEmergencyData(Go4EmergencyCommand_t val, const char *receiver=0)
Definition: TGo4Task.cxx:491
Bool_t IsMaster()
Definition: TGo4Task.h:94