GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
TGo4Slave.cxx
Go to the documentation of this file.
1// $Id$
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#include "TGo4Slave.h"
15
16#include "TROOT.h"
17
18#include "TGo4Log.h"
19#include "TGo4TaskStatus.h"
20#include "TGo4ServerTask.h"
21#include "TGo4ClientTask.h"
22#include "TGo4CommandInvoker.h"
24
25TGo4Slave::TGo4Slave(const char *name, Bool_t isserver, const char *serverhost, UInt_t negotport) :
26 TGo4TaskOwner(isserver),
27 fbMainIsRunning(kTRUE)
28{
29 TGo4CommandInvoker::Instance(); // make sure a command invoker exists
30 TGo4CommandInvoker::SetCommandList(new TGo4TaskHandlerCommandList("ListOfTaskHandlerCommands"));
31 TGo4CommandInvoker::Register("SlaveTask", this);
32 TGo4Task* task = nullptr;
33 if(IsServer()) {
34 task = new TGo4ServerTask(name, negotport,
35 kFALSE, //blockingmode
36 kFALSE, //standalone
37 kTRUE, //autostart
38 kTRUE, //autocreate
39 kFALSE //ismaster
40 );
41 } else {
42 task = new TGo4ClientTask(name, serverhost, negotport,
43 kFALSE, //blockingmode
44 kFALSE, //standalone
45 kFALSE, //autostart
46 kTRUE, //autocreate
47 kFALSE, //ismaster
48 kTRUE );//autoconnect
49 }
50 SetTask(task);
51}
52
56
61
62
64{
65 TGo4Log::Debug(" Slave ''%s'' default Start method, please override",GetName());
66 fbMainIsRunning = kTRUE;
67}
68
69
71{
72 TGo4Log::Debug(" Slave ''%s'' default Stop method, please override",GetName());
73 fbMainIsRunning = kFALSE;
74}
75
77{
78// may be overridden by concrete slave implementation
79
80}
82{
83// may be overridden by concrete slave implementation
84}
85
86void TGo4Slave::Terminate (Bool_t termapp)
87{
88 if(GetTask())
89 GetTask()->TGo4ThreadManager::Terminate(termapp);
90}
91
93{
94 Terminate();
95}
96
98{
100 UpdateStatus(stat); // set the internals
101 return stat;
102}
103
105{
106 if(GetTask())
107 GetTask()->UpdateStatus(state);
108}
109
111{
112 return GetTask() ? GetTask()->NextCommand() : nullptr;
113}
114
115void TGo4Slave::SendObject(TObject *obj, const char *receiver)
116{
117 if(GetTask())
118 GetTask()->SendObject(obj, receiver);
119}
120
121void TGo4Slave::SendStatus(TGo4Status *stat, const char *receiver)
122{
123 if(GetTask())
124 GetTask()->SendStatus(stat, receiver);
125}
126
128{
129 // may be overridden by concrete slave implementation
130 return 0;
131}
132
137
138
143
144
145void TGo4Slave::SendStatusMessage(Int_t level, Bool_t printout, const TString &text)
146{
147 if(GetTask())
148 GetTask()->SendStatusMessage(level, printout, "%s", text.Data());
149}
150
151
156
157void TGo4Slave::ExecuteString(const char *command)
158{
159 gROOT->ProcessLineSync(command);
160}
This class controls a client application running in a task which is controlled by another server task...
static TGo4CommandInvoker * Instance()
static void SetCommandList(TGo4CommandProtoList *list)
Application may exchange standard command list by own subclass with specialized commands,...
static void UnRegister(TGo4CommandReceiver *p)
static void Register(const char *name, TGo4CommandReceiver *p)
This is the Go4 Abstract Command Class; part of the Base command pattern.
Definition TGo4Command.h:35
static void Debug(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 0.
Definition TGo4Log.cxx:281
virtual TGo4TaskStatus * CreateStatus()
create a status object with information on the current (slave) task.
Definition TGo4Slave.cxx:97
virtual void TerminateFast()
Definition TGo4Slave.cxx:92
virtual void Terminate(Bool_t termapp=kTRUE)
Definition TGo4Slave.cxx:86
virtual void Start()
General start method of slave application to be called from remote command; should be re-implemented ...
Definition TGo4Slave.cxx:63
virtual ~TGo4Slave()
Definition TGo4Slave.cxx:57
virtual Int_t Initialization()
Overrides the ThreadManager Initialization; is used to setup the client connections on demand; checks...
virtual void SendStatusMessage(Int_t level, Bool_t printout, const TString &text)
Send message string in a status object to the gui.
void SendStatus(TGo4Status *stat, const char *receiver=nullptr)
Send status object via status channel to the server.
virtual void KillMain()
Kill the main thread; method to be called from command, should be overridden in user implementation.
Definition TGo4Slave.cxx:76
TGo4ThreadHandler * GetThreadHandler()
void SendStatusBuffer()
Send internal status buffer to the server.
virtual void UpdateStatus(TGo4TaskStatus *state)
method needed by method CreateStatus of any status subclasses to set the values of the clienttask spe...
TGo4Command * NextCommand()
Delivers next command from command queue.
void SendObject(TObject *obj, const char *receiver=nullptr)
Send object via data channel to the server.
virtual void ExecuteString(const char *command)
Execute string command.
virtual void Stop()
General stop method of slave application to be called from remote command; should be re-implemented b...
Definition TGo4Slave.cxx:70
Bool_t fbMainIsRunning
True if analysis main loop is running.
Definition TGo4Slave.h:40
void UpdateStatusBuffer()
Create status object and stream it into the status send buffer.
virtual void RestartMain()
Restart the main thread; method to be called from command, should be overridden in user implementatio...
Definition TGo4Slave.cxx:81
Class containing all command prototypes of the TaskHandler system commands (and the basic test comman...
Bool_t IsServer() const
TGo4Task * GetTask() const
friend class TGo4Task
friend class TGo4ServerTask
void SetTask(TGo4Task *task, Bool_t delold=kTRUE)
const char * GetName() const
Task status.
virtual TGo4Command * NextCommand()
Delivers next command from command queue.
Definition TGo4Task.cxx:325
virtual void SendStatus(TGo4Status *stat, const char *receiver=nullptr)
Send status object via status channel to the master.
Definition TGo4Task.cxx:246
virtual void SendStatusBuffer()
Send internal status buffer to the master(s).
Definition TGo4Task.cxx:263
void SendStatusMessage(Int_t level, Bool_t printout, const char *text,...)
Send message string in a status object to the gui.
Definition TGo4Task.cxx:272
virtual void UpdateStatus(TGo4TaskStatus *state)
method needed by method CreateStatus of any status subclasses to set the values of the clienttask spe...
Definition TGo4Task.cxx:393
void SendObject(TObject *obj, const char *receiver=nullptr)
Send object via data channel to the master.
Definition TGo4Task.cxx:222
void UpdateStatusBuffer()
Create status object and stream it into the status send buffer.
Definition TGo4Task.cxx:308
Go4 thread handler.
TGo4ThreadHandler * GetWorkHandler() const
Access to ThreadHandler for working threads.