00001 #ifndef baciTestUtils_h
00002 #define baciTestUtils_h
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00041 #ifndef __cplusplus
00042 #error This is a C++ include file and cannot be used from plain C
00043 #endif
00044
00045 #include <tao/corba.h>
00046 #include <ace/Read_Buffer.h>
00047
00048 #include <string>
00049 #include <baci.h>
00050
00051 class baciTestCBvoid: public virtual POA_ACS::CBvoid
00052 {
00053 public:
00054 baciTestCBvoid(std::string _prop) : prop(_prop) {}
00055
00056 virtual void working (const ACSErr::Completion & c,
00057 const ACS::CBDescOut & desc
00058 )
00059 {
00060 ACS_SHORT_LOG((LM_INFO, "(%s::CBvoid::working)", prop.c_str()));
00061 }
00062
00063 virtual void done (const ACSErr::Completion & c,
00064 const ACS::CBDescOut & desc
00065 )
00066 {
00067 ACS_SHORT_LOG ((LM_INFO, "(%s::CBvoid::done)", prop.c_str()));
00068 }
00069
00070 virtual CORBA::Boolean negotiate (ACS::TimeInterval time_to_transmit,
00071 const ACS::CBDescOut & desc
00072 )
00073 {
00074 return true;
00075 }
00076
00077 protected:
00078 std::string prop;
00079
00080 };
00081
00082 class baciTestCBdouble: public virtual POA_ACS::CBdouble
00083 {
00084
00085 public:
00086 baciTestCBdouble(std::string _prop, int c=5, int dc=1) : prop(_prop), count(c), done_c(dc) {}
00087
00088 virtual void working (
00089 CORBA::Double value,
00090 const ACSErr::Completion & c,
00091 const ACS::CBDescOut & desc
00092 )
00093 {
00094 if (count>0)
00095 {
00096 CompletionImpl completion(c);
00097 if (completion.isErrorFree())
00098 {
00099 ACS_SHORT_LOG((LM_INFO, "(%s::CBdouble::working) desc.id_tag: %u Value: %f TimeStamp: %s",
00100 prop.c_str(), (unsigned)desc.id_tag, value, getStringifiedUTC(c.timeStamp).c_str()));
00101 }
00102 else
00103 {
00104 ACS_SHORT_LOG((LM_INFO, "(%s::CBdouble::working) desc.id_tag: %u TimeStamp: %s containes an error", prop.c_str(), (unsigned)desc.id_tag, getStringifiedUTC(c.timeStamp).c_str()));
00105 completion.log();
00106 }
00107 }
00108 count--;
00109 }
00110
00111 virtual void done (
00112 CORBA::Double value,
00113 const ACSErr::Completion & c,
00114 const ACS::CBDescOut & desc
00115 )
00116 {
00117 if (done_c > 0 )
00118 {
00119 ACS_SHORT_LOG((LM_INFO, "(%s::CBdouble::done) desc.id_tag: %u Value: %f TimeStamp: %s",
00120 prop.c_str(), (unsigned)desc.id_tag, value, getStringifiedUTC(c.timeStamp).c_str()));
00121 }
00122 done_c--;
00123 }
00124
00125
00126 virtual CORBA::Boolean negotiate (
00127 ACS::TimeInterval time_to_transmit,
00128 const ACS::CBDescOut & desc
00129 )
00130 {
00131 return 1;
00132 }
00133
00134 int getCount(){ return count+done_c;}
00135 protected:
00136 std::string prop;
00137 int count, done_c;
00138
00139 };
00140
00141 class baciTestCBfloat: public virtual POA_ACS::CBfloat
00142 {
00143
00144 public:
00145 baciTestCBfloat(std::string _prop, int c=5, int dc=1) : prop(_prop), count(c), done_c(dc) {}
00146
00147 virtual void working (
00148 CORBA::Float value,
00149 const ACSErr::Completion & c,
00150 const ACS::CBDescOut & desc
00151 )
00152 {
00153 if (count>0)
00154 {
00155 ACS_SHORT_LOG((LM_INFO, "(%s::CBfloat::working) desc.id_tag: %u Value: %f TimeStamp: %s",
00156 prop.c_str(), (unsigned)desc.id_tag, value, getStringifiedUTC(c.timeStamp).c_str()));
00157 }
00158 count--;
00159 }
00160
00161 virtual void done (
00162 CORBA::Float value,
00163 const ACSErr::Completion & c,
00164 const ACS::CBDescOut & desc
00165 )
00166 {
00167 if (done_c > 0 )
00168 {
00169 ACS_SHORT_LOG((LM_INFO, "(%s::CBfloat::done) desc.id_tag: %u Value: %f TimeStamp: %s",
00170 prop.c_str(), (unsigned)desc.id_tag, value, getStringifiedUTC(c.timeStamp).c_str()));
00171 }
00172 done_c--;
00173 }
00174
00175
00176 virtual CORBA::Boolean negotiate (
00177 ACS::TimeInterval time_to_transmit,
00178 const ACS::CBDescOut & desc
00179 )
00180 {
00181 return 1;
00182 }
00183
00184 int getCount(){ return count+done_c;}
00185 protected:
00186 std::string prop;
00187 int count, done_c;
00188
00189 };
00190
00191 class baciTestCBpattern: public virtual POA_ACS::CBpattern
00192 {
00193
00194 public:
00195 baciTestCBpattern(std::string _prop, int c=5, int dc=1) : prop(_prop), count(c), done_c(dc) {}
00196
00197 virtual void working (
00198 ACS::pattern value,
00199 const ACSErr::Completion & c,
00200 const ACS::CBDescOut & desc
00201 )
00202 {
00203 if (count>0)
00204 {
00205 ACS_SHORT_LOG((LM_INFO, "(%s::CBpattern::working) desc.id_tag: %u Value: %llu TimeStamp: %s",
00206 prop.c_str(), (unsigned)desc.id_tag, value, getStringifiedUTC(c.timeStamp).c_str()));
00207 }
00208 count--;
00209 }
00210
00211 virtual void done (
00212 ACS::pattern value,
00213 const ACSErr::Completion & c,
00214 const ACS::CBDescOut & desc
00215 )
00216 {
00217 if (done_c > 0 )
00218 {
00219 ACS_SHORT_LOG((LM_INFO, "(%s::CBpattern::done) desc.id_tag: %u Value: %llu TimeStamp: %s",
00220 prop.c_str(), (unsigned)desc.id_tag, value, getStringifiedUTC(c.timeStamp).c_str()));
00221 }
00222 done_c--;
00223 }
00224
00225
00226 virtual CORBA::Boolean negotiate (
00227 ACS::TimeInterval time_to_transmit,
00228 const ACS::CBDescOut & desc
00229 )
00230 {
00231 return 1;
00232 }
00233
00234 int getCount(){ return count+done_c;}
00235 protected:
00236 std::string prop;
00237 int count, done_c;
00238
00239 };
00240
00241 int write_iors_to_file (const int count,
00242 CORBA::String_var name[],
00243 CORBA::String_var type[],
00244 CORBA::String_var ior[]);
00245 int read_IOR_from_file (std::string device, std::string &readIOR);
00246
00247 class CORBAShutdown
00248 {
00249 public:
00250 typedef void (*ShutdownFunction)();
00251
00252 static void setShutdownFunction(ShutdownFunction function);
00253 static void shutdown();
00254
00255 private:
00256 static ShutdownFunction m_func;
00257
00258 };
00259
00260 #endif
00261
00262
00263
00264