GSI Object Oriented Online Offline (Go4)  GO4-6.1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4Task.h
Go to the documentation of this file.
1 // $Id: TGo4Task.h 3053 2021-03-12 10:35:12Z 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 TGO4TASK_H
15 #define TGO4TASK_H
16 
17 #include "TGo4ThreadManager.h"
18 #include "TGo4CommandReceiver.h"
19 #include "Go4EmergencyCommands.h"
20 #include "TString.h"
21 
22 class TMutex;
23 class TGo4TaskOwner;
24 class TGo4Slave;
25 class TGo4Master;
26 class TGo4BufferQueue;
27 class TGo4ObjectQueue;
28 class TGo4TaskHandler;
31 class TGo4Command;
32 class TGo4Status;
33 class TGo4TaskStatus;
34 
36 
37 public:
38  friend class TGo4LocalCommandRunnable; // access to command queue
39  friend class TGo4Slave; // access to UpdateStatus
40  friend class TGo4TaskOwner; // set workisstopped flag
41 
42  TGo4Task(const char* name, Bool_t blockingmode,
43  Bool_t autostart=kFALSE,
44  Bool_t autocreate=kTRUE,
45  Bool_t ismaster=kFALSE);
46 
47  virtual ~TGo4Task();
48 
53  virtual void Start();
54 
59  virtual void Stop();
60 
66  virtual void Quit();
67 
73  virtual void KillMain();
74 
80  virtual void RestartMain();
81 
82  virtual void Terminate (Bool_t termapp=kTRUE);
83 
85  virtual void TerminateFast ();
86 
91  virtual void ExecuteString(const char* command);
92 
93  Bool_t IsMaster() { return fbCommandMaster; }
94 
97  void SetOwner(TGo4TaskOwner* owner);
98 
99  virtual TGo4TaskHandler* GetTaskHandler() { return 0; }
100 
101  virtual TGo4BufferQueue* GetCommandQueue(const char* task=0) { return 0; }
102 
103  virtual TGo4BufferQueue* GetStatusQueue(const char* task=0) { return 0; }
104 
105  virtual TGo4BufferQueue* GetDataQueue(const char* task=0) { return 0; }
106 
112  void AddUserCommand(TGo4Command* com);
113 
119 
126  TGo4Status* NextStatus(Bool_t wait=kTRUE);
127 
134  TObject * NextObject(Bool_t wait=kTRUE);
135 
137  virtual TGo4Command* NextCommand();
138 
142  void SendObject(TObject * obj, const char* receiver=0);
143 
147  virtual void SendStatus(TGo4Status * stat, const char* receiver=0);
148 
150  virtual void SendStatusBuffer();
151 
155 
162  void SendStatusMessage(Int_t level, Bool_t printout, const char* text, ...);
163 
170  void UpdateStatusBuffer();
171 
176  virtual Int_t Initialization();
177 
184  virtual TGo4TaskStatus* CreateStatus();
185 
189  Bool_t SubmitCommand(const char* name);
190 
195 
200  Bool_t SubmitEmergencyData(Go4EmergencyCommand_t val, const char* receiver=0);
201 
202 
205  Bool_t SubmitLocalCommand(TGo4Command* com);
206 
209  Bool_t SubmitCommand(TGo4Command* com);
210 
215  TGo4Command* MakeCommand(const char* name);
216 
225  void WakeCommandQueue(Int_t id=0);
226 
233  virtual Int_t StartWorkThreads();
234 
240  virtual Int_t StopWorkThreads();
241 
242  Bool_t IsWorkStopped(){return fbWorkIsStopped;}
243 
249  virtual void GetStatus();
250 
251  const char* GetCommanderName() const { return fxCommanderName.Data(); }
252 
254 
255  TGo4Slave* GetSlave() { return fxSlave; }
256 
264  void SendStopBuffers(const char* taskname=0);
265 
268  TBuffer* GetAbortBuffer(){return fxAbortBuffer;}
269 
270  static Int_t Get_fgiTERMID();
271 
272  protected:
273 
276 
279 
286  virtual void UpdateStatus(TGo4TaskStatus* state);
287 
289 
290  void SetMaster(Bool_t on=kTRUE) { fbCommandMaster=on; }
291 
292  void SetWorkIsStopped(Bool_t on) { fbWorkIsStopped=on; }
293 
295  TMutex * fxStatusMutex;
296 
298  TBuffer* fxStatusBuffer;
299 
300  private:
301 
302  void SetMaster(TGo4Master* m);
303 
304  void SetSlave(TGo4Slave* s);
305 
308 
311 
316 
319 
322 
325 
328 
331 
332 
334  TBuffer* fxStopBuffer;
335 
337  TBuffer* fxQuitBuffer;
338 
340  TBuffer* fxAbortBuffer;
341 
343  static const Int_t fgiTERMID;
344 
345  ClassDef(TGo4Task,1)
346 };
347 
348 #endif //TGO4TASK_H
virtual void UpdateStatus(TGo4TaskStatus *state)
Definition: TGo4Task.cxx:407
virtual void ExecuteString(const char *command)
Definition: TGo4Task.cxx:147
Go4EmergencyCommand_t
Bool_t IsWorkStopped()
Definition: TGo4Task.h:242
virtual Int_t StartWorkThreads()
Definition: TGo4Task.cxx:569
const char * GetCommanderName() const
Definition: TGo4Task.h:251
TBuffer * fxAbortBuffer
Definition: TGo4Task.h:340
TGo4Command * MakeCommand(const char *name)
Definition: TGo4Task.cxx:523
virtual void Stop()
Definition: TGo4Task.cxx:111
Bool_t SubmitLocalCommand(TGo4Command *com)
Definition: TGo4Task.cxx:529
TGo4Master * fxMaster
Definition: TGo4Task.h:321
void WakeCommandQueue(Int_t id=0)
Definition: TGo4Task.cxx:543
void SetSlave(TGo4Slave *s)
Definition: TGo4Task.cxx:93
virtual Int_t Initialization()
Definition: TGo4Task.cxx:376
void SetWorkIsStopped(Bool_t on)
Definition: TGo4Task.h:292
virtual ~TGo4Task()
Definition: TGo4Task.cxx:72
virtual TGo4Command * NextCommand()
Definition: TGo4Task.cxx:339
TGo4TaskOwner * fxOwner
Definition: TGo4Task.h:327
TGo4ObjectQueue * fxLocalCommandQueue
Definition: TGo4Task.h:310
TGo4TaskHandlerCommandList * fxCommandPrototype
Definition: TGo4Task.h:307
TBuffer * fxStopBuffer
Definition: TGo4Task.h:334
TBuffer * fxQuitBuffer
Definition: TGo4Task.h:337
TGo4ObjectQueue * GetLocalCommandQueue()
Definition: TGo4Task.h:288
virtual TGo4TaskHandler * GetTaskHandler()
Definition: TGo4Task.h:99
virtual TGo4BufferQueue * GetStatusQueue(const char *task=0)
Definition: TGo4Task.h:103
virtual TGo4BufferQueue * GetCommandQueue(const char *task=0)
Definition: TGo4Task.h:101
void SendStopBuffers(const char *taskname=0)
Definition: TGo4Task.cxx:581
virtual void RestartMain()
Definition: TGo4Task.cxx:126
TGo4Slave * fxSlave
Definition: TGo4Task.h:324
virtual Int_t StopWorkThreads()
Definition: TGo4Task.cxx:575
static const Int_t fgiTERMID
Definition: TGo4Task.h:343
virtual void TerminateFast()
Definition: TGo4Task.cxx:139
virtual void SendStatusBuffer()
Definition: TGo4Task.cxx:276
TGo4Slave * GetSlave()
Definition: TGo4Task.h:255
virtual void GetStatus()
Definition: TGo4Task.cxx:557
void SendObject(TObject *obj, const char *receiver=0)
Definition: TGo4Task.cxx:235
virtual void SendStatus(TGo4Status *stat, const char *receiver=0)
Definition: TGo4Task.cxx:259
Bool_t SubmitCommand(const char *name)
Definition: TGo4Task.cxx:423
TGo4Master * GetMaster()
Definition: TGo4Task.h:253
Bool_t fbWorkIsStopped
Definition: TGo4Task.h:330
TMutex * fxStatusMutex
Definition: TGo4Task.h:295
Bool_t SubmitEmergencyCommand(Go4EmergencyCommand_t val)
Definition: TGo4Task.cxx:452
TMutex * GetStatusBufferMutex()
Definition: TGo4Task.h:154
void SetOwner(TGo4TaskOwner *owner)
Definition: TGo4Task.cxx:99
void AddUserCommandList(TGo4CommandProtoList *comlist)
Definition: TGo4Task.cxx:224
virtual TGo4TaskHandlerCommandList * CreateCommandList()
Definition: TGo4Task.cxx:518
TGo4Task(const char *name, Bool_t blockingmode, Bool_t autostart=kFALSE, Bool_t autocreate=kTRUE, Bool_t ismaster=kFALSE)
Definition: TGo4Task.cxx:39
TString fxCommanderName
Definition: TGo4Task.h:318
TBuffer * fxStatusBuffer
Definition: TGo4Task.h:298
void SendStatusMessage(Int_t level, Bool_t printout, const char *text,...)
Definition: TGo4Task.cxx:285
void SetMaster(Bool_t on=kTRUE)
Definition: TGo4Task.h:290
TObject * NextObject(Bool_t wait=kTRUE)
Definition: TGo4Task.cxx:199
Bool_t fbCommandMaster
Definition: TGo4Task.h:315
virtual void Terminate(Bool_t termapp=kTRUE)
Definition: TGo4Task.cxx:131
void AddUserCommand(TGo4Command *com)
Definition: TGo4Task.cxx:219
virtual TGo4TaskStatus * CreateStatus()
Definition: TGo4Task.cxx:416
void UpdateStatusBuffer()
Definition: TGo4Task.cxx:322
virtual void KillMain()
Definition: TGo4Task.cxx:121
virtual void Start()
Definition: TGo4Task.cxx:106
TGo4TaskHandlerCommandList * GetPrototype()
Definition: TGo4Task.cxx:155
virtual void Quit()
Definition: TGo4Task.cxx:116
TGo4Status * NextStatus(Bool_t wait=kTRUE)
Definition: TGo4Task.cxx:161
static Int_t Get_fgiTERMID()
Definition: TGo4Task.cxx:611
virtual TGo4BufferQueue * GetDataQueue(const char *task=0)
Definition: TGo4Task.h:105
TBuffer * GetAbortBuffer()
Definition: TGo4Task.h:268
Bool_t SubmitEmergencyData(Go4EmergencyCommand_t val, const char *receiver=0)
Definition: TGo4Task.cxx:474
Bool_t IsMaster()
Definition: TGo4Task.h:93