Line data Source code
1 : // SPDX-FileCopyrightText: 2022-2026 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 : #include <qtpokit/pokitmeter.h>
8 : #include <qtpokit/pokitpro.h>
9 :
10 7140 : class DsoCommand : public DeviceCommand
11 : {
12 11830 : Q_OBJECT
13 :
14 : public:
15 : explicit DsoCommand(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 : static quint16 maxWindowSize(const PokitProduct product);
26 : static bool configureWindow(const PokitProduct product, const quint32 sampleRate, DsoService::Settings &settings);
27 :
28 : protected slots:
29 : void serviceDetailsDiscovered() override;
30 :
31 : private:
32 : quint8 (* minRangeFunc)(const PokitProduct product, const quint32 maxValue) { nullptr };
33 : quint32 rangeOptionValue { 0 }; ///< The parsed value of range option.
34 : quint32 sampleRateValue { 0 }; ///< The parsed value of the sample-rate option.
35 : quint32 samplesValue { 0 }; ///< The parsed value of the samples option.
36 : DsoService * service { nullptr }; ///< Bluetooth service this command interacts with.
37 : DsoService::Settings settings { ///< Settings for the Pokit device's DSO mode.
38 : DsoService::Command::FreeRunning, 0.0f, DsoService::Mode::DcVoltage,
39 : +PokitMeter::VoltageRange::AutoRange, 0, 0
40 : };
41 : DsoService::Metadata metadata; ///< Most recent DSO metadata.
42 : qint32 samplesToGo { 0 }; ///< Number of samples we're expecting in the current window.
43 : bool showCsvHeader { true }; ///< Whether or not to show a header as the first line of CSV output.
44 :
45 : private slots:
46 : void settingsWritten();
47 : void metadataRead(const DsoService::Metadata &data);
48 : void outputSamples(const DsoService::Samples &samples);
49 :
50 : QTPOKIT_BEFRIEND_TEST(DsoCommand)
51 : };
|