Build: add GCC-13, Clang-14, Clang-15, Clang-16, Clang-17
[marnav.git] / include / marnav / nmea / alr.hpp
blob54df2d9c9805400ba0b0ea29ac3cd6068585692b
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::nmea
9 /// @brief ALR - Set Alarm State
10 ///
11 /// @code
12 /// 1 2 3 4 5
13 /// | | | | |
14 /// $--ALR,hhmmss.ss,xxx,a,a,c--c*hh<CR><LF>
15 /// @endcode
16 ///
17 /// Field Number:
18 /// 1. Time UTC
19 /// 2. Alarm number
20 /// 3. Alarm condition
21 /// - A = Exceeded threshold
22 /// - V = Not exceeded threshold
23 /// 4. Alarm acknowledge state
24 /// - A = Acknoledged
25 /// - V = Unacknowledged
26 /// 5. Alarm text
27 ///
28 class alr : public sentence
30 friend class detail::factory;
32 public:
33 constexpr static sentence_id ID = sentence_id::ALR;
34 constexpr static const char * TAG = "ALR";
36 /// Alarm condition
37 enum class condition : char {
38 threshold_exceeded, ///< NMEA representation: 'A'
39 threshold_not_exceeded, ///< NMEA representation: 'V'
42 /// Alarm acknowledge state
43 enum class acknowledge : char {
44 acknowledged, ///< NMEA representation: 'A'
45 not_acknowledged, ///< NMEA representation: 'V'
48 alr();
49 alr(talker talk);
50 alr(const alr &) = default;
51 alr & operator=(const alr &) = default;
52 alr(alr &&) = default;
53 alr & operator=(alr &&) = default;
55 protected:
56 alr(talker talk, fields::const_iterator first, fields::const_iterator last);
57 void append_data_to(std::string &, const version &) const override;
59 private:
60 nmea::time time_utc_;
61 uint32_t number_ = 0u;
62 condition condition_ = condition::threshold_exceeded;
63 acknowledge acknowledge_ = acknowledge::acknowledged;
64 std::string text_;
66 public:
67 nmea::time get_time_utc() const { return time_utc_; }
68 uint32_t get_number() const { return number_; }
69 condition get_condition() const { return condition_; }
70 acknowledge get_acknowledge() const { return acknowledge_; }
71 const std::string & get_text() const { return text_; }
73 void set_time_utc(const nmea::time & t) { time_utc_ = t; }
74 void set_number(uint32_t n) { number_ = n; }
75 void set_condition(condition c) { condition_ = c; }
76 void set_acknowledge(acknowledge a) { acknowledge_ = a; }
77 void set_text(const std::string & t);
80 std::string to_string(alr::condition t);
81 std::string to_string(alr::acknowledge t);
83 std::string to_name(alr::condition t);
84 std::string to_name(alr::acknowledge t);
87 #endif