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