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

baciAlarmSystemMonitorBase.h

Go to the documentation of this file.
00001 #ifndef _ALARM_SYSTEM_MONITOR_BASE_H
00002 #define _ALARM_SYSTEM_MONITOR_BASE_H
00003 /*******************************************************************************
00004  * ALMA - Atacama Large Millimiter Array
00005  * (c) European Southern Observatory, 2006
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: baciAlarmSystemMonitorBase.h,v 1.4 2011/09/02 11:39:00 bjeram Exp $"
00022  *
00023  * who       when      what
00024  * --------  --------  ----------------------------------------------
00025  * bjeram  2006-09-13  created
00026  */
00027 
00028 /************************************************************************
00029  *
00030  *----------------------------------------------------------------------
00031  */
00032 
00033 #ifndef __cplusplus
00034 #error This is a C++ include file and cannot be used from plain C
00035 #endif
00036 
00037 #include <AlarmSystemInterface.h>
00038 #include <baciEvent.h>
00039 
00040 namespace baci
00041 {
00042 
00047 class baci_EXPORT AlarmSystemMonitorBase : public EventStrategy
00048 {
00049 public:
00050 
00051         AlarmSystemMonitorBase(EventDispatcher * eventDispatcher);
00052 
00053         virtual ~AlarmSystemMonitorBase();
00054 
00055         bool failed();
00056         void succeeded();
00057 
00058         virtual bool isSuspended() { return false; }
00059 
00060         // here we do not need recovery stuff
00061         virtual int getId(void){ return -1; }
00062 
00063         virtual const char* getName(void){ return ""; }
00064 
00065         virtual const char* getObjectState(void){ return ""; }
00066 
00067         virtual void setObjectState(const char * state){}
00068         // ... and also implementation of  POA_ACS::Subscription can be empty
00069         virtual void suspend () {}
00070 
00071         virtual void resume () {}
00072 
00073         virtual void destroy () {}
00074 
00079         void setLevel(int level){ alarmLevel_m = level; }
00080 
00085         void setFaultFamily(const char *ff);
00086 
00091         void setFaultMember(const char *fm);
00092 
00093 protected:
00094 
00095         virtual void check(BACIValue &val,
00096                         const ACSErr::Completion & c,
00097                         const ACS::CBDescOut & desc )=0;
00098 
00104         void sendAlarm(int code, bool active);
00105 
00106 
00111         virtual void clearAlarm();
00112 
00113 
00118         virtual void recheckAlarm();
00119 
00127         void setProperty(const char *name, const char *prop);
00128 
00129         template <class VT>
00130         void setProperty(const char *name, VT value)
00131         {
00132                 std::ostringstream ostr;
00133                 std::string ts;
00134 
00135                 ostr << value << std::ends;
00136                 ts =  ostr.str();
00137                 setProperty(name, ts.c_str());
00138         }//setProperty<>
00139 
00140 
00141 private:
00142 
00146         void operator=(const AlarmSystemMonitorBase&);
00147 
00151         AlarmSystemMonitorBase(const AlarmSystemMonitorBase&);
00152 
00153 
00154 protected:
00155         ACE_CString name_m;
00156 
00157         bool suspended_m;
00158 
00159         int failureCount_m;
00160 
00161         CBDescIn desc_mIn;
00162 
00163         ACS::TimeInterval interval_m;
00164 
00165         EventDispatcher * eventDispatcher_mp;
00166 
00167         // The alarm system source
00168         // The source is a singleton (there is no need to delete this pointer)
00169         acsalarm::AlarmSystemInterface* alarmSource_map;
00170 
00174         int alarmRaised_m;
00175 
00176         std::string faultMember_m;  
00177         std::string faultFamily_m;  
00178 
00179         int alarmLevel_m;  
00180 
00181 
00182         int lastAlarmFaultCode_m; 
00183         BACIValue lastAlarmValue_m;     //value that caused (raised or cleared) the last alarm
00184 
00185         // here we can store alarm propertes
00186         std::map<std::string, std::string> alarmProperties_m;
00187 
00188         ACE_Recursive_Thread_Mutex faultStructMutex_m;
00189 };//class AlarmSystemMonitorBase
00190 
00191 }// namespace baci
00192 
00193 #endif 

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