Serial Studio 1.1.6
A dashboard software for your embedded projects
|
#include <Console.h>
Public Types | |
enum class | DisplayMode { DisplayPlainText , DisplayHexadecimal } |
enum class | DataMode { DataUTF8 , DataHexadecimal } |
enum class | LineEnding { NoLineEnding , NewLine , CarriageReturn , BothNewLineAndCarriageReturn } |
Public Slots | |
void | save () |
void | clear () |
void | historyUp () |
void | historyDown () |
void | send (const QString &data) |
void | setEcho (const bool enabled) |
void | print (const QString &fontFamily) |
void | setAutoscroll (const bool enabled) |
void | setShowTimestamp (const bool enabled) |
void | setDataMode (const IO::Console::DataMode &mode) |
void | setLineEnding (const IO::Console::LineEnding &mode) |
void | setDisplayMode (const IO::Console::DisplayMode &mode) |
void | append (const QString &str, const bool addTimestamp=false) |
Signals | |
void | echoChanged () |
void | dataReceived () |
void | dataModeChanged () |
void | autoscrollChanged () |
void | lineEndingChanged () |
void | displayModeChanged () |
void | historyItemChanged () |
void | textDocumentChanged () |
void | showTimestampChanged () |
void | stringReceived (const QString &text) |
Public Member Functions | |
bool | echo () const |
bool | autoscroll () const |
bool | saveAvailable () const |
bool | showTimestamp () const |
DataMode | dataMode () const |
LineEnding | lineEnding () const |
DisplayMode | displayMode () const |
QString | currentHistoryString () const |
Q_INVOKABLE StringList | dataModes () const |
Q_INVOKABLE StringList | lineEndings () const |
Q_INVOKABLE StringList | displayModes () const |
Q_INVOKABLE QString | formatUserHex (const QString &text) |
Static Public Member Functions | |
static Console & | instance () |
Properties | |
bool | echo |
bool | autoscroll |
bool | showTimestamp |
bool | saveAvailable |
IO::Console::DataMode | dataMode |
IO::Console::LineEnding | lineEnding |
IO::Console::DisplayMode | displayMode |
QString | currentHistoryString |
Private Slots | |
void | onDataSent (const QByteArray &data) |
void | addToHistory (const QString &command) |
void | onDataReceived (const QByteArray &data) |
Private Member Functions | |
Console () | |
Console (Console &&)=delete | |
Console (const Console &)=delete | |
Console & | operator= (Console &&)=delete |
Console & | operator= (const Console &)=delete |
QByteArray | hexToBytes (const QString &data) |
QString | dataToString (const QByteArray &data) |
QString | plainTextStr (const QByteArray &data) |
QString | hexadecimalStr (const QByteArray &data) |
Private Attributes | |
DataMode | m_dataMode |
LineEnding | m_lineEnding |
DisplayMode | m_displayMode |
int | m_historyItem |
bool | m_echo |
bool | m_autoscroll |
bool | m_showTimestamp |
bool | m_isStartingLine |
StringList | m_lines |
StringList | m_historyItems |
QString | m_printFont |
QString | m_textBuffer |
The Console class.
The console class receives data from the IO::Manager
class and processes it so that it can be easily appended to a text edit widget.
The class also controls various UI-related factors, such as the display format of the data (e.g. ASCII or HEX), history of sent commands and exporting of the RX data.
|
strong |
|
strong |
|
strong |
|
explicitprivate |
Constructor function
|
privatedelete |
|
privatedelete |
|
privateslot |
Registers the given command to the list of sent commands.
|
slot |
Inserts the given string into the list of lines of the console, if addTimestamp is set to true
, an timestamp is added for each line.
bool IO::Console::autoscroll | ( | ) | const |
Returns true
if the vertical position of the console display shall be automatically moved to show latest data.
|
signal |
|
slot |
Deletes all the text displayed by the current QML text document
QString IO::Console::currentHistoryString | ( | ) | const |
Returns the current command history string selected by the user.
historyUp()
& historyDown()
functions. IO::Console::DataMode IO::Console::dataMode | ( | ) | const |
Returns the type of data that the user inputs to the console. There are two possible values:
DataMode::DataUTF8
the user is sending data formated in the UTF-8 codec.DataMode::DataHexadecimal
the user is sending binary data represented in hexadecimal format, we must do a conversion to obtain and send the appropiate binary data to the target device.
|
signal |
StringList IO::Console::dataModes | ( | ) | const |
Returns a list with the available data (sending) modes. This list must be synchronized with the order of the DataMode
enums.
|
signal |
|
private |
Converts the given data to a string according to the console display mode set by the user.
IO::Console::DisplayMode IO::Console::displayMode | ( | ) | const |
Returns the display format of the console. Posible values are:
DisplayMode::DisplayPlainText
display incoming data as an UTF-8 streamDisplayMode::DisplayHexadecimal
display incoming data in hexadecimal format
|
signal |
StringList IO::Console::displayModes | ( | ) | const |
Returns a list with the available console display modes. This list must be synchronized with the order of the DisplayMode
enums.
bool IO::Console::echo | ( | ) | const |
Returns true
if the console shall display the commands that the user has sent to the serial/network device.
|
signal |
QString IO::Console::formatUserHex | ( | const QString & | text | ) |
Validates the given text and adds space to display the text in a byte-oriented view
|
private |
Converts the given data into a HEX representation string.
|
private |
Converts the given data in HEX format into real binary data.
|
slot |
Comamnds sent by the user are stored in a StringList
, in which the first items are the oldest commands.
The user can navigate the list using the up/down keys. This function allows the user to navigate the list from oldst command to most recent command.
|
signal |
|
slot |
Comamnds sent by the user are stored in a StringList
, in which the first items are the oldest commands.
The user can navigate the list using the up/down keys. This function allows the user to navigate the list from most recent command to oldest command.
|
static |
Returns the only instance of the class
IO::Console::LineEnding IO::Console::lineEnding | ( | ) | const |
Returns the line ending character that is added to each datablock sent by the user. Possible values are:
LineEnding::NoLineEnding
leave data as-it-isLineEnding::NewLine
, add 'LineEnding::CarriageReturn
, add '\r' to the data sent by the userLineEnding::BothNewLineAndCarriageReturn
add '\r
|
signal |
StringList IO::Console::lineEndings | ( | ) | const |
Returns a list with the available line endings options. This list must be synchronized with the order of the LineEnding
enums.
|
privateslot |
Displays the given data in the console
|
privateslot |
Displays the given data in the console. QByteArray
to ~QString
conversion is done by the dataToString()
function, which displays incoming data either in UTF-8 or in hexadecimal mode.
|
private |
Converts the given data into an UTF-8 string
|
slot |
Creates a text document with current console output & prints it using native system libraries/toolkits.
fontFamily | the font family to use to render the text document |
|
slot |
Allows the user to export the information displayed on the console
bool IO::Console::saveAvailable | ( | ) | const |
Returns true
if data buffer contains information that the user can export.
|
slot |
Sends the given data to the currently connected device using the options specified by the user with the rest of the functions of this class.
data
is added to the history of sent commands, regardless if the data writing was successfull or not.
|
slot |
Enables/disables autoscrolling of the console text.
|
slot |
Changes the data mode for user commands. See dataMode()
for more information.
|
slot |
Changes the display mode of the console. See displayMode()
for more information.
|
slot |
Enables or disables displaying sent data in the console screen. See echo()
for more information.
|
slot |
Changes line ending mode for sent user commands. See lineEnding()
for more information.
|
slot |
Enables/disables displaying a timestamp of each received data block.
bool IO::Console::showTimestamp | ( | ) | const |
Returns true
if a timestamp should be shown before each displayed data block.
|
signal |
|
signal |
|
signal |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
readwrite |
|
read |
|
readwrite |
|
readwrite |
|
readwrite |
|
readwrite |
|
read |
|
readwrite |