AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
Loading...
Searching...
No Matches
isobus_virtual_terminal_client.hpp
Go to the documentation of this file.
1//================================================================================================
8//================================================================================================
9#ifndef ISOBUS_VIRTUAL_TERMINAL_CLIENT_HPP
10#define ISOBUS_VIRTUAL_TERMINAL_CLIENT_HPP
11
16#include "isobus/utility/event_dispatcher.hpp"
17#include "isobus/utility/processing_flags.hpp"
18#include "isobus/utility/thread_synchronization.hpp"
19
20#include <functional>
21#include <map>
22#include <memory>
23#include <string>
24#include <vector>
25
26#if !defined CAN_STACK_DISABLE_THREADS && !defined ARDUINO
27#include <thread>
28#endif
29
30namespace isobus
31{
32 //================================================================================================
42 //================================================================================================
44 {
45 public:
47 enum class Function : std::uint8_t
48 {
49 SoftKeyActivationMessage = 0x00,
50 ButtonActivationMessage = 0x01,
51 PointingEventMessage = 0x02,
52 VTSelectInputObjectMessage = 0x03,
53 VTESCMessage = 0x04,
54 VTChangeNumericValueMessage = 0x05,
55 VTChangeActiveMaskMessage = 0x06,
56 VTChangeSoftKeyMaskMessage = 0x07,
57 VTChangeStringValueMessage = 0x08,
58 VTOnUserLayoutHideShowMessage = 0x09,
59 VTControlAudioSignalTerminationMessage = 0x0A,
60 ObjectPoolTransferMessage = 0x11,
61 EndOfObjectPoolMessage = 0x12,
62 AuxiliaryAssignmentTypeOneCommand = 0x20,
63 AuxiliaryInputTypeOneStatus = 0x21,
64 PreferredAssignmentCommand = 0x22,
65 AuxiliaryInputTypeTwoMaintenanceMessage = 0x23,
66 AuxiliaryAssignmentTypeTwoCommand = 0x24,
67 AuxiliaryInputStatusTypeTwoEnableCommand = 0x25,
68 AuxiliaryInputTypeTwoStatusMessage = 0x26,
69 AuxiliaryCapabilitiesRequest = 0x27,
70 SelectActiveWorkingSet = 0x90,
71 ESCCommand = 0x92,
74 SelectInputObjectCommand = 0xA2,
75 ControlAudioSignalCommand = 0xA3,
76 SetAudioVolumeCommand = 0xA4,
77 ChangeChildLocationCommand = 0xA5,
78 ChangeSizeCommand = 0xA6,
79 ChangeBackgroundColourCommand = 0xA7,
80 ChangeNumericValueCommand = 0xA8,
81 ChangeEndPointCommand = 0xA9,
82 ChangeFontAttributesCommand = 0xAA,
83 ChangeLineAttributesCommand = 0xAB,
84 ChangeFillAttributesCommand = 0xAC,
85 ChangeActiveMaskCommand = 0xAD,
86 ChangeSoftKeyMaskCommand = 0xAE,
87 ChangeAttributeCommand = 0xAF,
88 ChangePriorityCommand = 0xB0,
89 ChangeListItemCommand = 0xB1,
90 DeleteObjectPoolCommand = 0xB2,
91 ChangeStringValueCommand = 0xB3,
92 ChangeChildPositionCommand = 0xB4,
93 ChangeObjectLabelCommand = 0xB5,
94 ChangePolygonPointCommand = 0xB6,
95 ChangePolygonScaleCommand = 0xB7,
96 GraphicsContextCommand = 0xB8,
97 GetAttributeValueMessage = 0xB9,
98 SelectColourMapCommand = 0xBA,
99 IdentifyVTMessage = 0xBB,
100 ExecuteExtendedMacroCommand = 0xBC,
101 LockUnlockMaskCommand = 0xBD,
102 ExecuteMacroCommand = 0xBE,
103 GetMemoryMessage = 0xC0,
104 GetSupportedWidecharsMessage = 0xC1,
105 GetNumberOfSoftKeysMessage = 0xC2,
106 GetTextFontDataMessage = 0xC3,
107 GetWindowMaskDataMessage = 0xC4,
108 GetSupportedObjectsMessage = 0xC5,
109 GetHardwareMessage = 0xC7,
110 StoreVersionCommand = 0xD0,
111 LoadVersionCommand = 0xD1,
112 DeleteVersionCommand = 0xD2,
113 ExtendedGetVersionsMessage = 0xD3,
114 ExtendedStoreVersionCommand = 0xD4,
115 ExtendedLoadVersionCommand = 0xD5,
116 ExtendedDeleteVersionCommand = 0xD6,
117 GetVersionsMessage = 0xDF,
118 GetVersionsResponse = 0xE0,
119 UnsupportedVTFunctionMessage = 0xFD,
120 VTStatusMessage = 0xFE,
121 WorkingSetMaintenanceMessage = 0xFF
122 };
123
125 enum class HideShowObjectCommand : std::uint8_t
126 {
127 HideObject = 0,
128 ShowObject = 1
129 };
130
132 enum class EnableDisableObjectCommand : std::uint8_t
133 {
134 DisableObject = 0,
135 EnableObject = 1
136 };
137
139 enum class SelectInputObjectOptions : std::uint8_t
140 {
142 SetFocusToObject = 0xFF
143 };
144
146 enum class VTVersion
147 {
149 Version3,
150 Version4,
151 Version5,
152 Version6,
154 };
155
162
164 enum class FontSize : std::uint8_t
165 {
166 Size6x8 = 0,
167 Size8x8 = 1,
168 Size8x12 = 2,
169 Size12x16 = 3,
170 Size16x16 = 4,
171 Size16x24 = 5,
172 Size24x32 = 6,
173 Size32x32 = 7,
174 Size32x48 = 8,
175 Size48x64 = 9,
176 Size64x64 = 10,
177 Size64x96 = 11,
178 Size96x128 = 12,
179 Size128x128 = 13,
180 Size128x192 = 14
181 };
182
184 enum class FontStyleBits : std::uint8_t
185 {
186 Bold = 0,
187 CrossedOut = 1,
188 Underlined = 2,
189 Italic = 3,
190 Inverted = 4,
191 Flashing = 5,
192 FlashingHidden = 6,
194 };
195
197 enum class FontType : std::uint8_t
198 {
199 ISO8859_1 = 0,
200 ISO8859_15 = 1,
201 ISO8859_2 = 2,
202 Reserved_1 = 3,
203 ISO8859_4 = 4,
204 ISO8859_5 = 5,
205 Reserved_2 = 6,
206 ISO8859_7 = 7,
207 ReservedEnd = 239,
208 ProprietaryBegin = 240,
209 ProprietaryEnd = 255
210 };
211
220
222 enum class MaskType : std::uint8_t
223 {
224 DataMask = 1,
225 AlarmMask = 2
226 };
227
229 enum class AlarmMaskPriority : std::uint8_t
230 {
231 High = 0,
232 Medium = 1,
233 Low = 2
234 };
235
237 enum class MaskLockState : std::uint8_t
238 {
239 UnlockMask = 0,
240 LockMask = 1
241 };
242
244 enum class KeyActivationCode : std::uint8_t
245 {
248 ButtonStillHeld = 2,
250 };
251
253 enum class ESCMessageErrorCode : std::uint8_t
254 {
255 NoError = 0,
256 NoInputFieldOpen = 1,
257 OtherError = 5
258 };
259
261 enum class MacroEventID : std::uint8_t
262 {
263 Reserved = 0,
264 OnActivate = 1,
265 OnDeactivate = 2,
266 OnShow = 3,
267 OnHide = 4,
268 OnEnable = 5,
269 OnDisable = 6,
278 OnChangeSize = 15,
279 OnChangeValue = 16,
280 OnChangePriority = 17,
281 OnChangeEndPoint = 18,
284 OnESC = 21,
285 OnEntryOfValue = 22,
286 OnEntryOfNewValue = 23,
287 OnKeyPress = 24,
288 OnKeyRelease = 25,
292 ReservedBegin = 29,
293 ReservedEnd = 254,
295 };
296
298 enum class GraphicMode : std::uint8_t
299 {
300 Monochrome = 0,
301 SixteenColour = 1,
303 };
304
326
354
374
378 VirtualTerminalClient(std::shared_ptr<PartneredControlFunction> partner, std::shared_ptr<InternalControlFunction> clientSource);
379
382
385
386 // Setup Functions
389 void initialize(bool spawnThread);
390
394 bool get_is_initialized() const;
395
398 bool get_is_connected() const;
399
401 void terminate();
402
405
408 std::shared_ptr<PartneredControlFunction> get_partner_control_function() const;
409
412 std::shared_ptr<InternalControlFunction> get_internal_control_function() const;
413
416 std::uint8_t get_active_working_set_master_address() const;
417
427
437
446
454
462
475
487
495
503
510
519
522 EventDispatcher<VTKeyEvent> &get_vt_soft_key_event_dispatcher();
523
526 EventDispatcher<VTKeyEvent> &get_vt_button_event_dispatcher();
527
530 EventDispatcher<VTPointingEvent> &get_vt_pointing_event_dispatcher();
531
534 EventDispatcher<VTSelectInputObjectEvent> &get_vt_select_input_object_event_dispatcher();
535
538 EventDispatcher<VTESCMessageEvent> &get_vt_esc_message_event_dispatcher();
539
542 EventDispatcher<VTChangeNumericValueEvent> &get_vt_change_numeric_value_event_dispatcher();
543
547 EventDispatcher<VTChangeActiveMaskEvent> &get_vt_change_active_mask_event_dispatcher();
548
552 EventDispatcher<VTChangeSoftKeyMaskEvent> &get_vt_change_soft_key_mask_event_dispatcher();
553
557 EventDispatcher<VTChangeStringValueEvent> &get_vt_change_string_value_event_dispatcher();
558
561 EventDispatcher<VTUserLayoutHideShowEvent> &get_vt_user_layout_hide_show_event_dispatcher();
562
565 EventDispatcher<VTAudioSignalTerminationEvent> &get_vt_control_audio_signal_termination_event_dispatcher();
566
569 EventDispatcher<AuxiliaryFunctionEvent> &get_auxiliary_function_event_dispatcher();
570
576 void set_auxiliary_input_model_identification_code(std::uint16_t modelIdentificationCode);
577
581
586 void add_auxiliary_input_object_id(const std::uint16_t auxiliaryInputID);
587
590 void remove_auxiliary_input_object_id(const std::uint16_t auxiliaryInputID);
591
598 void update_auxiliary_input(const std::uint16_t auxiliaryInputID, const std::uint16_t value1, const std::uint16_t value2, const bool controlLocked = false);
599
600 // Command Messages
601
610 bool send_hide_show_object(std::uint16_t objectID, HideShowObjectCommand command);
611
620 bool send_enable_disable_object(std::uint16_t objectID, EnableDisableObjectCommand command);
621
627 bool send_select_input_object(std::uint16_t objectID, SelectInputObjectOptions option);
628
631 bool send_ESC();
632
642 bool send_control_audio_signal(std::uint8_t activations, std::uint16_t frequency_hz, std::uint16_t duration_ms, std::uint16_t offTimeDuration_ms);
643
651 bool send_set_audio_volume(std::uint8_t volume_percent);
652
667 bool send_change_child_location(std::uint16_t objectID, std::uint16_t parentObjectID, std::uint8_t relativeXPositionChange, std::uint8_t relativeYPositionChange);
668
685 bool send_change_child_position(std::uint16_t objectID, std::uint16_t parentObjectID, std::uint16_t xPosition, std::uint16_t yPosition);
686
694 bool send_change_size_command(std::uint16_t objectID, std::uint16_t newWidth, std::uint16_t newHeight);
695
700 bool send_change_background_colour(std::uint16_t objectID, std::uint8_t colour);
701
708 bool send_change_numeric_value(std::uint16_t objectID, std::uint32_t value);
709
719 bool send_change_string_value(std::uint16_t objectID, uint16_t stringLength, const char *value);
720
729 bool send_change_string_value(std::uint16_t objectID, const std::string &value);
730
737 bool send_change_endpoint(std::uint16_t objectID, std::uint16_t width_px, std::uint16_t height_px, LineDirection direction);
738
747 bool send_change_font_attributes(std::uint16_t objectID, std::uint8_t colour, FontSize size, std::uint8_t type, std::uint8_t styleBitfield);
748
756 bool send_change_line_attributes(std::uint16_t objectID, std::uint8_t colour, std::uint8_t width, std::uint16_t lineArtBitmask);
757
765 bool send_change_fill_attributes(std::uint16_t objectID, FillType fillType, std::uint8_t colour, std::uint16_t fillPatternObjectID);
766
773 bool send_change_active_mask(std::uint16_t workingSetObjectID, std::uint16_t newActiveMaskObjectID);
774
782 bool send_change_softkey_mask(MaskType type, std::uint16_t dataOrAlarmMaskObjectID, std::uint16_t newSoftKeyMaskObjectID);
783
791 bool send_change_attribute(std::uint16_t objectID, std::uint8_t attributeID, std::uint32_t value);
792
800 bool send_change_attribute(std::uint16_t objectID, std::uint8_t attributeID, float value);
801
811 bool send_change_priority(std::uint16_t alarmMaskObjectID, AlarmMaskPriority priority);
812
822 bool send_change_list_item(std::uint16_t objectID, std::uint8_t listIndex, std::uint16_t newObjectID);
823
835 bool send_lock_unlock_mask(MaskLockState state, std::uint16_t objectID, std::uint16_t timeout_ms);
836
841 bool send_execute_macro(std::uint16_t objectID);
842
850 bool send_change_object_label(std::uint16_t objectID, std::uint16_t labelStringObjectID, std::uint8_t fontType, std::uint16_t graphicalDesignatorObjectID);
851
859 bool send_change_polygon_point(std::uint16_t objectID, std::uint8_t pointIndex, std::uint16_t newXValue, std::uint16_t newYValue);
860
868 bool send_change_polygon_scale(std::uint16_t objectID, std::uint16_t widthAttribute, std::uint16_t heightAttribute);
869
873 bool send_select_colour_map_or_palette(std::uint16_t objectID);
874
879 bool send_execute_extended_macro(std::uint16_t objectID);
880
884 bool send_select_active_working_set(std::uint64_t NAMEofWorkingSetMasterForDesiredWorkingSet);
885
886 // Graphics Context Commands:
893 bool send_set_graphics_cursor(std::uint16_t objectID, std::int16_t xPosition, std::int16_t yPosition);
894
902 bool send_move_graphics_cursor(std::uint16_t objectID, std::int16_t xOffset, std::int16_t yOffset);
903
910 bool send_set_foreground_colour(std::uint16_t objectID, std::uint8_t colour);
911
918 bool send_set_background_colour(std::uint16_t objectID, std::uint8_t colour);
919
928 bool send_set_line_attributes_object_id(std::uint16_t objectID, std::uint16_t lineAttributeobjectID);
929
938 bool send_set_fill_attributes_object_id(std::uint16_t objectID, std::uint16_t fillAttributeobjectID);
939
948 bool send_set_font_attributes_object_id(std::uint16_t objectID, std::uint16_t fontAttributesObjectID);
949
959 bool send_erase_rectangle(std::uint16_t objectID, std::uint16_t width, std::uint16_t height);
960
968 bool send_draw_point(std::uint16_t objectID, std::int16_t xOffset, std::int16_t yOffset);
969
980 bool send_draw_line(std::uint16_t objectID, std::int16_t xOffset, std::int16_t yOffset);
981
993 bool send_draw_rectangle(std::uint16_t objectID, std::uint16_t width, std::uint16_t height);
994
1007 bool send_draw_closed_ellipse(std::uint16_t objectID, std::uint16_t width, std::uint16_t height);
1008
1028 bool send_draw_polygon(std::uint16_t objectID, std::uint8_t numberOfPoints, const std::int16_t *listOfXOffsetsRelativeToCursor, const std::int16_t *listOfYOffsetsRelativeToCursor);
1029
1041 bool send_draw_text(std::uint16_t objectID, bool transparent, std::uint8_t textLength, const char *value);
1042
1052 bool send_pan_viewport(std::uint16_t objectID, std::int16_t xAttribute, std::int16_t yAttribute);
1053
1061 bool send_zoom_viewport(std::uint16_t objectID, float zoom);
1062
1070 bool send_pan_and_zoom_viewport(std::uint16_t objectID, std::int16_t xAttribute, std::int16_t yAttribute, float zoom);
1071
1080 bool send_change_viewport_size(std::uint16_t objectID, std::uint16_t width, std::uint16_t height);
1081
1088 bool send_draw_vt_object(std::uint16_t graphicsContextObjectID, std::uint16_t VTObjectID);
1089
1096 bool send_copy_canvas_to_picture_graphic(std::uint16_t graphicsContextObjectID, std::uint16_t objectID);
1097
1104 bool send_copy_viewport_to_picture_graphic(std::uint16_t graphicsContextObjectID, std::uint16_t objectID);
1105
1106 // VT Querying
1111 bool send_get_attribute_value(std::uint16_t objectID, std::uint8_t attributeID);
1112
1113 // Get Softkeys Response
1116 std::uint8_t get_softkey_x_axis_pixels() const;
1117
1120 std::uint8_t get_softkey_y_axis_pixels() const;
1121
1124 std::uint8_t get_number_virtual_softkeys() const;
1125
1128 std::uint8_t get_number_physical_softkeys() const;
1129
1130 // Get Text Font Data Response
1134 bool get_font_size_supported(FontSize value) const;
1135
1139 bool get_font_style_supported(FontStyleBits value) const;
1140
1141 // Get Hardware Responses
1145
1149
1153
1157
1161
1165
1169
1172 bool get_support_drag_operation() const;
1173
1177
1180 std::uint16_t get_number_x_pixels() const;
1181
1184 std::uint16_t get_number_y_pixels() const;
1185
1189
1193 bool is_vt_version_supported(VTVersion value) const;
1194
1197 std::uint16_t get_visible_data_mask() const;
1198
1201 std::uint16_t get_visible_soft_key_mask() const;
1202
1203 // ************************************************
1204 // Object Pool Interface
1205 // ************************************************
1206 // These are the functions for specifying your pool to upload.
1207 // You have a few options:
1208 // 1. Upload in one blob of contigious memory
1209 // This is good for small pools or pools where you have all the data in memory.
1210 // 2. Get a callback at some interval to provide data in chunks
1211 // This is probably better for huge pools if you are RAM constrained, or if your
1212 // pool is stored on some external device that you need to get data from in pages.
1213 // This is also the best way to load from IOP files!
1214 // If using callbacks, The object pool and pointer MUST NOT be deleted or leave scope until upload is done.
1215 // Version must be the same for all pools uploaded to this VT server!!!
1216
1223 void set_object_pool(std::uint8_t poolIndex,
1224 const std::uint8_t *pool,
1225 std::uint32_t size,
1226 std::string version = "");
1227
1233 void set_object_pool(std::uint8_t poolIndex,
1234 const std::vector<std::uint8_t> *pool,
1235 std::string version = "");
1236
1241 void set_object_pool_scaling(std::uint8_t poolIndex,
1242 std::uint32_t originalDataMaskDimensions_px,
1243 std::uint32_t originalSoftKyeDesignatorHeight_px);
1244
1253 void register_object_pool_data_chunk_callback(std::uint8_t poolIndex, std::uint32_t poolTotalSize, DataChunkCallback value, std::string version = "");
1254
1258 void update();
1259
1262
1263 protected:
1265 enum class GraphicsContextSubCommandID : std::uint8_t
1266 {
1267 SetGraphicsCursor = 0x00,
1268 MoveGraphicsCursor = 0x01,
1269 SetForegroundColour = 0x02,
1270 SetBackgroundColour = 0x03,
1274 EraseRectangle = 0x07,
1275 DrawPoint = 0x08,
1276 DrawLine = 0x09,
1277 DrawRectangle = 0x0A,
1278 DrawClosedEllipse = 0x0B,
1279 DrawPolygon = 0x0C,
1280 DrawText = 0x0D,
1281 PanViewport = 0x0E,
1282 ZoomViewport = 0x0F,
1283 PanAndZoomViewport = 0x10,
1284 ChangeViewportSize = 0x11,
1285 DrawVTObject = 0x12,
1288 };
1289
1291 enum class TransmitFlags : std::uint32_t
1292 {
1295
1297 };
1298
1300 enum class CurrentObjectPoolUploadState : std::uint8_t
1301 {
1303 InProgress,
1304 Success,
1305 Failed
1306 };
1307
1322
1325 {
1326 const std::uint64_t name;
1327 const std::uint16_t modelIdentificationCode;
1328 std::vector<AssignedAuxiliaryFunction> functions;
1329 };
1330
1333 {
1334 std::uint64_t lastStatusUpdate;
1335 bool enabled;
1338 std::uint16_t value1;
1339 std::uint16_t value2;
1340 };
1341
1342 static constexpr std::uint64_t AUXILIARY_INPUT_STATUS_DELAY = 1000;
1343 static constexpr std::uint64_t AUXILIARY_INPUT_STATUS_DELAY_INTERACTION = 50;
1344
1350 bool send_message_to_vt(const std::uint8_t *dataBuffer, std::uint32_t dataLength, CANIdentifier::CANPriority priority = CANIdentifier::CANPriority::Priority5) const;
1351
1352 // Object Pool Managment
1355 bool send_delete_object_pool() const;
1356
1360 bool send_working_set_maintenance(bool initializing) const;
1361
1366 bool send_get_memory(std::uint32_t requiredMemory) const;
1367
1370 bool send_get_number_of_softkeys() const;
1371
1374 bool send_get_text_font_data() const;
1375
1378 bool send_get_hardware() const;
1379
1382 bool send_get_supported_widechars() const;
1383
1386 bool send_get_window_mask_data() const;
1387
1390 bool send_get_supported_objects() const;
1391
1394 bool send_get_versions() const;
1395
1399 bool send_store_version(std::array<std::uint8_t, 7> versionLabel) const;
1400
1404 bool send_load_version(std::array<std::uint8_t, 7> versionLabel) const;
1405
1409 bool send_delete_version(std::array<std::uint8_t, 7> versionLabel) const;
1410
1413 bool send_extended_get_versions() const;
1414
1418 bool send_extended_store_version(std::array<std::uint8_t, 32> versionLabel) const;
1419
1423 bool send_extended_load_version(std::array<std::uint8_t, 32> versionLabel) const;
1424
1428 bool send_extended_delete_version(std::array<std::uint8_t, 32> versionLabel) const;
1429
1432 bool send_end_of_object_pool() const;
1433
1436 bool send_working_set_master() const;
1437
1441
1447 bool send_auxiliary_function_assignment_response(std::uint16_t functionObjectID, bool hasError, bool isAlreadyAssigned) const;
1448
1452
1458 bool send_auxiliary_input_status_enable_response(std::uint16_t objectID, bool isEnabled, bool hasError) const;
1459
1462
1466 bool update_auxiliary_input_status(std::uint16_t objectID);
1467
1470 void set_state(StateMachineState value);
1471
1475 static void process_flags(std::uint32_t flag, void *parent);
1476
1480 static void process_rx_message(const CANMessage &message, void *parentPointer);
1481
1489 static void process_callback(std::uint32_t parameterGroupNumber,
1490 std::uint32_t dataLength,
1491 std::shared_ptr<InternalControlFunction> sourceControlFunction,
1492 std::shared_ptr<ControlFunction> destinationControlFunction,
1493 bool successful,
1494 void *parentPointer);
1495
1505 static bool process_internal_object_pool_upload_callback(std::uint32_t callbackIndex,
1506 std::uint32_t bytesOffset,
1507 std::uint32_t numberOfBytesNeeded,
1508 std::uint8_t *chunkBuffer,
1509 void *parentPointer);
1510
1513 bool get_any_pool_needs_scaling() const;
1514
1517 bool scale_object_pools();
1518
1523
1528
1534 static FontSize remap_font_to_scale(FontSize originalFont, float scaleFactor);
1535
1539 static std::uint32_t get_minimum_object_length(VirtualTerminalObjectType type);
1540
1544 static std::uint32_t get_number_bytes_in_object(std::uint8_t *buffer);
1545
1549 static void process_standard_object_height_and_width(std::uint8_t *buffer, float scaleFactor);
1550
1556 bool resize_object(std::uint8_t *buffer, float scaleFactor, VirtualTerminalObjectType type);
1557
1561 bool is_function_unsupported(Function function) const;
1562
1566 bool is_function_unsupported(std::uint8_t functionCode) const;
1567
1571 bool send_command(const std::vector<std::uint8_t> &data);
1572
1577 bool queue_command(const std::vector<std::uint8_t> &data, bool replace = false);
1578
1583 bool replace_command(const std::vector<std::uint8_t> &data);
1584
1586 void process_command_queue();
1587
1590
1591 static constexpr std::uint32_t VT_STATUS_TIMEOUT_MS = 3000;
1592 static constexpr std::uint32_t WORKING_SET_MAINTENANCE_TIMEOUT_MS = 1000;
1593 static constexpr std::uint32_t AUXILIARY_MAINTENANCE_TIMEOUT_MS = 100;
1594
1595 std::shared_ptr<PartneredControlFunction> partnerControlFunction;
1596 std::shared_ptr<InternalControlFunction> myControlFunction;
1597
1598 ProcessingFlags txFlags;
1599
1600 // Status message contents from the VT
1601 std::uint32_t lastVTStatusTimestamp_ms = 0;
1605 std::uint8_t busyCodesBitfield = 0;
1607
1608 std::uint8_t connectedVTVersion = 0;
1609
1610 // Softkey capabilities
1611 std::uint8_t softKeyXAxisPixels = 0;
1612 std::uint8_t softKeyYAxisPixels = 0;
1614 std::uint8_t numberPhysicalSoftkeys = 0;
1615
1616 // Text Font Capabilities
1617 std::uint8_t smallFontSizesBitfield = 0;
1618 std::uint8_t largeFontSizesBitfield = 0;
1619 std::uint8_t fontStylesBitfield = 0;
1620
1621 // Hardware Capabilities, from the get hardware message
1623 std::uint16_t xPixels = 0;
1624 std::uint16_t yPixels = 0;
1625 std::uint8_t hardwareFeaturesBitfield = 0;
1626
1627 // Internal client state variables
1630 std::uint32_t stateMachineTimestamp_ms = 0;
1633 std::vector<ObjectPoolDataStruct> objectPools;
1634 std::vector<std::uint8_t> unsupportedFunctions;
1635 std::vector<AssignedAuxiliaryInputDevice> assignedAuxiliaryInputDevices;
1636 std::uint16_t ourModelIdentificationCode = 1;
1637 std::map<std::uint16_t, AuxiliaryInputState> ourAuxiliaryInputs;
1638#if !defined CAN_STACK_DISABLE_THREADS && !defined ARDUINO
1639 std::thread *workerThread = nullptr;
1640#endif
1641 bool firstTimeInState = false;
1642 bool initialized = false;
1645 bool shouldTerminate = false;
1646
1647 // Command queue
1648 std::vector<std::vector<std::uint8_t>> commandQueue;
1650 std::uint32_t lastCommandTimestamp_ms = 0;
1652
1653 // Activation event callbacks
1654 EventDispatcher<VTKeyEvent> softKeyEventDispatcher;
1655 EventDispatcher<VTKeyEvent> buttonEventDispatcher;
1656 EventDispatcher<VTPointingEvent> pointingEventDispatcher;
1657 EventDispatcher<VTSelectInputObjectEvent> selectInputObjectEventDispatcher;
1658 EventDispatcher<VTESCMessageEvent> escMessageEventDispatcher;
1659 EventDispatcher<VTChangeNumericValueEvent> changeNumericValueEventDispatcher;
1660 EventDispatcher<VTChangeActiveMaskEvent> changeActiveMaskEventDispatcher;
1661 EventDispatcher<VTChangeSoftKeyMaskEvent> changeSoftKeyMaskEventDispatcher;
1662 EventDispatcher<VTChangeStringValueEvent> changeStringValueEventDispatcher;
1663 EventDispatcher<VTUserLayoutHideShowEvent> userLayoutHideShowEventDispatcher;
1664 EventDispatcher<VTAudioSignalTerminationEvent> audioSignalTerminationEventDispatcher;
1665 EventDispatcher<AuxiliaryFunctionEvent> auxiliaryFunctionEventDispatcher;
1666
1667 // Object Pool info
1669 std::uint32_t lastObjectPoolIndex = 0;
1670 };
1671
1672} // namespace isobus
1673
1674// Required for FontSize to be used as a key in std::unordered_map, issue in C++11: https://cplusplus.github.io/LWG/issue2148
1675#if __cplusplus < 201402L
1676namespace std
1677{
1679 template<>
1680 struct hash<isobus::VirtualTerminalClient::FontSize>
1681 {
1686 {
1687 return static_cast<size_t>(fontSize);
1688 }
1689 };
1690}
1691#endif
1692
1693#endif // ISOBUS_VIRTUAL_TERMINAL_CLIENT_HPP
A representation of an ISOBUS ECU that we can send from. Use this class when defining your own contro...
A class that describes a control function on the bus that the stack should communicate with....
Similar to a data mask, but takes priority and will be shown over data masks.
CANPriority
Defines all the CAN frame priorities that can be encoded in a frame ID.
@ Priority5
Priority highest - 5.
A class that represents a generic CAN message of arbitrary length.
The Data Mask describes the objects that will appear in the Data Mask area of the physical display.
An interface for requesting and parsing the ISO11783 language command PGN, 0xFE0F.
A struct for storing information of a function assigned to an auxiliary input.
std::uint16_t inputObjectID
The object ID assigned on the auxiliary inputs end.
AssignedAuxiliaryFunction(std::uint16_t functionObjectID, std::uint16_t inputObjectID, AuxiliaryTypeTwoFunctionType functionType)
Constructs a AssignedAuxiliaryFunction, sets default values.
bool operator==(const AssignedAuxiliaryFunction &other) const
Allows easy comparison of two AssignedAuxiliaryFunction objects.
AuxiliaryTypeTwoFunctionType functionType
The type of function.
std::uint16_t functionObjectID
The object ID of the function present in our object pool.
An client interface for interacting with a virtual terminal (VT) server.
bool send_change_font_attributes(std::uint16_t objectID, std::uint8_t colour, FontSize size, std::uint8_t type, std::uint8_t styleBitfield)
Sends the change font attributes command.
bool send_extended_load_version(std::array< std::uint8_t, 32 > versionLabel) const
Sends the extended load version message.
HideShowObjectCommand
Enumerates the states that can be sent with a hide/show object command.
EventDispatcher< VTUserLayoutHideShowEvent > & get_vt_user_layout_hide_show_event_dispatcher()
The event dispatcher for when a user-layout object is hidden or shown.
bool send_set_graphics_cursor(std::uint16_t objectID, std::int16_t xPosition, std::int16_t yPosition)
Sends the set graphics cursor command.
EventDispatcher< VTChangeActiveMaskEvent > changeActiveMaskEventDispatcher
A list of all change active mask callbacks.
bool get_support_pointing_device_with_pointing_message() const
Returns if the VT server supports a pointing device with pointing message.
bool send_pan_and_zoom_viewport(std::uint16_t objectID, std::int16_t xAttribute, std::int16_t yAttribute, float zoom)
Sends the pan and zoom viewport command.
bool send_change_polygon_scale(std::uint16_t objectID, std::uint16_t widthAttribute, std::uint16_t heightAttribute)
Sends the change polygon scale command.
bool get_support_drag_operation() const
Returns if the VT supports the drag operation.
void process_command_queue()
Tries to send all messages in the queue.
bool send_auxiliary_input_maintenance() const
Send the auxiliary control type 2 maintenance message.
static void process_standard_object_height_and_width(std::uint8_t *buffer, float scaleFactor)
Resizes the most common VT object format by some scale factor.
GraphicsContextSubCommandID
Enumerates the command types for graphics context objects.
@ SetLineAttributesObjectID
Sets the line attribute object ID.
@ MoveGraphicsCursor
Moves the cursor relative to current location.
@ SetGraphicsCursor
Sets the graphics cursor x/y attributes.
@ CopyViewportToPictureGraphic
Copies the viewport to picture graphic object.
@ CopyCanvasToPictureGraphic
Copies the canvas to picture graphic object.
@ SetFontAttributesObjectID
Sets the font attribute object ID.
@ SetFillAttributesObjectID
Sets the fill attribute object ID.
std::uint8_t get_active_working_set_master_address() const
Returns the active working set master's address.
bool commandAwaitingResponse
Determines if we are currently waiting for a response to a command.
bool get_support_intermediate_coordinates_during_drag_operations() const
Returns if the VT supports the intermediate coordinates during a drag operation.
bool send_set_font_attributes_object_id(std::uint16_t objectID, std::uint16_t fontAttributesObjectID)
Sends the set fill attributes object ID command.
std::uint8_t connectedVTVersion
The VT server's supported max version.
CurrentObjectPoolUploadState currentObjectPoolState
The current upload state of the object pool being processed.
std::shared_ptr< PartneredControlFunction > get_partner_control_function() const
Returns the control function of the VT server with which this VT client communicates.
void initialize(bool spawnThread)
This function starts the state machine. Call this once you have supplied 1 or more object pool and ar...
std::vector< ObjectPoolDataStruct > objectPools
A container to hold all object pools that have been assigned to the interface.
EventDispatcher< AuxiliaryFunctionEvent > & get_auxiliary_function_event_dispatcher()
The event dispatcher for for when a change in auxiliary input for a function is received.
EventDispatcher< VTChangeStringValueEvent > changeStringValueEventDispatcher
A list of all change string value callbacks.
bool send_store_version(std::array< std::uint8_t, 7 > versionLabel) const
Sends the store version message.
bool send_set_foreground_colour(std::uint16_t objectID, std::uint8_t colour)
Sends the set foreground colour command.
std::uint8_t currentCommandFunctionCode
The VT server's current command function code.
std::uint16_t yPixels
The y pixel dimension as reported by the VT server.
EventDispatcher< VTKeyEvent > softKeyEventDispatcher
A list of all soft key event callbacks.
LanguageCommandInterface languageCommandInterface
Used to determine the language and unit systems in use by the VT server.
bool send_change_child_position(std::uint16_t objectID, std::uint16_t parentObjectID, std::uint16_t xPosition, std::uint16_t yPosition)
Sends the change child position command.
EventDispatcher< VTESCMessageEvent > & get_vt_esc_message_event_dispatcher()
The event dispatcher for when an ESC message is received, e.g. an open object input is closed.
bool send_change_polygon_point(std::uint16_t objectID, std::uint8_t pointIndex, std::uint16_t newXValue, std::uint16_t newYValue)
Sends change polygon point command.
bool replace_command(const std::vector< std::uint8_t > &data)
Replaces the first message in the queue with the same function-code and priority, and removes the res...
Mutex commandQueueMutex
A mutex to protect the command queue.
void set_auxiliary_input_model_identification_code(std::uint16_t modelIdentificationCode)
Set the model identification code of our auxiliary input device.
bool send_select_active_working_set(std::uint64_t NAMEofWorkingSetMasterForDesiredWorkingSet)
Sends the select active working set command.
VirtualTerminalClient(VirtualTerminalClient &)=delete
Deleted copy constructor for VirtualTerminalClient.
bool send_get_supported_widechars() const
Sends the get supported widechars message.
EventDispatcher< VTPointingEvent > pointingEventDispatcher
A list of all pointing event callbacks.
bool send_draw_point(std::uint16_t objectID, std::int16_t xOffset, std::int16_t yOffset)
Sends the draw point command.
static std::uint32_t get_minimum_object_length(VirtualTerminalObjectType type)
Returns the minimum length that the specified object could possibly require in bytes.
EventDispatcher< VTChangeNumericValueEvent > changeNumericValueEventDispatcher
A list of all change numeric value callbacks.
bool send_get_supported_objects() const
Sends the get supported objects message.
bool send_enable_disable_object(std::uint16_t objectID, EnableDisableObjectCommand command)
Sends an enable/disable object command.
void worker_thread_function()
The worker thread will execute this function when it runs, if applicable.
FontType
Enumerates the different font types.
@ ProprietaryBegin
The beginning of the proprietary range.
@ ReservedEnd
Reserved from ISO8859_7 to this value.
@ ProprietaryEnd
The end of the proprietary region.
void set_object_pool(std::uint8_t poolIndex, const std::uint8_t *pool, std::uint32_t size, std::string version="")
Assigns an object pool to the client using a buffer and size.
GraphicMode supportedGraphicsMode
The graphics mode reported by the VT server.
StateMachineState
The internal state machine state of the VT client, mostly just public so tests can access it.
@ SendLoadVersion
Sending the load version command.
@ WaitForEndOfObjectPoolResponse
Client is waiting for the end of object pool response message.
@ WaitForGetNumberSoftKeysResponse
Client is waiting for a response to the "get number of soft keys" message.
@ WaitForGetVersionsResponse
Client is waiting for a response to the "get versions" message.
@ SendEndOfObjectPool
Client is sending the end of object pool message.
@ Connected
Client is connected to the VT server and the application layer is in control.
@ SendGetVersions
If a version label was specified, check to see if the VT has that version already.
@ SendGetTextFontData
Client is sending the "get text font data" message.
@ SendGetMemory
Client is sending the "get memory" message to see if VT has enough memory available.
@ SendGetHardware
Client is sending the "get hardware" message.
@ SendWorkingSetMasterMessage
Client is sending the working state master message.
@ WaitForGetMemoryResponse
Client is waiting for a response to the "get memory" message.
@ UploadObjectPool
Client is uploading the object pool.
@ SendGetNumberSoftkeys
Client is sending the "get number of soft keys" message.
@ WaitForStoreVersionResponse
Client is waiting for a response to the store version command.
@ ReadyForObjectPool
Client needs an object pool before connection can continue.
@ WaitForGetHardwareResponse
Client is waiting for a response to the "get hardware" message.
@ WaitForLoadVersionResponse
Client is waiting for the VT to respond to the "Load Version" command.
@ SendStoreVersion
Sending the store version command.
@ WaitForGetTextFontDataResponse
Client is waiting for a response to the "get text font data" message.
@ Failed
Client could not connect to the VT due to an error.
@ Disconnected
VT is not connected, and is not trying to connect yet.
@ WaitForPartnerVTStatusMessage
VT client is initialized, waiting for a VT server to come online.
std::uint32_t lastVTStatusTimestamp_ms
The timestamp of the last VT status message.
std::uint8_t smallFontSizesBitfield
The small font sizes supported by the VT server.
bool send_select_colour_map_or_palette(std::uint16_t objectID)
Sends the select colour map or palette command.
std::uint16_t get_visible_soft_key_mask() const
Returns the current soft key mask displayed by the VT server.
std::uint16_t get_number_x_pixels() const
Returns the number of x pixels in the data mask area.
bool send_change_object_label(std::uint16_t objectID, std::uint16_t labelStringObjectID, std::uint8_t fontType, std::uint16_t graphicalDesignatorObjectID)
Sends the change object label command.
bool send_extended_get_versions() const
Sends the get extended versions message.
bool get_support_touchscreen_with_pointing_message() const
Returns if the VT server supports a touchscreen with pointing message.
std::uint8_t softKeyYAxisPixels
The size of a soft key Y dimension as reported by the VT server.
static void process_flags(std::uint32_t flag, void *parent)
Processes the internal Tx flags.
bool send_change_list_item(std::uint16_t objectID, std::uint8_t listIndex, std::uint16_t newObjectID)
Sends the change list item command.
AlarmMaskPriority
The allowable priorities of an alarm mask.
@ High
Overrides lower priority alarm masks.
@ Medium
Overrides low priority alarm masks.
EventDispatcher< VTKeyEvent > buttonEventDispatcher
A list of all button event callbacks.
bool send_zoom_viewport(std::uint16_t objectID, float zoom)
Sends the zoom viewport command.
bool is_function_unsupported(Function function) const
Extract from the cache whether a VT does not support a specific function.
bool send_set_audio_volume(std::uint8_t volume_percent)
Sends the set audio volume command.
void update_auxiliary_input(const std::uint16_t auxiliaryInputID, const std::uint16_t value1, const std::uint16_t value2, const bool controlLocked=false)
Update the state of an auxiliary input. This should be called when the value of an auxiliary input ch...
bool send_change_string_value(std::uint16_t objectID, uint16_t stringLength, const char *value)
Sends the change string value command.
EventDispatcher< VTESCMessageEvent > escMessageEventDispatcher
A list of all ESC event callbacks.
bool send_execute_extended_macro(std::uint16_t objectID)
Sends the execute extended macro command.
std::uint16_t get_number_y_pixels() const
Returns the number of y pixels in the data mask area.
VirtualTerminalClient(std::shared_ptr< PartneredControlFunction > partner, std::shared_ptr< InternalControlFunction > clientSource)
The constructor for a VirtualTerminalClient.
std::uint8_t activeWorkingSetMasterAddress
The active working set master address.
LineDirection
Enumerates the different line directions that can be used when changing an endpoint of an object.
@ TopLeftToBottomRightOfEnclosingVirtualRectangle
Draws the line from top left to bottom right of the enclosing virtual rectangle.
@ BottomLeftToTopRightOfEnclosingVirtualRectangle
Draws the line from bottom left to top right of the enclosing virtual rectangle.
bool get_auxiliary_input_learn_mode_enabled() const
Get whether the VT has enabled the learn mode for the auxiliary input.
bool is_vt_version_supported(VTVersion value) const
Returns whether the VT version is supported by the VT server.
FontStyleBits
Enumerates the font style options that can be encoded in a font style bitfield.
@ CrossedOut
Crossed-out font style (strikethrough)
@ ProportionalFontRendering
Enables proportional font rendering if supported by the server.
@ Inverted
Inverted font style (upside down)
@ FlashingHidden
Flashing between hidden and shown font style.
std::uint16_t xPixels
The x pixel dimension as reported by the VT server.
std::uint8_t get_number_virtual_softkeys() const
Returns the number of virtual softkeys reported by the VT server.
KeyActivationCode
The different key activation codes that a button press can generate.
@ ButtonPressAborted
Press was aborted (user navigated away from the button and did not release it)
@ ButtonStillHeld
Button is being held down (sent cyclically)
std::uint16_t activeWorkingSetDataMaskObjectID
The active working set data mask object ID.
bool send_copy_viewport_to_picture_graphic(std::uint16_t graphicsContextObjectID, std::uint16_t objectID)
Sends the copy viewport to picture graphic command.
bool firstTimeInState
Stores if the current update cycle is the first time a state machine state has been processed.
static FontSize remap_font_to_scale(FontSize originalFont, float scaleFactor)
Remaps a font to some other font based on a scale factor This is not a one-size-fits-all solution,...
GraphicMode
Enumerates the various VT server graphics modes.
@ TwoHundredFiftySixColour
256 Colour mode (8 bit)
@ Monochrome
Monochromatic graphics mode (1 bit)
std::uint16_t activeWorkingSetSoftKeyMaskObjectID
The active working set's softkey mask object ID.
bool get_support_simultaneous_activation_buttons_and_softkeys() const
Returns if the VT server supports simultaneous activation of buttons and softkeys.
bool send_change_fill_attributes(std::uint16_t objectID, FillType fillType, std::uint8_t colour, std::uint16_t fillPatternObjectID)
Sends the change fill attributes command.
std::uint8_t softKeyXAxisPixels
The size of a soft key X dimension as reported by the VT server.
void set_object_pool_scaling(std::uint8_t poolIndex, std::uint32_t originalDataMaskDimensions_px, std::uint32_t originalSoftKyeDesignatorHeight_px)
Configures an object pool to be automatically scaled to match the target VT server.
bool send_get_memory(std::uint32_t requiredMemory) const
Sends the get memory message.
std::vector< std::vector< std::uint8_t > > commandQueue
A queue of commands to send to the VT server.
static bool process_internal_object_pool_upload_callback(std::uint32_t callbackIndex, std::uint32_t bytesOffset, std::uint32_t numberOfBytesNeeded, std::uint8_t *chunkBuffer, void *parentPointer)
The data callback passed to the network manger's send function for the transport layer messages.
bool send_hide_show_object(std::uint16_t objectID, HideShowObjectCommand command)
Sends a hide/show object command.
bool send_pan_viewport(std::uint16_t objectID, std::int16_t xAttribute, std::int16_t yAttribute)
Sends the pan viewport command.
bool send_change_size_command(std::uint16_t objectID, std::uint16_t newWidth, std::uint16_t newHeight)
Sends the change size command.
std::uint16_t ourModelIdentificationCode
The model identification code of this input device.
bool send_change_softkey_mask(MaskType type, std::uint16_t dataOrAlarmMaskObjectID, std::uint16_t newSoftKeyMaskObjectID)
Sends the change softkey mask command.
std::uint32_t lastCommandTimestamp_ms
The timestamp of the last command sent.
void add_auxiliary_input_object_id(const std::uint16_t auxiliaryInputID)
Add a new auxiliary input to be managed by this virtual terminal object.
bool send_change_viewport_size(std::uint16_t objectID, std::uint16_t width, std::uint16_t height)
Sends the change viewport size command.
bool get_is_connected() const
Check whether the client is connected to the VT server.
std::uint16_t get_visible_data_mask() const
Returns the current data mask displayed by the VT server.
EventDispatcher< VTKeyEvent > & get_vt_soft_key_event_dispatcher()
The event dispatcher for when a soft key is pressed or released.
CurrentObjectPoolUploadState
The different states of an object pool upload process.
@ InProgress
The object pool upload is in progress.
@ Uninitialized
The object pool upload has not been started.
static void process_callback(std::uint32_t parameterGroupNumber, std::uint32_t dataLength, std::shared_ptr< InternalControlFunction > sourceControlFunction, std::shared_ptr< ControlFunction > destinationControlFunction, bool successful, void *parentPointer)
The callback passed to the network manager's send function to know when a Tx is completed.
bool send_change_priority(std::uint16_t alarmMaskObjectID, AlarmMaskPriority priority)
Sends the change priority command.
EventDispatcher< VTAudioSignalTerminationEvent > audioSignalTerminationEventDispatcher
A list of all control audio signal termination callbacks.
MacroEventID
Enumerates the different events that can be associated with a macro.
@ OnChangeSize
Event on change of an object size.
@ OnShow
Event on an object being shown.
@ OnChangeAttribute
Event on change of an attribute value.
@ OnHide
Event on an object being hidden.
@ OnChangeValue
Event on change of an object value (like via change numeric value)
@ OnChangePriority
Event on change of a mask's priority.
@ OnKeyPress
Event on the press of a key.
@ OnDisable
Event on disabling an object.
@ OnPointingEventRelease
Event on a pointing event release.
@ ReservedBegin
Beginning of the reserved range.
@ OnChangeSoftKeyMask
Event on change of the soft key mask.
@ OnChangeLineAttributes
Event on change of a line attribute.
@ OnChangeBackgroundColour
Event on change of a background colour.
@ OnInputFieldDeselection
Event on deselection of an input field.
@ OnChangeChildLocation
Event on change of a child objects location.
@ OnEntryOfValue
Event on entry of a value.
@ OnActivate
Event on activation of an object (such as for data input)
@ OnEnable
Event on enable of an object.
@ OnDeactivate
Event on deactivation of an object.
@ OnChangeEndPoint
Event on change of an object endpoint.
@ OnPointingEventPress
Event on a pointing event press.
@ OnInputFieldSelection
Event when an input field is selected.
@ UseExtendedMacroReference
Use extended macro reference.
@ OnKeyRelease
Event on the release of a key.
@ OnChangeFontAttributes
Event on change of a font attribute.
@ OnEntryOfNewValue
Event on entry of a new value.
@ OnChangeFillAttributes
Event on change of a fill attribute.
@ OnChangeActiveMask
Event on changing the active mask.
@ OnChangeChildPosition
Event on changing a child object's position.
FontSize
Enumerates the different font sizes.
bool get_is_initialized() const
Returns if the client has been initialized.
bool send_lock_unlock_mask(MaskLockState state, std::uint16_t objectID, std::uint16_t timeout_ms)
Sends the lock unlock mask command.
EventDispatcher< VTChangeSoftKeyMaskEvent > changeSoftKeyMaskEventDispatcher
A list of all change soft key mask callbacks.
static constexpr std::uint32_t AUXILIARY_MAINTENANCE_TIMEOUT_MS
The delay between auxiliary maintenance messages.
VTVersion get_connected_vt_version() const
Returns the VT version supported supported by the VT server.
static std::uint32_t get_number_bytes_in_object(std::uint8_t *buffer)
Returns the total number of bytes in the VT object located at the specified memory location.
EventDispatcher< VTUserLayoutHideShowEvent > userLayoutHideShowEventDispatcher
A list of all user layout hide/show callbacks.
std::map< std::uint16_t, AuxiliaryInputState > ourAuxiliaryInputs
The inputs on this auxiliary input device.
bool send_auxiliary_functions_preferred_assignment() const
Send the preferred auxiliary control type 2 assignment command.
bool send_load_version(std::array< std::uint8_t, 7 > versionLabel) const
Sends the load version message.
void update()
Periodic Update Function (worker thread may call this)
bool send_execute_macro(std::uint16_t objectID)
Sends the execute macro command.
static bool get_is_object_scalable(VirtualTerminalObjectType type)
Returns if the specified object type can be scaled.
EventDispatcher< VTChangeStringValueEvent > & get_vt_change_string_value_event_dispatcher()
The event dispatcher for when a string value is changed.
EventDispatcher< VTPointingEvent > & get_vt_pointing_event_dispatcher()
The event dispatcher for when a pointing event is "pressed or released".
std::shared_ptr< InternalControlFunction > myControlFunction
The internal control function the client uses to send from.
void remove_auxiliary_input_object_id(const std::uint16_t auxiliaryInputID)
Remove an auxiliary input from the pool of managed auxiliary inputs.
bool resize_object(std::uint8_t *buffer, float scaleFactor, VirtualTerminalObjectType type)
Resizes a single VT object by some scale factor.
std::uint32_t lastWorkingSetMaintenanceTimestamp_ms
The timestamp from the last time we sent the maintenance message.
std::uint8_t busyCodesBitfield
The VT server's busy codes.
TransmitFlags
Flags used as a retry mechanism for sending important messages.
@ SendWorkingSetMaintenance
Flag to send the working set maintenenace message.
@ NumberFlags
The number of flags in this enum.
@ SendAuxiliaryMaintenance
Flag to send the auxiliary maintenance message.
bool send_draw_closed_ellipse(std::uint16_t objectID, std::uint16_t width, std::uint16_t height)
Sends the draw closed ellipse message.
EventDispatcher< VTAudioSignalTerminationEvent > & get_vt_control_audio_signal_termination_event_dispatcher()
The event dispatcher for when an audio signal is terminated.
Function
Enumerates the multiplexor byte values for VT commands.
bool queue_command(const std::vector< std::uint8_t > &data, bool replace=false)
Tries to send a command to the VT server, and queues it if it fails.
bool send_get_attribute_value(std::uint16_t objectID, std::uint8_t attributeID)
Sends the get attribute value message.
bool send_end_of_object_pool() const
Sends the end of object pool message.
bool get_any_pool_needs_scaling() const
Returns if any object pool had scaling configured.
EventDispatcher< AuxiliaryFunctionEvent > auxiliaryFunctionEventDispatcher
A list of all auxiliary function callbacks.
bool get_has_adjustable_volume_output() const
Returns if the VT server supports adjustable volume output.
bool sendWorkingSetMaintenance
Used internally to enable and disable cyclic sending of the working set maintenance message.
FillType
Enumerates the different fill types for an object.
@ FillWithLineColour
Fill with the colour of the outline of the shape.
@ FillWithPatternGivenByFillPatternAttribute
Fill with a patter provided by a fill pattern attribute.
@ FillWithSpecifiedColourInFillColourAttribute
Fill with the colour specified by a fill attribute.
@ NoFill
No fill will be applied.
bool send_draw_polygon(std::uint16_t objectID, std::uint8_t numberOfPoints, const std::int16_t *listOfXOffsetsRelativeToCursor, const std::int16_t *listOfYOffsetsRelativeToCursor)
Sends the draw polygon command.
static constexpr std::uint64_t AUXILIARY_INPUT_STATUS_DELAY
The delay between the auxiliary input status messages, in milliseconds.
bool send_ESC()
Sends the ESC message (Escape)
void update_auxiliary_input_status()
Send the auxiliary control type 2 status message for all inputs if applicable.
bool send_draw_text(std::uint16_t objectID, bool transparent, std::uint8_t textLength, const char *value)
Sends the draw text command.
bool shouldTerminate
Used to determine if the client should exit and join the worker thread.
bool send_change_line_attributes(std::uint16_t objectID, std::uint8_t colour, std::uint8_t width, std::uint16_t lineArtBitmask)
Sends the change line attributes command.
void register_object_pool_data_chunk_callback(std::uint8_t poolIndex, std::uint32_t poolTotalSize, DataChunkCallback value, std::string version="")
Assigns an object pool to the client where the client will get data in chunks during upload.
AuxiliaryTypeTwoFunctionType
Enumerates the various auxiliary input function types.
@ BidirectionalEncoder
Count increases when turning in the encoders "increase" direction, and decreases when turning in the ...
@ AnalogueMomentaryOneWay
One-way analogue (returns to 0%)
@ DualBooleanLatching
Three-position switch (maintains position) (Single Pole, Three Positions, Centre Off)
@ BooleanMomentary
Two-position switch (returns to off) (Momentary Single Pole, Single Throw)
@ DualBooleanLatchingDownpOnly
Three-position switch (maintains position only in down position) (Momentary Single Pole,...
@ QuadratureBooleanMomentary
Two Quadrature mounted Three-position switches (returns to centre position) (Momentary Single Pole,...
@ AnalogueLatching
Two-way analogue (Maintains position setting)
@ DualBooleanMomentary
Three-position switch (returns to off/centre position) (Momentary Single Pole, Three Positions,...
@ ReservedRemoveAssignment
Used for Remove assignment command.
@ AnalogueMomentaryBooleanLatching
two-way analogue (returns to centre position) with latching Boolean at 0% and 100% positions
@ AnalogueLatchingBooleanLatching
two-way analogue (maintains position setting) with momentary Boolean at 0% and 100% positions
@ DualBooleanLatchingUpOnly
Three-position switch (maintains position only in up position) (Single Pole, Three Positions,...
@ BooleanLatching
Two-position switch (maintains position) (Single Pole, Double Throw)
@ QuadratureAnalogueMomentary
Two Quadrature mounted Two-way analogue (returns to centre position - 50%)
@ QuadratureAnalogueLatching
Two Quadrature mounted Two-way analogue (maintains position)
@ AnalogueMomentaryTwoWay
Two-way analogue (returns to centre position - 50%)
bool get_font_size_supported(FontSize value) const
Returns if the selected font is supported.
std::uint8_t numberVirtualSoftkeysPerSoftkeyMask
The number of virtual softkeys per softkey mask as reported by the VT server.
std::uint8_t hardwareFeaturesBitfield
The reported hardware features from the VT server.
bool send_extended_store_version(std::array< std::uint8_t, 32 > versionLabel) const
Sends the extended store version message.
ESCMessageErrorCode
Enumerates the errors that can be present in an ESC message.
@ OtherError
Error is not one of the above.
bool get_multiple_frequency_audio_output() const
Returns if the VT server supports multiple frequency audio output.
bool get_font_style_supported(FontStyleBits value) const
Returns if the selected font style is supported.
void restart_communication()
Halts communication with the VT gracefully and restarts it.
EventDispatcher< VTChangeNumericValueEvent > & get_vt_change_numeric_value_event_dispatcher()
The event dispatcher for when a numeric value is changed in an input object.
bool send_move_graphics_cursor(std::uint16_t objectID, std::int16_t xOffset, std::int16_t yOffset)
Sends the move graphics cursor command.
std::vector< std::uint8_t > unsupportedFunctions
Holds the functions unsupported by the server.
bool send_set_line_attributes_object_id(std::uint16_t objectID, std::uint16_t lineAttributeobjectID)
Sends the set line attributes object id.
void set_state(StateMachineState value)
Sets the state machine state and updates the associated timestamp.
bool send_set_background_colour(std::uint16_t objectID, std::uint8_t colour)
Sends the set background colour command.
static constexpr std::uint32_t WORKING_SET_MAINTENANCE_TIMEOUT_MS
The delay between working set maintenance messages.
bool send_change_endpoint(std::uint16_t objectID, std::uint16_t width_px, std::uint16_t height_px, LineDirection direction)
Sends the change endpoint command, which changes the end of an output line.
bool send_delete_object_pool() const
Sends the delete object pool message.
bool send_command(const std::vector< std::uint8_t > &data)
Sends a command to the VT server.
bool send_draw_vt_object(std::uint16_t graphicsContextObjectID, std::uint16_t VTObjectID)
Sends the draw VT object command.
GraphicMode get_graphic_mode() const
Returns the graphics mode supported by the VT server.
StateMachineState state
The current client state machine state.
std::uint8_t numberPhysicalSoftkeys
The number of physical softkeys supported by the VT server.
DataChunkCallback objectPoolDataCallback
The callback to use to get pool data.
ProcessingFlags txFlags
A retry mechanism for internal Tx messages.
EventDispatcher< VTChangeActiveMaskEvent > & get_vt_change_active_mask_event_dispatcher()
The event dispatcher for when the active mask is changed.
std::vector< AssignedAuxiliaryInputDevice > assignedAuxiliaryInputDevices
A container to hold all auxiliary input devices known.
bool send_change_numeric_value(std::uint16_t objectID, std::uint32_t value)
Sends the change numeric value command.
SelectInputObjectOptions
Enumerates the states that can be sent with a select input object options command.
@ SetFocusToObject
Focuses the object (usually this draws a temporary box around it)
@ ActivateObjectForDataInput
Activates an object for data input.
bool sendAuxiliaryMaintenance
Used internally to enable and disable cyclic sending of the auxiliary maintenance message.
bool send_change_background_colour(std::uint16_t objectID, std::uint8_t colour)
Sends the change background colour command.
FontSize get_font_or_next_smallest_font(FontSize originalFont) const
Returns the closest font to the one you passed in, in decending order.
bool send_select_input_object(std::uint16_t objectID, SelectInputObjectOptions option)
Sends a select input object command.
EventDispatcher< VTKeyEvent > & get_vt_button_event_dispatcher()
The event dispatcher for when a button is pressed or released.
bool send_draw_rectangle(std::uint16_t objectID, std::uint16_t width, std::uint16_t height)
Sends the draw rectangle command.
bool send_auxiliary_function_assignment_response(std::uint16_t functionObjectID, bool hasError, bool isAlreadyAssigned) const
Send the auxiliary control type 2 assignment reponse message.
bool send_get_number_of_softkeys() const
Sends the get number of softkeys message.
std::thread * workerThread
The worker thread that updates this interface.
MaskLockState
Denotes the lock/unlock state of a mask. Used to freeze/unfreeze rendering of a mask.
@ LockMask
Locks the mask so rendering of it is not updated until it is unlocked or a timeout occurs.
@ UnlockMask
Renders the mask normally.
std::shared_ptr< InternalControlFunction > get_internal_control_function() const
Returns the internal control function being used by the client.
bool scale_object_pools()
Iterates through each object pool and scales each object in the pool automatically.
bool send_set_fill_attributes_object_id(std::uint16_t objectID, std::uint16_t fillAttributeobjectID)
Sends the fill attributes object id.
void terminate()
Terminates the client and joins the worker thread if applicable.
bool send_get_window_mask_data() const
Sends the get window mask data message.
bool send_get_text_font_data() const
Sends the get text font data message.
std::uint8_t get_softkey_y_axis_pixels() const
Returns the number of Y axis pixels in a softkey.
bool send_draw_line(std::uint16_t objectID, std::int16_t xOffset, std::int16_t yOffset)
Sends the draw line command.
bool send_copy_canvas_to_picture_graphic(std::uint16_t graphicsContextObjectID, std::uint16_t objectID)
Sends the copy canvas to picture graphic command.
bool send_extended_delete_version(std::array< std::uint8_t, 32 > versionLabel) const
Sends the extended delete version message.
std::uint8_t get_number_physical_softkeys() const
Returns the number of physical softkeys reported by the VT server.
std::uint32_t stateMachineTimestamp_ms
Timestamp from the last state machine update.
std::shared_ptr< PartneredControlFunction > partnerControlFunction
The partner control function this client will send to.
bool initialized
Stores the client initialization state.
bool send_erase_rectangle(std::uint16_t objectID, std::uint16_t width, std::uint16_t height)
Sends the erase rectangle command.
static void process_rx_message(const CANMessage &message, void *parentPointer)
Processes a CAN message destined for any VT client.
static constexpr std::uint32_t VT_STATUS_TIMEOUT_MS
The max allowable time between VT status messages before its considered offline.
bool send_change_child_location(std::uint16_t objectID, std::uint16_t parentObjectID, std::uint8_t relativeXPositionChange, std::uint8_t relativeYPositionChange)
Sends the change child location command.
std::uint8_t get_softkey_x_axis_pixels() const
Returns the number of X axis pixels in a softkey.
std::uint32_t lastAuxiliaryMaintenanceTimestamp_ms
The timestamp from the last time we sent the maintenance message.
std::uint32_t lastObjectPoolIndex
The last object pool index that was processed.
std::uint8_t fontStylesBitfield
The text font capabilities supported by the VT server.
bool send_delete_version(std::array< std::uint8_t, 7 > versionLabel) const
Sends the delete version message.
EventDispatcher< VTSelectInputObjectEvent > & get_vt_select_input_object_event_dispatcher()
The event dispatcher for when an input object event is triggered.
EventDispatcher< VTSelectInputObjectEvent > selectInputObjectEventDispatcher
A list of all select input object callbacks.
bool send_get_versions() const
Sends the get versions message.
bool send_change_active_mask(std::uint16_t workingSetObjectID, std::uint16_t newActiveMaskObjectID)
Sends the change active mask command.
static constexpr std::uint64_t AUXILIARY_INPUT_STATUS_DELAY_INTERACTION
The delay between the auxiliary input status messages when the input is interacted with,...
EventDispatcher< VTChangeSoftKeyMaskEvent > & get_vt_change_soft_key_mask_event_dispatcher()
The event dispatcher for when the soft key mask is changed.
bool send_get_hardware() const
Sends the get hardware message.
VTVersion
The different VT versions that a client or server might support.
@ Version3
Client or server supports all of VT version 3.
@ Version4
Client or server supports all of VT version 4.
@ Version5
Client or server supports all of VT version 5.
@ Version2OrOlder
Client or server supports VT version 2 or lower.
@ ReservedOrUnknown
Reserved value, not to be used.
@ Version6
Client or server supports all of VT version 6.
bool get_support_simultaneous_activation_physical_keys() const
Returns if the VT server supports simultaneous activation of physical keys.
bool send_auxiliary_input_status_enable_response(std::uint16_t objectID, bool isEnabled, bool hasError) const
Send the auxiliary input status type 2 enable response.
std::uint8_t largeFontSizesBitfield
The large font sizes supported by the VT server.
bool send_working_set_maintenance(bool initializing) const
Sends the working set maintenance message.
bool send_control_audio_signal(std::uint8_t activations, std::uint16_t frequency_hz, std::uint16_t duration_ms, std::uint16_t offTimeDuration_ms)
Sends the control audio signal command.
bool send_working_set_master() const
Sends the working set master message.
bool send_change_attribute(std::uint16_t objectID, std::uint8_t attributeID, std::uint32_t value)
Sends the change attribute command.
bool send_message_to_vt(const std::uint8_t *dataBuffer, std::uint32_t dataLength, CANIdentifier::CANPriority priority=CANIdentifier::CANPriority::Priority5) const
Sends a message to the VT server.
~VirtualTerminalClient()
The destructor for the VirtualTerminalClient.
EnableDisableObjectCommand
Enumerates the states that can be sent with an enable/disable object command.
Defines a set of values found in the isobus language command message from ISO11783-7 commonly used in...
Defines the different VT object types that can comprise a VT object pool.
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.
VirtualTerminalObjectType
The types of objects in an object pool by object type byte value.
bool(*)(std::uint32_t callbackIndex, std::uint32_t bytesOffset, std::uint32_t numberOfBytesNeeded, std::uint8_t *chunkBuffer, void *parentPointer) DataChunkCallback
A callback to get chunks of data for transfer by a protocol.
A struct for storing information about an auxiliary input device.
const std::uint16_t modelIdentificationCode
The model identification code.
std::vector< AssignedAuxiliaryFunction > functions
The functions assigned to this auxiliary input device (only applicable for listeners of input)
A struct for storing information of an auxilary function event.
VirtualTerminalClient * parentPointer
A pointer to the parent VT client.
Struct for storing the state of an auxiliary input on our device.
bool hasInteraction
Whether the auxiliary input is currently interacted with.
std::uint16_t value2
The second value of the auxiliary input. See Table J.5 of Part 6 of the standard for details.
bool enabled
Whether the auxiliary input is enabled by the VT.
std::uint64_t lastStatusUpdate
The time of the last status update, in milliseconds.
std::uint16_t value1
The first value of the auxiliary input. See Table J.5 of Part 6 of the standard for details.
bool controlLocked
Whether the auxiliary input is currently locked.
An object for storing information regarding an object pool upload.
std::uint32_t autoScaleSoftKeyDesignatorOriginalHeight
The original height of a soft key designator as designed in the pool (in pixels)
const std::uint8_t * objectPoolDataPointer
A pointer to an object pool.
std::string versionLabel
An optional version label that will be used to load/store the pool to the VT. 7 character max!
bool useDataCallback
Determines if the client will use callbacks to get the data in chunks.
DataChunkCallback dataCallback
A callback used to get data in chunks as an alternative to loading the whole pool at once.
const std::vector< std::uint8_t > * objectPoolVectorPointer
A pointer to an object pool (vector format)
std::vector< std::uint8_t > scaledObjectPool
Stores a copy of a pool to auto-scale in RAM before uploading it.
std::uint32_t autoScaleDataMaskOriginalDimension
The original length or width of this object pool's data mask area (in pixels)
A struct for storing information of a VT control audio signal termination event.
VirtualTerminalClient * parentPointer
A pointer to the parent VT client.
A struct for storing information of a VT change active mask event.
VirtualTerminalClient * parentPointer
A pointer to the parent VT client.
A struct for storing information of a VT change numeric value event.
VirtualTerminalClient * parentPointer
A pointer to the parent VT client.
A struct for storing information of a VT change soft key mask event.
VirtualTerminalClient * parentPointer
A pointer to the parent VT client.
std::uint16_t dataOrAlarmMaskObjectID
The data or alarm mask object ID.
A struct for storing information of a VT change string value event.
VirtualTerminalClient * parentPointer
A pointer to the parent VT client.
A struct for storing information of a VT ESC message event.
VirtualTerminalClient * parentPointer
A pointer to the parent VT client.
A struct for storing information of a VT key input event.
VirtualTerminalClient * parentPointer
A pointer to the parent VT client.
A struct for storing information of a VT pointing event.
VirtualTerminalClient * parentPointer
A pointer to the parent VT client.
A struct for storing information of a VT input object selection event.
VirtualTerminalClient * parentPointer
A pointer to the parent VT client.
A struct for storing information of a VT on user-layout hide/show event.
VirtualTerminalClient * parentPointer
A pointer to the parent VT client.
size_t operator()(const isobus::VirtualTerminalClient::FontSize &fontSize) const
Hashes a font size.