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

An interface for communicating as or interpreting the messages of ISOBUS Shortcut Buttons. More...

#include <isobus_shortcut_button_interface.hpp>

Classes

class  ISBServerData
 Stores data about a sender of the stop all implement operations switch state. More...
 

Public Types

enum class  StopAllImplementOperationsState : std::uint8_t { StopImplementOperations = 0 , PermitAllImplementsToOperationOn = 1 , Error = 2 , NotAvailable = 3 }
 Enumerates the states that can be sent in the main ISB message (pgn 64770, 0xFD02) More...
 

Public Member Functions

 ShortcutButtonInterface (std::shared_ptr< InternalControlFunction > internalControlFunction, bool serverEnabled=false)
 Constructor for a ShortcutButtonInterface.
 
virtual ~ShortcutButtonInterface ()
 Destructor for a ShortcutButtonInterface.
 
void initialize ()
 Used to initialize the interface. Registers for PGNs with the network manager.
 
bool get_is_initialized () const
 Returns if the interface has been initialized.
 
EventDispatcher< StopAllImplementOperationsState > & get_stop_all_implement_operations_state_event_dispatcher ()
 Gets the event dispatcher for when the assigned bus' ISB state changes. The assigned bus is determined by which internal control function you pass into the constructor.
 
void set_stop_all_implement_operations_state (StopAllImplementOperationsState newState)
 Sets the state that the interface will broadcast on the bus.
 
StopAllImplementOperationsState get_state () const
 Returns the current ISB state for the bus, which is a combination of the internal commanded state and the states reported by all other CFs.
 
void update ()
 This must be called cyclically to update the interface. This processes transmits and timeouts.
 

Private Types

enum class  TransmitFlags : std::uint32_t { SendStopAllImplementOperationsSwitchState = 0 , NumberOfFlags }
 Enumerates a set of flags that the interface uses to know if it should transmit a message. More...
 

Private Member Functions

void process_message (const CANMessage &message)
 A generic way for a protocol to process a received message.
 
bool send_stop_all_implement_operations_switch_state () const
 Sends the Stop all implement operations switch state message.
 

Static Private Member Functions

static void process_rx_message (const CANMessage &message, void *parentPointer)
 Parses incoming CAN messages for the interface.
 
static void process_flags (std::uint32_t flag, void *parent)
 Processes the internal Tx flags.
 

Private Attributes

std::list< ISBServerDataisobusShorcutButtonList
 A list of all senders of the ISB messages used to track transition counts.
 
std::shared_ptr< InternalControlFunctionsourceControlFunction = nullptr
 The internal control function that the interface is assigned to and will use to transmit.
 
EventDispatcher< StopAllImplementOperationsStateISBEventDispatcher
 Manages callbacks about ISB states.
 
ProcessingFlags txFlags
 A set of flags to manage retries while sending messages.
 
std::uint32_t allImplementsStopOperationsSwitchStateTimestamp_ms = 0
 A timestamp to track the need for cyclic transmission of PGN 0xFD02.
 
std::uint8_t stopAllImplementOperationsTransitionNumber = 0
 A counter used to track our transitions from "stop" to "permit" when acting as a server.
 
StopAllImplementOperationsState commandedState = StopAllImplementOperationsState::NotAvailable
 The state set by the user to transmit if we're acting as a server.
 
bool actAsISBServer = false
 A setting that enables sending the ISB messages rather than just receiving them.
 
bool initialized = false
 Stores if the interface has been initialized.
 

Static Private Attributes

static constexpr std::uint32_t TRANSMISSION_RATE_MS = 1000
 The cyclic transmission time for PGN 0xFD02.
 
static constexpr std::uint32_t TRANSMISSION_TIMEOUT_MS = 3000
 Amount of time between messages until we consider an ISB stale (arbitrary, but similar to VT timeout)
 

Detailed Description

An interface for communicating as or interpreting the messages of ISOBUS Shortcut Buttons.

Note
This interface must be cyclically updated from your application since it's an application layer message. Be sure to call "update" from time to time. Suggested rate is at least every 500ms, but ideally every 100ms or faster.

This interface parses the "All implements stop operations switch state" message that is sent by ISOBUS shortcut buttons, and also allows you to optionally transmit the same message as an ISOBUS shortcut button.

This message may be sent by any control function connected to the implement bus on forestry or agriculture implements providing to connected systems the current state of the all implement stop operations switch. At least one of these switches shall be in each operator location of the connected system.

All implements shall start a process to stop all operations when this broadcast message is received from any CF with a value of "Stop implement operations" (SPN 5140). Before an implement turns off all implement operations, it shall assume a failsafe condition. If an implement is operating in an automation mode, it may enter a failsafe condition before requesting the tractor ECU to exit the automation mode, e.g. PTO, Auxiliary valve, and/or tractor movement.

The working set master for the implement shall then inform the operator that the implement has stopped all operations due to the activation of the Stop All Implement Operations switch. Implement working set masters shall include, on their home screen, an indication, e.g. icon or a function name, if it supports Stop All Implement Operations. The Working Set shall monitor the number of transitions for each ISB server upon receiving first the message from a given ISB server. A Working Set shall consider an increase in the transitions without detecting a corresponding transition of the Stop all implement operations state as an error and react accordingly.

Definition at line 63 of file isobus_shortcut_button_interface.hpp.

Member Enumeration Documentation

◆ StopAllImplementOperationsState

Enumerates the states that can be sent in the main ISB message (pgn 64770, 0xFD02)

Enumerator
StopImplementOperations 

Stop implement operations.

PermitAllImplementsToOperationOn 

Permit all implements to operation ON.

Error 

Error indication.

NotAvailable 

Not available.

Definition at line 67 of file isobus_shortcut_button_interface.hpp.

◆ TransmitFlags

enum class isobus::ShortcutButtonInterface::TransmitFlags : std::uint32_t
strongprivate

Enumerates a set of flags that the interface uses to know if it should transmit a message.

Enumerator
SendStopAllImplementOperationsSwitchState 

A flag to send the main ISB message.

NumberOfFlags 

The number of flags defined in this enumeration.

Definition at line 124 of file isobus_shortcut_button_interface.hpp.

Constructor & Destructor Documentation

◆ ShortcutButtonInterface()

isobus::ShortcutButtonInterface::ShortcutButtonInterface ( std::shared_ptr< InternalControlFunction > internalControlFunction,
bool serverEnabled = false )

Constructor for a ShortcutButtonInterface.

Parameters
[in]internalControlFunctionThe InternalControlFunction that the interface will use to send messages (not nullptr)
[in]serverEnabledEnables the interface's transmission of the "Stop all implement operations" message.

Definition at line 22 of file isobus_shortcut_button_interface.cpp.

◆ ~ShortcutButtonInterface()

isobus::ShortcutButtonInterface::~ShortcutButtonInterface ( )
virtual

Destructor for a ShortcutButtonInterface.

Definition at line 30 of file isobus_shortcut_button_interface.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ get_is_initialized()

bool isobus::ShortcutButtonInterface::get_is_initialized ( ) const

Returns if the interface has been initialized.

Returns
true if the interface has been initialized

Definition at line 49 of file isobus_shortcut_button_interface.cpp.

◆ get_state()

ShortcutButtonInterface::StopAllImplementOperationsState isobus::ShortcutButtonInterface::get_state ( ) const

Returns the current ISB state for the bus, which is a combination of the internal commanded state and the states reported by all other CFs.

Returns
The current ISB state for the bus associated with the interface's internal control function

Definition at line 84 of file isobus_shortcut_button_interface.cpp.

Here is the caller graph for this function:

◆ get_stop_all_implement_operations_state_event_dispatcher()

EventDispatcher< ShortcutButtonInterface::StopAllImplementOperationsState > & isobus::ShortcutButtonInterface::get_stop_all_implement_operations_state_event_dispatcher ( )

Gets the event dispatcher for when the assigned bus' ISB state changes. The assigned bus is determined by which internal control function you pass into the constructor.

Returns
The event dispatcher which can be used to register callbacks/listeners to

Definition at line 54 of file isobus_shortcut_button_interface.cpp.

◆ initialize()

void isobus::ShortcutButtonInterface::initialize ( )

Used to initialize the interface. Registers for PGNs with the network manager.

Definition at line 38 of file isobus_shortcut_button_interface.cpp.

Here is the call graph for this function:

◆ process_flags()

void isobus::ShortcutButtonInterface::process_flags ( std::uint32_t flag,
void * parent )
staticprivate

Processes the internal Tx flags.

Parameters
[in]flagThe flag to process
[in]parentA context variable to find the relevant interface class

Definition at line 128 of file isobus_shortcut_button_interface.cpp.

◆ process_message()

void isobus::ShortcutButtonInterface::process_message ( const CANMessage & message)
private

A generic way for a protocol to process a received message.

Parameters
[in]messageA received CAN message

Definition at line 150 of file isobus_shortcut_button_interface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_rx_message()

void isobus::ShortcutButtonInterface::process_rx_message ( const CANMessage & message,
void * parentPointer )
staticprivate

Parses incoming CAN messages for the interface.

Parameters
messageThe CAN message to parse
parentPointerA generic context variable, usually the this pointer for this interface instance

Definition at line 121 of file isobus_shortcut_button_interface.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_stop_all_implement_operations_switch_state()

bool isobus::ShortcutButtonInterface::send_stop_all_implement_operations_switch_state ( ) const
private

Sends the Stop all implement operations switch state message.

Returns
true if the message was sent, otherwise false

Definition at line 216 of file isobus_shortcut_button_interface.cpp.

Here is the call graph for this function:

◆ set_stop_all_implement_operations_state()

void isobus::ShortcutButtonInterface::set_stop_all_implement_operations_state ( StopAllImplementOperationsState newState)

Sets the state that the interface will broadcast on the bus.

Note
This is only used when the interface was created as a server.
Parameters
[in]newStateThe state to broadcast on the bus if the interface is a server

Definition at line 59 of file isobus_shortcut_button_interface.cpp.

◆ update()

void isobus::ShortcutButtonInterface::update ( )

This must be called cyclically to update the interface. This processes transmits and timeouts.

Definition at line 106 of file isobus_shortcut_button_interface.cpp.

Member Data Documentation

◆ actAsISBServer

bool isobus::ShortcutButtonInterface::actAsISBServer = false
private

A setting that enables sending the ISB messages rather than just receiving them.

Definition at line 159 of file isobus_shortcut_button_interface.hpp.

◆ allImplementsStopOperationsSwitchStateTimestamp_ms

std::uint32_t isobus::ShortcutButtonInterface::allImplementsStopOperationsSwitchStateTimestamp_ms = 0
private

A timestamp to track the need for cyclic transmission of PGN 0xFD02.

Definition at line 156 of file isobus_shortcut_button_interface.hpp.

◆ commandedState

StopAllImplementOperationsState isobus::ShortcutButtonInterface::commandedState = StopAllImplementOperationsState::NotAvailable
private

The state set by the user to transmit if we're acting as a server.

Definition at line 158 of file isobus_shortcut_button_interface.hpp.

◆ initialized

bool isobus::ShortcutButtonInterface::initialized = false
private

Stores if the interface has been initialized.

Definition at line 160 of file isobus_shortcut_button_interface.hpp.

◆ ISBEventDispatcher

EventDispatcher<StopAllImplementOperationsState> isobus::ShortcutButtonInterface::ISBEventDispatcher
private

Manages callbacks about ISB states.

Definition at line 154 of file isobus_shortcut_button_interface.hpp.

◆ isobusShorcutButtonList

std::list<ISBServerData> isobus::ShortcutButtonInterface::isobusShorcutButtonList
private

A list of all senders of the ISB messages used to track transition counts.

Definition at line 152 of file isobus_shortcut_button_interface.hpp.

◆ sourceControlFunction

std::shared_ptr<InternalControlFunction> isobus::ShortcutButtonInterface::sourceControlFunction = nullptr
private

The internal control function that the interface is assigned to and will use to transmit.

Definition at line 153 of file isobus_shortcut_button_interface.hpp.

◆ stopAllImplementOperationsTransitionNumber

std::uint8_t isobus::ShortcutButtonInterface::stopAllImplementOperationsTransitionNumber = 0
private

A counter used to track our transitions from "stop" to "permit" when acting as a server.

Definition at line 157 of file isobus_shortcut_button_interface.hpp.

◆ TRANSMISSION_RATE_MS

constexpr std::uint32_t isobus::ShortcutButtonInterface::TRANSMISSION_RATE_MS = 1000
staticconstexprprivate

The cyclic transmission time for PGN 0xFD02.

Definition at line 149 of file isobus_shortcut_button_interface.hpp.

◆ TRANSMISSION_TIMEOUT_MS

constexpr std::uint32_t isobus::ShortcutButtonInterface::TRANSMISSION_TIMEOUT_MS = 3000
staticconstexprprivate

Amount of time between messages until we consider an ISB stale (arbitrary, but similar to VT timeout)

Definition at line 150 of file isobus_shortcut_button_interface.hpp.

◆ txFlags

ProcessingFlags isobus::ShortcutButtonInterface::txFlags
private

A set of flags to manage retries while sending messages.

Definition at line 155 of file isobus_shortcut_button_interface.hpp.


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