Dokit
Internal development documentation
Loading...
Searching...
No Matches
pokitmeter.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2022-2024 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
13namespace PokitMeter {
14
15namespace {
16 class Private
17 {
18 Q_DECLARE_TR_FUNCTIONS(PokitMeter)
19 };
20}
21
22/// Returns \a range as a user-friendly string.
24{
25 switch (range) {
26 case CurrentRange::_10mA: return Private::tr("Up to 10mA");
27 case CurrentRange::_30mA: return Private::tr("Up to 30mA");
28 case CurrentRange::_150mA: return Private::tr("Up to 150mA");
29 case CurrentRange::_300mA: return Private::tr("Up to 300mA");
30 case CurrentRange::_2A: return Private::tr("Up to 2A");
31 case CurrentRange::AutoRange: return Private::tr("Auto-range");
32 default: return QString();
33 }
34}
35
36/*!
37 * Returns the maximum value for \a range in (integer) microamps, or the string "Auto".
38 * If \a range is not a known valid value, then an null QVariant is returned.
39 */
41{
42 switch (range) {
43 case CurrentRange::_10mA: return 10'000;
44 case CurrentRange::_30mA: return 30'000;
45 case CurrentRange::_150mA: return 150'000;
46 case CurrentRange::_300mA: return 300'000;
47 case CurrentRange::_2A: return 2'000'000;
48 case CurrentRange::AutoRange: return Private::tr("Auto");
49 default: return QVariant();
50 }
51}
52
53/// Returns \a range as a user-friendly string.
55{
56 switch (range) {
57 case ResistanceRange::_160: return Private::tr("Up to 160Ω");
58 case ResistanceRange::_330: return Private::tr("Up to 330Ω");
59 case ResistanceRange::_890: return Private::tr("Up to 890Ω");
60 case ResistanceRange::_1K5: return Private::tr("Up to 1.5KΩ");
61 case ResistanceRange::_10K: return Private::tr("Up to 10KΩ");
62 case ResistanceRange::_100K: return Private::tr("Up to 100KΩ");
63 case ResistanceRange::_470K: return Private::tr("Up to 470KΩ");
64 case ResistanceRange::_1M: return Private::tr("Up to 1MΩ");
65 case ResistanceRange::AutoRange: return Private::tr("Auto-range");
66 default: return QString();
67 }
68}
69
70/*!
71 * Returns the maximum value for \a range in (integer) ohms, or the string "Auto".
72 * If \a range is not a known valid value, then an null QVariant is returned.
73 */
75{
76 switch (range) {
77 case ResistanceRange::_160: return 160;
78 case ResistanceRange::_330: return 330;
79 case ResistanceRange::_890: return 890;
80 case ResistanceRange::_1K5: return 1'500;
81 case ResistanceRange::_10K: return 10'000;
82 case ResistanceRange::_100K: return 100'000;
83 case ResistanceRange::_470K: return 470'000;
84 case ResistanceRange::_1M: return 1'000'000;
85 case ResistanceRange::AutoRange: return Private::tr("Auto");
86 default: return QVariant();
87 }
88}
89
90/// Returns \a range as a user-friendly string.
92{
93 switch (range) {
94 case VoltageRange::_300mV: return Private::tr("Up to 300mV");
95 case VoltageRange::_2V: return Private::tr("Up to 2V");
96 case VoltageRange::_6V: return Private::tr("Up to 6V");
97 case VoltageRange::_12V: return Private::tr("Up to 12V");
98 case VoltageRange::_30V: return Private::tr("Up to 30V");
99 case VoltageRange::_60V: return Private::tr("Up to 60V");
100 case VoltageRange::AutoRange: return Private::tr("Auto-range");
101 default: return QString();
102 }
103}
104
105/*!
106 * Returns the maximum value for \a range in (integer) millivolts, or the string "Auto".
107 * If \a range is not a known valid value, then an null QVariant is returned.
108 */
110{
111 switch (range) {
112 case VoltageRange::_300mV: return 300;
113 case VoltageRange::_2V: return 2'000;
114 case VoltageRange::_6V: return 6'000;
115 case VoltageRange::_12V: return 12'000;
116 case VoltageRange::_30V: return 30'000;
117 case VoltageRange::_60V: return 60'000;
118 case VoltageRange::AutoRange: return Private::tr("Auto");
119 default: return QVariant();
120 }
121}
122
123}
Encapsulates convenience functions for working with current ranges.
Encapsulates details specific to Pokit Meter devices.
Definition pokitmeter.h:19
QTPOKIT_EXPORT QString toString(const CurrentRange &range)
Returns range as a user-friendly string.
QTPOKIT_EXPORT QVariant maxValue(const CurrentRange &range)
Returns the maximum value for range in (integer) microamps, or the string "Auto".
@ _60V
Up to 60V DC (42V AC).
Encapsulates convenience functions for working with resistance ranges.
Encapsulates convenience functions for working with voltage ranges.
Declares the PokitMeter namespace.