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_update_helper.hpp>
Public Member Functions | |
VirtualTerminalClientUpdateHelper (std::shared_ptr< VirtualTerminalClient > client) | |
The constructor of class to help update the state of an active working set. | |
~VirtualTerminalClientUpdateHelper () | |
The destructor of class to unregister event listeners. | |
bool | set_numeric_value (std::uint16_t objectId, std::uint32_t value) |
Sets the numeric value of a tracked object. | |
bool | increase_numeric_value (std::uint16_t objectId, std::uint32_t step=1) |
Increases the numeric value of a tracked object. | |
bool | decrease_numeric_value (std::uint16_t objectId, std::uint32_t step=1) |
Decreases the numeric value of a tracked object. | |
void | set_callback_validate_numeric_value (const std::function< bool(std::uint16_t, std::uint32_t)> &callback) |
Register a callback function to validate a numeric value change of a tracked object. If the callback function returns true, the numeric value change will be acknowledged. Otherwise, if the callback function returns false, the numeric value change will be rejected by sending the current value back to the VT. | |
bool | set_active_data_or_alarm_mask (std::uint16_t workingSetId, std::uint16_t dataOrAlarmMaskId) |
Sets the active data/alarm mask. | |
bool | set_active_soft_key_mask (VirtualTerminalClient::MaskType maskType, std::uint16_t maskId, std::uint16_t softKeyMaskId) |
Sets the active soft key mask. | |
bool | set_attribute (std::uint16_t objectId, std::uint8_t attribute, std::uint32_t value) |
Sets the value of an attribute of a tracked object. | |
Public Member Functions inherited from isobus::VirtualTerminalClientStateTracker | |
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. | |
Private Member Functions | |
void | process_numeric_value_change_event (const VirtualTerminalClient::VTChangeNumericValueEvent &event) |
Processes a numeric value change event. | |
Private Attributes | |
std::shared_ptr< VirtualTerminalClient > | vtClient |
Holds the vt client. | |
std::function< bool(std::uint16_t, std::uint32_t)> | callbackValidateNumericValue |
Holds the callback function to validate a numeric value change. | |
EventCallbackHandle | numericValueChangeEventHandle |
Holds the handle to the numeric value change event listener. | |
Additional Inherited Members | |
Protected Attributes inherited from isobus::VirtualTerminalClientStateTracker | |
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 |
A helper class to update and track the state of an active working set.
Definition at line 19 of file isobus_virtual_terminal_client_update_helper.hpp.
|
explicit |
The constructor of class to help update the state of an active working set.
[in] | client | The virtual terminal client that provides the active working set. |
Definition at line 16 of file isobus_virtual_terminal_client_update_helper.cpp.
isobus::VirtualTerminalClientUpdateHelper::~VirtualTerminalClientUpdateHelper | ( | ) |
The destructor of class to unregister event listeners.
Definition at line 29 of file isobus_virtual_terminal_client_update_helper.cpp.
bool isobus::VirtualTerminalClientUpdateHelper::decrease_numeric_value | ( | std::uint16_t | objectId, |
std::uint32_t | step = 1 ) |
Decreases the numeric value of a tracked object.
[in] | objectId | The object id of the numeric value to decrease. |
[in] | step | The step size to decrease the numeric value with. |
Definition at line 67 of file isobus_virtual_terminal_client_update_helper.cpp.
bool isobus::VirtualTerminalClientUpdateHelper::increase_numeric_value | ( | std::uint16_t | objectId, |
std::uint32_t | step = 1 ) |
Increases the numeric value of a tracked object.
[in] | objectId | The object id of the numeric value to increase. |
[in] | step | The step size to increase the numeric value with. |
Definition at line 62 of file isobus_virtual_terminal_client_update_helper.cpp.
|
private |
Processes a numeric value change event.
[in] | event | The numeric value change event to process. |
Definition at line 77 of file isobus_virtual_terminal_client_update_helper.cpp.
bool isobus::VirtualTerminalClientUpdateHelper::set_active_data_or_alarm_mask | ( | std::uint16_t | workingSetId, |
std::uint16_t | dataOrAlarmMaskId ) |
Sets the active data/alarm mask.
[in] | workingSetId | The working set to set the active data/alarm mask for. |
[in] | dataOrAlarmMaskId | The data/alarm mask to set active. |
Definition at line 100 of file isobus_virtual_terminal_client_update_helper.cpp.
bool isobus::VirtualTerminalClientUpdateHelper::set_active_soft_key_mask | ( | VirtualTerminalClient::MaskType | maskType, |
std::uint16_t | maskId, | ||
std::uint16_t | softKeyMaskId ) |
Sets the active soft key mask.
[in] | maskType | The type of mask to set the active soft key mask for. |
[in] | maskId | The mask to set the active soft key mask for. |
[in] | softKeyMaskId | The soft key mask to set active. |
Definition at line 120 of file isobus_virtual_terminal_client_update_helper.cpp.
bool isobus::VirtualTerminalClientUpdateHelper::set_attribute | ( | std::uint16_t | objectId, |
std::uint8_t | attribute, | ||
std::uint32_t | value ) |
Sets the value of an attribute of a tracked object.
[in] | objectId | The object id of the attribute to set. |
[in] | attribute | The attribute to set. |
[in] | value | The value to set the attribute to. |
Definition at line 145 of file isobus_virtual_terminal_client_update_helper.cpp.
void isobus::VirtualTerminalClientUpdateHelper::set_callback_validate_numeric_value | ( | const std::function< bool(std::uint16_t, std::uint32_t)> & | callback | ) |
Register a callback function to validate a numeric value change of a tracked object. If the callback function returns true, the numeric value change will be acknowledged. Otherwise, if the callback function returns false, the numeric value change will be rejected by sending the current value back to the VT.
[in] | callback | The callback function to register, or nullptr to unregister. |
Definition at line 72 of file isobus_virtual_terminal_client_update_helper.cpp.
bool isobus::VirtualTerminalClientUpdateHelper::set_numeric_value | ( | std::uint16_t | objectId, |
std::uint32_t | value ) |
Sets the numeric value of a tracked object.
[in] | objectId | The object id of the numeric value to set. |
[in] | value | The value to set the numeric value to. |
Definition at line 37 of file isobus_virtual_terminal_client_update_helper.cpp.
|
private |
Holds the callback function to validate a numeric value change.
Definition at line 84 of file isobus_virtual_terminal_client_update_helper.hpp.
|
private |
Holds the handle to the numeric value change event listener.
Definition at line 85 of file isobus_virtual_terminal_client_update_helper.hpp.
|
private |
Holds the vt client.
Definition at line 82 of file isobus_virtual_terminal_client_update_helper.hpp.