AlarmNotifications
PANDA Slow Control Alarm Daemon
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
flashlight.h
Go to the documentation of this file.
1 
34 #ifndef FLASHLIGHT_H
35 #define FLASHLIGHT_H
36 
37 #include "oldgcccompat.h" // Compatibilty macros for GCC < 4.7
38 
39 #include <string>
40 #include <termios.h>
41 #include <vector>
42 
43 #include <boost/thread.hpp>
44 
45 namespace AlarmNotifications
46 {
47 
56 {
62  typedef std::vector<uint8_t> deviceCommand ;
63 private:
69  const std::string _deviceNode;
75  boost::mutex _serialLineMutex;
81  int _fd;
87  bool _fdOpen;
93  static const unsigned int deviceBaudRate = B9600; // Taken from the manual of the USB relais
94 
100  FlashLight();
108  void switchInternal ( const bool lightSwitch );
116  static deviceCommand createCommand ( const bool lightSwitch );
124  void openSerialInterface();
144  void writeSerialInteface ( const deviceCommand command );
151  void closeSerialInterface();
152 public:
159  static FlashLight& instance() noexcept;
165  ~FlashLight();
174  static void switchOn() noexcept;
183  static void switchOff() noexcept;
190  FlashLight ( const FlashLight& other ) = delete;
197  FlashLight ( FlashLight&& other ) = delete;
205  FlashLight& operator= ( const FlashLight& other ) = delete;
213  FlashLight& operator= ( FlashLight&& other ) = delete;
214 };
215 
216 }
217 
218 #endif // FLASHLIGHT_H