Skip to content

Commit e24de03

Browse files
committed
[VT]: Added a base class for VT object pools
Added a base class for VT object pools so that common information can be shared between VT servers and a VT designer application without duplicating our IOP parser. Added missing doxygen.
1 parent 5f3df7d commit e24de03

7 files changed

+3436
-3279
lines changed

isobus/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ set(ISOBUS_SRC
5050
"isobus_device_descriptor_object_pool_helpers.cpp"
5151
"can_message_data.cpp"
5252
"isobus_virtual_terminal_server.cpp"
53+
"isobus_virtual_terminal_working_set_base.cpp"
5354
"isobus_virtual_terminal_server_managed_working_set.cpp")
5455

5556
# Prepend the source directory path to all the source files
@@ -103,6 +104,7 @@ set(ISOBUS_INCLUDE
103104
"can_message_data.hpp"
104105
"isobus_virtual_terminal_base.hpp"
105106
"isobus_virtual_terminal_server.hpp"
107+
"isobus_virtual_terminal_working_set_base.hpp"
106108
"isobus_virtual_terminal_server_managed_working_set.hpp")
107109

108110
# Prepend the include directory path to all the include files

isobus/include/isobus/isobus/isobus_virtual_terminal_base.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace isobus
1515
{
16+
/// @brief A base class for the VT client and VT server that stores common definitions
1617
class VirtualTerminalBase
1718
{
1819
public:
@@ -267,6 +268,7 @@ namespace isobus
267268

268269
/// @brief Allows easy comparison of two `AssignedAuxiliaryFunction` objects
269270
/// @param[in] other the object to compare against
271+
/// @returns true if the two objects are equal, otherwise false
270272
bool operator==(const AssignedAuxiliaryFunction &other) const;
271273

272274
std::uint16_t functionObjectID; ///< The object ID of the function present in our object pool

isobus/include/isobus/isobus/isobus_virtual_terminal_server.hpp

Lines changed: 90 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -118,23 +118,69 @@ namespace isobus
118118
void process_macro(std::shared_ptr<isobus::VTObject> object, isobus::EventID macroEvent, isobus::VirtualTerminalObjectType targetObjectType, std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingset);
119119

120120
// ----------- Mandatory Functions you must implement -----------------------
121+
122+
/// @brief This function is called when the client wants to know if the server has enough memory to store the object pool.
123+
/// You should return true if the server has enough memory to store the object pool, otherwise false.
124+
/// @param[in] requestedMemory The amount of memory requested by the client
125+
/// @returns True if the server has enough memory to store the object pool, otherwise false
121126
virtual bool get_is_enough_memory(std::uint32_t requestedMemory) const = 0;
127+
128+
/// @brief This function is called when the client wants to know the version of the VT.
129+
/// @returns The version of the VT
122130
virtual VTVersion get_version() const = 0;
131+
132+
/// @brief This function is called when the interface wants to know the number of navigation soft keys.
133+
/// @returns The number of navigation soft keys
123134
virtual std::uint8_t get_number_of_navigation_soft_keys() const = 0;
135+
136+
/// @brief This function is called when the interface needs to know the number of x pixels (width) of your soft keys
137+
/// @returns The number of x pixels (width) of your soft keys
124138
virtual std::uint8_t get_soft_key_descriptor_x_pixel_width() const = 0;
139+
140+
/// @brief This function is called when the interface needs to know the number of y pixels (height) of your soft keys
141+
/// @returns The number of y pixels (height) of your soft keys
125142
virtual std::uint8_t get_soft_key_descriptor_y_pixel_width() const = 0;
143+
144+
/// @brief This function is called when the interface needs to know the number of possible virtual soft keys in your soft key mask render area
145+
/// @returns The number of possible virtual soft keys in your soft key mask render area
126146
virtual std::uint8_t get_number_of_possible_virtual_soft_keys_in_soft_key_mask() const = 0;
147+
148+
/// @brief This function is called when the interface needs to know the number of physical soft keys
149+
/// @returns The number of physical soft keys
127150
virtual std::uint8_t get_number_of_physical_soft_keys() const = 0;
151+
152+
/// @brief This function is called when the interface needs to know the number of x pixels (width) of your data key mask render area
153+
/// @returns The number of x pixels (width) of your soft key mask render area
128154
virtual std::uint16_t get_data_mask_area_size_x_pixels() const = 0;
155+
156+
/// @brief This function is called when the interface needs to know the number of y pixels (height) of your data key mask render area
157+
/// @returns The number of y pixels (height) of your data key mask render area
129158
virtual std::uint16_t get_data_mask_area_size_y_pixels() const = 0;
159+
160+
/// @brief The interface calls this function when it wants you to discontinue/suspend a working set
161+
/// @param[in] workingSetWithError The working set to suspend
130162
virtual void suspend_working_set(std::shared_ptr<VirtualTerminalServerManagedWorkingSet> workingSetWithError) = 0;
163+
164+
/// @brief This function is called when the interface needs to know the wide chars you support
165+
/// @param[in] codePlane The code plane to inquire about
166+
/// @param[in] firstWideCharInInquiryRange The first wide char in the inquiry range
167+
/// @param[in] lastWideCharInInquiryRange The last wide char in the inquiry range
168+
/// @param[out] numberOfRanges The number of wide char ranges supported
169+
/// @param[out] wideCharRangeArray The wide char range array
170+
/// @returns The error code for the supported wide chars inquiry
131171
virtual SupportedWideCharsErrorCode get_supported_wide_chars(std::uint8_t codePlane,
132172
std::uint16_t firstWideCharInInquiryRange,
133173
std::uint16_t lastWideCharInInquiryRange,
134174
std::uint8_t &numberOfRanges,
135175
std::vector<std::uint8_t> &wideCharRangeArray) = 0;
136176

177+
/// @brief This function is called when the interface needs to know what versions of object pools are available for a client.
178+
/// @param[in] clientNAME The client requesting the object pool versions
179+
/// @returns A vector of object pool versions available for the client
137180
virtual std::vector<std::array<std::uint8_t, 7>> get_versions(NAME clientNAME) = 0;
181+
182+
/// @brief This function is called when the interface needs to know what objects are supported by the server.
183+
/// @returns A vector of supported objects
138184
virtual std::vector<std::uint8_t> get_supported_objects() const = 0;
139185

140186
/// @brief This function is called when the client wants the server to load a previously stored object pool.
@@ -182,14 +228,38 @@ namespace isobus
182228
virtual bool delete_object_pool(NAME clientNAME) = 0;
183229

184230
//------------ Optional functions you can override --------------------
231+
232+
/// @brief If you want to override the graphics mode from its default 256 color mode, you can override this function.
233+
/// Though, that would be unusual.
234+
/// @returns The graphic mode of the VT to report to clients
185235
virtual VirtualTerminalBase::GraphicMode get_graphic_mode() const;
236+
237+
/// @brief If you want to override the amount of time the VT reports it takes to power up, you can override this function.
238+
/// @returns The amount of time the VT reports it takes to power up, or 255 if it is not known
186239
virtual std::uint8_t get_powerup_time() const;
240+
241+
/// @brief By default, the VT server will report that it supports all small and large fonts.
242+
/// If you want to override this, you can override this function.
243+
/// @returns The bitfield of supported small fonts
187244
virtual std::uint8_t get_supported_small_fonts_bitfield() const;
245+
246+
/// @brief By default, the VT server will report that it supports all small and large fonts.
247+
/// If you want to override this, you can override this function.
248+
/// @returns The bitfield of supported large fonts
188249
virtual std::uint8_t get_supported_large_fonts_bitfield() const;
189250

190251
//-------------- Callbacks/Event driven interface ---------------------
252+
253+
/// @brief Returns the event dispatcher for repaint events
254+
/// @returns The event dispatcher for repaint events
191255
EventDispatcher<std::shared_ptr<VirtualTerminalServerManagedWorkingSet>> &get_on_repaint_event_dispatcher();
256+
257+
/// @brief Returns the event dispatcher for change active mask events
258+
/// @returns The event dispatcher for change active mask events
192259
EventDispatcher<std::shared_ptr<VirtualTerminalServerManagedWorkingSet>, std::uint16_t, std::uint16_t> &get_on_change_active_mask_event_dispatcher();
260+
261+
/// @brief Returns the event dispatcher for when an object is focused
262+
/// @returns The event dispatcher for when an object is focused
193263
EventDispatcher<std::shared_ptr<VirtualTerminalServerManagedWorkingSet>, std::uint16_t, bool> &get_on_focus_object_event_dispatcher();
194264

195265
//----------------- Other Server Settings -----------------------------
@@ -363,6 +433,7 @@ namespace isobus
363433
AnyOtherError = 2
364434
};
365435

436+
/// @brief Enumerates the bit indices of the error fields that can be set in a delete object pool response
366437
enum class DeleteObjectPoolErrorBit : std::uint8_t
367438
{
368439
DeletionError = 0,
@@ -371,6 +442,8 @@ namespace isobus
371442

372443
/// @brief Checks to see if the message should be listened to based on
373444
/// what the message is, and if the client has sent the proper working set master message
445+
/// @param[in] message The CAN message to check
446+
/// @returns true if the source of the message is in a valid, managed state by our server, otherwise false
374447
bool check_if_source_is_managed(const CANMessage &message);
375448

376449
/// @brief Processes a macro's execution synchronously as if it were a CAN message.
@@ -397,7 +470,7 @@ namespace isobus
397470

398471
/// @brief Processes a CAN message from any VT client
399472
/// @param[in] message The CAN message being received
400-
/// @param[in] parentPointer A context variable to find the relevant VT server class
473+
/// @param[in] parent A context variable to find the relevant VT server class
401474
static void process_rx_message(const CANMessage &message, void *parent);
402475

403476
/// @brief Sends a message using the acknowledgement PGN
@@ -449,7 +522,6 @@ namespace isobus
449522

450523
/// @brief Sends a response to a change fill attributes command
451524
/// @param[in] objectID The object ID for the object to change
452-
/// @param[in] newObjectID The object ID for the object to place at the specified list index, or NULL_OBJECT_ID (0xFFFF)
453525
/// @param[in] errorBitfield An error bitfield
454526
/// @param[in] destination The control function to send the message to
455527
/// @returns true if the message was sent, otherwise false
@@ -464,6 +536,7 @@ namespace isobus
464536

465537
/// @brief Sends a response to a change list item command
466538
/// @param[in] objectID The object ID for the object to change
539+
/// @param[in] newObjectID The object ID for the object to place at the specified list index, or NULL_OBJECT_ID (0xFFFF)
467540
/// @param[in] errorBitfield An error bitfield
468541
/// @param[in] listIndex The list index to change, numbered 0 to n
469542
/// @param[in] destination The control function to send the message to
@@ -537,6 +610,7 @@ namespace isobus
537610
/// @param[in] parentIDOfFaultingObject The parent object ID for the faulty object, or NULL_OBJECT_ID
538611
/// @param[in] faultingObjectID The faulty object's ID or the NULL_OBJECT_ID
539612
/// @param[in] errorCodes A bitfield of error codes that describe the issues with the pool
613+
/// @param[in] destination The control function to send the message to
540614
/// @returns true if the message was sent, otherwise false
541615
bool send_end_of_object_pool_response(bool success,
542616
std::uint16_t parentIDOfFaultingObject,
@@ -593,20 +667,20 @@ namespace isobus
593667

594668
static constexpr std::uint8_t VERSION_LABEL_LENGTH = 7; ///< The length of a standard object pool version label
595669

596-
EventDispatcher<std::shared_ptr<VirtualTerminalServerManagedWorkingSet>> onRepaintEventDispatcher;
597-
EventDispatcher<std::shared_ptr<VirtualTerminalServerManagedWorkingSet>, std::uint16_t, std::uint16_t> onChangeActiveMaskEventDispatcher;
598-
EventDispatcher<std::shared_ptr<VirtualTerminalServerManagedWorkingSet>, std::uint16_t, bool> onFocusObjectEventDispatcher;
599-
LanguageCommandInterface languageCommandInterface;
600-
std::shared_ptr<InternalControlFunction> serverInternalControlFunction;
601-
std::vector<std::shared_ptr<VirtualTerminalServerManagedWorkingSet>> managedWorkingSetList;
602-
std::shared_ptr<VirtualTerminalServerManagedWorkingSet> activeWorkingSet;
603-
std::uint32_t statusMessageTimestamp_ms = 0;
604-
std::uint16_t activeWorkingSetDataMaskObjectID = NULL_OBJECT_ID;
605-
std::uint16_t activeWorkingSetSoftkeyMaskObjectID = NULL_OBJECT_ID;
606-
std::uint8_t activeWorkingSetMasterAddress = NULL_CAN_ADDRESS;
607-
std::uint8_t busyCodesBitfield = 0;
608-
std::uint8_t currentCommandFunctionCode = 0;
609-
bool initialized = false;
670+
EventDispatcher<std::shared_ptr<VirtualTerminalServerManagedWorkingSet>> onRepaintEventDispatcher; ///< Event dispatcher for repaint events
671+
EventDispatcher<std::shared_ptr<VirtualTerminalServerManagedWorkingSet>, std::uint16_t, std::uint16_t> onChangeActiveMaskEventDispatcher; ///< Event dispatcher for active mask change events
672+
EventDispatcher<std::shared_ptr<VirtualTerminalServerManagedWorkingSet>, std::uint16_t, bool> onFocusObjectEventDispatcher; ///< Event dispatcher for focus object events
673+
LanguageCommandInterface languageCommandInterface; ///< The language command interface for the server
674+
std::shared_ptr<InternalControlFunction> serverInternalControlFunction; ///< The internal control function for the server
675+
std::vector<std::shared_ptr<VirtualTerminalServerManagedWorkingSet>> managedWorkingSetList; ///< The list of managed working sets
676+
std::shared_ptr<VirtualTerminalServerManagedWorkingSet> activeWorkingSet; ///< The active working set
677+
std::uint32_t statusMessageTimestamp_ms = 0; ///< The timestamp of the last status message sent
678+
std::uint16_t activeWorkingSetDataMaskObjectID = NULL_OBJECT_ID; ///< The object ID of the active working set's data mask
679+
std::uint16_t activeWorkingSetSoftkeyMaskObjectID = NULL_OBJECT_ID; ///< The object ID of the active working set's soft key mask
680+
std::uint8_t activeWorkingSetMasterAddress = NULL_CAN_ADDRESS; ///< The address of the active working set's master
681+
std::uint8_t busyCodesBitfield = 0; ///< The busy codes bitfield
682+
std::uint8_t currentCommandFunctionCode = 0; ///< The current command function code being processed
683+
bool initialized = false; ///< True if the server has been initialized, otherwise false
610684
};
611685
} // namespace isobus
612686
#endif //ISOBUS_VIRTUAL_TERMINAL_SERVER_HPP

0 commit comments

Comments
 (0)