23 #include "TGo4LockGuard.h"
43 fbCommandMaster(ismaster), fxMaster(0), fxSlave(0),fxOwner(0),
44 fbWorkIsStopped(kFALSE),fxStopBuffer(0),fxQuitBuffer(0)
64 TString nomen(
"LocalCommandRunnable of "); nomen+=name;
101 SetMaster(dynamic_cast<TGo4Master*>(owner));
102 SetSlave(dynamic_cast<TGo4Slave*>(owner));
151 gROOT->ProcessLineSync(command);
188 if(!wait && statqueue->
IsEmpty())
return 0;
192 if(obj->InheritsFrom(TGo4Status::Class()))
198 TGo4Log::Debug(
" !!! Master Task: NextStatus ERROR, unknown object %s from status queue!!! ",
205 TGo4Log::Debug(
" !!! Master Task NextStatus ERROR -- NULL object from data queue!!! ");
224 if(!wait && dataqueue->
IsEmpty())
267 TGo4Log::Debug(
" !!! Task - ERROR sending object - no data queue !!! ");
287 TGo4Log::Debug(
" !!! Task - ERROR sending status: no status queue !!! ");
310 va_start(args, text);
311 vsnprintf(txtbuf, lbuflen, text, args);
316 TString receiver=txtbuf;
317 Ssiz_t pos=receiver.Index(
"::",2,0,TString::kExact);
320 receiver.Resize(pos);
321 dest=receiver.Data();
322 curs += ((size_t) pos);
332 if((level>0) && (go4mess!=0)) {
345 TFile *filsav = gFile;
362 if(comq==0)
return 0;
370 if(obj->InheritsFrom(TGo4Command::Class()))
409 TGo4Log::Debug(
" Task -- command list is created from Master factory");
414 TGo4Log::Debug(
" Task -- command list is created from Task factory");
442 if(!strcmp(name,
"THEMQuit"))
446 else if (!strcmp(name,
"THEMKill"))
450 else if (!strcmp(name,
"THEMRestart"))
515 if (com==0)
return kFALSE;
548 if(com==0)
return kFALSE;
570 com=
new TGo4Command(
"dummy",
"this wakes up queue",
id);
578 TGo4Log::Debug(
" Task ''%s'' Send Status to Command Master ",GetName());
virtual void UpdateStatus(TGo4TaskStatus *state)
virtual Int_t Initialization()
virtual Int_t Initialization()
virtual void ExecuteString(const char *command)
virtual void Terminate(Bool_t termapp=kTRUE)
virtual Int_t StartWorkThreads()
const char * GetCommanderName() const
virtual void TerminateFast()
void AddObject(TObject *object, Bool_t clone=kFALSE)
TGo4Command * MakeCommand(const char *name)
Bool_t SubmitLocalCommand(TGo4Command *com)
virtual TGo4TaskStatus * CreateStatus()
TObject * WaitObjectFromBuffer()
void WakeCommandQueue(Int_t id=0)
void SetSlave(TGo4Slave *s)
virtual Int_t Initialization()
static void SetCommandList(TGo4CommandProtoList *list)
static void UnRegister(TGo4CommandReceiver *p)
friend class TGo4LocalCommandRunnable
virtual TGo4Command * NextCommand()
TGo4ThreadHandler * fxWorkHandler
void SetTaskName(const char *)
virtual void TerminateFast()
TGo4ObjectQueue * fxLocalCommandQueue
TGo4TaskHandlerCommandList * fxCommandPrototype
Bool_t IsAborting() const
static Bool_t IsOutputEnabled()
TGo4ObjectQueue * GetLocalCommandQueue()
virtual TGo4TaskHandler * GetTaskHandler()
static void Register(const char *name, TGo4CommandReceiver *p)
void SendStopBuffers(const char *taskname=0)
static void OutputEnable(Bool_t on=kTRUE)
virtual void RestartMain()
Bool_t NewThread(const char *name, TGo4Runnable *runnable)
virtual TGo4TaskHandlerCommandList * CreateCommandList()
virtual void ExecuteString(const char *command)
virtual Int_t StopWorkThreads()
int main(int argc, char **argv)
static const Int_t fgiTERMID
virtual Int_t StopWorkThreads()
virtual void TerminateFast()
void SetTaskHandlerStatus(TGo4TaskHandlerStatus *thstate)
virtual void SendStatusBuffer()
virtual TGo4BufferQueue * GetDataQueue(const char *task=0)
void SendObject(TObject *obj, const char *receiver=0)
virtual void SendStatus(TGo4Status *stat, const char *receiver=0)
Bool_t SubmitCommand(const char *name)
static TGo4CommandInvoker * Instance()
virtual TGo4BufferQueue * GetCommandQueue(const char *task=0)
TGo4ThreadHandler * GetWorkHandler() const
Bool_t SubmitEmergencyCommand(Go4EmergencyCommand_t val)
void AddBuffer(TBuffer *buffer, Bool_t clone=kFALSE)
void SetOwner(TGo4TaskOwner *owner)
static const char * Message(Int_t prio, const char *text,...)
void AddUserCommandList(TGo4CommandProtoList *comlist)
virtual TGo4TaskHandlerCommandList * CreateCommandList()
Bool_t Start(const char *thname)
TGo4Task(const char *name, Bool_t blockingmode, Bool_t autostart=kFALSE, Bool_t autocreate=kTRUE, Bool_t ismaster=kFALSE)
void SendStatusMessage(Int_t level, Bool_t printout, const char *text,...)
void SetMaster(Bool_t on=kTRUE)
virtual TGo4TaskHandlerStatus * CreateStatus()
TObject * NextObject(Bool_t wait=kTRUE)
virtual TGo4BufferQueue * GetStatusQueue(const char *task=0)
void SetFlags(Bool_t blocking, Bool_t autocreate, Bool_t autostart, Bool_t terminating, Bool_t initdone)
void AddCommand(TGo4Command *com)
virtual void Terminate(Bool_t termapp=kTRUE)
virtual void RestartMain()
void AddUserCommand(TGo4Command *com)
void SetTask(TGo4Task *task, Bool_t delold=kTRUE)
virtual TGo4TaskStatus * CreateStatus()
void UpdateStatusBuffer()
TGo4Command * MakeCommand(const char *name)
TGo4TaskHandlerCommandList * GetPrototype()
static TBuffer * CreateValueBuffer(UInt_t val)
TGo4Status * NextStatus(Bool_t wait=kTRUE)
static Int_t Get_fgiTERMID()
void SetMode(Go4CommandMode_t m)
Bool_t SubmitEmergencyData(Go4EmergencyCommand_t val, const char *receiver=0)
void AddBufferFromObject(TObject *object)
virtual Int_t StartWorkThreads()
virtual void Terminate(Bool_t termapp=kTRUE)
static void Debug(const char *text,...)