CARMA C++
AlarmControlImpl.h
Go to the documentation of this file.
1 
10 #ifndef CARMA_ALARMCONTROLIMPL_H
11 #define CARMA_ALARMCONTROLIMPL_H
12 
13 #include <carma/monitor/AlarmSubsystem.h>
14 
15 #include <carma/util/AutoPthreadQuitAndJoinGroup.h>
16 #include <carma/util/PthreadMutex.h>
17 
18 namespace carma {
19 namespace alarm {
20 
21 class AudioControlThread2;
22 
27 {
28  public:
29 
30  // Constructor
31  AlarmControlImpl(AudioControlThread2 &control);
32 
33  // Destructor
34  virtual ~AlarmControlImpl();
35 
36  // Using the Tie template mechanism requires these methods to be public
37  void turnOn(const char *alarmName,
38  const char *mp,
39  const char *reason,
40  bool repeat);
41 
42  void turnOff();
43  void updateDeadMan();
44  void enableAlarm(bool enable);
45 
46  static void monitorThreadEP(AlarmControlImpl &This);
47 
48  private:
49 
50  // Separate the task of maintaining and updating state variables from
51  // physically turning alarm on and off (these do the latter).
52  void soundTheAlarm(const std::string &alarmName, bool repeat);
53  void silenceTheAlarm();
54 
55  // Group together state information so we know what needs mutex protected
56  struct AlarmState {
58  bool enable;
59  bool repeat;
60  time_t deadManSec;
61  double alarmTime;
62  bool on;
63  std::string mp;
64  std::string reason;
65  std::string alarmName;
66  };
67 
68  ::carma::monitor::AlarmSubsystem monitor_;
69  struct AlarmState state_;
70 
71  // Threads
72  carma::util::AutoPthreadQuitAndJoinGroup threadGroup_;
73 
74  // Audio Control
75  AudioControlThread2 &control_;
76 
77 }; // End class AlarmControlImpl
78 
79 } // namespace alarm
80 } // namespace carma
81 
82 #endif // CARMA_ALARMCONTROLIMPL_H
83 
84 /* vim: set ts=4 sts=4 sw=4 noet: */
AlarmControl implementation class.
A simple wrapper class that makes use of ::pthread_mutex_t easier in a C++ world. ...
Definition: PthreadMutex.h:41