Build: enhance docker use, reducing build options, cleanup
[marnav.git] / src / marnav / nmea / dsc.hpp
blob52fb6839453800f8a3e4124287e99e741a698058
1 #ifndef MARNAV__NMEA__DSC__HPP
2 #define MARNAV__NMEA__DSC__HPP
4 #include <marnav/nmea/sentence.hpp>
5 #include <marnav/utils/optional.hpp>
6 #include <marnav/utils/mmsi.hpp>
7 #include <marnav/geo/region.hpp>
9 namespace marnav
11 namespace nmea
13 /// @brief DSC - Digital Selective Calling Information
14 ///
15 /// @note This class is @b EXPERIMENTAL
16 ///
17 /// @code
18 /// 11
19 /// 1 2 3 4 5 6 7 8 9 10|
20 /// | | | | | | | | | | |
21 /// $--DSC,xx,xxxxxxxxxx,xx,xx,xx,xxxxxxxxxx,xxxx,?,?,a,a*hh<CR><LF>
22 /// @endcode
23 ///
24 /// Field Number:
25 /// 1. Format Specifier
26 /// 2. Address (MMSI or geographical area), 10 digits
27 /// 3. Category
28 /// 4. Nature of distress or Telecommand 1
29 /// 5. Telecommand 2
30 /// 6. Position or Channel/Frequency
31 /// 7. Time (HHMM)
32 /// 8. ?
33 /// 9. ?
34 /// 10. Acknowledgment
35 /// - B
36 /// - R
37 /// - S = End of Sequence
38 /// 11. Extension Indicator
39 /// - E = extension sentence (DSE) will follow, if not the field is null
40 ///
41 /// @todo IMPLEMENTATION
42 ///
43 class dsc : public sentence
45 friend class detail::factory;
47 public:
48 constexpr static sentence_id ID = sentence_id::DSC;
49 constexpr static const char * TAG = "DSC";
51 /// Format Specifier
52 enum class format_specifier : uint32_t {
53 geographical_area, ///< 102: Geographical, specifies an area
54 distress, ///< 112: Distress
55 all_ships, ///< 116: All Ships
56 individual_station, ///< 120: Individual Station
59 /// Category
60 enum class category : uint32_t {
61 routine, ///< 100: Routine Call
62 safety, ///< 108: Safety Call
63 urgency, ///< 110: Urgency Call
64 distress ///< 112: Distress
67 /// Nature of distress
68 enum class distress_designation : uint32_t {
69 fire = 100, ///< Fire/explosion
70 flooding = 101, ///< Flooding
71 collision = 102, ///< Collision
72 grounding = 103, ///< Grounding
73 listing = 104, ///< Listing, danger of capsizing
74 sinking = 105, ///< Sinking
75 adrift = 106, ///< Disabled and adrift
76 undesignated = 107, ///< Undesignated Distress
77 abandoning = 108, ///< Abandoning ship
78 piracy = 109, ///< Piracy / armed robbery attack
79 mob = 110, ///< Man over board
80 epirb = 112, ///< EPIRB emission
83 /// First Telecommand
84 enum class first_telecommand : uint32_t {
85 polling = 103, ///< Polling
86 unable_to_comply = 104, ///< Unable to comply
87 end_of_call = 105, ///< End of call
88 data = 106, ///< Data
89 distress_ack = 110, ///< Distress acknowledgement
90 distress_relay = 112, ///< Distress relay
91 test = 118, ///< Test
92 no_information = 126, ///< No Information
95 /// Second Telecommand
96 enum class second_telecommand : uint32_t {
97 no_information, ///< 126: No Information
100 enum class acknowledgement : char {
101 B, ///< ?
102 R, ///< ?
103 end_of_sequence ///< NMEA representation: 'S'
106 enum class extension_indicator : char {
107 none, ///< no NMEA representation
108 extension_follows ///< NMEA representation: 'E'
111 dsc();
112 dsc(const dsc &) = default;
113 dsc & operator=(const dsc &) = default;
114 dsc(dsc &&) = default;
115 dsc & operator=(dsc &&) = default;
117 protected:
118 dsc(talker talk, fields::const_iterator first, fields::const_iterator last);
119 virtual void append_data_to(std::string &) const override;
121 private:
122 format_specifier fmt_spec_ = format_specifier::distress;
123 uint64_t address_ = 0; // space for 10 decimal digits
124 category cat_ = category::distress;
125 // @todo Implement other 6 data members
126 acknowledgement ack_ = acknowledgement::end_of_sequence;
127 extension_indicator extension_ = extension_indicator::none;
129 public:
130 decltype(fmt_spec_) get_fmt_spec() const { return fmt_spec_; }
131 decltype(cat_) get_cat() const { return cat_; }
132 utils::mmsi get_mmsi() const;
133 geo::region get_geographical_area() const;
134 decltype(ack_) get_ack() const { return ack_; }
135 decltype(extension_) get_extension() const { return extension_; }
138 std::string to_string(dsc::format_specifier value);
139 std::string to_string(dsc::category value);
140 std::string to_string(dsc::acknowledgement value);
141 std::string to_string(dsc::extension_indicator value);
145 #endif