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

AlarmsMap.h

Go to the documentation of this file.
00001 #ifndef ALARMSMAP_H
00002 #define ALARMSMAP_H
00003 /*******************************************************************************
00004 * ALMA - Atacama Large Millimiter Array
00005 * (c) European Southern Observatory, 2011 
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: AlarmsMap.h,v 1.4 2012/04/19 14:55:47 acaproni Exp $"
00022 *
00023 * who       when      what
00024 * --------  --------  ----------------------------------------------
00025 * acaproni  2011-06-19  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 <map>
00033 #include "ace/Task.h"
00034 
00035 #include "acscommonC.h"
00036 
00037 #include <acsThread.h>
00038 
00039 namespace acsalarm {
00040 
00044 struct AlarmInfo  {
00045         // The time the alarm event has been submitted for the last time
00046         time_t acsTime_m;
00047 
00048         // The state of the last submission
00049         // It is true if ACTIVE, false if TERMINATE
00050         bool active_m;
00051 
00057         AlarmInfo(const bool isActive);
00058 
00062         AlarmInfo(const AlarmInfo& ai);
00063 };
00064 
00089 class AlarmsMap {
00090 public:
00091 
00095         AlarmsMap();
00096 
00100         virtual ~AlarmsMap() {}
00101 
00111         bool raise(std::string alarmID);
00112 
00119         void start();
00120 
00127         void shutdown();
00128 
00138         bool clear(std::string alarmID);
00139 
00144         virtual void updateInternalDataStructs();
00145 
00149         int size() { return alarmsMap.size(); }
00150 
00156         void getAllAlarms(std::vector<AlarmInfo> alarms);
00157 
00161         void clear() { alarmsMap.clear(); }
00162 
00163 private:
00164         // Alarms are stored in the que for the KEEP_ALARMS_TIME seconds
00165         // and then they are removed from the queue
00166         static const ACS::Time KEEP_ALARMS_TIME=30;
00167 
00168         // The map of the alarms
00169         //
00170         // The key is the alarm ID
00171         // The object is a pointer to an AlarmInfo (a pointer
00172         // because std::map does not support elements without
00173         // a default constructor while AlarmInfo needs at least the
00174         // state of the alarm
00175         std::map<std::string, AlarmInfo*> alarmsMap;
00176 
00177         // Synchronize access to the map
00178         ACE_Recursive_Thread_Mutex m_mutex;
00179 
00180         // true if the object has been shut down
00181         bool m_closed;
00182 
00191         bool alarmSet(std::string alarmID, bool state);
00192 };
00193 };
00194 
00195 
00196 #endif 

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