00001 #ifndef _baci_alarmT_H_
00002 #define _baci_alarmT_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
00033 #ifndef __cplusplus
00034 #error This is a C++ include file and cannot be used from plain C
00035 #endif
00036
00037 #include <baciEvent.h>
00038 #include <ACSErrTypeAlarm.h>
00039
00040 namespace baci {
00041
00042
00043 template<class T, class TCB, class POA_CB>
00044 class EventCB;
00045
00046
00047
00048 template<class T, class TCB, class POA_CB>
00049 class baci_EXPORT MonitorEventDispatcher :
00050 public EventDispatcher, public MonitorImplementator
00051 {
00052 public:
00053 MonitorEventDispatcher(const CBDescIn& descIn,
00054 const ACS::TimeInterval& interval,
00055 BACIProperty * property);
00056
00057 virtual ~MonitorEventDispatcher();
00058
00059 virtual int subscribe(EventStrategy * event);
00060
00061 virtual int unsubscribe(EventStrategy * event);
00062
00063 virtual void dispatch(T value,
00064 const ACSErr::Completion & c,
00065 const ACS::CBDescOut & desc);
00066
00067 virtual void suspend();
00068
00069 virtual void resume();
00070
00071 virtual void monitorDestroyed(void);
00072
00073 virtual void monitorStateChanged(void);
00074
00075 private:
00076
00077 int callbackID_m;
00078
00079 BACIMonitor * monitor_mp;
00080
00081 TCB *monitorCallback_mp;
00082
00083 EventCB<T, TCB, POA_CB>* callbackServant_mp;
00084
00088 void operator=(const MonitorEventDispatcher&);
00089
00093 MonitorEventDispatcher(const MonitorEventDispatcher&);
00094 };
00095
00096
00097
00098 template<class T, class TCB, class POA_CB>
00099 class baci_EXPORT EventCB : public virtual PortableServer::RefCountServantBase, public POA_CB
00100 {
00101 public:
00102
00103 EventCB(MonitorEventDispatcher<T, TCB, POA_CB>* dispatcher);
00104
00105 virtual ~EventCB();
00106
00107 virtual void disposeDispatcher();
00108
00109 virtual void working (T value,
00110 const ACSErr::Completion & c,
00111 const ACS::CBDescOut & desc);
00112
00113 virtual void done (T value,
00114 const ACSErr::Completion & c,
00115 const ACS::CBDescOut & desc);
00116
00117 virtual CORBA::Boolean negotiate (ACS::TimeInterval time_to_transmit,
00118 const ACS::CBDescOut & desc);
00119
00120 private:
00121
00122 MonitorEventDispatcher<T, TCB, POA_CB>* dispatcher_mp;
00123
00127 void operator=(const EventCB&);
00128
00132 EventCB(const EventCB&);
00133 };
00134
00135
00136
00137
00138 template<class T, class TPROP, class TALARM>
00139 class baci_EXPORT AlarmEventStrategy : public EventStrategy
00140 {
00141 public:
00142
00143 static const int maxFailureCount;
00144
00145 AlarmEventStrategy(TPROP * property, EventDispatcher * eventDispatcher);
00146
00147 AlarmEventStrategy(Callback_ptr callback_p,
00148 const CBDescIn& descIn,
00149 const ACS::TimeInterval& interval,
00150 TPROP * property,
00151 EventDispatcher * eventDispatcher);
00152
00153 virtual ~AlarmEventStrategy();
00154
00155 bool failed();
00156 void succeeded();
00157
00158 CORBA::Object_ptr getCORBAReference() const
00159 {
00160 return reference_mp;
00161 }
00162
00163 virtual bool isSuspended()
00164 {
00165 return suspended_m;
00166 }
00167
00168 virtual int getId(void);
00169
00170 virtual const char* getName(void);
00171
00172 virtual const char* getObjectState(void);
00173
00174 virtual void setObjectState(const char * state);
00175
00176 virtual void suspend ();
00177
00178 virtual void resume ();
00179
00180 virtual void destroy ();
00181
00182 private:
00183
00184 ACE_CString name_m;
00185
00186 bool suspended_m;
00187
00188 int failureCount_m;
00189
00190 CBDescIn desc_mIn;
00191
00192 ACS::TimeInterval interval_m;
00193
00194 EventDispatcher * eventDispatcher_mp;
00195
00196 CORBA::Object_ptr reference_mp;
00197
00198
00202 void operator=(const AlarmEventStrategy&);
00203
00207 AlarmEventStrategy(const AlarmEventStrategy&);
00208
00209
00210 protected:
00211
00212 TPROP *property_mp;
00213
00214 TALARM *callback_mp;
00215
00216 int alarmRaised_m;
00217 };
00218
00219
00220
00221
00222 template<class T, class TPROP, class TALARM>
00223 class baci_EXPORT AlarmEventStrategyDisc : public AlarmEventStrategy<T, TPROP, TALARM>
00224 {
00225 public:
00226 AlarmEventStrategyDisc(TPROP * property, EventDispatcher * eventDispatcher) :
00227 AlarmEventStrategy<T, TPROP, TALARM>(property, eventDispatcher)
00228 {};
00229
00230 AlarmEventStrategyDisc(Callback_ptr callback_p,
00231 const CBDescIn& descIn,
00232 const ACS::TimeInterval& interval,
00233 TPROP * property,
00234 EventDispatcher * eventDispatcher) :
00235 AlarmEventStrategy<T, TPROP, TALARM>(callback_p, descIn, interval, property, eventDispatcher)
00236 {};
00237
00238 virtual void check(BACIValue &value,
00239 const ACSErr::Completion & c,
00240 const ACS::CBDescOut & desc);
00241
00242 private:
00246 void operator=(const AlarmEventStrategyDisc&);
00247
00251 AlarmEventStrategyDisc(const AlarmEventStrategyDisc&);
00252 };
00253
00254
00255
00256
00257 template<class T, class TPROP, class TALARM>
00258 class baci_EXPORT AlarmEventStrategyCont : public AlarmEventStrategy<T, TPROP, TALARM>
00259 {
00260 public:
00261 AlarmEventStrategyCont(TPROP * property, EventDispatcher * eventDispatcher) :
00262 AlarmEventStrategy<T, TPROP, TALARM>(property, eventDispatcher)
00263 {};
00264
00265 AlarmEventStrategyCont(Callback_ptr callback_p,
00266 const CBDescIn& descIn,
00267 const ACS::TimeInterval& interval,
00268 TPROP * property,
00269 EventDispatcher * eventDispatcher) :
00270 AlarmEventStrategy<T, TPROP, TALARM>(callback_p, descIn, interval, property, eventDispatcher)
00271 {};
00272
00273 virtual void check(BACIValue &value,
00274 const ACSErr::Completion & c,
00275 const ACS::CBDescOut & desc);
00276
00277 private:
00281 void operator=(const AlarmEventStrategyCont&);
00282
00286 AlarmEventStrategyCont(const AlarmEventStrategyCont&);
00287 };
00288
00289
00290
00291
00292
00293 template<class T, class TPROP, class TALARM>
00294 class baci_EXPORT AlarmEventStrategyContSeq : public AlarmEventStrategy<T, TPROP, TALARM>
00295 {
00296 public:
00297 AlarmEventStrategyContSeq(TPROP * property, EventDispatcher * eventDispatcher) :
00298 AlarmEventStrategy<T, TPROP, TALARM>(property, eventDispatcher)
00299 {};
00300
00301 AlarmEventStrategyContSeq(Callback_ptr callback_p,
00302 const CBDescIn& descIn,
00303 const ACS::TimeInterval& interval,
00304 TPROP * property,
00305 EventDispatcher * eventDispatcher) :
00306 AlarmEventStrategy<T, TPROP, TALARM>(callback_p, descIn, interval, property, eventDispatcher)
00307 {};
00308
00309 virtual void check(BACIValue &value,
00310 const ACSErr::Completion & c,
00311 const ACS::CBDescOut & desc);
00312 protected:
00313
00314 int * alarmsRaised_mp;
00315 int alarmsRaisedLength_m;
00316
00317 private:
00321 void operator=(const AlarmEventStrategyContSeq&);
00322
00326 AlarmEventStrategyContSeq(const AlarmEventStrategyContSeq&);
00327 };
00328
00329
00330
00331
00332 template<class T, class TPROP, class TALARM>
00333 class baci_EXPORT AlarmEventStrategyDiscSeq : public AlarmEventStrategy<T, TPROP, TALARM>
00334 {
00335 public:
00336 AlarmEventStrategyDiscSeq(TPROP * property, EventDispatcher * eventDispatcher) :
00337 AlarmEventStrategy<T, TPROP, TALARM>(property, eventDispatcher)
00338 {};
00339
00340 AlarmEventStrategyDiscSeq(Callback_ptr callback_p,
00341 const CBDescIn& descIn,
00342 const ACS::TimeInterval& interval,
00343 TPROP * property,
00344 EventDispatcher * eventDispatcher) :
00345 AlarmEventStrategy<T, TPROP, TALARM>(callback_p, descIn, interval, property, eventDispatcher)
00346 {};
00347
00348 virtual void check(BACIValue &value,
00349 const ACSErr::Completion & c,
00350 const ACS::CBDescOut & desc);
00351
00352 protected:
00353
00354 int * alarmsRaised_mp;
00355 int alarmsRaisedLength_m;
00356
00357 private:
00361 void operator=(const AlarmEventStrategyDiscSeq&);
00362
00366 AlarmEventStrategyDiscSeq(const AlarmEventStrategyDiscSeq&);
00367 };
00368
00369 };
00370
00371 #endif