CARMA C++
AlarmManager.h
1 /*
2  * Alarm Output Manager
3  *
4  * This objects manages all of the alarm output functionality in the
5  * fault system. This is used to play tones when things go wrong, so
6  * that the observers can be woken up in the middle of the night for
7  * my amusement.
8  *
9  * Copyright (c) 2010 Ira W. Snyder <iws@ovro.caltech.edu>
10  */
11 
12 #ifndef ALARM_MANAGER_H
13 #define ALARM_MANAGER_H
14 
15 #include <string>
16 #include <list>
17 
20 #include <carma/util/ScopedPthreadMutexLock.h>
21 
22 #include <carma/fault/DagMLNode.h>
23 #include <carma/fault/Evaluators.h>
24 #include <carma/fault/FaultTransport.h>
25 #include <carma/fault/FaultSystemMonitorInfo.h>
26 
27 typedef std::list<std::string> StringList;
28 
29 class AlarmManager
30 {
31  public:
32  AlarmManager();
33 
34  /* attach to a given subarray */
35  void attach_alarm_output(DagMLNodePtr output);
36 
37  /* attach all monitor points to the Carma Monitor System */
38  void attach_to_monitor_system(carma::monitor::MonitorSystem *inputCms,
40 
41  /* special transient support */
42  void set_alarm_enable_state(const int saNo, const bool on);
43 
44  /* soft enable/disable of specific monitor point alarms */
45  void disable_alarms(const StringList &names);
46  void restore_alarms(const StringList &names);
47 
48  /* perform one mainloop cycle */
49  void perform_cycle(int frame, FaultTransportWriter &transport);
50 
51  /* get the monitor info from the last iteration */
52  const AlarmManagerMonitorInfo& getMonitorInfo() const;
53 
54  protected:
55  /* the basic step of any normal processing cycle */
56  void evaluate_alarm_output(int frame, FaultTransportWriter &transport);
57 
58  /* enable/disable a single monitor point alarm */
59  void set_monitor_point_alarm(const std::string &name, bool disable);
60  DagMLNodePtr check_monitor_point(const std::string &name);
61  void automatic_alarm_reenable(const int frame);
62 
63  /* Maps of various node types for quick lookups and traversals */
64  DagMLNodeMap monitor_map_;
65  DagMLNodeMap gather_map_;
66  DagMLNodeMap disabled_map_;
67 
68  /* Monitor Information */
69  AlarmManagerMonitorInfo monitor_;
70 
71  /* The alarm output node */
72  DagMLNodePtr alarm_output_;
73 
74  /* Fault Accumulator */
75  AlarmEvaluator evaluator_;
76 
77  /*
78  * Mutex to lock all user-accessible (public) operations
79  *
80  * This has the mutable keyword so that it can still be locked
81  * during methods which are marked const
82  */
83  mutable carma::util::PthreadMutex mutex_;
84 };
85 
86 #endif /* ALARM_MANAGER_H */
87 
88 /* vim: set ts=8 sts=8 sw=8 noet tw=92: */
The monitor system base class.
Semi-hand-forged extensions to the auto-generated classes for the Control subsystem.
Monitor system base class.
Definition: MonitorSystem.h:81
A simple wrapper class that makes use of ::pthread_mutex_t easier in a C++ world. ...
Definition: PthreadMutex.h:41