00001 #ifndef MONITOR_POINT_IMPL_H
00002 #define MONITOR_POINT_IMPL_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 #ifndef __cplusplus
00029 #error This is a C++ include file and cannot be used from plain C
00030 #endif
00031
00032 #include <tao/DynamicInterface/Request.h>
00033
00034 #include "MonitorCollectorS.h"
00035 #include <baciCharacteristicComponentImpl.h>
00036 #include <TMCDBCOMMON_IDLS.h>
00037 namespace TMCDB
00038 {
00039
00045 template <class T>
00046 void checkMonitorValue(T value){}
00047
00051 class MonitorPointBase : public virtual POA_ACS::Callback
00052 {
00053 public:
00054 MonitorPointBase(const char *propertyName, const ACS::TimeInterval &archivingInterval, TMCDB::DataValueType typeOfData, MonitorBlob& mb);
00055
00056 virtual ~MonitorPointBase();
00057
00058 void setPropertySerialNumber(serialNumberTypeSeq& sn);
00059
00060 ACE_CString &getPropertyName() { return propertyName_m; }
00061
00062 CORBA::Boolean negotiate(ACS::TimeInterval, const ACS::CBDescOut&){ return true; }
00063
00065 virtual void activate(maci::ContainerServices *cs)=0;
00066 virtual void deactivate(maci::ContainerServices *cs)=0;
00067
00069 virtual void startMonitoring()=0;
00070
00072 virtual void stopMonitoring()=0;
00073
00075 virtual void fillSeq()=0;
00076
00077 virtual void set_archiving_interval(ACS::TimeInterval time)=0;
00078
00079 virtual void suppress_archiving()=0;
00080
00081 virtual void enable_archiving()=0;
00082
00083 protected:
00084
00085 ACE_CString propertyName_m;
00086
00087 ACS::TimeInterval archivingInterval_m;
00088
00089 double valuePercentTrigger_m;
00090
00091 MonitorBlob& monitorBlob_m;
00092
00093 ACS::Monitor_var monitor_m;
00094
00095 ACS::Subscription_var subscription_m;
00096
00097 ACS::OffShoot_var monitorCallback_m;
00098 ACS::OffShoot_var alarmCallback_m;
00099
00100 unsigned int curSeqPos_m;
00101 unsigned int curSeqInit_m;
00102 bool bufferFull;
00103
00104 unsigned int seqLen_m;
00105
00106 ACE_Thread_Mutex switchMutex_m;
00107
00108 bool monitorSuppressed_m;
00109 bool alarmSuppressed_m;
00110 double alarmTimerTrigger_m;
00111
00112 static const unsigned int maxSeqSegments_m = 2;
00113 static const unsigned int prealocSeqLen_m = 100;
00114
00115 CORBA::Long backLogSize_m;
00116
00117 };
00118
00119 template <class T, class TBLOB_SEQ, class TPROP, class TCB, class TBASE>
00120 class MonitorPoint : public MonitorPointBase
00121 {
00122 public:
00123 MonitorPoint(const char *propertyName, const ACS::TimeInterval &monitoringInterval, ACS::Property* property, TMCDB::DataValueType typeOfData, MonitorBlob& mb);
00124
00125 virtual ~MonitorPoint();
00126
00127
00128 void setMonitorServant(TCB *servant);
00129
00130 virtual void activate(maci::ContainerServices *cs);
00131 virtual void deactivate(maci::ContainerServices *cs);
00132
00134 virtual void startMonitoring();
00135
00137 virtual void stopMonitoring();
00138
00139 void fillSeq();
00140
00141 void set_archiving_interval(ACS::TimeInterval time);
00142
00143 virtual void suppress_archiving();
00144
00145 virtual void enable_archiving();
00146
00148 void working(T value, const ACSErr::Completion& comp, const ACS::CBDescOut& cbdescout);
00149
00151 void done(T value, const ACSErr::Completion& comp, const ACS::CBDescOut& cbdescout);
00152 protected:
00153 TPROP* property_m;
00154 TBLOB_SEQ blobDataSeq_m;
00155 TBLOB_SEQ blobDataSeqTemp_m;
00156 TBASE valueTrigger_m;
00157 TCB * monitorServant_m;
00158 };
00159
00160 template <class T, class TBLOB_SEQ, class TPROP, class TMCB, class TACB, class TBASE, class TSEQ, class TALARM>
00161 class ROMonitorPoint : public MonitorPoint<T, TBLOB_SEQ, TPROP, TMCB, TBASE>
00162 {
00163 public:
00164 ROMonitorPoint(const char *propertyName, const ACS::TimeInterval &monitoringInterval, ACS::Property* property, TMCDB::DataValueType typeOfData, MonitorBlob& mb);
00165 ~ROMonitorPoint();
00166
00167 void setAlarmServant(TACB *servant);
00168 void activate(maci::ContainerServices *cs);
00169 void deactivate(maci::ContainerServices *cs);
00171 void startMonitoring();
00172 void stopMonitoring();
00173 void suppress_archiving();
00174 void enable_archiving();
00175
00176 void alarm_raised(TALARM value, const ACSErr::Completion& comp, const ACS::CBDescOut& cbdescout);
00177 void alarm_cleared(TALARM value, const ACSErr::Completion& comp, const ACS::CBDescOut& cbdescout);
00178 protected:
00179 TACB * alarmServant_m;
00180 };
00181
00182 class EnumMonitorPoint : public MonitorPointBase
00183 {
00184 public:
00185 EnumMonitorPoint(const char *propertyName, const ACS::TimeInterval &monitoringInterval, ACS::Property* property, TMCDB::DataValueType typeOfData, MonitorBlob& mb);
00186 ~EnumMonitorPoint();
00187
00188 void setMonitorServant(POA_ACS::CBuLong *servant);
00189
00190 virtual void activate(maci::ContainerServices *cs);
00191 virtual void deactivate(maci::ContainerServices *cs);
00192
00194 virtual void startMonitoring();
00195
00197 virtual void stopMonitoring();
00198
00199 void fillSeq();
00200
00201 void set_archiving_interval(ACS::TimeInterval time);
00202
00203 virtual void suppress_archiving();
00204
00205 virtual void enable_archiving();
00206
00208 void working(CORBA::ULong value, const ACSErr::Completion& comp, const ACS::CBDescOut& cbdescout);
00209
00211 void done(CORBA::ULong value, const ACSErr::Completion& comp, const ACS::CBDescOut& cbdescout);
00212 protected:
00213 ACS::TypelessProperty* property_m;
00214 enumBlobDataSeq blobDataSeq_m;
00215 enumBlobDataSeq blobDataSeqTemp_m;
00216 CORBA::ULong valueTrigger_m;
00217 POA_ACS::CBuLong * monitorServant_m;
00218 };
00219
00220 class ROEnumMonitorPoint : public EnumMonitorPoint
00221 {
00222 public:
00223 ROEnumMonitorPoint(const char *propertyName, const ACS::TimeInterval &monitoringInterval, ACS::Property* property, TMCDB::DataValueType typeOfData, MonitorBlob& mb);
00224 ~ROEnumMonitorPoint();
00225
00226 void setAlarmServant(POA_ACS::AlarmuLong *servant);
00227 void activate(maci::ContainerServices *cs);
00228 void deactivate(maci::ContainerServices *cs);
00230 void startMonitoring();
00231 void stopMonitoring();
00232 void suppress_archiving();
00233 void enable_archiving();
00234
00235 void alarm_raised(CORBA::ULong& value, const ACSErr::Completion& comp, const ACS::CBDescOut& cbdescout);
00236 void alarm_cleared(CORBA::ULong& value, const ACSErr::Completion& comp, const ACS::CBDescOut& cbdescout);
00237 protected:
00238 POA_ACS::AlarmuLong * alarmServant_m;
00239 };
00240
00241 template <class T>
00242 T initValue(unsigned int len);
00243 template <>
00244 char* initValue(unsigned int len);
00245 #include "MonitorPoint.i"
00246
00247 };
00248
00249 #endif