AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
|
This interface manages and parses ISOBUS speed messages. More...
#include <isobus_speed_distance_messages.hpp>
Classes | |
class | GroundBasedSpeedData |
Message normally sent by the Tractor ECU on the implement bus on construction and agricultural implements providing to connected systems the current measured ground speed (also includes a free-running distance counter and an indication of the direction of travel). More... | |
class | MachineSelectedSpeedCommandData |
Message that provides the control of the machine speed and direction. If you receive this message, you can sniff the speed commands being sent to the TECU or act as the TECU or propulsion interface yourself. More... | |
class | MachineSelectedSpeedData |
Message that provides the current machine selected speed, direction and source parameters. More... | |
class | WheelBasedMachineSpeedData |
Groups the data encoded in an ISO "Wheel-based Speed and Distance" message. More... | |
Public Types | |
enum class | MachineDirection : std::uint8_t { Forward = 0 , Reverse = 1 , Error = 2 , NotAvailable = 3 } |
Enumerates the values of the direction of travel for the machine. More... | |
Public Member Functions | |
SpeedMessagesInterface (std::shared_ptr< InternalControlFunction > source, bool enableSendingGroundBasedSpeedPeriodically=false, bool enableSendingWheelBasedSpeedPeriodically=false, bool enableSendingMachineSelectedSpeedPeriodically=false, bool enableSendingMachineSelectedSpeedCommandPeriodically=false) | |
Constructor for a SpeedMessagesInterface. | |
~SpeedMessagesInterface () | |
Destructor for SpeedMessagesInterface. Cleans up PGN registrations if needed. | |
void | initialize () |
Sets up the class and registers it to receive callbacks from the network manager for processing guidance messages. The class will not receive messages if this is not called. | |
bool | get_initialized () const |
Returns if the interface has been initialized. | |
std::size_t | get_number_received_wheel_based_speed_sources () const |
Returns the number of received, unique wheel-based speed message sources. | |
std::size_t | get_number_received_ground_based_speed_sources () const |
Returns the number of received, unique ground-based speed message sources. | |
std::size_t | get_number_received_machine_selected_speed_sources () const |
Returns the number of received, unique machine selected speed message sources. | |
std::size_t | get_number_received_machine_selected_speed_command_sources () const |
Returns the number of received, unique machine selected speed command message sources. | |
std::shared_ptr< MachineSelectedSpeedData > | get_received_machine_selected_speed (std::size_t index) |
Returns the content of the machine selected speed message based on the index of the sender. Use this to read the received messages' content. | |
std::shared_ptr< WheelBasedMachineSpeedData > | get_received_wheel_based_speed (std::size_t index) |
Returns the content of the wheel-based speed message based on the index of the sender. Use this to read the received messages' content. | |
std::shared_ptr< GroundBasedSpeedData > | get_received_ground_based_speed (std::size_t index) |
Returns the content of the ground-based speed message based on the index of the sender. Use this to read the received messages' content. | |
std::shared_ptr< MachineSelectedSpeedCommandData > | get_received_machine_selected_speed_command (std::size_t index) |
Returns the content of the machine selected speed command message based on the index of the sender. Use this to read the received messages' content. | |
EventDispatcher< const std::shared_ptr< WheelBasedMachineSpeedData >, bool > & | get_wheel_based_machine_speed_data_event_publisher () |
Returns an event dispatcher which you can use to get callbacks when new/updated wheel-based speed messages are received. | |
EventDispatcher< const std::shared_ptr< MachineSelectedSpeedData >, bool > & | get_machine_selected_speed_data_event_publisher () |
Returns an event dispatcher which you can use to get callbacks when new/updated machine selected speed messages are received. | |
EventDispatcher< const std::shared_ptr< GroundBasedSpeedData >, bool > & | get_ground_based_machine_speed_data_event_publisher () |
Returns an event dispatcher which you can use to get callbacks when new/updated ground-based speed messages are received. | |
EventDispatcher< const std::shared_ptr< MachineSelectedSpeedCommandData >, bool > & | get_machine_selected_speed_command_data_event_publisher () |
Returns an event dispatcher which you can use to get callbacks when new/updated machine selected speed command messages are received. | |
void | update () |
Call this cyclically to update the interface. Transmits messages if needed and processes timeouts for received messages. | |
Public Attributes | |
MachineSelectedSpeedData | machineSelectedSpeedTransmitData |
Use this to configure transmission of the machine selected speed message. If you pass in an internal control function to the constructor of this class, then this message is available to be sent. | |
WheelBasedMachineSpeedData | wheelBasedSpeedTransmitData |
Use this to configure transmission of the wheel-based speed message. If you pass in an internal control function to the constructor of this class, then this message is available to be sent. | |
GroundBasedSpeedData | groundBasedSpeedTransmitData |
Use this to configure transmission of the ground-based speed message. If you pass in an internal control function to the constructor of this class, then this message is available to be sent. | |
MachineSelectedSpeedCommandData | machineSelectedSpeedCommandTransmitData |
Use this to configure transmission of the machine selected speed command message. If you pass in an internal control function to the constructor of this class, then this message is available to be sent. | |
Protected Types | |
enum class | TransmitFlags : std::uint32_t { SendWheelBasedSpeed = 0 , SendMachineSelectedSpeed , SendGroundBasedSpeed , SendMachineSelectedSpeedCommand , NumberOfFlags } |
Enumerates a set of flags to manage transmitting messages owned by this interface. More... | |
Protected Member Functions | |
bool | send_machine_selected_speed () const |
Sends the machine selected speed message. | |
bool | send_wheel_based_speed () const |
Sends the wheel-based speed message. | |
bool | send_ground_based_speed () const |
Sends the ground-based speed message. | |
bool | send_machine_selected_speed_command () const |
Sends the machine selected speed command message. | |
Static Protected Member Functions | |
static void | process_flags (std::uint32_t flag, void *parentPointer) |
Processes one flag (which sends the associated message) | |
static void | process_rx_message (const CANMessage &message, void *parentPointer) |
Processes a CAN message. | |
Protected Attributes | |
ProcessingFlags | txFlags |
Tx flag for sending messages periodically. | |
EventDispatcher< const std::shared_ptr< WheelBasedMachineSpeedData >, bool > | wheelBasedMachineSpeedDataEventPublisher |
An event publisher for notifying when new wheel-based speed messages are received. | |
EventDispatcher< const std::shared_ptr< MachineSelectedSpeedData >, bool > | machineSelectedSpeedDataEventPublisher |
An event publisher for notifying when new machine selected speed messages are received. | |
EventDispatcher< const std::shared_ptr< GroundBasedSpeedData >, bool > | groundBasedSpeedDataEventPublisher |
An event publisher for notifying when new ground-based speed messages are received. | |
EventDispatcher< const std::shared_ptr< MachineSelectedSpeedCommandData >, bool > | machineSelectedSpeedCommandDataEventPublisher |
An event publisher for notifying when new machine selected speed command messages are received. | |
std::vector< std::shared_ptr< WheelBasedMachineSpeedData > > | receivedWheelBasedSpeedMessages |
A list of all received wheel-based speed messages. | |
std::vector< std::shared_ptr< MachineSelectedSpeedData > > | receivedMachineSelectedSpeedMessages |
A list of all received machine selected speed messages. | |
std::vector< std::shared_ptr< GroundBasedSpeedData > > | receivedGroundBasedSpeedMessages |
A list of all received ground-based speed messages. | |
std::vector< std::shared_ptr< MachineSelectedSpeedCommandData > > | receivedMachineSelectedSpeedCommandMessages |
A list of all received ground-based speed messages. | |
std::uint32_t | wheelBasedSpeedTransmitTimestamp_ms = 0 |
Timestamp used to know when to transmit the wheel-based speed message in milliseconds. | |
std::uint32_t | machineSelectedSpeedTransmitTimestamp_ms = 0 |
Timestamp used to know when to transmit the machine selected speed message in milliseconds. | |
std::uint32_t | groundBasedSpeedTransmitTimestamp_ms = 0 |
Timestamp used to know when to transmit the ground-based speed message in milliseconds. | |
std::uint32_t | machineSelectedSpeedCommandTransmitTimestamp_ms = 0 |
Timestamp used to know when to transmit the ground-based speed message in milliseconds. | |
bool | initialized = false |
Stores if the interface has been initialized. | |
Static Protected Attributes | |
static constexpr std::uint32_t | SPEED_DISTANCE_MESSAGE_TX_INTERVAL_MS = 100 |
The interval (in milliseconds) defined in ISO11783-7 for sending this class's messages. | |
static constexpr std::uint32_t | SPEED_DISTANCE_MESSAGE_RX_TIMEOUT_MS = 3 * SPEED_DISTANCE_MESSAGE_TX_INTERVAL_MS |
A (somewhat arbitrary) timeout for detecting stale messages. | |
static constexpr std::uint32_t | SAEds05_MAX_VALUE = 4211081215 |
The maximum valid value for a SAEds05 slot (see J1939) | |
static constexpr std::uint16_t | SAEvl01_MAX_VALUE = 64255 |
The maximum valid value for a SAEvl01 slot (see J1939) | |
This interface manages and parses ISOBUS speed messages.
Definition at line 26 of file isobus_speed_distance_messages.hpp.
|
strong |
Enumerates the values of the direction of travel for the machine.
Definition at line 47 of file isobus_speed_distance_messages.hpp.
|
strongprotected |
Enumerates a set of flags to manage transmitting messages owned by this interface.
Definition at line 578 of file isobus_speed_distance_messages.hpp.
isobus::SpeedMessagesInterface::SpeedMessagesInterface | ( | std::shared_ptr< InternalControlFunction > | source, |
bool | enableSendingGroundBasedSpeedPeriodically = false, | ||
bool | enableSendingWheelBasedSpeedPeriodically = false, | ||
bool | enableSendingMachineSelectedSpeedPeriodically = false, | ||
bool | enableSendingMachineSelectedSpeedCommandPeriodically = false ) |
Constructor for a SpeedMessagesInterface.
[in] | source | The internal control function to use when sending messages, or nullptr for listen only |
[in] | enableSendingGroundBasedSpeedPeriodically | If true, ground-based speed will be sent periodically. (Normally you will not want to send this unless you are sensing the speed yourself) |
[in] | enableSendingWheelBasedSpeedPeriodically | If true, wheel-based speed will be sent periodically. (Normally you will not want to send this unless you are sensing the speed yourself) |
[in] | enableSendingMachineSelectedSpeedPeriodically | If true, machine-selected speed will be sent periodically. (Normally you will not want to send this unless you are selecting the speed yourself) |
[in] | enableSendingMachineSelectedSpeedCommandPeriodically | If true, machine-selected speed command will be sent periodically. (Normally you will not want to send this unless you are intending to cause machine motion) |
Definition at line 31 of file isobus_speed_distance_messages.cpp.
isobus::SpeedMessagesInterface::~SpeedMessagesInterface | ( | ) |
Destructor for SpeedMessagesInterface. Cleans up PGN registrations if needed.
Definition at line 44 of file isobus_speed_distance_messages.cpp.
EventDispatcher< const std::shared_ptr< SpeedMessagesInterface::GroundBasedSpeedData >, bool > & isobus::SpeedMessagesInterface::get_ground_based_machine_speed_data_event_publisher | ( | ) |
Returns an event dispatcher which you can use to get callbacks when new/updated ground-based speed messages are received.
Definition at line 511 of file isobus_speed_distance_messages.cpp.
bool isobus::SpeedMessagesInterface::get_initialized | ( | ) | const |
Returns if the interface has been initialized.
Definition at line 432 of file isobus_speed_distance_messages.cpp.
EventDispatcher< const std::shared_ptr< SpeedMessagesInterface::MachineSelectedSpeedCommandData >, bool > & isobus::SpeedMessagesInterface::get_machine_selected_speed_command_data_event_publisher | ( | ) |
Returns an event dispatcher which you can use to get callbacks when new/updated machine selected speed command messages are received.
Definition at line 516 of file isobus_speed_distance_messages.cpp.
EventDispatcher< const std::shared_ptr< SpeedMessagesInterface::MachineSelectedSpeedData >, bool > & isobus::SpeedMessagesInterface::get_machine_selected_speed_data_event_publisher | ( | ) |
Returns an event dispatcher which you can use to get callbacks when new/updated machine selected speed messages are received.
Definition at line 506 of file isobus_speed_distance_messages.cpp.
std::size_t isobus::SpeedMessagesInterface::get_number_received_ground_based_speed_sources | ( | ) | const |
Returns the number of received, unique ground-based speed message sources.
Definition at line 442 of file isobus_speed_distance_messages.cpp.
std::size_t isobus::SpeedMessagesInterface::get_number_received_machine_selected_speed_command_sources | ( | ) | const |
Returns the number of received, unique machine selected speed command message sources.
Definition at line 452 of file isobus_speed_distance_messages.cpp.
std::size_t isobus::SpeedMessagesInterface::get_number_received_machine_selected_speed_sources | ( | ) | const |
Returns the number of received, unique machine selected speed message sources.
Definition at line 447 of file isobus_speed_distance_messages.cpp.
std::size_t isobus::SpeedMessagesInterface::get_number_received_wheel_based_speed_sources | ( | ) | const |
Returns the number of received, unique wheel-based speed message sources.
Definition at line 437 of file isobus_speed_distance_messages.cpp.
std::shared_ptr< SpeedMessagesInterface::GroundBasedSpeedData > isobus::SpeedMessagesInterface::get_received_ground_based_speed | ( | std::size_t | index | ) |
Returns the content of the ground-based speed message based on the index of the sender. Use this to read the received messages' content.
[in] | index | An index of senders of the ground-based speed message |
Definition at line 479 of file isobus_speed_distance_messages.cpp.
std::shared_ptr< SpeedMessagesInterface::MachineSelectedSpeedData > isobus::SpeedMessagesInterface::get_received_machine_selected_speed | ( | std::size_t | index | ) |
Returns the content of the machine selected speed message based on the index of the sender. Use this to read the received messages' content.
[in] | index | An index of senders of the machine selected speed message |
Definition at line 457 of file isobus_speed_distance_messages.cpp.
std::shared_ptr< SpeedMessagesInterface::MachineSelectedSpeedCommandData > isobus::SpeedMessagesInterface::get_received_machine_selected_speed_command | ( | std::size_t | index | ) |
Returns the content of the machine selected speed command message based on the index of the sender. Use this to read the received messages' content.
[in] | index | An index of senders of the machine selected speed command message |
Definition at line 490 of file isobus_speed_distance_messages.cpp.
std::shared_ptr< SpeedMessagesInterface::WheelBasedMachineSpeedData > isobus::SpeedMessagesInterface::get_received_wheel_based_speed | ( | std::size_t | index | ) |
Returns the content of the wheel-based speed message based on the index of the sender. Use this to read the received messages' content.
[in] | index | An index of senders of the wheel-based speed message |
Definition at line 468 of file isobus_speed_distance_messages.cpp.
EventDispatcher< const std::shared_ptr< SpeedMessagesInterface::WheelBasedMachineSpeedData >, bool > & isobus::SpeedMessagesInterface::get_wheel_based_machine_speed_data_event_publisher | ( | ) |
Returns an event dispatcher which you can use to get callbacks when new/updated wheel-based speed messages are received.
Definition at line 501 of file isobus_speed_distance_messages.cpp.
void isobus::SpeedMessagesInterface::initialize | ( | ) |
Sets up the class and registers it to receive callbacks from the network manager for processing guidance messages. The class will not receive messages if this is not called.
Definition at line 416 of file isobus_speed_distance_messages.cpp.
|
staticprotected |
Processes one flag (which sends the associated message)
[in] | flag | The flag to process |
[in] | parentPointer | A pointer to the interface instance |
Definition at line 582 of file isobus_speed_distance_messages.cpp.
|
staticprotected |
Processes a CAN message.
[in] | message | The CAN message being received |
[in] | parentPointer | A context variable to find the relevant instance of this class |
Definition at line 626 of file isobus_speed_distance_messages.cpp.
|
protected |
Sends the ground-based speed message.
Definition at line 848 of file isobus_speed_distance_messages.cpp.
|
protected |
Sends the machine selected speed message.
Definition at line 793 of file isobus_speed_distance_messages.cpp.
|
protected |
Sends the machine selected speed command message.
Definition at line 872 of file isobus_speed_distance_messages.cpp.
|
protected |
Sends the wheel-based speed message.
Definition at line 821 of file isobus_speed_distance_messages.cpp.
void isobus::SpeedMessagesInterface::update | ( | ) |
Call this cyclically to update the interface. Transmits messages if needed and processes timeouts for received messages.
Definition at line 521 of file isobus_speed_distance_messages.cpp.
|
protected |
An event publisher for notifying when new ground-based speed messages are received.
Definition at line 622 of file isobus_speed_distance_messages.hpp.
GroundBasedSpeedData isobus::SpeedMessagesInterface::groundBasedSpeedTransmitData |
Use this to configure transmission of the ground-based speed message. If you pass in an internal control function to the constructor of this class, then this message is available to be sent.
Definition at line 498 of file isobus_speed_distance_messages.hpp.
|
protected |
Timestamp used to know when to transmit the ground-based speed message in milliseconds.
Definition at line 630 of file isobus_speed_distance_messages.hpp.
|
protected |
Stores if the interface has been initialized.
Definition at line 632 of file isobus_speed_distance_messages.hpp.
|
protected |
An event publisher for notifying when new machine selected speed command messages are received.
Definition at line 623 of file isobus_speed_distance_messages.hpp.
MachineSelectedSpeedCommandData isobus::SpeedMessagesInterface::machineSelectedSpeedCommandTransmitData |
Use this to configure transmission of the machine selected speed command message. If you pass in an internal control function to the constructor of this class, then this message is available to be sent.
Definition at line 502 of file isobus_speed_distance_messages.hpp.
|
protected |
Timestamp used to know when to transmit the ground-based speed message in milliseconds.
Definition at line 631 of file isobus_speed_distance_messages.hpp.
|
protected |
An event publisher for notifying when new machine selected speed messages are received.
Definition at line 621 of file isobus_speed_distance_messages.hpp.
MachineSelectedSpeedData isobus::SpeedMessagesInterface::machineSelectedSpeedTransmitData |
Use this to configure transmission of the machine selected speed message. If you pass in an internal control function to the constructor of this class, then this message is available to be sent.
Definition at line 490 of file isobus_speed_distance_messages.hpp.
|
protected |
Timestamp used to know when to transmit the machine selected speed message in milliseconds.
Definition at line 629 of file isobus_speed_distance_messages.hpp.
|
protected |
A list of all received ground-based speed messages.
Definition at line 626 of file isobus_speed_distance_messages.hpp.
|
protected |
A list of all received ground-based speed messages.
Definition at line 627 of file isobus_speed_distance_messages.hpp.
|
protected |
A list of all received machine selected speed messages.
Definition at line 625 of file isobus_speed_distance_messages.hpp.
|
protected |
A list of all received wheel-based speed messages.
Definition at line 624 of file isobus_speed_distance_messages.hpp.
|
staticconstexprprotected |
The maximum valid value for a SAEds05 slot (see J1939)
Definition at line 590 of file isobus_speed_distance_messages.hpp.
|
staticconstexprprotected |
The maximum valid value for a SAEvl01 slot (see J1939)
Definition at line 591 of file isobus_speed_distance_messages.hpp.
|
staticconstexprprotected |
A (somewhat arbitrary) timeout for detecting stale messages.
Definition at line 589 of file isobus_speed_distance_messages.hpp.
|
staticconstexprprotected |
The interval (in milliseconds) defined in ISO11783-7 for sending this class's messages.
Definition at line 588 of file isobus_speed_distance_messages.hpp.
|
protected |
Tx flag for sending messages periodically.
Definition at line 619 of file isobus_speed_distance_messages.hpp.
|
protected |
An event publisher for notifying when new wheel-based speed messages are received.
Definition at line 620 of file isobus_speed_distance_messages.hpp.
WheelBasedMachineSpeedData isobus::SpeedMessagesInterface::wheelBasedSpeedTransmitData |
Use this to configure transmission of the wheel-based speed message. If you pass in an internal control function to the constructor of this class, then this message is available to be sent.
Definition at line 494 of file isobus_speed_distance_messages.hpp.
|
protected |
Timestamp used to know when to transmit the wheel-based speed message in milliseconds.
Definition at line 628 of file isobus_speed_distance_messages.hpp.