Dokit
Internal development documentation
Loading...
Searching...
No Matches
loggerstopcommand.cpp
1// SPDX-FileCopyrightText: 2022-2023 Paul Colby <git@colby.id.au>
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
4#include "loggerstopcommand.h"
5
7
8#include <QJsonDocument>
9#include <QJsonObject>
10
11#include <iostream>
12
13/*!
14 * \class LoggerStopCommand
15 *
16 * The LoggerStopCommand class implements the `logger stop` CLI command.
17 */
18
19/*!
20 * Construct a new LoggerStopCommand object with \a parent.
21 */
23{
24
25}
26
27/*!
28 * \copybrief DeviceCommand::getService
29 *
30 * This override returns a pointer to a DataLoggerService object.
31 */
43
44/*!
45 * \copybrief DeviceCommand::serviceDetailsDiscovered
46 *
47 * This override stops the device's logger.
48 */
50{
51 DeviceCommand::serviceDetailsDiscovered(); // Just logs consistently.
52 qCInfo(lc).noquote() << tr("Stopping logger.");
54}
55
56/*!
57 * Invoked when the data logger settings have been written.
58 */
60{
61 qCDebug(lc).noquote() << tr("Settings written; data logger has stopped.");
62 switch (format) {
64 std::cout << qUtf8Printable(tr("logger_stop_result\nsuccess\n"));
65 break;
67 std::cout << qUtf8Printable(QLatin1String("true\n"));
68 break;
70 std::cout << qUtf8Printable(tr("Done.\n"));
71 break;
72 }
73 if (device) disconnect(); // Will exit the application once disconnected.
74}
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 stopLogger()
Stop the data logger.
void settingsWritten()
This signal is emitted when the Settings characteristic has been written successfully.
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...
DataLoggerService * service
Bluetooth service this command interracts with.
void settingsWritten()
Invoked when the data logger settings have been written.
AbstractPokitService * getService() override
Returns a Pokit service object for the derived command class.
void serviceDetailsDiscovered() override
Handles service detail discovery events.
LoggerStopCommand(QObject *const parent=nullptr)
Construct a new LoggerStopCommand object with parent.
DataLoggerService * dataLogger()
Returns a pointer to a DataLoggerService instance that uses this device's controller for access.
Declares the PokitDevice class.
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)