4#include "calibratecommand.h"
9#include <QJsonDocument>
55 const float temperatureFloat = temperatureString.
toFloat(&ok);
59 errors.
append(
tr(
"Unrecognised temperature format: %1").arg(temperatureString));
90 qCInfo(lc).noquote() <<
tr(
"Calibrating temperature at %1 degrees celcius...").
arg(
temperature);
103 std::cout << qUtf8Printable(
tr(
"calibration_result\nsuccess\n"));
109 std::cout << qUtf8Printable(
tr(
"Done.\n"));
Declares the CalibrationService class.
virtual QStringList supportedOptions(const QCommandLineParser &parser) const
Returns a list of CLI option names supported by this command.
OutputFormat format
Selected output format.
@ Text
Plain unstructured text.
@ Csv
RFC 4180 compliant CSV text.
@ Json
RFC 8259 compliant JSON text.
virtual QStringList processOptions(const QCommandLineParser &parser)
Processes the relevant options from the command line parser.
virtual QStringList requiredOptions(const QCommandLineParser &parser) const
Returns a list of CLI option names required by this command.
The AbstractPokitService class provides a common base for Pokit services classes.
QStringList processOptions(const QCommandLineParser &parser) override
Processes the relevant options from the command line parser.
CalibrateCommand(QObject *const parent=nullptr)
Construct a new CalibrateCommand object with parent.
CalibrationService * service
Bluetooth service this command interracts with.
float temperature
Ambient temperature from the CLI options.
AbstractPokitService * getService() override
Returns a Pokit service object for the derived command class.
QStringList supportedOptions(const QCommandLineParser &parser) const override
Returns a list of CLI option names supported by this command.
void serviceDetailsDiscovered() override
Handles service detail discovery events.
QStringList requiredOptions(const QCommandLineParser &parser) const override
Returns a list of CLI option names required by this command.
void temperatureCalibrated()
Handles CalibrationService::temperatureCalibrated events, by outputting the result and exiting.
bool calibrateTemperature(const float ambientTemperature)
Set's the Pokit device's name to name.
void temperatureCalibrated()
This signal is emitted when the Temperature characteristic has been written succesfully.
The AbstractCommand class extends AbstractCommand to add a PokitDevice instance.
PokitDevice * device
Pokit Bluetooth device (if any) this command inerracts 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...
CalibrationService * calibration()
Returns a pointer to a CalibrationService instance that uses this device's controller for access.
Declares the PokitDevice class.
QString value(const QString &optionName) const const
void exit(int returnCode)
void append(const T &value)
bool isEmpty() 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
float toFloat(bool *ok) const const