33#include "DeviCounterConnection.h"
34#include <NDEVR/Connection.h>
35#include <NDEVR/Random.h>
36#include <NDEVR/Thread.h>
45 DeviCounterSimulatorIO()
49 simulateDeploymentStart();
50 simulateRandomEvent();
54 simulateRandomEvent();
58 memcpy(s, m_next_send.c_str(), final_size);
66 simulateRandomEvent();
68 memcpy(s, m_next_send.c_str(), final_size);
69 if (final_size >= m_next_send.size())
72 m_next_send.removeAllIndex(0, size);
77 simulateRandomEvent();
84 simulateRandomEvent();
91 simulateRandomEvent();
108 void simulateDeploymentStart()
112 void simulateRandomEvent()
const
118 m_distance += m_speed * (
Time::SystemTime() - m_last_speed_time).elapsedSeconds();
123 + String(m_distance) +
";"
124 + String(m_speed) +
";"
125 + String(m_battery_voltage) +
";999;0;0*12";
137 return m_next_send.size();
140 uint08 elapsedTime()
const
144 mutable Time m_start_time;
145 mutable Time m_last_speed_time;
146 mutable String m_error = String(
"0000");
147 mutable fltp08 m_battery_voltage = 0.0;
148 mutable fltp08 m_distance = 0.0;
149 mutable fltp08 m_temperature = 0.0;
150 mutable fltp08 m_speed = 0.0;
151 mutable String m_next_send;
152 mutable Time next_send_time = Constant<Time>::Invalid;
153 bool m_is_open =
false;
ConnectionBackend(LogPtr log)
Constructs a ConnectionBackend with the given log.
uint04 bytesAvailable() const final override
Returns the number of bytes available to read.
void tx(const StringView &) final override
Transmits a string command over the connection.
uint04 rx(char *s, uint04 size=Constant< uint04 >::Max) final override
Reads and consumes data from the receive buffer.
TranslatedString lastError() const final override
Returns the last error message from this backend.
bool waitForReadyRead(const TimeSpan &span) final override
Blocks until data is available to read or the timeout expires.
void close() final override
Closes the connection.
uint04 peek(char *s, uint04 size=Constant< uint04 >::Max) const final override
Reads data from the receive buffer without consuming it.
bool open(const ConnectionInfo &) final override
Opens the connection using the provided connection info.
bool isOpen() const final override
Checks whether the connection is currently open.
The core String View class for the NDEVR API.
static void RequestSleep(const TimeSpan &interval)
Puts the current thread to sleep for a specified duration.
Stores a time span, or difference between two times, with an optional start time.
static Time SystemTime()
Retrieves the current system time which is a combination of std::chrono::steady_clock to ensure smoot...
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
The primary namespace for the NDEVR SDK.
constexpr t_type getMin(const t_type &left, const t_type &right)
Finds the minimum of the given arguments based on the < operator Author: Tyler Parke Date: 2017-11-05...
t_type MakeRandom(t_type max)
Returns a pseudo-random number between 0 and the associated max value.
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
A structure designed to store information about a specific Connection.