GSI Object Oriented Online Offline (Go4)  GO4-6.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4Master.cxx
Go to the documentation of this file.
1 // $Id: TGo4Master.cxx 2757 2020-04-16 11:45:21Z 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 #include "TGo4Master.h"
15 
16 #include "TGo4ServerTask.h"
17 #include "TGo4ClientTask.h"
18 #include "TGo4CommandInvoker.h"
20 
23 {
24 }
25 
26 TGo4Master::TGo4Master(const char* name, Bool_t isserver, const char* serverhost, UInt_t negotport)
27 : TGo4TaskOwner(isserver)
28 {
29  TGo4CommandInvoker::Instance(); // make sure a command invoker exists
30  TGo4CommandInvoker::Register("MasterTask", this);
31  TGo4Task* task(0);
32  if(IsServer())
33  task = new TGo4ServerTask(name, negotport,
34  kFALSE, //blockingmode
35  kFALSE, //standalone
36  kTRUE, //autostart
37  kTRUE, //autocreate
38  kTRUE); //ismaster
39  else
40  task = new TGo4ClientTask(name, serverhost, negotport,
41  kFALSE, //blockingmode
42  kFALSE, //standalone
43  kFALSE, //autostart
44  kTRUE, //autocreate
45  kTRUE, //ismaster
46  kFALSE); // autoconnect
47  SetTask(task);
48 }
49 
51 {
53 }
54 
56 {
57  return new TGo4TaskHandlerCommandList("Go4ServerTaskDefaultCommandList");
58 }
59 
60 Bool_t TGo4Master::SubmitCommand(const char* name)
61 {
62  if (GetTask()==0) return kFALSE;
63  return GetTask()->SubmitCommand(name);
64 }
65 
67 {
68  if (GetTask()==0) return kFALSE;
69  return GetTask()->SubmitEmergencyCommand(val);
70 }
71 
73 {
74  if (GetTask()==0) return kFALSE;
75  return GetTask()->SubmitCommand(com);
76 }
77 
78 Bool_t TGo4Master::DisconnectSlave(const char* name, Bool_t waitforslave)
79 {
80  Bool_t rev=kTRUE;
81  if(IsServer()) {
82  TGo4ServerTask* server = dynamic_cast<TGo4ServerTask*> (GetTask());
83  if(server)
84  rev=server->RemoveClient(name, waitforslave); //waitforclient
85  else
86  rev=kFALSE;
87  } else {
88  TGo4ClientTask* client = dynamic_cast<TGo4ClientTask*> (GetTask());
89  if(client) {
90  rev=client->DisconnectServer();
91  client->Terminate(kFALSE); // terminate taskowner (TGo4Display), but not application
92  } else
93  rev=kFALSE;
94  }
95  return rev;
96 }
virtual Bool_t RemoveClient(const char *name, Bool_t clientwait=kTRUE, Bool_t isterminating=kFALSE)
Go4EmergencyCommand_t
Bool_t DisconnectServer(Bool_t isterminating=kFALSE)
static void UnRegister(TGo4CommandReceiver *p)
virtual Bool_t DisconnectSlave(const char *name=0, Bool_t waitforslave=kTRUE)
Definition: TGo4Master.cxx:78
static void Register(const char *name, TGo4CommandReceiver *p)
virtual TGo4TaskHandlerCommandList * CreateCommandList()
Definition: TGo4Master.cxx:55
Bool_t IsServer()
Definition: TGo4TaskOwner.h:39
friend class TGo4ServerTask
Definition: TGo4TaskOwner.h:29
Bool_t SubmitCommand(const char *name)
Definition: TGo4Task.cxx:423
static TGo4CommandInvoker * Instance()
Bool_t SubmitEmergencyCommand(Go4EmergencyCommand_t val)
Definition: TGo4Master.cxx:66
TGo4Task * GetTask()
Definition: TGo4TaskOwner.h:41
Bool_t SubmitEmergencyCommand(Go4EmergencyCommand_t val)
Definition: TGo4Task.cxx:452
virtual ~TGo4Master()
Definition: TGo4Master.cxx:50
virtual void Terminate(Bool_t termapp=kTRUE)
Definition: TGo4Task.cxx:131
void SetTask(TGo4Task *task, Bool_t delold=kTRUE)
Bool_t SubmitCommand(const char *name)
Definition: TGo4Master.cxx:60