Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 65 lines (53 sloc) 2.182 kB
113e862 Add message 19
schwehr authored
1 // Since 2010-May-05
2 // Msg 19 C - Extended Class B equipment position report
3 #include "ais.h"
4
5 Ais19::Ais19(const char *nmea_payload) {
6 assert(nmea_payload);
7
8 init();
9 if (strlen(nmea_payload) != 52) { status = AIS_ERR_BAD_BIT_COUNT; return; }
10
11 std::bitset<312> bs; // 1 + a partial slot
12 status = aivdm_to_bits(bs, nmea_payload);
13 if (had_error()) return;
14
15 message_id = ubits(bs, 0, 6);
16 if (19 != message_id) { status = AIS_ERR_WRONG_MSG_TYPE; return; }
17 repeat_indicator = ubits(bs,6,2);
18 mmsi = ubits(bs,8,30);
19
20 spare = ubits(bs,38,8);
21 sog = ubits(bs,46,10) / 10.;
22
23 position_accuracy = ubits(bs,56,1);
24 x = sbits(bs, 57, 28) / 600000.;
25 y = sbits(bs, 85, 27) / 600000.;
26
27 cog = ubits(bs, 112, 12) / 10.;
28 true_heading = ubits(bs, 124, 9);
29 timestamp = ubits(bs, 133, 6);
30 spare2 = ubits(bs, 139, 4);
31
32 name = ais_str(bs, 143, 120);
33
34 type_and_cargo = ubits(bs, 263, 8);
35 dim_a = ubits(bs, 271, 9);
36 dim_b = ubits(bs, 280, 9);
37 dim_c = ubits(bs, 289, 6);
38 dim_d = ubits(bs, 295, 6);
39
40 fix_type = ubits(bs, 301, 4);
41 raim = bool(bs[305]);
42 dte = bs[306];
43 assigned_mode = bs[307];
44 spare3 = ubits(bs,308,4);
45 }
46
47 void
48 Ais19::print() {
49 std::cout << "Class B Extended Position and ship: " << message_id
50 << "\tmmsi: " << mmsi << " repeat: " << repeat_indicator << "\n"
51 << "\tspare: " << spare << " sog: " << sog << "\n"
52 << "\tposacc: " << position_accuracy << "\n"
53 << "\tx: " << x << " y: " << y << "\n"
54 << "\tcog: " << cog << " true_heading: " << true_heading << "\n"
55 << "\ttimestamp: " << timestamp << " spare2: " << spare2 << "\n"
56 << "\tname: " << name << "\n"
57 << "\ttype_and_cargo: " << type_and_cargo << "\n"
58 << "\tdim: " << dim_a << " " << dim_b << " "<< dim_c << " " << dim_d << " (m)\n"
59 << "\tfix_type: " << fix_type << "\n"
60 << "\traim: " << (raim?"true":"false") << "\n"
61 << "\tdte: " << dte << " assigned_mode: " << assigned_mode << "\n"
62 << "\tspare3: " << spare3 << std::endl
63 ;
64 }
Something went wrong with that request. Please try again.