![]() |
NDEVR
API Documentation
|
A base class for communicating with Hardware, typically firmware by the software. More...
Classes | |
| struct | CommandQueueItem |
| An item in the command queue containing the command, arguments, and validation regex. More... | |
| struct | CommandRecord |
| A record of a command execution with timing information. More... | |
Public Member Functions | |
| void | addCommandToFront (t_type command, const String &args=String(), const String ®ex=String()) |
| Adds a command to the front of the queue so it executes next. | |
| virtual bool | allowMultipleCommandsInStream (t_type command, const StringView &args) const |
| Returns whether multiple instances of the same command are allowed in the queue. | |
| uint04 | bufferOffset () const |
| Returns the current buffer offset for data reads. | |
| virtual void | cancelCommand () |
| Cancels the currently executing command and records its statistics. | |
| void | clearCommands () |
| Removes all pending and blocking commands from the queue. | |
| CommandInformation | commandInformation (t_type command) |
| Returns the stored statistics and configuration for the given command. | |
| TimeSpan | commandTimeout () const |
| Returns the response timeout for the currently executing command. | |
| const String & | currentArgs () const |
| Returns the arguments for the currently executing command. | |
| t_type | currentCommand () const |
| Returns the currently executing command type. | |
| const String & | currentRegex () const |
| Returns the validation regex for the currently executing command. | |
| void | disableCommand (t_type command) |
| Disables a command, removing it from the queue and marking it as unsupported. | |
| virtual void | endCommandQueue () |
| Called when the command queue is shutting down. | |
| virtual void | executeCommand (const t_type &command, const StringView &args)=0 |
| Executes a command with the given arguments. | |
| void | executeCommandBlocking (const t_type &command, const StringView &args=StringView()) |
| Posts a command and blocks until it has been executed and completed. | |
| void | finishCommand () |
| Marks the current command as finished and records its execution statistics. | |
| String | getCommandCSVInfo (bool only_supported, bool include_identity_info, char deliminator=',') const |
| Serializes all command information to a CSV-formatted string. | |
| JSONNode | getCommandJSONInfo (bool only_supported) const |
| Serializes all command information to a JSON tree. | |
| bool | hasPending () const |
| Returns whether there are any pending or currently executing commands. | |
| bool | hasPendingCommand (t_type command) const |
| Checks whether a specific command is pending in the queue. | |
| virtual void | onFailure (const t_type &command) |
| Called when a command fails. | |
| bool | popCommandAndExecute () |
| Pops the next command from the queue and executes it. | |
| void | postCommand (t_type command, const StringView &args=StringView(), const StringView ®ex=StringView()) |
| Posts a command to the end of the queue. | |
| void | removeCommand (t_type command) |
| Removes all instances of the given command from the queue. | |
| virtual void | retryCommand () |
| Cancels the current command and re-adds it to the front of the queue for retry. | |
| TimeSpan | rxDelay () const |
| Returns the receive delay for the currently executing command. | |
| void | setBufferOffset (uint04 buffer_offset) |
| Sets the buffer offset for data reads. | |
| void | setFromJSONInfo (const JSONNode &root, bool allow_command_override, LogPtr log) |
| Loads command configuration and statistics from a JSON tree. | |
| void | setSupport (t_type command, CommandSupport support) |
| Sets the support status for a command. | |
| void | setSupported (t_type command, bool supported) |
| Sets whether a command is supported or not. | |
| virtual bool | supportsCommand (t_type command) const |
| Checks whether the hardware supports the given command. | |
| TimeSpan | txDelay () const |
| Returns the transmission delay for the currently executing command. | |
Static Public Attributes | |
| static const uint04 | s_buffer_size = 256000 |
| The default buffer size for command data. | |
Protected Attributes | |
| uint04 | m_buffer_offset = 0 |
| The current offset into the data buffer. | |
| Dictionary< t_type, CommandInformation > | m_command_info |
| Map of command types to their configuration and statistics. | |
| CommandQueueItem | m_current_command |
| The command currently being executed. | |
| Time | m_current_command_start_time = Constant<Time>::Invalid |
| When the current command began executing. | |
| Buffer< CommandQueueItem > | m_ordered_commands |
| The ordered list of commands waiting to be executed. | |
| CommandQueueItem | m_pending_block_command |
| A blocking command waiting to be executed with priority. | |
| Dictionary< t_type, uint04 > | m_pending_commands |
| Map of pending command types to their count in the queue. | |
| Buffer< CommandRecord > | m_records |
| Historical records of executed commands. | |
A base class for communicating with Hardware, typically firmware by the software.
Commands a queued up and sent, before waiting for a response for each command.
Definition at line 81 of file HardwareCommandQueue.h.
|
inline |
Adds a command to the front of the queue so it executes next.
| [in] | command | The command to add. |
| [in] | args | Optional arguments for the command. |
| [in] | regex | Optional validation regex for the response. |
Definition at line 161 of file HardwareCommandQueue.h.
References allowMultipleCommandsInStream(), m_ordered_commands, and m_pending_commands.
Referenced by retryCommand().
|
inlinevirtual |
Returns whether multiple instances of the same command are allowed in the queue.
| [in] | command | The command to check. |
| [in] | args | The arguments for the command. |
Definition at line 190 of file HardwareCommandQueue.h.
Referenced by addCommandToFront(), and postCommand().
|
inline |
Returns the stored statistics and configuration for the given command.
| [in] | command | The command to query. |
Definition at line 360 of file HardwareCommandQueue.h.
References m_command_info.
|
inline |
Returns the response timeout for the currently executing command.
Definition at line 419 of file HardwareCommandQueue.h.
References m_command_info, and m_current_command.
|
inline |
Disables a command, removing it from the queue and marking it as unsupported.
| [in] | command | The command to disable. |
Definition at line 377 of file HardwareCommandQueue.h.
References e_not_supported, m_command_info, m_ordered_commands, and m_pending_commands.
|
inlinevirtual |
Called when the command queue is shutting down.
Override to perform cleanup.
Definition at line 413 of file HardwareCommandQueue.h.
|
pure virtual |
Executes a command with the given arguments.
Must be implemented by subclasses.
| [in] | command | The command to execute. |
| [in] | args | The arguments for the command. |
Referenced by popCommandAndExecute().
|
inline |
Posts a command and blocks until it has been executed and completed.
| [in] | command | The command to execute. |
| [in] | args | Optional arguments for the command. |
Definition at line 313 of file HardwareCommandQueue.h.
References m_current_command, m_pending_block_command, and ThreadFunctions::RequestSleep().
|
inline |
Serializes all command information to a CSV-formatted string.
| [in] | only_supported | If true, only includes commands that are supported. |
| [in] | include_identity_info | If true, includes default args, delays, regex, and timeout. |
| [in] | deliminator | The delimiter character to use between fields. |
Definition at line 539 of file HardwareCommandQueue.h.
References cast(), CommandInformation::default_argument, String::DisplayString(), e_not_supported, TimeSpan::elapsedSeconds(), TranslatedString::englishTranslation(), m_command_info, CommandInformation::number_of_attempts, CommandInformation::number_of_failures, CommandInformation::response_timeout, CommandInformation::rx_delay, CommandInformation::supports_command, CommandInformation::total_time, CommandInformation::tx_delay, and CommandInformation::validation_regex.
|
inline |
Serializes all command information to a JSON tree.
| [in] | only_supported | If true, only includes commands that are supported. |
Definition at line 498 of file HardwareCommandQueue.h.
References cast(), CommandInformation::command, CommandInformation::default_argument, String::DisplayString(), e_not_supported, TimeSpan::elapsedSeconds(), TranslatedString::englishTranslation(), m_command_info, CommandInformation::number_of_attempts, CommandInformation::number_of_failures, CommandInformation::response_timeout, CommandInformation::rx_delay, CommandInformation::supports_command, CommandInformation::total_time, CommandInformation::tx_delay, and CommandInformation::validation_regex.
|
inline |
Returns whether there are any pending or currently executing commands.
Definition at line 596 of file HardwareCommandQueue.h.
References m_current_command, and m_pending_commands.
|
inline |
Checks whether a specific command is pending in the queue.
| [in] | command | The command to check for. |
Definition at line 108 of file HardwareCommandQueue.h.
References m_pending_commands.
|
inlinevirtual |
Called when a command fails.
Updates failure statistics and support status.
| [in] | command | The command that failed. |
Definition at line 291 of file HardwareCommandQueue.h.
References e_not_known, e_not_supported, and m_command_info.
|
inline |
Pops the next command from the queue and executes it.
Definition at line 198 of file HardwareCommandQueue.h.
References executeCommand(), m_current_command, m_current_command_start_time, m_ordered_commands, m_pending_block_command, m_pending_commands, and Time::SystemTime().
|
inline |
Posts a command to the end of the queue.
If the command already exists and multiple commands are not allowed, the existing entry is updated instead.
| [in] | command | The command to post. |
| [in] | args | Optional arguments for the command. |
| [in] | regex | Optional validation regex for the response. |
Definition at line 118 of file HardwareCommandQueue.h.
References allowMultipleCommandsInStream(), m_ordered_commands, and m_pending_commands.
|
inline |
Removes all instances of the given command from the queue.
| [in] | command | The command to remove. |
Definition at line 142 of file HardwareCommandQueue.h.
References IsValid(), m_ordered_commands, and m_pending_commands.
|
inline |
Returns the receive delay for the currently executing command.
Definition at line 435 of file HardwareCommandQueue.h.
References m_command_info, and m_current_command.
|
inline |
Sets the buffer offset for data reads.
| [in] | buffer_offset | The new buffer offset. |
Definition at line 607 of file HardwareCommandQueue.h.
References m_buffer_offset.
|
inline |
Loads command configuration and statistics from a JSON tree.
| [in] | root | The JSON node containing command information. |
| [in] | allow_command_override | If true, allows overriding command strings, delays, and support status. |
| [in] | log | The log to report errors to. |
Definition at line 445 of file HardwareCommandQueue.h.
References cast(), CommandInformation::command, CommandInformation::default_argument, String::DisplayString(), LogMessage::e_error, TranslatedString::englishTranslation(), JSONNode::getAs(), JSONNode::hasNode(), m_command_info, CommandInformation::number_of_attempts, CommandInformation::number_of_failures, CommandInformation::response_timeout, CommandInformation::rx_delay, CommandInformation::supports_command, CommandInformation::total_time, CommandInformation::tx_delay, and CommandInformation::validation_regex.
|
inline |
Sets the support status for a command.
| [in] | command | The command to update. |
| [in] | support | The new CommandSupport status. |
Definition at line 398 of file HardwareCommandQueue.h.
References m_command_info.
|
inline |
Sets whether a command is supported or not.
| [in] | command | The command to update. |
| [in] | supported | True to mark as supported, false to mark as unsupported. |
Definition at line 405 of file HardwareCommandQueue.h.
References e_not_supported, e_supported, and m_command_info.
|
inlinevirtual |
Checks whether the hardware supports the given command.
| [in] | command | The command to check. |
Definition at line 369 of file HardwareCommandQueue.h.
References e_not_supported, and m_command_info.
|
inline |
Returns the transmission delay for the currently executing command.
Definition at line 427 of file HardwareCommandQueue.h.
References m_command_info, and m_current_command.