AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | List of all members
isobus::NMEA2000Messages::VesselHeading Class Reference

Represents the data sent in the NMEA2K PGN 127250 (0x1F112) More...

#include <nmea2000_message_definitions.hpp>

Public Types

enum class  HeadingSensorReference : std::uint8_t { True = 0 , Magnetic = 1 , Error = 2 , NotApplicableOrNull = 3 }
 The reference which the vessel heading is relative to. More...
 

Public Member Functions

 VesselHeading (std::shared_ptr< ControlFunction > source)
 Constructor for a VesselHeading message data object.
 
std::shared_ptr< ControlFunctionget_control_function () const
 Returns the control function sending this instance of this message.
 
std::uint32_t get_timestamp () const
 Returns a timestamp in milliseconds corresponding to when the message was last sent or received.
 
bool set_timestamp (std::uint32_t timestamp)
 Sets the time in milliseconds when the message was last sent or received.
 
std::uint16_t get_raw_heading () const
 Returns the vessel heading in units of 0.0001 radians, which are the message's base units.
 
float get_heading () const
 Returns the vessel heading in radians.
 
bool set_heading (std::uint16_t heading)
 Sets the vessel heading.
 
std::int16_t get_raw_magnetic_deviation () const
 Returns the magnetic deviation in 0.0001 radians.
 
float get_magnetic_deviation () const
 Returns the magnetic deviation in radians.
 
bool set_magnetic_deviation (std::int16_t deviation)
 Sets the magnetic deviation in 0.0001 radians.
 
std::int16_t get_raw_magnetic_variation () const
 Returns the magnetic variation in units of 0.0001 radians.
 
float get_magnetic_variation () const
 Returns the magnetic variation in units of radians.
 
bool set_magnetic_variation (std::int16_t variation)
 Sets the magnetic variation, in units of 0.0001 radians.
 
std::uint8_t get_sequence_id () const
 Returns the sequence ID. This is used to associate data within other PGNs with this message.
 
bool set_sequence_id (std::uint8_t sequenceNumber)
 Sets the sequence ID for this message.
 
HeadingSensorReference get_sensor_reference () const
 Returns the reference to which the reported heading is relative to.
 
bool set_sensor_reference (HeadingSensorReference reference)
 Sets the reference to which the reported heading is relative to.
 
void serialize (std::vector< std::uint8_t > &buffer) const
 Takes the current state of the object and serializes it into a buffer to be sent.
 
bool deserialize (const CANMessage &receivedMessage)
 Deserializes a CAN message to populate this object's contents. Updates the timestamp when called.
 

Static Public Member Functions

static std::uint32_t get_timeout ()
 Returns the timeout (the sending interval) for this message in milliseconds.
 

Private Attributes

std::shared_ptr< ControlFunctionsenderControlFunction
 The sender of the message data.
 
std::uint32_t messageTimestamp_ms = 0
 A timestamp in milliseconds when this message was last sent or received.
 
std::uint16_t headingReading = 0
 The raw heading in 0.0001 radians, relative to the indicated HeadingSensorReference.
 
std::int16_t magneticDeviation = 0
 The magnetic deviation if not included in the reading in 0.0001 radians. Positive values are easterly.
 
std::int16_t magneticVariation = 0
 The magnetic variation if applicable in 0.0001 radians. Positive values are easterly. If the reference is magnetic, you can add this to the heading to get data relative to true north.
 
std::uint8_t sequenceID = 0
 The sequence identifier field is used to tie related PGNs together. Somewhat arbitrary.
 
HeadingSensorReference sensorReference = HeadingSensorReference::NotApplicableOrNull
 Indicates what the heading is relative to, ie true or magnetic north.
 

Static Private Attributes

static constexpr std::uint32_t CYCLIC_MESSAGE_RATE_MS = 100
 The interval in milliseconds on which this message should be sent/received.
 

Detailed Description

Represents the data sent in the NMEA2K PGN 127250 (0x1F112)

Definition at line 30 of file nmea2000_message_definitions.hpp.

Member Enumeration Documentation

◆ HeadingSensorReference

The reference which the vessel heading is relative to.

Enumerator
True 

True North.

Magnetic 

Magnetic North.

Definition at line 34 of file nmea2000_message_definitions.hpp.

Constructor & Destructor Documentation

◆ VesselHeading()

isobus::NMEA2000Messages::VesselHeading::VesselHeading ( std::shared_ptr< ControlFunction > source)
explicit

Constructor for a VesselHeading message data object.

Parameters
[in]sourceThe control function sending this message

Definition at line 24 of file nmea2000_message_definitions.cpp.

Member Function Documentation

◆ deserialize()

bool isobus::NMEA2000Messages::VesselHeading::deserialize ( const CANMessage & receivedMessage)

Deserializes a CAN message to populate this object's contents. Updates the timestamp when called.

Parameters
[in]receivedMessageThe CAN message to parse when deserializing
Returns
True if the message was successfully deserialized and the data content was different than the stored content.

Definition at line 135 of file nmea2000_message_definitions.cpp.

Here is the call graph for this function:

◆ get_control_function()

std::shared_ptr< ControlFunction > isobus::NMEA2000Messages::VesselHeading::get_control_function ( ) const

Returns the control function sending this instance of this message.

Returns
The control function sending this instance of this message

Definition at line 29 of file nmea2000_message_definitions.cpp.

◆ get_heading()

float isobus::NMEA2000Messages::VesselHeading::get_heading ( ) const

Returns the vessel heading in radians.

Returns
Vessel heading in radians

Definition at line 51 of file nmea2000_message_definitions.cpp.

◆ get_magnetic_deviation()

float isobus::NMEA2000Messages::VesselHeading::get_magnetic_deviation ( ) const

Returns the magnetic deviation in radians.

Returns
The magnetic deviation in radians

Definition at line 68 of file nmea2000_message_definitions.cpp.

◆ get_magnetic_variation()

float isobus::NMEA2000Messages::VesselHeading::get_magnetic_variation ( ) const

Returns the magnetic variation in units of radians.

Returns
The magnetic variation in units of radians

Definition at line 85 of file nmea2000_message_definitions.cpp.

◆ get_raw_heading()

std::uint16_t isobus::NMEA2000Messages::VesselHeading::get_raw_heading ( ) const

Returns the vessel heading in units of 0.0001 radians, which are the message's base units.

Returns
Vessel heading in units of 0.0001 radians

Definition at line 46 of file nmea2000_message_definitions.cpp.

◆ get_raw_magnetic_deviation()

std::int16_t isobus::NMEA2000Messages::VesselHeading::get_raw_magnetic_deviation ( ) const

Returns the magnetic deviation in 0.0001 radians.

Returns
The magnetic deviation in 0.0001 radians

Definition at line 63 of file nmea2000_message_definitions.cpp.

◆ get_raw_magnetic_variation()

std::int16_t isobus::NMEA2000Messages::VesselHeading::get_raw_magnetic_variation ( ) const

Returns the magnetic variation in units of 0.0001 radians.

Returns
The magnetic variation in units of 0.0001 radians

Definition at line 80 of file nmea2000_message_definitions.cpp.

◆ get_sensor_reference()

VesselHeading::HeadingSensorReference isobus::NMEA2000Messages::VesselHeading::get_sensor_reference ( ) const

Returns the reference to which the reported heading is relative to.

Returns
The reference to which the reported heading is relative to

Definition at line 109 of file nmea2000_message_definitions.cpp.

◆ get_sequence_id()

std::uint8_t isobus::NMEA2000Messages::VesselHeading::get_sequence_id ( ) const

Returns the sequence ID. This is used to associate data within other PGNs with this message.

Returns
The sequence ID for this message

Definition at line 97 of file nmea2000_message_definitions.cpp.

◆ get_timeout()

std::uint32_t isobus::NMEA2000Messages::VesselHeading::get_timeout ( )
static

Returns the timeout (the sending interval) for this message in milliseconds.

Returns
This message's timeout (the sending interval) in milliseconds

Definition at line 155 of file nmea2000_message_definitions.cpp.

Here is the caller graph for this function:

◆ get_timestamp()

std::uint32_t isobus::NMEA2000Messages::VesselHeading::get_timestamp ( ) const

Returns a timestamp in milliseconds corresponding to when the message was last sent or received.

Returns
A timestamp in milliseconds corresponding to when the message was last sent or received

Definition at line 34 of file nmea2000_message_definitions.cpp.

◆ serialize()

void isobus::NMEA2000Messages::VesselHeading::serialize ( std::vector< std::uint8_t > & buffer) const

Takes the current state of the object and serializes it into a buffer to be sent.

Parameters
[in]bufferA vector to populate with the message data

Definition at line 121 of file nmea2000_message_definitions.cpp.

◆ set_heading()

bool isobus::NMEA2000Messages::VesselHeading::set_heading ( std::uint16_t heading)

Sets the vessel heading.

Parameters
[in]headingThe heading to set in 0.0001 radians
Returns
True if the value that was set was different from the stored value

Definition at line 56 of file nmea2000_message_definitions.cpp.

Here is the caller graph for this function:

◆ set_magnetic_deviation()

bool isobus::NMEA2000Messages::VesselHeading::set_magnetic_deviation ( std::int16_t deviation)

Sets the magnetic deviation in 0.0001 radians.

Parameters
[in]deviationThe magnetic deviation to set, in units of 0.0001 radians
Returns
true if the value that was set was different from the stored value

Definition at line 73 of file nmea2000_message_definitions.cpp.

Here is the caller graph for this function:

◆ set_magnetic_variation()

bool isobus::NMEA2000Messages::VesselHeading::set_magnetic_variation ( std::int16_t variation)

Sets the magnetic variation, in units of 0.0001 radians.

Parameters
[in]variationThe magnetic variation to set, in units of 0.0001 radians
Returns
true if the value that was set was different from the stored value

Definition at line 90 of file nmea2000_message_definitions.cpp.

Here is the caller graph for this function:

◆ set_sensor_reference()

bool isobus::NMEA2000Messages::VesselHeading::set_sensor_reference ( HeadingSensorReference reference)

Sets the reference to which the reported heading is relative to.

Parameters
[in]referenceThe reference to set
Returns
true if the value that was set was different from the stored value

Definition at line 114 of file nmea2000_message_definitions.cpp.

Here is the caller graph for this function:

◆ set_sequence_id()

bool isobus::NMEA2000Messages::VesselHeading::set_sequence_id ( std::uint8_t sequenceNumber)

Sets the sequence ID for this message.

Parameters
[in]sequenceNumberThe sequence number to set. Max value is 252.
Returns
true if the value that was set was different from the stored value

Definition at line 102 of file nmea2000_message_definitions.cpp.

Here is the caller graph for this function:

◆ set_timestamp()

bool isobus::NMEA2000Messages::VesselHeading::set_timestamp ( std::uint32_t timestamp)

Sets the time in milliseconds when the message was last sent or received.

Parameters
[in]timestampThe timestamp (in milliseconds) to set for when this message was sent or received
Returns
true if the value that was set was different from the stored value

Definition at line 39 of file nmea2000_message_definitions.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ CYCLIC_MESSAGE_RATE_MS

constexpr std::uint32_t isobus::NMEA2000Messages::VesselHeading::CYCLIC_MESSAGE_RATE_MS = 100
staticconstexprprivate

The interval in milliseconds on which this message should be sent/received.

Definition at line 130 of file nmea2000_message_definitions.hpp.

◆ headingReading

std::uint16_t isobus::NMEA2000Messages::VesselHeading::headingReading = 0
private

The raw heading in 0.0001 radians, relative to the indicated HeadingSensorReference.

Definition at line 134 of file nmea2000_message_definitions.hpp.

◆ magneticDeviation

std::int16_t isobus::NMEA2000Messages::VesselHeading::magneticDeviation = 0
private

The magnetic deviation if not included in the reading in 0.0001 radians. Positive values are easterly.

Definition at line 135 of file nmea2000_message_definitions.hpp.

◆ magneticVariation

std::int16_t isobus::NMEA2000Messages::VesselHeading::magneticVariation = 0
private

The magnetic variation if applicable in 0.0001 radians. Positive values are easterly. If the reference is magnetic, you can add this to the heading to get data relative to true north.

Definition at line 136 of file nmea2000_message_definitions.hpp.

◆ messageTimestamp_ms

std::uint32_t isobus::NMEA2000Messages::VesselHeading::messageTimestamp_ms = 0
private

A timestamp in milliseconds when this message was last sent or received.

Definition at line 133 of file nmea2000_message_definitions.hpp.

◆ senderControlFunction

std::shared_ptr<ControlFunction> isobus::NMEA2000Messages::VesselHeading::senderControlFunction
private

The sender of the message data.

Definition at line 132 of file nmea2000_message_definitions.hpp.

◆ sensorReference

HeadingSensorReference isobus::NMEA2000Messages::VesselHeading::sensorReference = HeadingSensorReference::NotApplicableOrNull
private

Indicates what the heading is relative to, ie true or magnetic north.

Definition at line 138 of file nmea2000_message_definitions.hpp.

◆ sequenceID

std::uint8_t isobus::NMEA2000Messages::VesselHeading::sequenceID = 0
private

The sequence identifier field is used to tie related PGNs together. Somewhat arbitrary.

Definition at line 137 of file nmea2000_message_definitions.hpp.


The documentation for this class was generated from the following files: