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 : 8 1054 : class MeterCommand : public DeviceCommand 9 : { 10 : public: 11 : explicit MeterCommand(QObject * const parent); 12 : 13 : QStringList requiredOptions(const QCommandLineParser &parser) const override; 14 : QStringList supportedOptions(const QCommandLineParser &parser) const override; 15 : 16 : public slots: 17 : QStringList processOptions(const QCommandLineParser &parser) override; 18 : 19 : protected: 20 : AbstractPokitService * getService() override; 21 : 22 : protected slots: 23 : void serviceDetailsDiscovered() override; 24 : 25 : private: 26 : MultimeterService * service; ///< Bluetooth service this command interracts with. 27 : MultimeterService::Settings settings; ///< Settings for the Pokit device's multimeter mode. 28 : int samplesToGo; ///< Number of samples to read, if specified on the CLI. 29 : bool showCsvHeader; ///< Whether or not to show a header as the first line of CSV output. 30 : 31 : static MultimeterService::Range lowestRange(const MultimeterService::Mode mode, const quint32 desiredMax); 32 : static MultimeterService::CurrentRange lowestCurrentRange(const quint32 desiredMax); 33 : static MultimeterService::ResistanceRange lowestResistanceRange(const quint32 desiredMax); 34 : static MultimeterService::VoltageRange lowestVoltageRange(const quint32 desiredMax); 35 : 36 : private slots: 37 : void settingsWritten(); 38 : void outputReading(const MultimeterService::Reading &reading); 39 : 40 : friend class TestMeterCommand; 41 : };