AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
Loading...
Searching...
No Matches
isobus_virtual_terminal_client_state_tracker.hpp
Go to the documentation of this file.
1//================================================================================================
8//================================================================================================
9
10#ifndef ISOBUS_VIRTUAL_TERMINAL_CLIENT_STATE_TRACKER_HPP
11#define ISOBUS_VIRTUAL_TERMINAL_CLIENT_STATE_TRACKER_HPP
12
16
17#include <deque>
18#include <map>
19#include <vector>
20
21namespace isobus
22{
27 {
28 public:
31 explicit VirtualTerminalClientStateTracker(std::shared_ptr<ControlFunction> client);
32
35
37 void initialize();
38
40 void terminate();
41
43
47 void add_tracked_numeric_value(std::uint16_t objectId, std::uint32_t initialValue = 0);
48
51 void remove_tracked_numeric_value(std::uint16_t objectId);
52
56 std::uint32_t get_numeric_value(std::uint16_t objectId) const;
57
60 std::uint16_t get_active_mask() const;
61
64 const std::deque<std::uint16_t> &get_mask_history() const;
65
68 std::size_t get_max_mask_history_size() const;
69
72 void set_max_mask_history_size(std::size_t size);
73
77 void add_tracked_soft_key_mask(std::uint16_t dataOrAlarmMaskId, std::uint16_t initialSoftKeyMaskId = 0);
78
81 void remove_tracked_soft_key_mask(std::uint16_t dataOrAlarmMaskId);
82
85 std::uint16_t get_active_soft_key_mask() const;
86
90 std::uint16_t get_soft_key_mask(std::uint16_t dataOrAlarmMaskId) const;
91
94 bool is_working_set_active() const;
95
100 void add_tracked_attribute(std::uint16_t objectId, std::uint8_t attribute, std::uint32_t initialValue = 0);
101
105 void remove_tracked_attribute(std::uint16_t objectId, std::uint8_t attribute);
106
111 std::uint32_t get_attribute(std::uint16_t objectId, std::uint8_t attribute) const;
112
113 protected:
114 std::shared_ptr<ControlFunction> client;
115 std::shared_ptr<ControlFunction> server;
116
125 std::map<std::uint16_t, std::uint32_t> numericValueStates;
132 std::deque<std::uint16_t> dataAndAlarmMaskHistory;
135 std::map<std::uint16_t, std::uint16_t> softKeyMasks;
136 std::map<std::uint16_t, std::map<std::uint8_t, std::uint32_t>> attributeStates;
145
146 private:
149 void cache_active_mask(std::uint16_t maskId);
150
154 static void process_rx_or_tx_message(const CANMessage &message, void *parentPointer);
155
158 void process_status_message(const CANMessage &message);
159
163
167
170 {
171 std::uint32_t value;
172 std::uint16_t objectId;
173 std::uint8_t attribute;
174 };
175
176 std::map<std::shared_ptr<ControlFunction>, ChangeAttributeCommand> pendingChangeAttributeCommands;
177 };
178} // namespace isobus
179
180#endif // ISOBUS_VIRTUAL_TERMINAL_CLIENT_STATE_TRACKER_HPP
General constants used throughout this library.
Defines a base class to represent a generic ISOBUS control function.
An abstraction of a CAN message, could be > 8 data bytes.
A class that represents a generic CAN message of arbitrary length.
A helper class to update and track the state of an active working set.
std::shared_ptr< ControlFunction > client
The control function of the virtual terminal client to track.
void add_tracked_attribute(std::uint16_t objectId, std::uint8_t attribute, std::uint32_t initialValue=0)
Adds an attribute to track.
void add_tracked_soft_key_mask(std::uint16_t dataOrAlarmMaskId, std::uint16_t initialSoftKeyMaskId=0)
Adds a data/alarm mask to track the soft key mask for.
void add_tracked_numeric_value(std::uint16_t objectId, std::uint32_t initialValue=0)
TODO: void initialize_with_defaults(ObjectPool &objectPool);.
std::uint32_t get_attribute(std::uint16_t objectId, std::uint8_t attribute) const
Get the value of an attribute of a tracked object.
std::map< std::shared_ptr< ControlFunction >, ChangeAttributeCommand > pendingChangeAttributeCommands
Holds the pending change attribute command for a control function.
static void process_rx_or_tx_message(const CANMessage &message, void *parentPointer)
Processes a received or transmitted message.
std::uint16_t activeDataOrAlarmMask
Holds the data/alarm mask currently visible on the server for this client.
void cache_active_mask(std::uint16_t maskId)
Cache a mask as the active mask on the server.
std::map< std::uint16_t, std::uint16_t > softKeyMasks
Holds the data/alarms masks with their associated soft keys masks for tracked objects.
std::deque< std::uint16_t > dataAndAlarmMaskHistory
Holds the history of data/alarm masks that were active on the server for this client.
void remove_tracked_soft_key_mask(std::uint16_t dataOrAlarmMaskId)
Removes a data/alarm mask from tracking the soft key mask for.
void remove_tracked_numeric_value(std::uint16_t objectId)
Removes a numeric value from tracking.
std::uint16_t get_active_soft_key_mask() const
Get the soft key mask currently active on thse server for this client. It may not be displayed if the...
std::uint16_t get_soft_key_mask(std::uint16_t dataOrAlarmMaskId) const
Get the soft key mask currently associated with a data/alarm mask.
std::map< std::uint16_t, std::map< std::uint8_t, std::uint32_t > > attributeStates
void process_message_from_connected_server(const CANMessage &message)
Processes a VT->ECU message received by any client, sent from the connected server.
const std::deque< std::uint16_t > & get_mask_history() const
Get the history of data/alarm masks that were active on the server for this client.
void remove_tracked_attribute(std::uint16_t objectId, std::uint8_t attribute)
Removes an attribute from tracking.
bool is_working_set_active() const
Get whether the working set of the client is active on the server.
void set_max_mask_history_size(std::size_t size)
Sets the maximum size of the data/alarm mask history (default: 100)
std::shared_ptr< ControlFunction > server
The control function of the server the client is connected to.
void process_message_to_connected_server(const CANMessage &message)
Processes a ECU->VT message received by the connected server, sent from any control function.
void process_status_message(const CANMessage &message)
Processes a status message from a VT server.
VirtualTerminalClientStateTracker(std::shared_ptr< ControlFunction > client)
The constructor to track the state of an active working set provided by a client.
std::uint8_t activeWorkingSetAddress
Holds the address of the control function that currently has.
std::uint32_t get_numeric_value(std::uint16_t objectId) const
Gets the current numeric value of a tracked object.
std::size_t maxDataAndAlarmMaskHistorySize
Holds the maximum size of the data/alarm mask history.
std::size_t get_max_mask_history_size() const
Get the maximum size of the data/alarm mask history.
std::uint16_t get_active_mask() const
Get the data/alarm mask currently active on the server for this client. It may not be displayed if th...
This namespace encompasses all of the ISO11783 stack's functionality to reduce global namespace pollu...
constexpr std::uint8_t NULL_CAN_ADDRESS
The NULL CAN address defined by J1939 and ISO11783.
constexpr std::uint16_t NULL_OBJECT_ID
Special ID used to indicate no object.
Data structure to hold the properties of a change attribute command.
std::uint8_t attribute
Holds the id of the attribute to be changed of the specified object.