Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4TaskHandler/TGo4Task.h

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 /* Generated by Together */
00017 
00018 #ifndef TGO4TASK_H
00019 #define TGO4TASK_H
00020 
00021 #include "Rtypes.h"
00022 #include "TObject.h"
00023 #include "TString.h"
00024 #include "Go4CommandsBase/TGo4Command.h"
00025 #include "Go4CommandsBase/TGo4CommandReceiver.h"
00026 #include "Go4ThreadManager/TGo4ThreadManager.h"
00027 #include "Go4StatusBase/TGo4Status.h"
00028 #include "Go4CommandsTaskHandler/TGo4TaskHandlerCommandList.h"
00029 #include "Go4CommandsTaskHandler/Go4CommandsTaskHandler.h"
00030 
00031 #include "TGo4TaskHandler.h"
00032 
00033 //#include "Go4Queue/TGo4BufferQueue.h"
00034 //#include "Go4Queue/TGo4ObjectQueue.h"
00035 
00036 #include "TGo4TaskStatus.h"
00037 #include <Rtypes.h>
00038 class TGo4TaskOwner;
00039 class TGo4Slave;
00040 class TGo4Master;
00041 class TMutex;
00042 class TBuffer;
00043 class TGo4BufferQueue;
00044 class TGo4ObjectQueue;
00045 
00046 class TGo4Task : public TGo4ThreadManager, public TGo4CommandReceiver{
00047 
00048 public:
00049     friend class TGo4LocalCommandRunnable; // access to command queue
00050     friend class TGo4Slave; // access to UpdateStatus
00051     friend class TGo4TaskOwner; // set workisstopped flag
00052     
00053     TGo4Task(const char* name, Bool_t blockingmode,
00054                                Bool_t autostart=kFALSE,
00055                                Bool_t autocreate=kTRUE,
00056                                Bool_t ismaster=kFALSE);
00057 
00058     virtual ~TGo4Task();
00059 
00064     virtual void Start();
00065 
00070     virtual void Stop();
00071 
00077     virtual void Quit();
00078 
00084     virtual void KillMain();
00085 
00091     virtual void RestartMain();
00092 
00093     virtual void Terminate (Bool_t termapp=kTRUE);
00094 
00096     virtual void TerminateFast ();
00097 
00102     virtual void ExecuteString(const Text_t* command);
00103 
00104     Bool_t IsMaster()
00105         {
00106            return fbCommandMaster;   
00107         }
00108     
00111     void SetOwner(TGo4TaskOwner* owner);
00112     
00113     virtual TGo4TaskHandler* GetTaskHandler();
00114 
00115     virtual TGo4BufferQueue* GetCommandQueue(const char* task=0);
00116 
00117     virtual TGo4BufferQueue* GetStatusQueue(const char* task=0);
00118 
00119     virtual TGo4BufferQueue* GetDataQueue(const char* task=0);
00120 
00126     void AddUserCommand(TGo4Command* com);
00127 
00132     void AddUserCommandList(TGo4CommandProtoList * comlist);
00133 
00140     TGo4Status * NextStatus(Bool_t wait=kTRUE);
00141 
00148     TObject * NextObject(Bool_t wait=kTRUE);
00149 
00151     virtual TGo4Command* NextCommand();
00152 
00156     void SendObject(TObject * obj, const char* receiver=0);
00157 
00161     virtual void SendStatus(TGo4Status * stat, const char* receiver=0);
00162 
00164     virtual void SendStatusBuffer();
00165 
00172     void SendStatusMessage(Int_t level, Bool_t printout, const char* text, ...);
00173 
00180     void UpdateStatusBuffer();  
00181    
00186     virtual Int_t Initialization();
00187 
00194     virtual TGo4TaskStatus* CreateStatus();
00195 
00199     Bool_t SubmitCommand(const char* name);
00200 
00204     Bool_t SubmitEmergencyCommand(Go4EmergencyCommand_t val);
00205 
00210     Bool_t SubmitEmergencyData(Go4EmergencyCommand_t val, const char* receiver=0);
00211 
00212 
00217     Bool_t SubmitLocalCommand(TGo4Command* com);
00218 
00223     Bool_t SubmitCommand(TGo4Command* com);
00224 
00229     TGo4Command* MakeCommand(const char* name);
00230 
00239     void WakeCommandQueue(Int_t id=0);
00240 
00247     virtual Int_t StartWorkThreads();
00248 
00254     virtual Int_t StopWorkThreads();
00255 
00256 
00257     Bool_t IsWorkStopped(){return fbWorkIsStopped;}
00258 
00259  
00265     virtual void GetStatus();
00266 
00267 
00268     const char* GetCommanderName() const { return fxCommanderName.Data(); }
00269 
00270     TGo4Master* GetMaster()
00271         {
00272            return fxMaster;   
00273         }
00274 
00275     TGo4Slave* GetSlave()
00276         {
00277            return fxSlave;   
00278         }
00279 
00280 
00288     void SendStopBuffers(const char* taskname=0);
00289 
00290 
00291 
00295       static const Int_t fgiTERMID;
00296 
00297 protected:
00298 
00302     virtual TGo4TaskHandlerCommandList*  CreateCommandList();
00303 
00307     TGo4TaskHandlerCommandList * GetPrototype();
00308 
00315     virtual void UpdateStatus(TGo4TaskStatus* state);
00316 
00317     TGo4ObjectQueue* GetLocalCommandQueue()
00318         {
00319            return fxLocalCommandQueue;
00320         }
00321 
00322     void SetMaster(Bool_t on=kTRUE)
00323         {
00324             fbCommandMaster=on;   
00325         }
00326 
00327     void SetWorkIsStopped(Bool_t on){fbWorkIsStopped=on;}
00328 
00333     TMutex * fxStatusMutex;
00334 
00339     TBuffer* fxStatusBuffer;
00340 
00341 
00342 
00343 private:
00344 
00345 
00346   
00347     void SetMaster(TGo4Master* m)
00348         {
00349             if(m) SetMaster(kTRUE);
00350             fxMaster=m;
00351         }
00352 
00353     void SetSlave(TGo4Slave* s)
00354         {
00355             if(s) SetMaster(kFALSE);
00356             fxSlave=s;
00357         }
00358 
00359 
00360 private:
00361 
00365     TGo4TaskHandlerCommandList * fxCommandPrototype;
00366     
00370     TGo4ObjectQueue* fxLocalCommandQueue;
00371 
00378     Bool_t fbCommandMaster;
00379 
00383     TString fxCommanderName;
00384 
00385 
00386 
00388     TGo4Master * fxMaster; 
00389 
00391     TGo4Slave * fxSlave; 
00392 
00394     TGo4TaskOwner * fxOwner;
00395 
00400     Bool_t fbWorkIsStopped;
00401 
00402 
00404     TBuffer* fxStopBuffer; 
00405     
00407     TBuffer* fxQuitBuffer; 
00408         
00409 ClassDef(TGo4Task,1)    
00410 };
00411 #endif //TGO4TASK_H
00412 
00413 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:56:06 2005 for Go4-v2.10-5 by doxygen1.2.15