NMEA: sentence ALR added
[marnav.git] / include / marnav / nmea / alr.hpp
blob45558d576a290922ba8c3d666c075c830fe6aaf6
1 #ifndef MARNAV_NMEA_ALR_HPP
2 #define MARNAV_NMEA_ALR_HPP
4 #include <marnav/nmea/sentence.hpp>
5 #include <marnav/nmea/time.hpp>
7 namespace marnav
9 namespace nmea
11 /// @brief ALR - Set Alarm State
12 ///
13 /// @code
14 /// 1 2 3 4 5
15 /// | | | | |
16 /// $--ALR,hhmmss.ss,xxx,a,a,c--c*hh<CR><LF>
17 /// @endcode
18 ///
19 /// Field Number:
20 /// 1. Time UTC
21 /// 2. Alarm number
22 /// 3. Alarm condition
23 /// - A = Exceeded threshold
24 /// - V = Not exceeded threshold
25 /// 4. Alarm acknowledge state
26 /// - A = Acknoledged
27 /// - V = Unacknowledged
28 /// 5. Alarm text
29 ///
30 class alr : public sentence
32 friend class detail::factory;
34 public:
35 constexpr static sentence_id ID = sentence_id::ALR;
36 constexpr static const char * TAG = "ALR";
38 /// Alarm condition
39 enum class condition : char {
40 threshold_exceeded, ///< NMEA representation: 'A'
41 threshold_not_exceeded, ///< NMEA representation: 'V'
44 /// Alarm acknowledge state
45 enum class acknowledge : char {
46 acknowledged, ///< NMEA representation: 'A'
47 not_acknowledged, ///< NMEA representation: 'V'
50 alr();
51 alr(talker talk);
52 alr(const alr &) = default;
53 alr & operator=(const alr &) = default;
54 alr(alr &&) = default;
55 alr & operator=(alr &&) = default;
57 protected:
58 alr(talker talk, fields::const_iterator first, fields::const_iterator last);
59 virtual void append_data_to(std::string &) const override;
61 private:
62 nmea::time time_utc_;
63 uint32_t number_ = 0u;
64 condition condition_ = condition::threshold_exceeded;
65 acknowledge acknowledge_ = acknowledge::acknowledged;
66 std::string text_;
68 public:
69 nmea::time get_time_utc() const { return time_utc_; }
70 uint32_t get_number() const { return number_; }
71 condition get_condition() const { return condition_; }
72 acknowledge get_acknowledge() const { return acknowledge_; }
73 const std::string & get_text() const { return text_; }
75 void set_time_utc(const nmea::time & t) { time_utc_ = t; }
76 void set_number(uint32_t n) { number_ = n; }
77 void set_condition(condition c) { condition_ = c; }
78 void set_acknowledge(acknowledge a) { acknowledge_ = a; }
79 void set_text(const std::string & t);
82 std::string to_string(alr::condition t);
83 std::string to_string(alr::acknowledge t);
85 std::string to_name(alr::condition t);
86 std::string to_name(alr::acknowledge t);
90 #endif