• 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.5 2012/07/26 12:55:35 gchiozzi 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         int isAlarmRaised(){ return alarmRaised_m; }
00094 
00095 protected:
00096 
00097         virtual void check(BACIValue &val,
00098                         const ACSErr::Completion & c,
00099                         const ACS::CBDescOut & desc )=0;
00100 
00106         virtual void sendAlarm(int code, bool active);
00107 
00108 
00113         virtual void clearAlarm();
00114 
00115 
00120         virtual void recheckAlarm();
00121 
00129         void setProperty(const char *name, const char *prop);
00130 
00131         template <class VT>
00132         void setProperty(const char *name, VT value)
00133         {
00134                 std::ostringstream ostr;
00135                 std::string ts;
00136 
00137                 ostr << value << std::ends;
00138                 ts =  ostr.str();
00139                 setProperty(name, ts.c_str());
00140         }//setProperty<>
00141 
00142 
00143 private:
00144 
00148         void operator=(const AlarmSystemMonitorBase&);
00149 
00153         AlarmSystemMonitorBase(const AlarmSystemMonitorBase&);
00154 
00155 
00156 protected:
00157         ACE_CString name_m;
00158 
00159         bool suspended_m;
00160 
00161         int failureCount_m;
00162 
00163         CBDescIn desc_mIn;
00164 
00165         ACS::TimeInterval interval_m;
00166 
00167         EventDispatcher * eventDispatcher_mp;
00168 
00169         // The alarm system source
00170         // The source is a singleton (there is no need to delete this pointer)
00171         acsalarm::AlarmSystemInterface* alarmSource_map;
00172 
00176         int alarmRaised_m;
00177 
00178         std::string faultMember_m;  
00179         std::string faultFamily_m;  
00180 
00181         int alarmLevel_m;  
00182 
00183 
00184         int lastAlarmFaultCode_m; 
00185         BACIValue lastAlarmValue_m;     //value that caused (raised or cleared) the last alarm
00186 
00187         // here we can store alarm propertes
00188         std::map<std::string, std::string> alarmProperties_m;
00189 
00190         ACE_Recursive_Thread_Mutex faultStructMutex_m;
00191 };//class AlarmSystemMonitorBase
00192 
00193 }// namespace baci
00194 
00195 #endif 

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