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