00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TGo4Command.h"
00017
00018 #include <iostream.h>
00019
00020 #include "TGo4CommandReceiver.h"
00021 #include "Go4Log/TGo4Log.h"
00022
00023 ClassImp(TGo4Command)
00024
00025 char* TGo4Command::fgcMODEDESCRIPTION[]=
00026 {"NOMODE","Observer","Controller","Administrator"};
00027
00028
00029 TGo4Command::TGo4Command(const char* name, const char* description, Int_t id) :
00030 TNamed(name, "This is a TGo4Command")
00031 {
00032 TRACE((12,"TGo4Command::TGo4Command(Text_t * name, Text_t * description, Int_t id)", __LINE__, __FILE__));
00033 SetDescription(description);
00034 SetReceiverName("NoNameReceiver");
00035 SetTaskName("NoNameTask");
00036 fiCommandID = id;
00037 fiVersion = 1;
00038 fbIsSynchron = kFALSE;
00039 fbIsEnabled = kTRUE;
00040 fbIsExclusive = kFALSE;
00041 fbIsLocal = kFALSE;
00042 fiProtection=kGo4ComModeObserver;
00043 fiMode=kGo4ComModeRefused;
00044 }
00045
00046 TGo4Command::TGo4Command() : TNamed()
00047 {
00048 TRACE((12,"TGo4Command::TGo4Command()", __LINE__, __FILE__));
00049 SetDescription("Default command");
00050 SetReceiverName("NoNameReceiver");
00051 SetTaskName("NoNameTask");
00052 fiCommandID = -1;
00053 fiVersion = 1;
00054 fbIsSynchron = kFALSE;
00055 fbIsEnabled = kTRUE;
00056 fbIsExclusive = kFALSE;
00057 fbIsLocal = kFALSE;
00058 fiProtection=kGo4ComModeObserver;
00059 fiMode=kGo4ComModeRefused;
00060 }
00061
00062 TGo4Command::~TGo4Command()
00063 {
00064 TRACE((12,"TGo4Command::~TGo4Command()", __LINE__, __FILE__));
00065 }
00066
00067 Int_t TGo4Command::GetCommandID() const
00068 {
00069 TRACE((10,"Int_t TGo4Command::GetCommandID() const ", __LINE__, __FILE__));
00070 return fiCommandID;
00071 }
00072
00073 void TGo4Command::Help()
00074 {
00075 TRACE((10,"void TGo4Command::Help()", __LINE__, __FILE__));
00076 }
00077
00078 Bool_t TGo4Command::IsEnabled() const
00079 {
00080 TRACE((10,"Bool_t TGo4Command::IsEnabled() const", __LINE__, __FILE__));
00081 return fbIsEnabled;
00082 }
00083
00084 Bool_t TGo4Command::IsExclusive() const
00085 {
00086 TRACE((10,"Bool_t TGo4Command::IsExclusive() const", __LINE__, __FILE__));
00087 return fbIsExclusive;
00088 }
00089
00090 const char* TGo4Command::GetReceiverName() const
00091 {
00092 TRACE((10,"const Text_t * TGo4Command::GetReceiverName()", __LINE__, __FILE__));
00093 return fxReceiverName.Data();
00094 }
00095
00096 void TGo4Command::SetReceiverName(const char* name)
00097 {
00098 TRACE((10,"void TGo4Command::SetReceiverName(const char*)", __LINE__, __FILE__));
00099 fxReceiverName = name;
00100 }
00101
00102 const char* TGo4Command::GetTaskName() const
00103 {
00104 TRACE((10,"const Text_t * TGo4Command::GetTaskName()", __LINE__, __FILE__));
00105 return fxTaskName.Data();
00106 }
00107
00108 void TGo4Command::SetTaskName(const char* name)
00109 {
00110 TRACE((10,"void TGo4Command::SetTaskName(const char*)", __LINE__, __FILE__));
00111 fxTaskName=name;
00112 }
00113
00114 void TGo4Command::SetDescription(const char* txt)
00115 {
00116 TRACE((10,"void TGo4Command::SetDescription(const char*)", __LINE__, __FILE__));
00117 fxDescription = txt;
00118 }
00119 const char* TGo4Command::What() const
00120 {
00121 TRACE((10,"const Text_t * TGo4Command::What()", __LINE__, __FILE__));
00122 return fxDescription.Data();
00123 }
00124
00125 Int_t TGo4Command::ExeCom()
00126 {
00127 TRACE((10,"Int_t TGo4Command::ExeCom()", __LINE__, __FILE__));
00128 cout << What() << endl;
00129 return 0;
00130 }
00131
00132 Int_t TGo4Command::UnExeCom()
00133 {
00134 TRACE((10,"Int_t TGo4Command::UnExeCom()", __LINE__, __FILE__));
00135 return 0;
00136 }
00137
00138 Int_t TGo4Command::RefuseCom()
00139 {
00140 TGo4Log::Warn("Not allowed to execute %s in mode %d:%s",
00141 GetName(), GetMode(), GetModeDescription(GetMode()));
00142 return 0;
00143 }
00144
00145 Bool_t TGo4Command::Log(Int_t mode)
00146 {
00147 TRACE((10,"Bool_t TGo4Command::Log(Int_t mode)", __LINE__, __FILE__));
00148 switch (mode)
00149 {
00150 case 0:
00151 cout << What() << endl;
00152 break;
00153 default:
00154 break;
00155 }
00156 return kTRUE;
00157 }
00158
00159 Bool_t TGo4Command::IsSynchron() const
00160 {
00161 TRACE((10,"Bool_t TGo4Command::IsSynchron() const", __LINE__, __FILE__));
00162 return fbIsSynchron;
00163 }
00164
00165 Bool_t TGo4Command::IsLocal() const
00166 {
00167 return fbIsLocal;
00168 }
00169
00170
00171 void TGo4Command::SetReceiver(TGo4CommandReceiver * rec)
00172 {
00173 TRACE((12,"void TGo4Command::SetReceiver(TGo4CommandReceiver * rec)", __LINE__, __FILE__));
00174 fxReceiverBase = rec;
00175 }
00176
00177
00178 const char* TGo4Command::GetModeDescription(Go4CommandMode_t mode)
00179 {
00180 if(mode<0 || mode>3) return 0;
00181 return fgcMODEDESCRIPTION[mode];
00182 }
00183
00184
00185