Line data Source code
1 : // SPDX-FileCopyrightText: 2022-2023 Paul Colby <git@colby.id.au> 2 : // SPDX-License-Identifier: LGPL-3.0-or-later 3 : 4 : #include "devicecommand.h" 5 : 6 : #include <qtpokit/multimeterservice.h> 7 : #include <qtpokit/pokitmeter.h> 8 : #include <qtpokit/pokitpro.h> 9 : 10 1206 : class MeterCommand : public DeviceCommand 11 : { 12 3276 : Q_OBJECT 13 : 14 : public: 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 : 20 : public slots: 21 : QStringList processOptions(const QCommandLineParser &parser) override; 22 : 23 : protected: 24 : AbstractPokitService * getService() override; 25 : 26 : protected slots: 27 : void serviceDetailsDiscovered() override; 28 : 29 : private: 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. 34 : { MultimeterService::Mode::DcVoltage, +PokitMeter::VoltageRange::AutoRange, 1000 }; 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 : 38 : private slots: 39 : void settingsWritten(); 40 : void outputReading(const MultimeterService::Reading &reading); 41 : 42 : friend class TestMeterCommand; 43 : };