Debian Codegraph @

src/libais/ais20.cpp

raw symbols SCIP
1 // Msg 20 D - data link management
2
3 #include "ais.h"
4
5 namespace libais{
6
7 Ais20::Ais20(const char *nmea_payload, const size_t pad)
8 : AisMsg(nmea_payload, pad), spare(0), offset_1(0), num_slots_1(0),
9 timeout_1(0), incr_1(0), group_valid_2(false), offset_2(0),
10 num_slots_2(0), timeout_2(0), incr_2(0), group_valid_3(false),
11 offset_3(0), num_slots_3(0), timeout_3(0), incr_3(0),
12 group_valid_4(false), offset_4(0), num_slots_4(0), timeout_4(0),
13 incr_4(0), spare2(0) {
14 if (!CheckStatus()) {
15 return;
16 }
17 if (num_bits < 72 || num_bits > 160) {
18 status = AIS_ERR_BAD_BIT_COUNT; return;
19 }
20
21 // 160, but must be 6 bit aligned
22 assert(message_id == 20);
23
24 bits.SeekTo(38);
25 spare = bits.ToUnsignedInt(38, 2);
26
27 offset_1 = bits.ToUnsignedInt(40, 12);
28 num_slots_1 = bits.ToUnsignedInt(52, 4);
29 timeout_1 = bits.ToUnsignedInt(56, 3);
30 incr_1 = bits.ToUnsignedInt(59, 11);
31
32 if (num_bits == 72) {
33 spare2 = bits.ToUnsignedInt(70, 2);
34 assert(bits.GetRemaining() == 0);
35 status = AIS_OK;
36 return;
37 }
38
39 group_valid_2 = true;
40 offset_2 = bits.ToUnsignedInt(70, 12);
41 num_slots_2 = bits.ToUnsignedInt(82, 4);
42 timeout_2 = bits.ToUnsignedInt(86, 3);
43 incr_2 = bits.ToUnsignedInt(89, 11);
44 // 100 bits for the message
45 // 104 is the next byte boundary
46 // 108 is the next 6 bit boundary -> 18 characters
47 if (num_bits >= 100 && num_bits <=108) {
48 spare2 = bits.ToUnsignedInt(100, bits.GetRemaining());
49 status = AIS_OK;
50 return;
51 }
52
53 group_valid_3 = true;
54 offset_3 = bits.ToUnsignedInt(100, 12);
55 num_slots_3 = bits.ToUnsignedInt(112, 4);
56 timeout_3 = bits.ToUnsignedInt(116, 3);
57 incr_3 = bits.ToUnsignedInt(119, 11);
58 // 130 bits for the message
59 // 136 is the next byte boundary
60 // 138 is the next 6 bit boundary -> 23 characters
61 if (num_bits >= 130 && num_bits <= 138) {
62 // Makes the result 8 bit / 1 byte aligned.
63 spare2 = bits.ToUnsignedInt(130, bits.GetRemaining());
64 status = AIS_OK;
65 return;
66 }
67
68 group_valid_4 = true;
69 offset_4 = bits.ToUnsignedInt(130, 12);
70 num_slots_4 = bits.ToUnsignedInt(142, 4);
71 timeout_4 = bits.ToUnsignedInt(146, 3);
72 incr_4 = bits.ToUnsignedInt(149, 11);
73
74 spare2 = 0;
75
76 assert(bits.GetRemaining() == 0);
77 status = AIS_OK;
78 }
79
80 } // namespace libais