AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
|
A helper class to update and track the state of an active working set. More...
#include <isobus_virtual_terminal_client_state_tracker.hpp>
Classes | |
struct | ChangeAttributeCommand |
Data structure to hold the properties of a change attribute command. More... | |
Public Member Functions | |
VirtualTerminalClientStateTracker (std::shared_ptr< ControlFunction > client) | |
The constructor to track the state of an active working set provided by a client. | |
~VirtualTerminalClientStateTracker () | |
The destructor. | |
void | initialize () |
Initializes the state tracker. | |
void | terminate () |
Terminate the state tracker. | |
void | add_tracked_numeric_value (std::uint16_t objectId, std::uint32_t initialValue=0) |
TODO: void initialize_with_defaults(ObjectPool &objectPool);. | |
void | remove_tracked_numeric_value (std::uint16_t objectId) |
Removes a numeric value from tracking. | |
std::uint32_t | get_numeric_value (std::uint16_t objectId) const |
Gets the current numeric value of a tracked object. | |
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 the working set is not active. | |
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. | |
std::size_t | get_max_mask_history_size () const |
Get the maximum size of the data/alarm mask history. | |
void | set_max_mask_history_size (std::size_t size) |
Sets the maximum size of the data/alarm mask history (default: 100) | |
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 | remove_tracked_soft_key_mask (std::uint16_t dataOrAlarmMaskId) |
Removes a data/alarm mask from tracking the soft key mask for. | |
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 working set is not active. | |
std::uint16_t | get_soft_key_mask (std::uint16_t dataOrAlarmMaskId) const |
Get the soft key mask currently associated with a data/alarm mask. | |
bool | is_working_set_active () const |
Get whether the working set of the client is active on the server. | |
void | add_tracked_attribute (std::uint16_t objectId, std::uint8_t attribute, std::uint32_t initialValue=0) |
Adds an attribute to track. | |
void | remove_tracked_attribute (std::uint16_t objectId, std::uint8_t attribute) |
Removes an attribute from tracking. | |
std::uint32_t | get_attribute (std::uint16_t objectId, std::uint8_t attribute) const |
Get the value of an attribute of a tracked object. | |
Protected Attributes | |
std::shared_ptr< ControlFunction > | client |
The control function of the virtual terminal client to track. | |
std::shared_ptr< ControlFunction > | server |
The control function of the server the client is connected to. | |
std::map< std::uint16_t, std::uint32_t > | numericValueStates |
std::uint16_t | activeDataOrAlarmMask = NULL_OBJECT_ID |
Holds the data/alarm mask currently visible on the server for this client. | |
std::deque< std::uint16_t > | dataAndAlarmMaskHistory |
Holds the history of data/alarm masks that were active on the server for this client. | |
std::size_t | maxDataAndAlarmMaskHistorySize = 100 |
Holds the maximum size of the data/alarm mask history. | |
std::uint8_t | activeWorkingSetAddress = NULL_CAN_ADDRESS |
Holds the address of the control function that currently has. | |
std::map< std::uint16_t, std::uint16_t > | softKeyMasks |
Holds the data/alarms masks with their associated soft keys masks for tracked objects. | |
std::map< std::uint16_t, std::map< std::uint8_t, std::uint32_t > > | attributeStates |
Private Member Functions | |
void | cache_active_mask (std::uint16_t maskId) |
Cache a mask as the active mask on the server. | |
void | process_status_message (const CANMessage &message) |
Processes a status message from a VT server. | |
void | process_message_from_connected_server (const CANMessage &message) |
Processes a VT->ECU message received by any client, sent from the connected server. | |
void | process_message_to_connected_server (const CANMessage &message) |
Processes a ECU->VT message received by the connected server, sent from any control function. | |
Static Private Member Functions | |
static void | process_rx_or_tx_message (const CANMessage &message, void *parentPointer) |
Processes a received or transmitted message. | |
Private Attributes | |
std::map< std::shared_ptr< ControlFunction >, ChangeAttributeCommand > | pendingChangeAttributeCommands |
Holds the pending change attribute command for a control function. | |
A helper class to update and track the state of an active working set.
The state is from the client's perspective. It might not be the same as the state of the server, but tries to be as close as possible.
Definition at line 26 of file isobus_virtual_terminal_client_state_tracker.hpp.
|
explicit |
The constructor to track the state of an active working set provided by a client.
[in] | client | The control function of the client. May be external. |
Definition at line 20 of file isobus_virtual_terminal_client_state_tracker.cpp.
isobus::VirtualTerminalClientStateTracker::~VirtualTerminalClientStateTracker | ( | ) |
The destructor.
Definition at line 25 of file isobus_virtual_terminal_client_state_tracker.cpp.
void isobus::VirtualTerminalClientStateTracker::add_tracked_attribute | ( | std::uint16_t | objectId, |
std::uint8_t | attribute, | ||
std::uint32_t | initialValue = 0 ) |
Adds an attribute to track.
[in] | objectId | The object id of the attribute to track. |
[in] | attribute | The attribute to track. |
[in] | initialValue | The initial value of the attribute to track. |
Definition at line 146 of file isobus_virtual_terminal_client_state_tracker.cpp.
void isobus::VirtualTerminalClientStateTracker::add_tracked_numeric_value | ( | std::uint16_t | objectId, |
std::uint32_t | initialValue = 0 ) |
TODO: void initialize_with_defaults(ObjectPool &objectPool);.
Adds a numeric value to track.
[in] | objectId | The object id of the numeric value to track. |
[in] | initialValue | The initial value of the numeric value to track. |
Definition at line 44 of file isobus_virtual_terminal_client_state_tracker.cpp.
void isobus::VirtualTerminalClientStateTracker::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.
[in] | dataOrAlarmMaskId | The data/alarm mask to track the soft key mask for. |
[in] | initialSoftKeyMaskId | The initial soft key mask to associate with the data/alarm mask. |
Definition at line 97 of file isobus_virtual_terminal_client_state_tracker.cpp.
|
private |
Cache a mask as the active mask on the server.
TODO: std::map<std::uint16_t, std::uint8_t> alarmMaskPrioritiesStates; ///< Holds the 'alarm mask priority' state of tracked objects. TODO: std::map<std::uint16_t, std::pair<std::uint8_t, std::uint16_t>> listItemStates; ///< Holds the 'list item' state of tracked objects. TODO: add lock/unlock mask state TODO: add object label state TODO: add polygon point state TODO: add polygon scale state TODO: add graphics context state TODO: std::uint16_t currentColourMap; ///< Holds the current colour map/palette object.
[in] | maskId | The mask to cache as the active mask on the server. |
Definition at line 199 of file isobus_virtual_terminal_client_state_tracker.cpp.
std::uint16_t isobus::VirtualTerminalClientStateTracker::get_active_mask | ( | ) | const |
Get the data/alarm mask currently active on the server for this client. It may not be displayed if the working set is not active.
Definition at line 77 of file isobus_virtual_terminal_client_state_tracker.cpp.
std::uint16_t isobus::VirtualTerminalClientStateTracker::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 working set is not active.
Definition at line 119 of file isobus_virtual_terminal_client_state_tracker.cpp.
std::uint32_t isobus::VirtualTerminalClientStateTracker::get_attribute | ( | std::uint16_t | objectId, |
std::uint8_t | attribute ) const |
Get the value of an attribute of a tracked object.
[in] | objectId | The object id of the attribute to get. |
[in] | attribute | The attribute to get. |
Definition at line 181 of file isobus_virtual_terminal_client_state_tracker.cpp.
const std::deque< std::uint16_t > & isobus::VirtualTerminalClientStateTracker::get_mask_history | ( | ) | const |
Get the history of data/alarm masks that were active on the server for this client.
Definition at line 82 of file isobus_virtual_terminal_client_state_tracker.cpp.
std::size_t isobus::VirtualTerminalClientStateTracker::get_max_mask_history_size | ( | ) | const |
Get the maximum size of the data/alarm mask history.
Definition at line 87 of file isobus_virtual_terminal_client_state_tracker.cpp.
std::uint32_t isobus::VirtualTerminalClientStateTracker::get_numeric_value | ( | std::uint16_t | objectId | ) | const |
Gets the current numeric value of a tracked object.
[in] | objectId | The object id of the numeric value to get. |
Definition at line 66 of file isobus_virtual_terminal_client_state_tracker.cpp.
std::uint16_t isobus::VirtualTerminalClientStateTracker::get_soft_key_mask | ( | std::uint16_t | dataOrAlarmMaskId | ) | const |
Get the soft key mask currently associated with a data/alarm mask.
[in] | dataOrAlarmMaskId | The data/alarm mask to get the currently associated soft key mask for. |
Definition at line 130 of file isobus_virtual_terminal_client_state_tracker.cpp.
void isobus::VirtualTerminalClientStateTracker::initialize | ( | ) |
Initializes the state tracker.
Definition at line 30 of file isobus_virtual_terminal_client_state_tracker.cpp.
bool isobus::VirtualTerminalClientStateTracker::is_working_set_active | ( | ) | const |
Get whether the working set of the client is active on the server.
Definition at line 141 of file isobus_virtual_terminal_client_state_tracker.cpp.
|
private |
Processes a VT->ECU message received by any client, sent from the connected server.
[in] | message | The message to process. |
Definition at line 260 of file isobus_virtual_terminal_client_state_tracker.cpp.
|
private |
Processes a ECU->VT message received by the connected server, sent from any control function.
[in] | message | The message to process. |
Definition at line 369 of file isobus_virtual_terminal_client_state_tracker.cpp.
|
staticprivate |
Processes a received or transmitted message.
[in] | message | The message to process. |
[in] | parentPointer | The pointer to the parent object, which should be the VirtualTerminalClientStateTracker. |
Definition at line 217 of file isobus_virtual_terminal_client_state_tracker.cpp.
|
private |
Processes a status message from a VT server.
[in] | message | The message to process. |
Definition at line 242 of file isobus_virtual_terminal_client_state_tracker.cpp.
void isobus::VirtualTerminalClientStateTracker::remove_tracked_attribute | ( | std::uint16_t | objectId, |
std::uint8_t | attribute ) |
Removes an attribute from tracking.
[in] | objectId | The object id of the attribute to remove from tracking. |
[in] | attribute | The attribute to remove from tracking. |
Definition at line 163 of file isobus_virtual_terminal_client_state_tracker.cpp.
void isobus::VirtualTerminalClientStateTracker::remove_tracked_numeric_value | ( | std::uint16_t | objectId | ) |
Removes a numeric value from tracking.
[in] | objectId | The object id of the numeric value to remove from tracking. |
Definition at line 55 of file isobus_virtual_terminal_client_state_tracker.cpp.
void isobus::VirtualTerminalClientStateTracker::remove_tracked_soft_key_mask | ( | std::uint16_t | dataOrAlarmMaskId | ) |
Removes a data/alarm mask from tracking the soft key mask for.
[in] | dataOrAlarmMaskId | The data/alarm mask to remove the soft key mask from tracking for. |
Definition at line 108 of file isobus_virtual_terminal_client_state_tracker.cpp.
void isobus::VirtualTerminalClientStateTracker::set_max_mask_history_size | ( | std::size_t | size | ) |
Sets the maximum size of the data/alarm mask history (default: 100)
[in] | size | The maximum size of the data/alarm mask history. |
Definition at line 92 of file isobus_virtual_terminal_client_state_tracker.cpp.
void isobus::VirtualTerminalClientStateTracker::terminate | ( | ) |
Terminate the state tracker.
Definition at line 37 of file isobus_virtual_terminal_client_state_tracker.cpp.
|
protected |
Holds the data/alarm mask currently visible on the server for this client.
TODO: std::map<std::uint16_t, std::string> stringValueStates; ///< Holds the 'string value' state of tracked objects. TODO: std::map<std::uint16_t, std::uint8_t> endPointStates; ///< Holds the 'end point' state of tracked objects. TODO: add font attribute state TODO: add line attribute state TODO: add fill attribute state
Definition at line 131 of file isobus_virtual_terminal_client_state_tracker.hpp.
|
protected |
Holds the address of the control function that currently has.
Definition at line 134 of file isobus_virtual_terminal_client_state_tracker.hpp.
|
protected |
Holds the 'attribute' state of tracked objects.
Definition at line 136 of file isobus_virtual_terminal_client_state_tracker.hpp.
|
protected |
The control function of the virtual terminal client to track.
Definition at line 114 of file isobus_virtual_terminal_client_state_tracker.hpp.
|
protected |
Holds the history of data/alarm masks that were active on the server for this client.
Definition at line 132 of file isobus_virtual_terminal_client_state_tracker.hpp.
|
protected |
Holds the maximum size of the data/alarm mask history.
Definition at line 133 of file isobus_virtual_terminal_client_state_tracker.hpp.
|
protected |
TODO: std::map<std::uint16_t, bool> shownStates; ///< Holds the 'hide/show' state of tracked objects. TODO: std::map<std::uint16_t, bool> enabledStates; ///< Holds the 'enable/disable' state of tracked objects. TODO: std::map<std::uint16_t, bool> selectedStates; ///< Holds the 'selected for input' state of tracked objects. TODO: add current audio signal state TODO: std::uint8_t audioVolumeState; ///< Holds the current audio volume. TODO: std::map<std::uint16_t, std::pair<std::uint16_t, std::uint16_t>> positionStates; ///< Holds the 'position (x,y)' state of tracked objects. TODO: std::map<std::uint16_t, std::pair<std::uint16_t, std::uint16_t>> sizeStates; ///< Holds the 'size (width,height)' state of tracked objects. TODO: std::map<std::uint16_t, std::uint8_t> backgroundColourStates; ///< Holds the 'background colour' state of tracked objects. Holds the 'numeric value' state of tracked objects.
Definition at line 125 of file isobus_virtual_terminal_client_state_tracker.hpp.
|
private |
Holds the pending change attribute command for a control function.
Definition at line 176 of file isobus_virtual_terminal_client_state_tracker.hpp.
|
protected |
The control function of the server the client is connected to.
Definition at line 115 of file isobus_virtual_terminal_client_state_tracker.hpp.
|
protected |
Holds the data/alarms masks with their associated soft keys masks for tracked objects.
Definition at line 135 of file isobus_virtual_terminal_client_state_tracker.hpp.