1 #include "binary_200_10.hpp"
9 binary_200_10::binary_200_10()
10 : vessel_id("@@@@@@@@")
14 void binary_200_10::read_from(const raw
& payload
)
16 if (payload
.size() != SIZE_BITS
)
17 throw std::invalid_argument
{"wrong number of bits in playload of binary_200_10"};
19 get(payload
, vessel_id
);
22 get(payload
, shiptype
);
24 get(payload
, draught
);
26 get(payload
, speed_q
);
27 get(payload
, course_q
);
28 get(payload
, heading_q
);
31 void binary_200_10::write_to(raw
& payload
) const
33 payload
= raw(SIZE_BITS
);
34 set(payload
, vessel_id
);
37 set(payload
, shiptype
);
39 set(payload
, draught
);
41 set(payload
, speed_q
);
42 set(payload
, course_q
);
43 set(payload
, heading_q
);
46 std::string
binary_200_10::get_vessel_id() const
48 return trim_ais_string(vessel_id
);
51 void binary_200_10::set_vessel_id(const std::string
& t
)
54 vessel_id
= t
.substr(0, 8);
60 /// Returns the lenght in meters.
61 double binary_200_10::get_length() const
66 void binary_200_10::set_length(double t
)
68 length
= std::max(0u, std::min(8000u, static_cast<uint32_t>(std::round(10.0 * t
))));
71 /// Returns the beam in meters.
72 double binary_200_10::get_beam() const
77 void binary_200_10::set_beam(double t
)
79 beam
= std::max(0u, std::min(1000u, static_cast<uint32_t>(std::round(10.0 * t
))));
82 /// Returns the draught in meters.
83 double binary_200_10::get_draught() const
85 return 0.01 * draught
;
88 void binary_200_10::set_draught(double t
)
90 draught
= std::max(0u, std::min(200u, static_cast<uint32_t>(std::round(100.0 * t
))));