NDEVR
API Documentation
DeviCounterSimulatorIO

Simulated ConnectionBackend that generates fake DeviCounter data for testing without hardware. More...

Inheritance diagram for DeviCounterSimulatorIO:
[legend]
Collaboration diagram for DeviCounterSimulatorIO:
[legend]

Public Member Functions

uint04 bytesAvailable () const final override
 Returns the number of bytes available to read.
void close () final override
 Closes the connection.
bool isOpen () const final override
 Checks whether the connection is currently open.
TranslatedString lastError () const final override
 Returns the last error message from this backend.
bool open (const ConnectionInfo &) final override
 Opens the connection using the provided connection info.
uint04 peek (char *s, uint04 size=Constant< uint04 >::Max) const final override
 Reads data from the receive buffer without consuming it.
uint04 rx (char *s, uint04 size=Constant< uint04 >::Max) final override
 Reads and consumes data from the receive buffer.
void tx (const StringView &) final override
 Transmits a string command over the connection.
bool waitForReadyRead (const TimeSpan &span) final override
 Blocks until data is available to read or the timeout expires.
Public Member Functions inherited from ConnectionBackend
 ConnectionBackend (LogPtr log)
 Constructs a ConnectionBackend with the given log.
void connectionStateChangedSignal (ConnectionState state)
 Emitted when the connection state changes.
void dataAvailableSignal ()
 Emitted when data is available to be read from the connection.
virtual String threadID () const
 Returns the thread ID this backend must execute on, if any.

Additional Inherited Members

Protected Attributes inherited from ConnectionBackend
LogPtr m_log
 Log for diagnostic messages.

Detailed Description

Simulated ConnectionBackend that generates fake DeviCounter data for testing without hardware.


Definition at line 42 of file DeviCounterSimulator.h.

Member Function Documentation

◆ bytesAvailable()

uint04 DeviCounterSimulatorIO::bytesAvailable ( ) const
inlinefinaloverridevirtual

Returns the number of bytes available to read.

Returns
The number of bytes in the receive buffer.

Implements ConnectionBackend.

Definition at line 134 of file DeviCounterSimulator.h.

References Time::SystemTime().

◆ isOpen()

bool DeviCounterSimulatorIO::isOpen ( ) const
inlinefinaloverridevirtual

Checks whether the connection is currently open.

Returns
True if the connection is open.

Implements ConnectionBackend.

Definition at line 94 of file DeviCounterSimulator.h.

◆ lastError()

TranslatedString DeviCounterSimulatorIO::lastError ( ) const
inlinefinaloverridevirtual

Returns the last error message from this backend.

Returns
A translated error string describing the last error.

Implements ConnectionBackend.

Definition at line 130 of file DeviCounterSimulator.h.

◆ open()

bool DeviCounterSimulatorIO::open ( const ConnectionInfo & request)
inlinefinaloverridevirtual

Opens the connection using the provided connection info.

Parameters
[in]requestThe connection parameters.
Returns
True if the connection was opened successfully.

Implements ConnectionBackend.

Definition at line 80 of file DeviCounterSimulator.h.

References MakeRandom().

◆ peek()

uint04 DeviCounterSimulatorIO::peek ( char * s,
uint04 size = Constantuint04 >::Max ) const
inlinefinaloverridevirtual

Reads data from the receive buffer without consuming it.

Parameters
[in]sThe buffer to write peeked data into.
[in]sizeMaximum number of bytes to peek.
Returns
The number of bytes actually peeked.

Implements ConnectionBackend.

Definition at line 52 of file DeviCounterSimulator.h.

References getMin(), and Time::SystemTime().

◆ rx()

uint04 DeviCounterSimulatorIO::rx ( char * s,
uint04 max_size = Constantuint04 >::Max )
inlinefinaloverridevirtual

Reads and consumes data from the receive buffer.

Parameters
[in]sThe buffer to write received data into.
[in]max_sizeMaximum number of bytes to read.
Returns
The number of bytes actually read.

Implements ConnectionBackend.

Definition at line 61 of file DeviCounterSimulator.h.

References getMin(), and Time::SystemTime().

◆ tx()

void DeviCounterSimulatorIO::tx ( const StringView & command)
inlinefinaloverridevirtual

Transmits a string command over the connection.

Parameters
[in]commandThe data to transmit.

Implements ConnectionBackend.

Definition at line 75 of file DeviCounterSimulator.h.

◆ waitForReadyRead()

bool DeviCounterSimulatorIO::waitForReadyRead ( const TimeSpan & span)
inlinefinaloverridevirtual

Blocks until data is available to read or the timeout expires.

Parameters
[in]spanMaximum time to wait.
Returns
True if data became available before the timeout.

Implements ConnectionBackend.

Definition at line 98 of file DeviCounterSimulator.h.

References getMin(), ThreadFunctions::RequestSleep(), and Time::SystemTime().


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