GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
TGo4Command.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 "TGo4Command.h"
15
16#include <iostream>
17
18#include "TGo4Log.h"
19
21 {"NOMODE","Observer","Controller","Administrator"};
22
23
24TGo4Command::TGo4Command(const char *name, const char *description, Int_t id) :
25 TNamed(name, "This is a TGo4Command")
26{
27 GO4TRACE((12,"TGo4Command::TGo4Command(const char *name, const char *description, Int_t id)", __LINE__, __FILE__));
28 SetDescription(description);
29 SetReceiverName("NoNameReceiver");
30 SetTaskName("NoNameTask");
31 fiCommandID = id;
32 fiVersion = 1;
33 fbIsSynchron = kFALSE;
34 fbIsEnabled = kTRUE;
35 fbIsExclusive = kFALSE;
36 fbIsLocal = kFALSE;
39 fxReceiverBase = nullptr;
40}
41
43{
44 GO4TRACE((12,"TGo4Command::TGo4Command()", __LINE__, __FILE__));
45 SetDescription("Default command");
46 SetReceiverName("NoNameReceiver");
47 SetTaskName("NoNameTask");
48 fiCommandID = -1;
49 fiVersion = 1;
50 fbIsSynchron = kFALSE;
51 fbIsEnabled = kTRUE;
52 fbIsExclusive = kFALSE;
53 fbIsLocal = kFALSE;
56 fxReceiverBase = nullptr;
57}
58
60{
61 GO4TRACE((12,"TGo4Command::~TGo4Command()", __LINE__, __FILE__));
62}
63
65{
66 GO4TRACE((10,"Int_t TGo4Command::GetCommandID() const ", __LINE__, __FILE__));
67 return fiCommandID;
68}
69
71{
72 GO4TRACE((10,"void TGo4Command::Help()", __LINE__, __FILE__));
73}
74
76{
77 GO4TRACE((10,"Bool_t TGo4Command::IsEnabled() const", __LINE__, __FILE__));
78 return fbIsEnabled;
79}
80
82{
83 GO4TRACE((10,"Bool_t TGo4Command::IsExclusive() const", __LINE__, __FILE__));
84 return fbIsExclusive;
85}
86
88{
89 GO4TRACE((10,"const char *TGo4Command::GetReceiverName()", __LINE__, __FILE__));
90 return fxReceiverName.Data();
91}
92
93void TGo4Command::SetReceiverName(const char *name)
94{
95 GO4TRACE((10,"void TGo4Command::SetReceiverName(const char *)", __LINE__, __FILE__));
96 fxReceiverName = name;
97}
98
99const char *TGo4Command::GetTaskName() const
100{
101 GO4TRACE((10,"const char *TGo4Command::GetTaskName()", __LINE__, __FILE__));
102 return fxTaskName.Data();
103}
104
105void TGo4Command::SetTaskName(const char *name)
106{
107 GO4TRACE((10,"void TGo4Command::SetTaskName(const char *)", __LINE__, __FILE__));
108 fxTaskName=name;
109}
110
111void TGo4Command::SetDescription(const char *txt)
112{
113 GO4TRACE((10,"void TGo4Command::SetDescription(const char *)", __LINE__, __FILE__));
114 fxDescription = txt;
115}
116
117const char *TGo4Command::What() const
118{
119 GO4TRACE((10,"const char *TGo4Command::What()", __LINE__, __FILE__));
120 return fxDescription.Data();
121}
122
124{
125 GO4TRACE((10,"Int_t TGo4Command::ExeCom()", __LINE__, __FILE__));
126 std::cout << What() << std::endl;
127 return 0;
128}
129
131{
132 TGo4Log::Warn("Not allowed to execute %s in mode %d:%s",
133 GetName(), GetMode(), GetModeDescription(GetMode()));
134 return 0;
135}
136
137Bool_t TGo4Command::Log(Int_t mode)
138{
139 GO4TRACE((10,"Bool_t TGo4Command::Log(Int_t mode)", __LINE__, __FILE__));
140 switch (mode) {
141 case 0:
142 std::cout << What() << std::endl;
143 break;
144 default:
145 break;
146 }
147 return kTRUE;
148}
149
151{
152 GO4TRACE((10,"Bool_t TGo4Command::IsSynchron() const", __LINE__, __FILE__));
153 return fbIsSynchron;
154}
155
157{
158 return fbIsLocal;
159}
160
161
163{
164 GO4TRACE((12,"void TGo4Command::SetReceiver(TGo4CommandReceiver *)", __LINE__, __FILE__));
165 fxReceiverBase = rec;
166}
167
168
170{
171 if(mode<0 || mode>3) return nullptr;
172 return fgcMODEDESCRIPTION[mode];
173}
174
175
177{
178// please override this function!
179
180}
Go4CommandMode_t
These values define command execution rights.
Definition TGo4Command.h:27
@ kGo4ComModeRefused
Definition TGo4Command.h:28
@ kGo4ComModeObserver
Definition TGo4Command.h:29
#define GO4TRACE(X)
Definition TGo4Log.h:25
TString fxDescription
Int_t fiCommandID
Definition TGo4Command.h:95
Bool_t fbIsExclusive
Definition TGo4Command.h:91
Bool_t IsLocal() const
static const char * GetModeDescription(Go4CommandMode_t mode)
text description of current execution mode
Bool_t fbIsLocal
Definition TGo4Command.h:93
virtual Bool_t Log(Int_t mode=0)
virtual Int_t RefuseCom()
Optional action if command is not allowed (warning message e.g.)
const char * What() const
TGo4CommandReceiver * fxReceiverBase
virtual void Set(TGo4RemoteCommand *remcon)
Set internals of this command from specification of external remote command (command container).
Bool_t IsExclusive() const
Bool_t IsSynchron() const
void SetDescription(const char *)
Bool_t fbIsSynchron
Definition TGo4Command.h:92
static const char * fgcMODEDESCRIPTION[]
resolve description of command modes here
Definition TGo4Command.h:20
virtual Int_t ExeCom()
Do the command action.
TString fxReceiverName
Bool_t fbIsEnabled
Definition TGo4Command.h:90
void SetReceiverName(const char *)
virtual void SetReceiver(TGo4CommandReceiver *rec)
Go4CommandMode_t fiProtection
Execute protection of this command.
TString fxTaskName
const char * GetTaskName() const
virtual ~TGo4Command()
Bool_t IsEnabled() const
Go4CommandMode_t GetMode() const
Definition TGo4Command.h:76
Go4CommandMode_t fiMode
mode value for execution rights of sending task
Definition TGo4Command.h:99
void SetTaskName(const char *)
const char * GetReceiverName() const
Int_t GetCommandID() const
Int_t fiVersion
Definition TGo4Command.h:96
virtual void Help()
static void Warn(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 2.
Definition TGo4Log.cxx:307
This command is a container for commands to be send from master to slave via inter-process transport.