4#include "loggerfetchcommand.h"
9#include <QJsonDocument>
16#if (QT_VERSION < QT_VERSION_CHECK(6, 5, 0))
17 #define DOKIT_QT_UTC Qt::UTC
20 #define DOKIT_QT_UTC QTimeZone::UTC
62 qCInfo(lc).noquote() <<
tr(
"Fetching logger samples...");
73 qCDebug(lc) <<
"status:" << (int)(data.
status);
74 qCDebug(lc) <<
"scale:" << data.
scale;
83 qCInfo(lc).noquote() <<
tr(
"Fetching %Ln logger sample/s...",
nullptr, data.
numberOfSamples);
99 qCDebug(lc).noquote() <<
tr(R
"(No known unit for mode %1 "%2".)").arg((int)
metadata.
mode)
104 for (
const qint16 &sample: samples) {
111 std::cout << qUtf8Printable(
tr(
"timestamp,value,unit,range\n"));
114 .arg(timeString).arg(value).arg(unit, range));
129 std::cout << qUtf8Printable(
tr(
"%1 %2 %3\n").arg(timeString).arg(value).arg(unit));
136 qCInfo(lc).noquote() <<
tr(
"Finished fetching %Ln sample/s (with %L1 remaining).",
OutputFormat format
Selected output format.
@ Text
Plain unstructured text.
@ Csv
RFC 4180 compliant CSV text.
@ Json
RFC 8259 compliant JSON text.
The AbstractPokitService class provides a common base for Pokit services classes.
bool enableMetadataNotifications()
Enables client-side notifications of Data Logger metadata changes.
bool enableReadingNotifications()
Enables client-side notifications of Data Logger readings.
void metadataRead(const DataLoggerService::Metadata &meta)
This signal is emitted when the Metadata characteristic has been read successfully.
static QString toString(const Mode &mode)
Returns mode as a user-friendly string.
bool fetchSamples()
Start the data logger.
void samplesRead(const DataLoggerService::Samples &samples)
This signal is emitted when the Reading characteristic has been notified.
@ DcVoltage
Measure DC voltage.
@ AcCurrent
Measure AC current.
@ AcVoltage
Measure AC voltage.
@ Temperature
Measure temperature.
@ DcCurrent
Measure DC current.
The AbstractCommand class extends AbstractCommand to add a PokitDevice instance.
PokitDevice * device
Pokit Bluetooth device (if any) this command interracts with.
virtual void serviceDetailsDiscovered()
Handles service detail discovery events.
void disconnect(int exitCode=EXIT_SUCCESS)
Disconnects the underlying Pokit device, and sets exitCode to be return to the OS once the disconnect...
qint32 samplesToGo
Number of samples we're still expecting to receive.
DataLoggerService::Metadata metadata
Most recent data logging metadata.
DataLoggerService * service
Bluetooth service this command interracts with.
bool showCsvHeader
Whether or not to show a header as the first line of CSV output.
void outputSamples(const DataLoggerService::Samples &samples)
Outputs logger samples in the selected ouput format.
AbstractPokitService * getService() override
Returns a Pokit service object for the derived command class.
LoggerFetchCommand(QObject *const parent=nullptr)
Construct a new LoggerFetchCommand object with parent.
void serviceDetailsDiscovered() override
Handles service detail discovery events.
quint64 timestamp
Current sample's epoch milliseconds timestamp.
void metadataRead(const DataLoggerService::Metadata &data)
Invoked when metadata has been received from the data logger.
DataLoggerService * dataLogger()
Returns a pointer to a DataLoggerService instance that uses this device's controller for access.
Declares the PokitDevice class.
std::string toStdString() const const
QDateTime fromMSecsSinceEpoch(qint64 msecs)
QDateTime fromSecsSinceEpoch(qint64 secs, Qt::TimeSpec spec, int offsetSeconds)
QString toString(Qt::DateFormat format) const const
QByteArray toJson() const const
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QString tr(const char *sourceText, const char *disambiguation, int n)
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
QString fromLatin1(const char *str, int size)
QString fromUtf8(const char *str, int size)
QString & insert(int position, QChar ch)
bool isEmpty() const const
QString number(int n, int base)