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