GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
TGo4Master.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 "TGo4Master.h"
15
16#include "TGo4ServerTask.h"
17#include "TGo4ClientTask.h"
18#include "TGo4CommandInvoker.h"
20
25
26TGo4Master::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 = nullptr;
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
54
56{
57 return new TGo4TaskHandlerCommandList("Go4ServerTaskDefaultCommandList");
58}
59
60Bool_t TGo4Master::SubmitCommand(const char *name)
61{
62 if (!GetTask()) return kFALSE;
63 return GetTask()->SubmitCommand(name);
64}
65
67{
68 if (!GetTask()) return kFALSE;
69 return GetTask()->SubmitEmergencyCommand(val);
70}
71
73{
74 if (!GetTask()) return kFALSE;
75 return GetTask()->SubmitCommand(com);
76}
77
78Bool_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}
Go4EmergencyCommand_t
This class controls a client application running in a task which is controlled by another server task...
Bool_t DisconnectServer(Bool_t isterminating=kFALSE)
Disconnect the current server task, but do not terminate the client.
static TGo4CommandInvoker * Instance()
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
virtual Bool_t DisconnectSlave(const char *name=nullptr, Bool_t waitforslave=kTRUE)
Bool_t SubmitEmergencyCommand(Go4EmergencyCommand_t val)
send emergency quit command to the current slave task
Bool_t SubmitCommand(const char *name)
send command specified by name to the current slave task
virtual ~TGo4Master()
virtual TGo4TaskHandlerCommandList * CreateCommandList()
factory method for command list; overridden by implementation
virtual Bool_t RemoveClient(const char *name, Bool_t clientwait=kTRUE, Bool_t isterminating=kFALSE)
Remove the client task specified by name from this server.
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)
Bool_t SubmitEmergencyCommand(Go4EmergencyCommand_t val)
send emergency quit command to the current client task
Definition TGo4Task.cxx:433
void Terminate(Bool_t termapp=kTRUE) override
deletes the Manager instance via Control timer.
Definition TGo4Task.cxx:130
Bool_t SubmitCommand(const char *name)
send command specified by name to the current client task
Definition TGo4Task.cxx:409