Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef TGO4TASK_H
00015 #define TGO4TASK_H
00016
00017 #include "TGo4ThreadManager.h"
00018 #include "TGo4CommandReceiver.h"
00019 #include "Go4EmergencyCommands.h"
00020
00021 #include "TString.h"
00022
00023 class TMutex;
00024 class TGo4TaskOwner;
00025 class TGo4Slave;
00026 class TGo4Master;
00027 class TGo4BufferQueue;
00028 class TGo4ObjectQueue;
00029 class TGo4TaskHandler;
00030 class TGo4TaskHandlerCommandList;
00031 class TGo4CommandProtoList;
00032 class TGo4Command;
00033 class TGo4Status;
00034 class TGo4TaskStatus;
00035
00036 class TGo4Task : public TGo4ThreadManager, public TGo4CommandReceiver {
00037
00038 public:
00039 friend class TGo4LocalCommandRunnable;
00040 friend class TGo4Slave;
00041 friend class TGo4TaskOwner;
00042
00043 TGo4Task(const char* name, Bool_t blockingmode,
00044 Bool_t autostart=kFALSE,
00045 Bool_t autocreate=kTRUE,
00046 Bool_t ismaster=kFALSE);
00047
00048 virtual ~TGo4Task();
00049
00054 virtual void Start();
00055
00060 virtual void Stop();
00061
00067 virtual void Quit();
00068
00074 virtual void KillMain();
00075
00081 virtual void RestartMain();
00082
00083 virtual void Terminate (Bool_t termapp=kTRUE);
00084
00086 virtual void TerminateFast ();
00087
00092 virtual void ExecuteString(const char* command);
00093
00094 Bool_t IsMaster() { return fbCommandMaster; }
00095
00098 void SetOwner(TGo4TaskOwner* owner);
00099
00100 virtual TGo4TaskHandler* GetTaskHandler();
00101
00102 virtual TGo4BufferQueue* GetCommandQueue(const char* task=0);
00103
00104 virtual TGo4BufferQueue* GetStatusQueue(const char* task=0);
00105
00106 virtual TGo4BufferQueue* GetDataQueue(const char* task=0);
00107
00113 void AddUserCommand(TGo4Command* com);
00114
00119 void AddUserCommandList(TGo4CommandProtoList * comlist);
00120
00127 TGo4Status* NextStatus(Bool_t wait=kTRUE);
00128
00135 TObject * NextObject(Bool_t wait=kTRUE);
00136
00138 virtual TGo4Command* NextCommand();
00139
00143 void SendObject(TObject * obj, const char* receiver=0);
00144
00148 virtual void SendStatus(TGo4Status * stat, const char* receiver=0);
00149
00151 virtual void SendStatusBuffer();
00152
00155 TMutex* GetStatusBufferMutex(){return fxStatusMutex;}
00156
00163 void SendStatusMessage(Int_t level, Bool_t printout, const char* text, ...);
00164
00171 void UpdateStatusBuffer();
00172
00177 virtual Int_t Initialization();
00178
00185 virtual TGo4TaskStatus* CreateStatus();
00186
00190 Bool_t SubmitCommand(const char* name);
00191
00195 Bool_t SubmitEmergencyCommand(Go4EmergencyCommand_t val);
00196
00201 Bool_t SubmitEmergencyData(Go4EmergencyCommand_t val, const char* receiver=0);
00202
00203
00206 Bool_t SubmitLocalCommand(TGo4Command* com);
00207
00210 Bool_t SubmitCommand(TGo4Command* com);
00211
00216 TGo4Command* MakeCommand(const char* name);
00217
00226 void WakeCommandQueue(Int_t id=0);
00227
00234 virtual Int_t StartWorkThreads();
00235
00241 virtual Int_t StopWorkThreads();
00242
00243 Bool_t IsWorkStopped(){return fbWorkIsStopped;}
00244
00247 virtual void LockAll();
00248
00251 virtual void UnLockAll();
00252
00253
00259 virtual void GetStatus();
00260
00261 const char* GetCommanderName() const { return fxCommanderName.Data(); }
00262
00263 TGo4Master* GetMaster() { return fxMaster; }
00264
00265 TGo4Slave* GetSlave() { return fxSlave; }
00266
00274 void SendStopBuffers(const char* taskname=0);
00275
00278 TBuffer* GetAbortBuffer(){return fxAbortBuffer;}
00279
00280 static Int_t Get_fgiTERMID();
00281
00282 protected:
00283
00285 virtual TGo4TaskHandlerCommandList* CreateCommandList();
00286
00288 TGo4TaskHandlerCommandList * GetPrototype();
00289
00296 virtual void UpdateStatus(TGo4TaskStatus* state);
00297
00298 TGo4ObjectQueue* GetLocalCommandQueue() { return fxLocalCommandQueue; }
00299
00300 void SetMaster(Bool_t on=kTRUE) { fbCommandMaster=on; }
00301
00302 void SetWorkIsStopped(Bool_t on) { fbWorkIsStopped=on; }
00303
00305 TMutex * fxStatusMutex;
00306
00308 TBuffer* fxStatusBuffer;
00309
00310 private:
00311
00312 void SetMaster(TGo4Master* m);
00313
00314 void SetSlave(TGo4Slave* s);
00315
00317 TGo4TaskHandlerCommandList * fxCommandPrototype;
00318
00320 TGo4ObjectQueue* fxLocalCommandQueue;
00321
00325 Bool_t fbCommandMaster;
00326
00328 TString fxCommanderName;
00329
00331 TGo4Master * fxMaster;
00332
00334 TGo4Slave * fxSlave;
00335
00337 TGo4TaskOwner * fxOwner;
00338
00340 Bool_t fbWorkIsStopped;
00341
00342
00344 TBuffer* fxStopBuffer;
00345
00347 TBuffer* fxQuitBuffer;
00348
00350 TBuffer* fxAbortBuffer;
00351
00353 static const Int_t fgiTERMID;
00354
00355
00356 ClassDef(TGo4Task,1)
00357 };
00358
00359 #endif //TGO4TASK_H