Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add navigational status values #249

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/libais/ais.h
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,29 @@ class AisMsg {
bool CheckStatus() const;
};

enum AIS_NAVIGATIONAL_STATUS {
AIS_NV_STATUS_UNDER_WAY_USING_ENGINE = 0,
AIS_NV_STATUS_AT_ANCHOR = 1,
AIS_NV_STATUS_NOT_UNDER_COMMAND = 2,
AIS_NV_STATUS_RESTRICTED_MANEUVERABILITY = 3,
AIS_NV_STATUS_CONSTRAINED_BY_DRAUGHT = 4,
AIS_NV_STATUS_MOORED = 5,
AIS_NV_STATUS_AGROUND = 6,
AIS_NV_STATUS_ENGAGED_IN_FISHING = 7,
AIS_NV_STATUS_UNDER_WAY_SAILING = 8,
AIS_NV_STATUS_RESERVED1 = 9, // reserved for future amendment of navigational status for ships carrying DG, HS, or MP, or IMO hazard or pollutant category C, high-speed craft (HSC)
AIS_NV_STATUS_RESERVED2 = 10, // reserved for future amendment of navigational status for ships carrying dangerous goods (DG), harmful substances (HS) or marine pollutants (MP), or IMO hazard or pollutant category A, wing in ground (WIG)
AIS_NV_STATUS_TOWING_ASTERN = 11, // power-driven vessel towing astern (regional use)
AIS_NV_STATUS_PUSHING_AHEAD_OR_TOWING_ALONGSIDE = 12, // power-driven vessel pushing ahead or towing alongside (regional use)
AIS_NV_STATUS_RESERVED3 = 13, // reserved for future use
AIS_NV_STATUS_SART = 14, // AIS-SART (active), MOB-AIS, EPIRB-AIS
AIS_NV_STATUS_UNDEFINED = 15, // undefined = default (also used by AIS-SART, MOB-AIS and EPIRB-AIS under test)
};

// TODO(schwehr): factor out commstate from all messages?
class Ais1_2_3 : public AisMsg {
public:
int nav_status;
AIS_NAVIGATIONAL_STATUS nav_status;
bool rot_over_range;
int rot_raw;
float rot;
Expand Down
4 changes: 2 additions & 2 deletions src/libais/ais1_2_3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using std::abs;
namespace libais {

Ais1_2_3::Ais1_2_3(const char *nmea_payload, const size_t pad)
: AisMsg(nmea_payload, pad), nav_status(0), rot_over_range(false),
: AisMsg(nmea_payload, pad), nav_status(AIS_NV_STATUS_UNDEFINED), rot_over_range(false),
rot_raw(0), rot(0.0), sog(0.0), position_accuracy(0),
cog(0.0), true_heading(0), timestamp(0), special_manoeuvre(0), spare(0),
raim(false), sync_state(0),
Expand All @@ -32,7 +32,7 @@ Ais1_2_3::Ais1_2_3(const char *nmea_payload, const size_t pad)
assert(message_id >= 1 && message_id <= 3);

bits.SeekTo(38);
nav_status = bits.ToUnsignedInt(38, 4);
nav_status = (AIS_NAVIGATIONAL_STATUS)bits.ToUnsignedInt(38, 4);

rot_raw = bits.ToInt(42, 8);
rot_over_range = abs(rot_raw) > 126 ? true : false;
Expand Down