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 GO4TRACE((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 GO4TRACE((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 GO4TRACE((12,"TGo4Command::~TGo4Command()", __LINE__, __FILE__));
00061 }
00062
00063 Int_t TGo4Command::GetCommandID() const
00064 {
00065 GO4TRACE((10,"Int_t TGo4Command::GetCommandID() const ", __LINE__, __FILE__));
00066 return fiCommandID;
00067 }
00068
00069 void TGo4Command::Help()
00070 {
00071 GO4TRACE((10,"void TGo4Command::Help()", __LINE__, __FILE__));
00072 }
00073
00074 Bool_t TGo4Command::IsEnabled() const
00075 {
00076 GO4TRACE((10,"Bool_t TGo4Command::IsEnabled() const", __LINE__, __FILE__));
00077 return fbIsEnabled;
00078 }
00079
00080 Bool_t TGo4Command::IsExclusive() const
00081 {
00082 GO4TRACE((10,"Bool_t TGo4Command::IsExclusive() const", __LINE__, __FILE__));
00083 return fbIsExclusive;
00084 }
00085
00086 const char* TGo4Command::GetReceiverName() const
00087 {
00088 GO4TRACE((10,"const char * TGo4Command::GetReceiverName()", __LINE__, __FILE__));
00089 return fxReceiverName.Data();
00090 }
00091
00092 void TGo4Command::SetReceiverName(const char* name)
00093 {
00094 GO4TRACE((10,"void TGo4Command::SetReceiverName(const char*)", __LINE__, __FILE__));
00095 fxReceiverName = name;
00096 }
00097
00098 const char* TGo4Command::GetTaskName() const
00099 {
00100 GO4TRACE((10,"const char * TGo4Command::GetTaskName()", __LINE__, __FILE__));
00101 return fxTaskName.Data();
00102 }
00103
00104 void TGo4Command::SetTaskName(const char* name)
00105 {
00106 GO4TRACE((10,"void TGo4Command::SetTaskName(const char*)", __LINE__, __FILE__));
00107 fxTaskName=name;
00108 }
00109
00110 void TGo4Command::SetDescription(const char* txt)
00111 {
00112 GO4TRACE((10,"void TGo4Command::SetDescription(const char*)", __LINE__, __FILE__));
00113 fxDescription = txt;
00114 }
00115 const char* TGo4Command::What() const
00116 {
00117 GO4TRACE((10,"const char * TGo4Command::What()", __LINE__, __FILE__));
00118 return fxDescription.Data();
00119 }
00120
00121 Int_t TGo4Command::ExeCom()
00122 {
00123 GO4TRACE((10,"Int_t TGo4Command::ExeCom()", __LINE__, __FILE__));
00124 std::cout << What() << std::endl;
00125 return 0;
00126 }
00127
00128 Int_t TGo4Command::RefuseCom()
00129 {
00130 TGo4Log::Warn("Not allowed to execute %s in mode %d:%s",
00131 GetName(), GetMode(), GetModeDescription(GetMode()));
00132 return 0;
00133 }
00134
00135 Bool_t TGo4Command::Log(Int_t mode)
00136 {
00137 GO4TRACE((10,"Bool_t TGo4Command::Log(Int_t mode)", __LINE__, __FILE__));
00138 switch (mode) {
00139 case 0:
00140 std::cout << What() << std::endl;
00141 break;
00142 default:
00143 break;
00144 }
00145 return kTRUE;
00146 }
00147
00148 Bool_t TGo4Command::IsSynchron() const
00149 {
00150 GO4TRACE((10,"Bool_t TGo4Command::IsSynchron() const", __LINE__, __FILE__));
00151 return fbIsSynchron;
00152 }
00153
00154 Bool_t TGo4Command::IsLocal() const
00155 {
00156 return fbIsLocal;
00157 }
00158
00159
00160 void TGo4Command::SetReceiver(TGo4CommandReceiver * rec)
00161 {
00162 GO4TRACE((12,"void TGo4Command::SetReceiver(TGo4CommandReceiver * rec)", __LINE__, __FILE__));
00163 fxReceiverBase = rec;
00164 }
00165
00166
00167 const char* TGo4Command::GetModeDescription(Go4CommandMode_t mode)
00168 {
00169 if(mode<0 || mode>3) return 0;
00170 return fgcMODEDESCRIPTION[mode];
00171 }
00172
00173
00174 void TGo4Command::Set(TGo4RemoteCommand*)
00175 {
00176
00177
00178 }