Dokit
Internal development documentation
Loading...
Searching...
No Matches
DsoCommand Class Reference

The DsoCommand class implements the dso CLI command. More...

Inheritance diagram for DsoCommand:
[legend]
Collaboration diagram for DsoCommand:
[legend]

Public Slots

QStringList processOptions (const QCommandLineParser &parser) override
 Processes the relevant options from the command line parser.
 
- Public Slots inherited from DeviceCommand
bool start () override
 Begins scanning for the Pokit device.
 
- Public Slots inherited from AbstractCommand
virtual QStringList processOptions (const QCommandLineParser &parser)
 Processes the relevant options from the command line parser.
 
virtual bool start ()=0
 Begins the functionality of this command, and returns true if begun successfully, false otherwise.
 

Public Member Functions

 DsoCommand (QObject *const parent=nullptr)
 Construct a new DsoCommand object with parent.
 
QStringList requiredOptions (const QCommandLineParser &parser) const override
 Returns a list of CLI option names required by this command.
 
QStringList supportedOptions (const QCommandLineParser &parser) const override
 Returns a list of CLI option names supported by this command.
 
- Public Member Functions inherited from DeviceCommand
 DeviceCommand (QObject *const parent=nullptr)
 Construct a new DeviceCommand object with parent.
 
- Public Member Functions inherited from AbstractCommand
 AbstractCommand (QObject *const parent=nullptr)
 Constructs a new command with parent.
 
- Public Member Functions inherited from QObject
virtual const QMetaObjectmetaObject () const const
 
 QObject (QObject *parent)
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const const
 
void setObjectName (const QString &name)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
bool signalsBlocked () const const
 
bool blockSignals (bool block)
 
QThreadthread () const const
 
void moveToThread (QThread *targetThread)
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
void killTimer (int id)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
const QObjectListchildren () const const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectTree ()
 
void dumpObjectInfo ()
 
void dumpObjectTree () const const
 
void dumpObjectInfo () const const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const const
 
QList< QByteArraydynamicPropertyNames () const const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
bool inherits (const char *className) const const
 
void deleteLater ()
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
qobject_cast (QObject *object)
 
qobject_cast (const QObject *object)
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
 Q_CLASSINFO (Name, Value)
 
 Q_INTERFACES (...)
 
 Q_PROPERTY (...)
 
 Q_ENUMS (...)
 
 Q_FLAGS (...)
 
 Q_ENUM (...)
 
 Q_FLAG (...)
 
 Q_ENUM_NS (...)
 
 Q_FLAG_NS (...)
 
 Q_OBJECT Q_OBJECT
 
 Q_GADGET Q_GADGET
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SLOTS Q_SLOTS
 
 Q_SLOT Q_SLOT
 
 Q_EMIT Q_EMIT
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 

Protected Slots

void serviceDetailsDiscovered () override
 Handles service detail discovery events.
 
- Protected Slots inherited from DeviceCommand
virtual void controllerError (const QLowEnergyController::Error error)
 Handles controller error events.
 
virtual void deviceDisconnected ()
 Handles devics disconnection events.
 
virtual void serviceError (const QLowEnergyService::ServiceError error)
 Handles service error events.
 
virtual void serviceDetailsDiscovered ()
 Handles service detail discovery events.
 
- Protected Slots inherited from AbstractCommand
virtual void deviceDiscovered (const QBluetoothDeviceInfo &info)=0
 Handles PokitDiscoveryAgent::pokitDeviceDiscovered signal.
 
virtual void deviceDiscoveryFinished ()=0
 Handles PokitDiscoveryAgent::deviceDiscoveryFinished signal.
 

Protected Member Functions

AbstractPokitServicegetService () override
 Returns a Pokit service object for the derived command class.
 
- Protected Member Functions inherited from DeviceCommand
void disconnect (int exitCode=EXIT_SUCCESS)
 Disconnects the underlying Pokit device, and sets exitCode to be return to the OS once the disconnection has taken place.
 
- Protected Member Functions inherited from QObject
QObjectsender () const const
 
int senderSignalIndex () const const
 
int receivers (const char *signal) const const
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 

Private Slots

void settingsWritten ()
 Invoked when the DSO settings have been written.
 
void metadataRead (const DsoService::Metadata &data)
 Invoked when metadata has been received from the DSO.
 
void outputSamples (const DsoService::Samples &samples)
 Outputs DSO samples in the selected ouput format.
 

Private Attributes

quint8(* minRangeFunc )(const PokitProduct product, const quint32 maxValue)
 Pointer to function for converting rangeOptionValue to a Pokit device's range enumerator.
 
quint32 rangeOptionValue { 0 }
 The parsed value of range option.
 
DsoServiceservice { nullptr }
 Bluetooth service this command interracts with.
 
DsoService::Settings settings
 Settings for the Pokit device's DSO mode.
 
DsoService::Metadata metadata
 Most recent DSO metadata.
 
qint32 samplesToGo { 0 }
 Number of samples we're expecting in the current window.
 
bool showCsvHeader { true }
 Whether or not to show a header as the first line of CSV output.
 

Friends

class TestDsoCommand
 

Additional Inherited Members

- Public Types inherited from AbstractCommand
enum class  OutputFormat { Csv , Json , Text }
 Supported output formats. More...
 
- Static Public Member Functions inherited from AbstractCommand
static QString escapeCsvField (const QString &field)
 Returns an RFC 4180 compliant version of field.
 
template<typename R >
static quint32 parseNumber (const QString &value, const QString &unit, const quint32 sensibleMinimum=0)
 Returns value as an integer multiple of the ratio R.
 
- Static Public Member Functions inherited from QObject
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- Static Protected Member Functions inherited from DeviceCommand
template<typename T >
static T minRange (const quint32 maxValue)
 
static quint8 minCapacitanceRange (const PokitProduct product, const quint32 maxValue)
 Returns the product's lowest capacitance range that can measure at least up to maxValue (nF), or AutoRange if no such range is available.
 
static quint8 minCurrentRange (const PokitProduct product, const quint32 maxValue)
 Returns the product's lowest current range that can measure at least up to maxValue (µA), or AutoRange if no such range is available.
 
static quint8 minResistanceRange (const PokitProduct product, const quint32 maxValue)
 Returns the product's lowest resistance range that can measure at least up to maxValue (Ω), or AutoRange if no such range is available.
 
static quint8 minVoltageRange (const PokitProduct product, const quint32 maxValue)
 t Returns the product's lowest voltage range that can measure at least up to maxValue (mV), or AutoRange if no such range is available.
 
- Static Protected Member Functions inherited from AbstractCommand
static Q_LOGGING_CATEGORY (lc, "dokit.cli.command", QtInfoMsg)
 Logging category for UI commands.
 
- Protected Attributes inherited from DeviceCommand
PokitDevicedevice { nullptr }
 Pokit Bluetooth device (if any) this command interracts with.
 
int exitCodeOnDisconnect { EXIT_FAILURE }
 Exit code to return on device disconnection.
 
- Protected Attributes inherited from AbstractCommand
QString deviceToScanFor
 Device (if any) that were passed to processOptions().
 
PokitDiscoveryAgentdiscoveryAgent
 Agent for Pokit device descovery.
 
OutputFormat format { OutputFormat::Text }
 Selected output format.
 
- Properties inherited from QObject
 objectName
 

Detailed Description

The DsoCommand class implements the dso CLI command.

Definition at line 10 of file dsocommand.h.

Constructor & Destructor Documentation

◆ DsoCommand()

DsoCommand::DsoCommand ( QObject *const parent = nullptr)
explicit

Construct a new DsoCommand object with parent.

Definition at line 22 of file dsocommand.cpp.

23{
24
25}
DeviceCommand(QObject *const parent=nullptr)
Construct a new DeviceCommand object with parent.
QObject * parent() const const

Member Function Documentation

◆ getService()

AbstractPokitService * DsoCommand::getService ( )
overrideprotectedvirtual

Returns a Pokit service object for the derived command class.

This override returns a pointer to a DsoService object.

Implements DeviceCommand.

Definition at line 169 of file dsocommand.cpp.

170{
171 Q_ASSERT(device);
172 if (!service) {
173 service = device->dso();
174 Q_ASSERT(service);
177 }
178 return service;
179}
PokitDevice * device
Pokit Bluetooth device (if any) this command interracts with.
DsoService * service
Bluetooth service this command interracts with.
Definition dsocommand.h:32
void settingsWritten()
Invoked when the DSO settings have been written.
void settingsWritten()
This signal is emitted when the Settings characteristic has been written successfully.
DsoService * dso()
Returns a pointer to DsoService instance that uses this device's controller for access.
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)

References QObject::connect(), DeviceCommand::device, PokitDevice::dso(), service, settingsWritten(), and DsoService::settingsWritten().

Here is the call graph for this function:

◆ metadataRead

void DsoCommand::metadataRead ( const DsoService::Metadata & data)
privateslot

Invoked when metadata has been received from the DSO.

Definition at line 227 of file dsocommand.cpp.

228{
229 qCDebug(lc) << "status:" << (int)(data.status);
230 qCDebug(lc) << "scale:" << data.scale;
231 qCDebug(lc) << "mode:" << DsoService::toString(data.mode);
232 qCDebug(lc) << "range:" << service->toString(data.range, data.mode);
233 qCDebug(lc) << "samplingWindow:" << (int)data.samplingWindow;
234 qCDebug(lc) << "numberOfSamples:" << data.numberOfSamples;
235 qCDebug(lc) << "samplingRate:" << data.samplingRate << "Hz";
236 this->metadata = data;
237 this->samplesToGo = data.numberOfSamples;
238}
qint32 samplesToGo
Number of samples we're expecting in the current window.
Definition dsocommand.h:38
DsoService::Metadata metadata
Most recent DSO metadata.
Definition dsocommand.h:37
static QString toString(const Mode &mode)
Returns mode as a user-friendly string.
quint32 samplingRate
Sampling rate used during last acquisition (1 to 1MHz).
Definition dsoservice.h:91
DsoStatus status
Current DSO status.
Definition dsoservice.h:85
float scale
Scale to apply to read samples.
Definition dsoservice.h:86
quint16 numberOfSamples
Number of samples acquired (1 to 8192).
Definition dsoservice.h:90
quint8 range
Range used during last acquisition.
Definition dsoservice.h:88
Mode mode
Operation mode used during last acquisition.
Definition dsoservice.h:87
quint32 samplingWindow
Sampling window (microseconds) used during last acquisition.
Definition dsoservice.h:89

References metadata, DsoService::Metadata::mode, DsoService::Metadata::numberOfSamples, DsoService::Metadata::range, samplesToGo, DsoService::Metadata::samplingRate, DsoService::Metadata::samplingWindow, DsoService::Metadata::scale, service, DsoService::Metadata::status, and DsoService::toString().

Referenced by settingsWritten().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ outputSamples

void DsoCommand::outputSamples ( const DsoService::Samples & samples)
privateslot

Outputs DSO samples in the selected ouput format.

Definition at line 243 of file dsocommand.cpp.

244{
245 QString unit;
246 switch (metadata.mode) {
247 case DsoService::Mode::DcVoltage: unit = QLatin1String("Vdc"); break;
248 case DsoService::Mode::AcVoltage: unit = QLatin1String("Vac"); break;
249 case DsoService::Mode::DcCurrent: unit = QLatin1String("Adc"); break;
250 case DsoService::Mode::AcCurrent: unit = QLatin1String("Aac"); break;
251 default:
252 qCDebug(lc).noquote() << tr(R"(No known unit for mode %1 "%2".)").arg((int)metadata.mode)
254 }
256
257 for (const qint16 &sample: samples) {
258 static int sampleNumber = 0; ++sampleNumber;
259 const float value = sample * metadata.scale;
260 switch (format) {
262 for (; showCsvHeader; showCsvHeader = false) {
263 std::cout << qUtf8Printable(tr("sample_number,value,unit,range\n"));
264 }
265 std::cout << qUtf8Printable(QString::fromLatin1("%1,%2,%3,%4\n")
266 .arg(sampleNumber).arg(value).arg(unit, range));
267 break;
269 std::cout << QJsonDocument(QJsonObject{
270 { QLatin1String("value"), value },
271 { QLatin1String("unit"), unit },
272 { QLatin1String("range"), range },
274 }).toJson().toStdString();
275 break;
277 std::cout << qUtf8Printable(tr("%1 %2 %3\n").arg(sampleNumber).arg(value).arg(unit));
278 break;
279 }
280 --samplesToGo;
281 }
282 if (samplesToGo <= 0) {
283 qCInfo(lc).noquote() << tr("Finished fetching %Ln sample/s (with %L2 to remaining).",
285 if (device) disconnect(); // Will exit the application once disconnected.
286 }
287}
OutputFormat format
Selected output format.
@ Text
Plain unstructured text.
@ Csv
RFC 4180 compliant CSV text.
@ Json
RFC 8259 compliant JSON text.
void disconnect(int exitCode=EXIT_SUCCESS)
Disconnects the underlying Pokit device, and sets exitCode to be return to the OS once the disconnect...
bool showCsvHeader
Whether or not to show a header as the first line of CSV output.
Definition dsocommand.h:39
@ DcVoltage
Measure DC voltage.
@ AcCurrent
Measure AC current.
@ AcVoltage
Measure AC voltage.
@ DcCurrent
Measure DC current.
QString tr(const char *sourceText, const char *disambiguation, int n)
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
QString fromLatin1(const char *str, int size)

References DsoService::AcCurrent, DsoService::AcVoltage, QString::arg(), AbstractCommand::Csv, DsoService::DcCurrent, DsoService::DcVoltage, DeviceCommand::device, DeviceCommand::disconnect(), AbstractCommand::format, QString::fromLatin1(), AbstractCommand::Json, metadata, DsoService::Metadata::mode, DsoService::Metadata::numberOfSamples, DsoService::Metadata::range, samplesToGo, DsoService::Metadata::scale, service, showCsvHeader, AbstractCommand::Text, DsoService::toString(), and QObject::tr().

Referenced by settingsWritten().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processOptions

QStringList DsoCommand::processOptions ( const QCommandLineParser & parser)
overrideslot

Processes the relevant options from the command line parser.

This implementation extends DeviceCommand::processOptions to process additional CLI options supported (or required) by this command.

Definition at line 51 of file dsocommand.cpp.

52{
54 if (!errors.isEmpty()) {
55 return errors;
56 }
57
58 // Parse the (required) mode option.
59 if (const QString mode = parser.value(QLatin1String("mode")).trimmed().toLower();
60 mode.startsWith(QLatin1String("ac v")) || mode.startsWith(QLatin1String("vac"))) {
62 } else if (mode.startsWith(QLatin1String("dc v")) || mode.startsWith(QLatin1String("vdc"))) {
64 } else if (mode.startsWith(QLatin1String("ac c")) || mode.startsWith(QLatin1String("aac"))) {
66 } else if (mode.startsWith(QLatin1String("dc c")) || mode.startsWith(QLatin1String("adc"))) {
68 } else {
69 errors.append(tr("Unknown DSO mode: %1").arg(parser.value(QLatin1String("mode"))));
70 return errors;
71 }
72
73 // Parse the (required) range option.
74 QString unit;
75 {
76 const QString value = parser.value(QLatin1String("range"));
77 quint32 sensibleMinimum = 0;
78 switch (settings.mode) {
80 Q_ASSERT(false); // Not possible, since the mode parsing above never allows Idle.
81 break;
85 unit = QLatin1String("V");
86 sensibleMinimum = 50; // mV.
87 break;
91 unit = QLatin1String("A");
92 sensibleMinimum = 5; // mA.
93 break;
94 }
95 Q_ASSERT(!unit.isEmpty());
96 rangeOptionValue = parseNumber<std::milli>(value, unit, sensibleMinimum);
97 if (rangeOptionValue == 0) {
98 errors.append(tr("Invalid range value: %1").arg(value));
99 }
100 }
101
102 // Parse the trigger-level option.
103 if (parser.isSet(QLatin1String("trigger-level"))) {
104 const QString value = parser.value(QLatin1String("trigger-level"));
105 const quint32 level = parseNumber<std::micro>(value, unit);
106 if (level == 0) {
107 errors.append(tr("Invalid trigger-level value: %1").arg(value));
108 } else {
109 settings.triggerLevel = (float)(level/1'000'000.0);
110 }
111 }
112
113 // Parse the trigger-mode option.
114 if (parser.isSet(QLatin1String("trigger-mode"))) {
115 const QString triggerMode = parser.value(QLatin1String("trigger-mode")).trimmed().toLower();
116 if (triggerMode.startsWith(QLatin1String("free"))) {
118 } else if (triggerMode.startsWith(QLatin1String("ris"))) {
120 } else if (triggerMode.startsWith(QLatin1String("fall"))) {
122 } else {
123 errors.append(tr("Unknown trigger mode: %1").arg(
124 parser.value(QLatin1String("trigger-mode"))));
125 }
126 }
127
128 // Ensure that if either trigger option is present, then both are.
129 if (parser.isSet(QLatin1String("trigger-level")) !=
130 parser.isSet(QLatin1String("trigger-mode"))) {
131 errors.append(tr("If either option is provided, then both must be: trigger-level, trigger-mode"));
132 }
133
134 // Parse the interval option.
135 if (parser.isSet(QLatin1String("interval"))) {
136 const QString value = parser.value(QLatin1String("interval"));
137 const quint32 interval = parseNumber<std::micro>(value, QLatin1String("s"), 500'000);
138 if (interval == 0) {
139 errors.append(tr("Invalid interval value: %1").arg(value));
140 } else {
141 settings.samplingWindow = interval;
142 }
143 }
144
145 // Parse the samples option.
146 if (parser.isSet(QLatin1String("samples"))) {
147 const QString value = parser.value(QLatin1String("samples"));
148 const quint32 samples = parseNumber<std::ratio<1>>(value, QLatin1String("S"));
149 if (samples == 0) {
150 errors.append(tr("Invalid samples value: %1").arg(value));
151 } else if (samples > std::numeric_limits<quint16>::max()) {
152 errors.append(tr("Samples value (%1) must be no greater than %2")
153 .arg(value).arg(std::numeric_limits<quint16>::max()));
154 } else {
155 if (samples > 8192) {
156 qCWarning(lc).noquote() << tr("Pokit devices do not officially support great than 8192 samples");
157 }
158 settings.numberOfSamples = (quint16)samples;
159 }
160 }
161 return errors;
162}
static quint32 parseNumber(const QString &value, const QString &unit, const quint32 sensibleMinimum=0)
Returns value as an integer multiple of the ratio R.
virtual QStringList processOptions(const QCommandLineParser &parser)
Processes the relevant options from the command line parser.
static quint8 minVoltageRange(const PokitProduct product, const quint32 maxValue)
t Returns the product's lowest voltage range that can measure at least up to maxValue (mV),...
static quint8 minCurrentRange(const PokitProduct product, const quint32 maxValue)
Returns the product's lowest current range that can measure at least up to maxValue (µA),...
DsoService::Settings settings
Settings for the Pokit device's DSO mode.
Definition dsocommand.h:33
quint8(* minRangeFunc)(const PokitProduct product, const quint32 maxValue)
Pointer to function for converting rangeOptionValue to a Pokit device's range enumerator.
Definition dsocommand.h:30
quint32 rangeOptionValue
The parsed value of range option.
Definition dsocommand.h:31
@ Idle
Make device idle.
@ FreeRunning
Run free, without waiting for edge triggers.
@ RisingEdgeTrigger
Trigger on a rising edge.
@ FallingEdgeTrigger
Trigger on a falling edge.
bool isSet(const QString &name) const const
QString value(const QString &optionName) const const
void append(const T &value)
bool isEmpty() const const
bool isEmpty() const const
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const const
QString toLower() const const
Mode mode
Desired operation mode.
Definition dsoservice.h:70
Command command
Custom operation request.
Definition dsoservice.h:68
quint32 samplingWindow
Desired sampling window in microseconds.
Definition dsoservice.h:72
float triggerLevel
Trigger threshold level in Volts or Amps, depending on mode.
Definition dsoservice.h:69
quint16 numberOfSamples
Desired number of samples to acquire.
Definition dsoservice.h:73

References DsoService::AcCurrent, DsoService::AcVoltage, QList::append(), QString::arg(), DsoService::Settings::command, DsoService::DcCurrent, DsoService::DcVoltage, DsoService::FallingEdgeTrigger, DsoService::FreeRunning, DsoService::Idle, QList::isEmpty(), QString::isEmpty(), QCommandLineParser::isSet(), DeviceCommand::minCurrentRange(), minRangeFunc, DeviceCommand::minVoltageRange(), DsoService::Settings::mode, DsoService::Settings::numberOfSamples, AbstractCommand::parseNumber(), AbstractCommand::processOptions(), rangeOptionValue, DsoService::RisingEdgeTrigger, DsoService::Settings::samplingWindow, settings, QString::startsWith(), QString::toLower(), QObject::tr(), DsoService::Settings::triggerLevel, and QCommandLineParser::value().

Here is the call graph for this function:

◆ requiredOptions()

QStringList DsoCommand::requiredOptions ( const QCommandLineParser & parser) const
overridevirtual

Returns a list of CLI option names required by this command.

The main console appication may use this list to output an eror (and exit) if any of the returned names are not found in the parsed CLI options.

The (already parsed) parser may be used adjust the returned required options depending on the value of other options. For example, the logger command only requires the --mode option if the --command option is start.

This base implementation simply returns an empty list. Derived classes should override this function to include any required options.

Reimplemented from AbstractCommand.

Definition at line 27 of file dsocommand.cpp.

28{
30 QLatin1String("mode"),
31 QLatin1String("range"),
32 };
33}
virtual QStringList requiredOptions(const QCommandLineParser &parser) const
Returns a list of CLI option names required by this command.

References AbstractCommand::requiredOptions().

Here is the call graph for this function:

◆ serviceDetailsDiscovered

void DsoCommand::serviceDetailsDiscovered ( )
overrideprotectedslot

Handles service detail discovery events.

This override fetches the current device's status, and outputs it in the selected format.

Definition at line 186 of file dsocommand.cpp.

187{
188 DeviceCommand::serviceDetailsDiscovered(); // Just logs consistently.
191 qCInfo(lc).noquote() << tr("Sampling %1, with range %2, %Ln sample/s over %L3us", nullptr, settings.numberOfSamples)
192 .arg(DsoService::toString(settings.mode), (range.isNull()) ? QString::fromLatin1("N/A") : range)
193 .arg(settings.samplingWindow);
195}
virtual void serviceDetailsDiscovered()
Handles service detail discovery events.
bool setSettings(const Settings &settings)
Configures the Pokit device's DSO mode.
QTPOKIT_EXPORT PokitProduct pokitProduct(const QBluetoothDeviceInfo &info)
Returns the PokitProduct corresponding the Bluetotoh device info.
bool isNull() const const
quint8 range
Desired range, eg settings.range = +PokitPro::CurrentRange::AutoRange;.
Definition dsoservice.h:71

References QString::arg(), QString::fromLatin1(), QString::isNull(), minRangeFunc, DsoService::Settings::mode, DsoService::Settings::numberOfSamples, AbstractPokitService::pokitProduct(), DsoService::Settings::range, rangeOptionValue, DsoService::Settings::samplingWindow, service, DeviceCommand::serviceDetailsDiscovered(), DsoService::setSettings(), settings, DsoService::toString(), and QObject::tr().

Here is the call graph for this function:

◆ settingsWritten

void DsoCommand::settingsWritten ( )
privateslot

Invoked when the DSO settings have been written.

Definition at line 214 of file dsocommand.cpp.

215{
216 Q_ASSERT(service);
217 qCDebug(lc).noquote() << tr("Settings written; DSO has started.");
222}
void outputSamples(const DsoService::Samples &samples)
Outputs DSO samples in the selected ouput format.
void metadataRead(const DsoService::Metadata &data)
Invoked when metadata has been received from the DSO.
void metadataRead(const DsoService::Metadata &meta)
This signal is emitted when the Metadata characteristic has been read successfully.
bool enableMetadataNotifications()
Enables client-side notifications of DSO metadata changes.
bool enableReadingNotifications()
Enables client-side notifications of DSO readings.
void samplesRead(const DsoService::Samples &samples)
This signal is emitted when the Reading characteristic has been notified.

References QObject::connect(), DsoService::enableMetadataNotifications(), DsoService::enableReadingNotifications(), metadataRead(), DsoService::metadataRead(), outputSamples(), DsoService::samplesRead(), service, and QObject::tr().

Referenced by getService().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ supportedOptions()

QStringList DsoCommand::supportedOptions ( const QCommandLineParser & parser) const
overridevirtual

Returns a list of CLI option names supported by this command.

The main console appication may use this list to output a warning for any parsed CLI options not included in the returned list.

The (already parsed) parser may be used adjust the returned supported options depending on the value of other options. For example, the logger command only supported the --timestamp option if the --command option is start.

This base implementation simply returns requiredOptions(). Derived classes should override this function to include optional options, such as:

QStringList Derived::supportedOptions(const QCommandLineParser &parser) const
{
list.sort();
list.removeDuplicates(); // Optional, recommended.
return list;
}
virtual QStringList supportedOptions(const QCommandLineParser &parser) const
Returns a list of CLI option names supported by this command.
int removeDuplicates()
void sort(Qt::CaseSensitivity cs)

Reimplemented from AbstractCommand.

Definition at line 35 of file dsocommand.cpp.

36{
38 QLatin1String("interval"),
39 QLatin1String("samples"),
40 QLatin1String("trigger-level"),
41 QLatin1String("trigger-mode"),
42 };
43}

References AbstractCommand::supportedOptions().

Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ TestDsoCommand

friend class TestDsoCommand
friend

Definition at line 46 of file dsocommand.h.

Member Data Documentation

◆ metadata

DsoService::Metadata DsoCommand::metadata
private

Most recent DSO metadata.

Definition at line 37 of file dsocommand.h.

Referenced by metadataRead(), and outputSamples().

◆ minRangeFunc

quint8(* DsoCommand::minRangeFunc) (const PokitProduct product, const quint32 maxValue)
inlineprivate

Pointer to function for converting rangeOptionValue to a Pokit device's range enumerator.

This function pointer is assigned during the command line parsing, but is not invoked until after the device's services are discovere, because prior to that discovery, we don't know which product (Meter vs Pro vs Clamp, etc) we're talking to and thus which enumerator list to be using.

If the current mode does not support ranges (eg diode, and continuity modes), then this member will be nullptr.

See also
processOptions
serviceDetailsDiscovered

Definition at line 30 of file dsocommand.h.

30{ nullptr };

Referenced by processOptions(), and serviceDetailsDiscovered().

◆ rangeOptionValue

quint32 DsoCommand::rangeOptionValue { 0 }
private

The parsed value of range option.

Definition at line 31 of file dsocommand.h.

31{ 0 }; ///< The parsed value of range option.

Referenced by processOptions(), and serviceDetailsDiscovered().

◆ samplesToGo

qint32 DsoCommand::samplesToGo { 0 }
private

Number of samples we're expecting in the current window.

Definition at line 38 of file dsocommand.h.

38{ 0 }; ///< Number of samples we're expecting in the current window.

Referenced by metadataRead(), and outputSamples().

◆ service

DsoService* DsoCommand::service { nullptr }
private

Bluetooth service this command interracts with.

Definition at line 32 of file dsocommand.h.

32{ nullptr }; ///< Bluetooth service this command interracts with.

Referenced by getService(), metadataRead(), outputSamples(), serviceDetailsDiscovered(), and settingsWritten().

◆ settings

DsoService::Settings DsoCommand::settings
private
Initial value:

Settings for the Pokit device's DSO mode.

Definition at line 33 of file dsocommand.h.

33 { ///< Settings for the Pokit device's DSO mode.
36 };

Referenced by processOptions(), and serviceDetailsDiscovered().

◆ showCsvHeader

bool DsoCommand::showCsvHeader { true }
private

Whether or not to show a header as the first line of CSV output.

Definition at line 39 of file dsocommand.h.

39{ true }; ///< Whether or not to show a header as the first line of CSV output.

Referenced by outputSamples().


The documentation for this class was generated from the following files: