Go to the documentation of this file.00001 #ifndef _ALARM_SYSTEM_MONITOR_BASE_H
00002 #define _ALARM_SYSTEM_MONITOR_BASE_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 
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         
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         
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         }
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         
00168         
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;     
00184 
00185         
00186         std::map<std::string, std::string> alarmProperties_m;
00187 
00188         ACE_Recursive_Thread_Mutex faultStructMutex_m;
00189 };
00190 
00191 }
00192 
00193 #endif