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