AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
Loading...
Searching...
No Matches
isobus_shortcut_button_interface.hpp
Go to the documentation of this file.
1//================================================================================================
22//================================================================================================
23#ifndef ISOBUS_SHORTCUT_BUTTON_INTERFACE_HPP
24#define ISOBUS_SHORTCUT_BUTTON_INTERFACE_HPP
25
29#include "isobus/utility/event_dispatcher.hpp"
30#include "isobus/utility/processing_flags.hpp"
31
32#include <array>
33#include <functional>
34#include <list>
35#include <memory>
36
37namespace isobus
38{
64 {
65 public:
67 enum class StopAllImplementOperationsState : std::uint8_t
68 {
71 Error = 2,
72 NotAvailable = 3
73 };
74
78 ShortcutButtonInterface(std::shared_ptr<InternalControlFunction> internalControlFunction, bool serverEnabled = false);
79
82
84 void initialize();
85
88 bool get_is_initialized() const;
89
93 EventDispatcher<StopAllImplementOperationsState> &get_stop_all_implement_operations_state_event_dispatcher();
94
99
104
107 void update();
108
109 private:
122
124 enum class TransmitFlags : std::uint32_t
125 {
127
129 };
130
134 static void process_rx_message(const CANMessage &message, void *parentPointer);
135
139 static void process_flags(std::uint32_t flag, void *parent);
140
143 void process_message(const CANMessage &message);
144
148
149 static constexpr std::uint32_t TRANSMISSION_RATE_MS = 1000;
150 static constexpr std::uint32_t TRANSMISSION_TIMEOUT_MS = 3000;
151
152 std::list<ISBServerData> isobusShorcutButtonList;
153 std::shared_ptr<InternalControlFunction> sourceControlFunction = nullptr;
154 EventDispatcher<StopAllImplementOperationsState> ISBEventDispatcher;
155 ProcessingFlags txFlags;
159 bool actAsISBServer = false;
160 bool initialized = false;
161 };
162} // namespace isobus
163#endif // ISOBUS_SHORTCUT_BUTTON_INTERFACE_HPP
A class that represents a control function's NAME.
A representation of an ISOBUS ECU that we can send from. Use this class when defining your own contro...
An abstraction of a CAN message, could be > 8 data bytes.
A class that represents a generic CAN message of arbitrary length.
A class that represents an ISO11783 control function NAME from an address claim.
Definition can_NAME.hpp:24
Stores data about a sender of the stop all implement operations switch state.
std::uint32_t messageReceivedTimestamp_ms
Tracks the last time we received a message from this ISB so we can time them out if needed.
NAME ISONAME
The ISONAME of the sender, used as a lookup key.
std::uint8_t stopAllImplementOperationsTransitionNumber
Number of transitions from Permit (01) to Stop (00) since power up of the stop all implement operatio...
StopAllImplementOperationsState commandedState
The last state we received from this ISB.
ISBServerData()=default
Constructor for ISBServerData, sets default values.
An interface for communicating as or interpreting the messages of ISOBUS Shortcut Buttons.
ShortcutButtonInterface(std::shared_ptr< InternalControlFunction > internalControlFunction, bool serverEnabled=false)
Constructor for a ShortcutButtonInterface.
bool get_is_initialized() const
Returns if the interface has been initialized.
EventDispatcher< StopAllImplementOperationsState > ISBEventDispatcher
Manages callbacks about ISB states.
bool actAsISBServer
A setting that enables sending the ISB messages rather than just receiving them.
virtual ~ShortcutButtonInterface()
Destructor for a ShortcutButtonInterface.
static constexpr std::uint32_t TRANSMISSION_RATE_MS
The cyclic transmission time for PGN 0xFD02.
std::list< ISBServerData > isobusShorcutButtonList
A list of all senders of the ISB messages used to track transition counts.
TransmitFlags
Enumerates a set of flags that the interface uses to know if it should transmit a message.
@ NumberOfFlags
The number of flags defined in this enumeration.
@ SendStopAllImplementOperationsSwitchState
A flag to send the main ISB message.
std::shared_ptr< InternalControlFunction > sourceControlFunction
The internal control function that the interface is assigned to and will use to transmit.
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 determine...
StopAllImplementOperationsState commandedState
The state set by the user to transmit if we're acting as a server.
void process_message(const CANMessage &message)
A generic way for a protocol to process a received message.
ProcessingFlags txFlags
A set of flags to manage retries while sending messages.
void set_stop_all_implement_operations_state(StopAllImplementOperationsState newState)
Sets the state that the interface will broadcast on the bus.
bool initialized
Stores if the interface has been initialized.
bool send_stop_all_implement_operations_switch_state() const
Sends the Stop all implement operations switch state message.
void initialize()
Used to initialize the interface. Registers for PGNs with the network manager.
StopAllImplementOperationsState get_state() const
Returns the current ISB state for the bus, which is a combination of the internal commanded state and...
std::uint8_t stopAllImplementOperationsTransitionNumber
A counter used to track our transitions from "stop" to "permit" when acting as a server.
static constexpr std::uint32_t TRANSMISSION_TIMEOUT_MS
Amount of time between messages until we consider an ISB stale (arbitrary, but similar to VT timeout)
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.
void update()
This must be called cyclically to update the interface. This processes transmits and timeouts.
StopAllImplementOperationsState
Enumerates the states that can be sent in the main ISB message (pgn 64770, 0xFD02)
@ PermitAllImplementsToOperationOn
Permit all implements to operation ON.
std::uint32_t allImplementsStopOperationsSwitchStateTimestamp_ms
A timestamp to track the need for cyclic transmission of PGN 0xFD02.
This namespace encompasses all of the ISO11783 stack's functionality to reduce global namespace pollu...