Dokit
Internal development documentation
Loading...
Searching...
No Matches
pokitproducts.cpp File Reference

Defines the PokitProduct helper functions. More...

#include <qtpokit/pokitmeter.h>
#include <qtpokit/pokitpro.h>
#include <qtpokit/pokitproducts.h>
#include <qtpokit/statusservice.h>
#include "pokitproducts_p.h"
#include <QCoreApplication>
#include <QLoggingCategory>
Include dependency graph for pokitproducts.cpp:

Go to the source code of this file.

Namespaces

namespace  CapacitanceRange
 Encapsulates convenience functions for working with capacitance ranges.
 
namespace  CurrentRange
 Encapsulates convenience functions for working with current ranges.
 
namespace  ResistanceRange
 Encapsulates convenience functions for working with resistance ranges.
 
namespace  VoltageRange
 Encapsulates convenience functions for working with voltage ranges.
 

Functions

static Q_LOGGING_CATEGORY (lc, "dokit.pokit.products", QtInfoMsg)
 Logging category for this file.
 
QTPOKIT_BEGIN_NAMESPACE QString toString (const PokitProduct product)
 Returns product as user-friendly string.
 
bool isPokitProduct (const QBluetoothDeviceInfo &info)
 Returns true if info describes a Pokit device.
 
PokitProduct pokitProduct (const QBluetoothDeviceInfo &info)
 Returns the PokitProduct corresponding the Bluetotoh device info.
 
bool isPokitProduct (const QList< QBluetoothUuid > &serviceUuids)
 Returns true if serviceUuids contains a known Pokit Status service UUID.
 
bool isPokitProduct (const QLowEnergyController &controller)
 Returns true if controller describes a Pokit device.
 
PokitProduct pokitProduct (const QList< QBluetoothUuid > &serviceUuids)
 Returns the PokitProduct corresponding to the Bluetooth serviceUuids.
 
PokitProduct pokitProduct (const QLowEnergyController &controller)
 Returns the PokitProduct corresponding to the Bluetooth controller.
 
QString CapacitanceRange::toString (const PokitProduct product, const quint8 range)
 Returns product's capacitance range as a human-friendly string.
 
QVariant CapacitanceRange::maxValue (const PokitProduct product, const quint8 range)
 Returns the maximum value for product's range in (integer) nanofarads, or the string "Auto".
 
QString CurrentRange::toString (const PokitProduct product, const quint8 range)
 Returns product's current range as a human-friendly string.
 
QVariant CurrentRange::maxValue (const PokitProduct product, const quint8 range)
 Returns the maximum value for product's range in (integer) microamps, or the string "Auto".
 
QString ResistanceRange::toString (const PokitProduct product, const quint8 range)
 Returns product's current range as a human-friendly string.
 
QVariant ResistanceRange::maxValue (const PokitProduct product, const quint8 range)
 Returns the maximum value for product's range in (integer) ohms, or the string "Auto".
 
QString VoltageRange::toString (const PokitProduct product, const quint8 range)
 Returns product's current range as a human-friendly string.
 
QVariant VoltageRange::maxValue (const PokitProduct product, const quint8 range)
 Returns the maximum value for product's range in (integer) millivolts, or the string "Auto".
 

Detailed Description

Defines the PokitProduct helper functions.

Definition in file pokitproducts.cpp.

Function Documentation

◆ isPokitProduct() [1/3]

bool isPokitProduct ( const QBluetoothDeviceInfo & info)

Returns true if info describes a Pokit device.

Currently, this is based on whether or not info's service UUIDs includes a known Pokit Status service, but this test criteria might be swapped for something else sometime.

Definition at line 43 of file pokitproducts.cpp.

44{
45 return isPokitProduct(info.serviceUuids());
46}
bool isPokitProduct(const QBluetoothDeviceInfo &info)
Returns true if info describes a Pokit device.
QList< QBluetoothUuid > serviceUuids(QBluetoothDeviceInfo::DataCompleteness *completeness) const const

References isPokitProduct(), and QBluetoothDeviceInfo::serviceUuids().

Referenced by PokitDiscoveryAgentPrivate::deviceDiscovered(), DeviceCommand::deviceDiscovered(), PokitDiscoveryAgentPrivate::deviceUpdated(), isPokitProduct(), and isPokitProduct().

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

◆ isPokitProduct() [2/3]

bool isPokitProduct ( const QList< QBluetoothUuid > & serviceUuids)

Returns true if serviceUuids contains a known Pokit Status service UUID.

Currently, this is the only known way to detect a Pokit device.

Definition at line 67 of file pokitproducts.cpp.

68{
71}
bool contains(const T &value) const const
static const QBluetoothUuid pokitPro
UUID of the Pokit Pro's Pokit Status service.
static const QBluetoothUuid pokitMeter
UUID of the Pokit Meter's Pokit Status service.

References QList::contains(), StatusService::ServiceUuids::pokitMeter, and StatusService::ServiceUuids::pokitPro.

Here is the call graph for this function:

◆ isPokitProduct() [3/3]

bool isPokitProduct ( const QLowEnergyController & controller)

Returns true if controller describes a Pokit device.

Currently, this is based on whether or not controller's service UUIDs includes a known Pokit Status service, but this test criteria might be swapped for something else sometime.

See also
isPokitProduct

Definition at line 82 of file pokitproducts.cpp.

83{
84 return isPokitProduct(controller.services());
85}
QList< QBluetoothUuid > services() const const

References isPokitProduct(), and QLowEnergyController::services().

Here is the call graph for this function:

◆ pokitProduct() [1/3]

PokitProduct pokitProduct ( const QBluetoothDeviceInfo & info)

Returns the PokitProduct corresponding the Bluetotoh device info.

If info is not a Pokit device, then result is undefined.

See also
isPokitProduct

Definition at line 55 of file pokitproducts.cpp.

56{
57 return pokitProduct(info.serviceUuids());
58}
PokitProduct pokitProduct(const QBluetoothDeviceInfo &info)
Returns the PokitProduct corresponding the Bluetotoh device info.

References pokitProduct(), and QBluetoothDeviceInfo::serviceUuids().

Referenced by DeviceCommand::deviceDiscovered(), pokitProduct(), and pokitProduct().

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

◆ pokitProduct() [2/3]

PokitProduct pokitProduct ( const QList< QBluetoothUuid > & serviceUuids)

Returns the PokitProduct corresponding to the Bluetooth serviceUuids.

Currently, this is based on whether or not servceUuids includes a known Pokit Status service, but this test criteria might be swapped for something else sometime.

See also
isPokitProduct

Definition at line 95 of file pokitproducts.cpp.

96{
99 } else if (serviceUuids.contains(StatusService::ServiceUuids::pokitPro)) {
101 } else {
102 qCWarning(lc).noquote()
103 << QCoreApplication::translate("PokitProducts", "Device is not a Pokit product", "pokitProduct");
104 qCDebug(lc).noquote() << "Service UUIDs:" << serviceUuids;
105 return PokitProduct::PokitMeter; // Need to fallback to something; Pokit Meter is just the lowest product.
106 }
107}
@ PokitPro
Pokit Pro.
@ PokitMeter
Pokit Meter.
QString translate(const char *context, const char *sourceText, const char *disambiguation, int n)

References QList::contains(), PokitMeter, StatusService::ServiceUuids::pokitMeter, PokitPro, StatusService::ServiceUuids::pokitPro, and QCoreApplication::translate().

Here is the call graph for this function:

◆ pokitProduct() [3/3]

PokitProduct pokitProduct ( const QLowEnergyController & controller)

Returns the PokitProduct corresponding to the Bluetooth controller.

Currently, this is based on whether or not controller's service UUIDs includes a known Pokit Status service, but this test criteria might be swapped for something else sometime.

See also
isPokitProduct

Definition at line 117 of file pokitproducts.cpp.

118{
119 return pokitProduct(controller.services());
120}

References pokitProduct(), and QLowEnergyController::services().

Here is the call graph for this function:

◆ toString()

QTPOKIT_BEGIN_NAMESPACE QString toString ( const PokitProduct product)

Returns product as user-friendly string.

Definition at line 26 of file pokitproducts.cpp.

27{
28 switch (product) {
29 case PokitProduct::PokitMeter: return QStringLiteral("Pokit Meter");
30 case PokitProduct::PokitPro: return QStringLiteral("Pokit Pro");
31 }
32 qCWarning(lc).noquote() << QCoreApplication::translate("PokitProducts",
33 "Unknown PokitProduct value: %1", "toString").arg((int)product);
34 return QString();
35}
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const

References QString::arg(), PokitMeter, PokitPro, and QCoreApplication::translate().

Referenced by AbstractPokitServicePrivate::createServiceObject(), and DeviceCommand::deviceDiscovered().

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