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/dsoservice.h> 7 : 8 1584 : class DsoCommand : public DeviceCommand 9 : { 10 3834 : Q_OBJECT 11 : 12 : public: 13 : explicit DsoCommand(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 : DsoService * service { nullptr }; ///< Bluetooth service this command interracts with. 29 : DsoService::Settings settings { ///< Settings for the Pokit device's DSO mode. 30 : DsoService::Command::FreeRunning, 0.0f, DsoService::Mode::DcVoltage, 31 : DsoService::VoltageRange::_30V_to_60V, 1000*1000, 1000 32 : }; 33 : DsoService::Metadata metadata; ///< Most recent DSO metadata. 34 : qint32 samplesToGo { 0 }; ///< Number of samples we're expecting in the current window. 35 : bool showCsvHeader { true }; ///< Whether or not to show a header as the first line of CSV output. 36 : 37 : static DsoService::Range lowestRange(const DsoService::Mode mode, 38 : const quint32 desiredMax); 39 : static DsoService::CurrentRange lowestCurrentRange(const quint32 desiredMax); 40 : static DsoService::VoltageRange lowestVoltageRange(const quint32 desiredMax); 41 : 42 : private slots: 43 : void settingsWritten(); 44 : void metadataRead(const DsoService::Metadata &data); 45 : void outputSamples(const DsoService::Samples &samples); 46 : 47 : friend class TestDsoCommand; 48 : };