• Classes
  • Modules
  • Namespaces
  • Files
  • Related Pages
  • File List
  • File Members

MonitorPoint.h

Go to the documentation of this file.
00001 #ifndef MONITOR_POINT_IMPL_H
00002 #define MONITOR_POINT_IMPL_H
00003 /*******************************************************************************
00004 * ALMA - Atacama Large Millimiter Array
00005 * (c) European Southern Observatory, 2009
00006 *
00007 * This library is free software; you can redistribute it and/or
00008 * modify it under the terms of the GNU Lesser General Public
00009 * License as published by the Free Software Foundation; either
00010 * version 2.1 of the License, or (at your option) any later version.
00011 *
00012 * This library is distributed in the hope that it will be useful,
00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 * Lesser General Public License for more details.
00016 *
00017 * You should have received a copy of the GNU Lesser General Public
00018 * License along with this library; if not, write to the Free Software
00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00020 *
00021 * "@(#) $Id: MonitorPoint.h,v 1.5 2012/10/10 09:48:54 bjeram Exp $"
00022 *
00023 * who       when      what
00024 * --------  --------  ----------------------------------------------
00025 * bjeram  2009-02-11  created
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; // interval in which the value should be archived (and so monitored)
00088 
00089         double valuePercentTrigger_m; // Delta value percentage a value can change before the value should be archived (and so monitored)
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; //when we switch the collection sequence
00107 
00108         bool monitorSuppressed_m;
00109         bool alarmSuppressed_m;
00110         double alarmTimerTrigger_m;
00111 
00112         static const unsigned int maxSeqSegments_m = 2; // maximum sequence segments. maxSeqSegments_m*prealocSeqLen_m defines the buffer maximum size
00113         static const unsigned int prealocSeqLen_m = 100; // preallocated length of the sequence. This is the step that the sequence will grow
00114 
00115         CORBA::Long backLogSize_m;
00116         //TBD: do we need also type (as string or ..)?
00117 };//MonitorPointBase
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         //Sets the servant for the property monitor
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; // Delta value describing how much a value can change before the value should be archived (and so monitored)
00157         TCB * monitorServant_m;
00158 };//MonitorPoint
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         //Sets the servant for the alarm monitor
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         //Implementing Alarm interface
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         //Sets the servant for the property monitor
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; // Delta value describing how much a value can change before the value should be archived (and so monitored)
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         //Sets the servant for the alarm monitor
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         //Implementing Alarm interface
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

Generated on Mon May 4 2015 08:27:43 for ACS-2015.4 C++ API by  doxygen 1.7.0