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

baciBACIMonitor.h

Go to the documentation of this file.
00001 #ifndef baciBACIMonitor_H
00002 #define baciBACIMonitor_H
00003 
00004 /*******************************************************************
00005 * ALMA - Atacama Large Millimiter Array
00006 * (c) European Southern Observatory, 2003 
00007 *
00008 *This library is free software; you can redistribute it and/or
00009 *modify it under the terms of the GNU Lesser General Public
00010 *License as published by the Free Software Foundation; either
00011 *version 2.1 of the License, or (at your option) any later version.
00012 *
00013 *This library is distributed in the hope that it will be useful,
00014 *but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 *Lesser General Public License for more details.
00017 *
00018 *You should have received a copy of the GNU Lesser General Public
00019 *License along with this library; if not, write to the Free Software
00020 *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00021 *
00022 * "@(#) $Id: baciBACIMonitor.h,v 1.6 2011/03/30 17:57:23 tstaig Exp $"
00023 *
00024 * who       when      what
00025 * --------  --------  ----------------------------------------------
00026 * dfugate 2005-01-17 created
00027 */
00028 
00034 #ifndef __cplusplus
00035 #error This is a C++ include file and cannot be used from plain C
00036 #endif
00037 
00038 #include "baciExport.h"
00039 #include "acsutilTimeStamp.h"
00040 #include <acscommonC.h>
00041 #include "baciValue.h"
00042 #include "logging.h"
00043 #include <vector>
00044 
00045 namespace baci {
00046 
00047 
00048 
00049 // forwards
00050 class BACIProperty;
00051 
00052 /* ------------------------------------------------------------------------ */
00053 
00060 class baci_EXPORT MonitorImplementator 
00061 {
00062 public:
00063 
00070   virtual int initialization() { return 0; }
00071 
00077   virtual void monitorDestroyed(void) = 0;
00078 
00083   virtual void monitorStateChanged(void) = 0;
00084 
00085   virtual ~MonitorImplementator() {}
00086 
00087 };  /* MonitorImplementator */
00088 
00089 /* ------------------------------------------------------------------------ */
00090 
00099 class baci_EXPORT BACIMonitor
00100 {
00101 
00102 public:
00103 
00127   enum UpdateMode { mumNull=0, 
00128                     mumLast=1, 
00129                     mumTrunc=2 };
00130   
00134   BACIMonitor(const ACE_CString& _name, int _callbackID,
00135               MonitorImplementator* monitorImplementator_p,
00136               const ACS::TimeInterval& _triggerTime, const BACIValue& _triggerValue, 
00137               const ACS::TimeInterval& _minTriggerTime, const BACIValue& _minTriggerValue, 
00138               BACIProperty* _property, 
00139               const ACS::TimeInterval& _transmitTime=0,
00140               const UpdateMode& _updateMode=mumLast,
00141               const bool _achivingMonitor=false,
00142               const bool _suspended=false,
00143               const bool _deltaValueAndTimerInteraction=false,   // delta trigger reset timer and interval is greather than minTriggerTime
00144               const unsigned int _priority=3);        // archiver default priority
00145 
00147   void destroy();
00148   
00149   void suspend();
00150   void resume();
00151   void setLastTime(const ACS::TimeInterval& _lastTime);
00152   void setTriggerValue(const BACIValue& _triggerValue);
00153   void setTriggerValuePercent(const BACIValue& _triggerValuePercent);
00154   void setMinTriggerValue(const BACIValue& _minTriggerValue);
00155   void setLastValue(const BACIValue& _lastValue);
00156   void setTriggerOnValue(bool enable);
00157   void setTriggerOnValuePercent(bool enable);
00158 
00159   /* ---- */
00160 
00161   const char * getName() const { return name_m.c_str(); }
00162   bool isSuspended() const { return suspended_m; }
00163  
00164   BACIMonitor& operator=(const BACIMonitor& mon) 
00165   {
00166     if (this!=&mon)
00167       {
00168         name_m=mon.name_m; 
00169         callbackID_m=mon.callbackID_m; 
00170         triggerTime_m=mon.triggerTime_m; 
00171         transmitTime_m=mon.transmitTime_m;
00172         lastTime_m=mon.lastTime_m; 
00173         triggerValue_m=mon.triggerValue_m; 
00174         triggerValuePercent_m=mon.triggerValuePercent_m; 
00175         lastValue_m=mon.lastValue_m; 
00176         triggerOnValue_m=mon.triggerOnValue_m;
00177         triggerOnValuePercent_m=mon.triggerOnValuePercent_m;
00178         property_mp=mon.property_mp;
00179         suspended_m=mon.suspended_m; 
00180         archivingMonitor_m=mon.archivingMonitor_m; 
00181         updateMode_m=mon.updateMode_m;
00182 
00183         monitorImplementator_mp = mon.monitorImplementator_mp;
00184         minTriggerTime_m = mon.minTriggerTime_m;
00185         userControlledTransmitTime_m = mon.userControlledTransmitTime_m;
00186         minTriggerValue_m = mon.minTriggerValue_m;
00187         deltaValueAndTimerInteraction_m = mon.deltaValueAndTimerInteraction_m;
00188         priority_m = mon.priority_m;
00189         inDestructionState_m = mon.inDestructionState_m;
00190         destroyed_m = mon.destroyed_m;
00191       } 
00192     return *this;
00193   }
00194   
00195   bool operator==(const BACIMonitor& mon) const { return callbackID_m==mon.callbackID_m; }
00196 
00197   UpdateMode getUpdateMode() const { return updateMode_m; }
00198   int getCallbackID() const { return callbackID_m; }
00199   ACS::TimeInterval getTriggerTime() const { return triggerTime_m; }
00200   ACS::TimeInterval getMinTriggerTime() const { return minTriggerTime_m; }
00201   ACS::TimeInterval getLastTime() const { return lastTime_m; }
00202   ACS::TimeInterval getTransmitTime() const { return transmitTime_m; }
00203   BACIValue getTriggerValue() const { return triggerValue_m; }
00204   BACIValue getTriggerValuePercent() const { return triggerValuePercent_m; }
00205   BACIValue getMinTriggerValue() const { return minTriggerValue_m; }
00206   BACIValue getLastValue() const { return lastValue_m; }
00207   bool getTriggerOnValue() const { return triggerOnValue_m; }
00208   bool getTriggerOnValuePercent() const { return triggerOnValuePercent_m; }
00209 
00210   void setUpdateMode(const UpdateMode& _updateMode);
00211   void setTriggerTime(const ACS::TimeInterval& _triggerTime);
00212   void setMinTriggerTime(const ACS::TimeInterval& _minTriggerTime);
00213 
00214   void setTransmitTime(const ACS::TimeInterval& _transmitTime)
00215   {
00216     transmitTime_m = _transmitTime;
00217   }
00218 
00222     void monitorStateChanged() 
00223         {
00224             ACS_TRACE("baci::BACIMonitor::monitorStateChanged");
00225             if (monitorImplementator_mp!=0)
00226                 {
00227                 monitorImplementator_mp->monitorStateChanged();
00228                 }
00229         }
00230 
00231   MonitorImplementator* getMonitorImplementator() const { return monitorImplementator_mp; }
00232   BACIProperty* getProperty() const { return property_mp; }
00233 
00234   bool isInDestructionState() const { return inDestructionState_m; };
00235 
00236   bool isArchivingMonitor() const { return archivingMonitor_m; };
00237 
00238   bool isDeltaValueAndTimerInteraction() const { return deltaValueAndTimerInteraction_m; };
00239 
00240   unsigned int getPriority() const { return priority_m; };
00241 
00242 private:
00243 
00249   ~BACIMonitor();
00250 
00251   void internalDestroy();
00252 
00253 
00254   ACE_CString name_m;
00255   int callbackID_m;
00256   
00257   MonitorImplementator* monitorImplementator_mp;
00258 
00259   UpdateMode updateMode_m;
00260   
00261     ACS::TimeInterval triggerTime_m;
00262     ACS::TimeInterval minTriggerTime_m;
00263   ACS::TimeInterval transmitTime_m;
00264   bool userControlledTransmitTime_m;
00265   ACS::TimeInterval lastTime_m;
00266     
00267     BACIValue triggerValue_m;
00268     BACIValue triggerValuePercent_m;
00269     BACIValue minTriggerValue_m; 
00270     BACIValue lastValue_m;
00271   bool triggerOnValue_m;
00272   bool triggerOnValuePercent_m;
00273   
00274   BACIProperty* property_mp;
00275   
00276   bool archivingMonitor_m;
00277 
00278   bool suspended_m;
00279 
00280   bool deltaValueAndTimerInteraction_m;
00281 
00282   unsigned int priority_m;
00283 
00284   bool inDestructionState_m;
00285 
00286   bool destroyed_m;
00287 
00288     friend class BACIProperty;
00289 
00290 };   /* BACIMonitor */
00291 
00295 typedef std::vector<BACIMonitor*> BACIMonitorVector;
00296 /* ------------------------------------------------------------------------ */
00297 
00298  }; 
00299 
00300 #endif /* baci_H */ 
00301 
00302 

Generated on Thu Jan 12 2012 23:13:50 for ACS-10.0 C++ API by  doxygen 1.7.0