Dokit
Internal development documentation
Loading...
Searching...
No Matches
pokitmeter.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2022-2025 Paul Colby <git@colby.id.au>
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
4/*!
5 * \file
6 * Declares the PokitMeter namespace.
7 */
8
10
11#include <QCoreApplication>
12#include <QLoggingCategory>
13
14namespace PokitMeter {
15
16static Q_LOGGING_CATEGORY(lc, "dokit.pokit.products.meter", QtInfoMsg); ///< Logging category for this file.
17
18namespace {
19 class Private
20 {
21 Q_DECLARE_TR_FUNCTIONS(PokitMeter)
22 };
23}
24
25/// Returns \a range as a user-friendly string.
27{
28 switch (range) {
29 case CurrentRange::_10mA: return Private::tr("Up to 10mA");
30 case CurrentRange::_30mA: return Private::tr("Up to 30mA");
31 case CurrentRange::_150mA: return Private::tr("Up to 150mA");
32 case CurrentRange::_300mA: return Private::tr("Up to 300mA");
33 case CurrentRange::_2A: return Private::tr("Up to 2A");
34 case CurrentRange::AutoRange: return Private::tr("Auto-range");
35 default: return QString();
36 }
37}
38
39/*!
40 * Returns the maximum value for \a range in microamps, or 0 if \a range is not a known value for Pokit Meter devices.
41 */
42quint32 maxValue(const CurrentRange &range)
43{
44 switch (range) {
45 case CurrentRange::_10mA: return 10'000;
46 case CurrentRange::_30mA: return 30'000;
47 case CurrentRange::_150mA: return 150'000;
48 case CurrentRange::_300mA: return 300'000;
49 case CurrentRange::_2A: return 2'000'000;
50 case CurrentRange::AutoRange: return 2'000'000;
51 default:
52 qCWarning(lc).noquote() << Private::tr("Unknown CurrentRange value: %1").arg((int)range);
53 return 0;
54 }
55}
56
57/// Returns \a range as a user-friendly string.
59{
60 switch (range) {
61 case ResistanceRange::_160: return Private::tr("Up to 160Ω");
62 case ResistanceRange::_330: return Private::tr("Up to 330Ω");
63 case ResistanceRange::_890: return Private::tr("Up to 890Ω");
64 case ResistanceRange::_1K5: return Private::tr("Up to 1.5KΩ");
65 case ResistanceRange::_10K: return Private::tr("Up to 10KΩ");
66 case ResistanceRange::_100K: return Private::tr("Up to 100KΩ");
67 case ResistanceRange::_470K: return Private::tr("Up to 470KΩ");
68 case ResistanceRange::_1M: return Private::tr("Up to 1MΩ");
69 case ResistanceRange::AutoRange: return Private::tr("Auto-range");
70 default: return QString();
71 }
72}
73
74/*!
75 * Returns the maximum value for \a range in ohms, or 0 if \a range is not a known value for Pokit Meter devices.
76 */
77quint32 maxValue(const ResistanceRange &range)
78{
79 switch (range) {
80 case ResistanceRange::_160: return 160;
81 case ResistanceRange::_330: return 330;
82 case ResistanceRange::_890: return 890;
83 case ResistanceRange::_1K5: return 1'500;
84 case ResistanceRange::_10K: return 10'000;
85 case ResistanceRange::_100K: return 100'000;
86 case ResistanceRange::_470K: return 470'000;
87 case ResistanceRange::_1M: return 1'000'000;
88 case ResistanceRange::AutoRange: return 1'000'000;
89 default:
90 qCWarning(lc).noquote() << Private::tr("Unknown ResistanceRange value: %1").arg((int)range);
91 return 0;
92 }
93}
94
95/// Returns \a range as a user-friendly string.
97{
98 switch (range) {
99 case VoltageRange::_300mV: return Private::tr("Up to 300mV");
100 case VoltageRange::_2V: return Private::tr("Up to 2V");
101 case VoltageRange::_6V: return Private::tr("Up to 6V");
102 case VoltageRange::_12V: return Private::tr("Up to 12V");
103 case VoltageRange::_30V: return Private::tr("Up to 30V");
104 case VoltageRange::_60V: return Private::tr("Up to 60V");
105 case VoltageRange::AutoRange: return Private::tr("Auto-range");
106 default: return QString();
107 }
108}
109
110/*!
111 * Returns the maximum value for \a range in millivolts, or 0 if \a range is not a known value for Pokit Meter devices.
112 */
113quint32 maxValue(const VoltageRange &range)
114{
115 switch (range) {
116 case VoltageRange::_300mV: return 300;
117 case VoltageRange::_2V: return 2'000;
118 case VoltageRange::_6V: return 6'000;
119 case VoltageRange::_12V: return 12'000;
120 case VoltageRange::_30V: return 30'000;
121 case VoltageRange::_60V: return 60'000;
122 case VoltageRange::AutoRange: return 60'000;
123 default:
124 qCWarning(lc).noquote() << Private::tr("Unknown VoltageRange value: %1").arg((int)range);
125 return 0;
126 }
127}
128
129}
Encapsulates convenience functions for working with current ranges.
Encapsulates details specific to Pokit Meter devices.
Definition pokitmeter.h:17
QTPOKIT_EXPORT QString toString(const CurrentRange &range)
Returns range as a user-friendly string.
@ _60V
Up to 60V DC (42V AC).
Definition pokitmeter.h:53
static Q_LOGGING_CATEGORY(lc, "dokit.pokit.products.meter", QtInfoMsg)
Logging category for this file.
QTPOKIT_EXPORT quint32 maxValue(const CurrentRange &range)
Returns the maximum value for range in microamps, or 0 if range is not a known value for Pokit Meter ...
Encapsulates convenience functions for working with resistance ranges.
Encapsulates convenience functions for working with voltage ranges.
Declares the PokitMeter namespace.