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

A helper class to update and track the state of an active working set. More...

#include <isobus_virtual_terminal_client_update_helper.hpp>

Inheritance diagram for isobus::VirtualTerminalClientUpdateHelper:
[legend]
Collaboration diagram for isobus::VirtualTerminalClientUpdateHelper:
[legend]

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< VirtualTerminalClientvtClient
 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< ControlFunctionclient
 The control function of the virtual terminal client to track.
 
std::shared_ptr< ControlFunctionserver
 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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ VirtualTerminalClientUpdateHelper()

isobus::VirtualTerminalClientUpdateHelper::VirtualTerminalClientUpdateHelper ( std::shared_ptr< VirtualTerminalClient > client)
explicit

The constructor of class to help update the state of an active working set.

Parameters
[in]clientThe virtual terminal client that provides the active working set.

Definition at line 16 of file isobus_virtual_terminal_client_update_helper.cpp.

Here is the call graph for this function:

◆ ~VirtualTerminalClientUpdateHelper()

isobus::VirtualTerminalClientUpdateHelper::~VirtualTerminalClientUpdateHelper ( )

The destructor of class to unregister event listeners.

Definition at line 29 of file isobus_virtual_terminal_client_update_helper.cpp.

Member Function Documentation

◆ decrease_numeric_value()

bool isobus::VirtualTerminalClientUpdateHelper::decrease_numeric_value ( std::uint16_t objectId,
std::uint32_t step = 1 )

Decreases the numeric value of a tracked object.

Parameters
[in]objectIdThe object id of the numeric value to decrease.
[in]stepThe step size to decrease the numeric value with.
Returns
True if the value was decreased successfully, false otherwise.

Definition at line 67 of file isobus_virtual_terminal_client_update_helper.cpp.

Here is the call graph for this function:

◆ increase_numeric_value()

bool isobus::VirtualTerminalClientUpdateHelper::increase_numeric_value ( std::uint16_t objectId,
std::uint32_t step = 1 )

Increases the numeric value of a tracked object.

Parameters
[in]objectIdThe object id of the numeric value to increase.
[in]stepThe step size to increase the numeric value with.
Returns
True if the value was increased successfully, false otherwise.

Definition at line 62 of file isobus_virtual_terminal_client_update_helper.cpp.

Here is the call graph for this function:

◆ process_numeric_value_change_event()

void isobus::VirtualTerminalClientUpdateHelper::process_numeric_value_change_event ( const VirtualTerminalClient::VTChangeNumericValueEvent & event)
private

Processes a numeric value change event.

Parameters
[in]eventThe numeric value change event to process.

Definition at line 77 of file isobus_virtual_terminal_client_update_helper.cpp.

Here is the caller graph for this function:

◆ set_active_data_or_alarm_mask()

bool isobus::VirtualTerminalClientUpdateHelper::set_active_data_or_alarm_mask ( std::uint16_t workingSetId,
std::uint16_t dataOrAlarmMaskId )

Sets the active data/alarm mask.

Parameters
[in]workingSetIdThe working set to set the active data/alarm mask for.
[in]dataOrAlarmMaskIdThe data/alarm mask to set active.
Returns
True if the data/alarm mask was set active successfully, false otherwise.

Definition at line 100 of file isobus_virtual_terminal_client_update_helper.cpp.

◆ set_active_soft_key_mask()

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.

Parameters
[in]maskTypeThe type of mask to set the active soft key mask for.
[in]maskIdThe mask to set the active soft key mask for.
[in]softKeyMaskIdThe soft key mask to set active.
Returns
True if the soft key mask was set active successfully, false otherwise.

Definition at line 120 of file isobus_virtual_terminal_client_update_helper.cpp.

◆ set_attribute()

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.

Note
If the to be tracked working set consists of more than the master, this function is incompatible with a VT prior to version 4. For working sets consisting of only the master, this function is compatible with any VT version.
Parameters
[in]objectIdThe object id of the attribute to set.
[in]attributeThe attribute to set.
[in]valueThe value to set the attribute to.
Returns
True if the attribute was set successfully, false otherwise.

Definition at line 145 of file isobus_virtual_terminal_client_update_helper.cpp.

◆ set_callback_validate_numeric_value()

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.

Parameters
[in]callbackThe callback function to register, or nullptr to unregister.

Definition at line 72 of file isobus_virtual_terminal_client_update_helper.cpp.

◆ set_numeric_value()

bool isobus::VirtualTerminalClientUpdateHelper::set_numeric_value ( std::uint16_t objectId,
std::uint32_t value )

Sets the numeric value of a tracked object.

Parameters
[in]objectIdThe object id of the numeric value to set.
[in]valueThe value to set the numeric value to.
Returns
True if the value was set successfully, false otherwise.

Definition at line 37 of file isobus_virtual_terminal_client_update_helper.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ callbackValidateNumericValue

std::function<bool(std::uint16_t, std::uint32_t)> isobus::VirtualTerminalClientUpdateHelper::callbackValidateNumericValue
private

Holds the callback function to validate a numeric value change.

Definition at line 84 of file isobus_virtual_terminal_client_update_helper.hpp.

◆ numericValueChangeEventHandle

EventCallbackHandle isobus::VirtualTerminalClientUpdateHelper::numericValueChangeEventHandle
private

Holds the handle to the numeric value change event listener.

Definition at line 85 of file isobus_virtual_terminal_client_update_helper.hpp.

◆ vtClient

std::shared_ptr<VirtualTerminalClient> isobus::VirtualTerminalClientUpdateHelper::vtClient
private

Holds the vt client.

Definition at line 82 of file isobus_virtual_terminal_client_update_helper.hpp.


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