Dokit
Internal development documentation
Loading...
Searching...
No Matches
metercommand.h
1// SPDX-FileCopyrightText: 2022-2024 Paul Colby <git@colby.id.au>
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
4#include "devicecommand.h"
5
8#include <qtpokit/pokitpro.h>
9
11{
13
14public:
15 explicit MeterCommand(QObject * const parent = nullptr);
16
17 QStringList requiredOptions(const QCommandLineParser &parser) const override;
18 QStringList supportedOptions(const QCommandLineParser &parser) const override;
19
20public slots:
21 QStringList processOptions(const QCommandLineParser &parser) override;
22
23protected:
25
26protected slots:
27 void serviceDetailsDiscovered() override;
28
29private:
30 quint8 (* minRangeFunc)(const PokitProduct product, const quint32 maxValue) { nullptr };
31 quint32 rangeOptionValue { 0 }; ///< The parsed value of range option, if one was supplied.
32 MultimeterService * service { nullptr }; ///< Bluetooth service this command interracts with.
33 MultimeterService::Settings settings ///< Settings for the Pokit device's multimeter mode.
35 int samplesToGo { -1 } ; ///< Number of samples to read, if specified on the CLI.
36 bool showCsvHeader { true }; ///< Whether or not to show a header as the first line of CSV output.
37
38private slots:
39 void settingsWritten();
40 void outputReading(const MultimeterService::Reading &reading);
41
42 friend class TestMeterCommand;
43};
The AbstractPokitService class provides a common base for Pokit services classes.
The AbstractCommand class extends AbstractCommand to add a PokitDevice instance.
The MeterCommand class implements the meter CLI command.
QStringList requiredOptions(const QCommandLineParser &parser) const override
Returns a list of CLI option names required by this command.
quint32 rangeOptionValue
The parsed value of range option, if one was supplied.
MultimeterService::Settings settings
< Settings for the Pokit device's multimeter mode.
bool showCsvHeader
Whether or not to show a header as the first line of CSV output.
void outputReading(const MultimeterService::Reading &reading)
Outputs meter reading in the selected ouput format.
QStringList processOptions(const QCommandLineParser &parser) override
Processes the relevant options from the command line parser.
void settingsWritten()
Invoked when the multimeter settings have been written, to begin reading the meter values.
QStringList supportedOptions(const QCommandLineParser &parser) const override
Returns a list of CLI option names supported by this command.
quint8(* minRangeFunc)(const PokitProduct product, const quint32 maxValue)
Pointer to function for converting rangeOptionValue to a Pokit device's range enumerator.
AbstractPokitService * getService() override
Returns a Pokit service object for the derived command class.
void serviceDetailsDiscovered() override
Handles service detail discovery events.
MeterCommand(QObject *const parent=nullptr)
Construct a new MeterCommand object with parent.
int samplesToGo
Number of samples to read, if specified on the CLI.
MultimeterService * service
Bluetooth service this command interracts with.
The MultimeterService class accesses the Multimeter service of Pokit devices.
@ DcVoltage
Measure DC voltage.
Declares the MultimeterService class.
Declares the PokitMeter namespace.
Declares the PokitPro namespace.
PokitProduct
Pokit products known to, and supported by, the QtPokit library.
Q_OBJECTQ_OBJECT
QObject * parent() const const
Attributes included in the Reading characterstic.
Attributes included in the Settings characterstic.