Dokit
Internal development documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
pokitpro.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 * Defined the PokitPro helper functions.
7 */
8
9#include <qtpokit/pokitpro.h>
10
11#include <QCoreApplication>
12#include <QLoggingCategory>
13
15
16namespace PokitPro {
17
18static Q_LOGGING_CATEGORY(lc, "dokit.pokit.products.pro", QtInfoMsg); ///< Logging category for this file.
19
20namespace {
21 class Private
22 {
23 Q_DECLARE_TR_FUNCTIONS(PokitPro)
24 };
25}
26
27/*!
28 * \cond internal
29 * \enum CapacitanceRange
30 * \pokitApi These Pokit Pro enumeration values are as-yet undocumented by Pokit Innovations.
31 * [\@pcolby](https://github.com/pcolby) reverse-engineered them as part of the
32 * [dokit](https://github.com/pcolby/dokit) project.
33 * \endcond
34 */
35
36/// Returns \a range as a user-friendly string.
38{
39 switch (range) {
40 case CapacitanceRange::_100nF: return Private::tr("Up to 100nF");
41 case CapacitanceRange::_10uF: return Private::tr("Up to 10μF");
42 case CapacitanceRange::_1mF: return Private::tr("Up to 1mF");
43 case CapacitanceRange::AutoRange: return Private::tr("Auto-range");
44 default: return QString();
45 }
46}
47
48/*!
49 * Returns the maximum value for \a range in nanofarads, or 0 if \a range is not a known value for Pokit Pro devices.
50 */
51quint32 maxValue(const CapacitanceRange &range)
52{
53 switch (range) {
54 case CapacitanceRange::_100nF: return 100;
55 case CapacitanceRange::_10uF: return 10'000;
56 case CapacitanceRange::_1mF: return 1'000'000;
57 case CapacitanceRange::AutoRange: return 1'000'000;
58 default:
59 qCWarning(lc).noquote() << Private::tr("Unknown CapacitanceRange value: %1").arg((int)range);
60 return 0;
61 }
62}
63
64/*!
65 * \cond internal
66 * \enum CurrentRange
67 * \pokitApi These Pokit Pro enumeration values are as-yet undocumented by Pokit Innovations.
68 * [\@pcolby](https://github.com/pcolby) reverse-engineered them as part of the
69 * [dokit](https://github.com/pcolby/dokit) project.
70 * \endcond
71 */
72
73/// Returns \a range as a user-friendly string.
75{
76 switch (range) {
77 case CurrentRange::_500uA: return Private::tr("Up to 500μA");
78 case CurrentRange::_2mA: return Private::tr("Up to 2mA");
79 case CurrentRange::_10mA: return Private::tr("Up to 10mA");
80 case CurrentRange::_125mA: return Private::tr("Up to 125mA");
81 case CurrentRange::_300mA: return Private::tr("Up to 300mA");
82 case CurrentRange::_3A: return Private::tr("Up to 3A");
83 case CurrentRange::_10A: return Private::tr("Up to 10A");
84 case CurrentRange::AutoRange: return Private::tr("Auto-range");
85 default: return QString();
86 }
87}
88
89/*!
90 * Returns the maximum value for \a range in microamps, or 0 if \a range is not a known value for Pokit Pro devices.
91 */
92quint32 maxValue(const CurrentRange &range)
93{
94 switch (range) {
95 case CurrentRange::_500uA: return 500;
96 case CurrentRange::_2mA: return 2'000;
97 case CurrentRange::_10mA: return 10'000;
98 case CurrentRange::_125mA: return 125'000;
99 case CurrentRange::_300mA: return 300'000;
100 case CurrentRange::_3A: return 3'000'000;
101 case CurrentRange::_10A: return 10'000'000;
102 case CurrentRange::AutoRange: return 10'000'000;
103 default:
104 qCWarning(lc).noquote() << Private::tr("Unknown CurrentRange value: %1").arg((int)range);
105 return 0;
106 }
107}
108
109/*!
110 * \cond internal
111 * \enum ResistanceRange
112 * \pokitApi These Pokit Pro enumeration values are as-yet undocumented by Pokit Innovations.
113 * [\@pcolby](https://github.com/pcolby) reverse-engineered them as part of the
114 * [dokit](https://github.com/pcolby/dokit) project.
115 * \endcond
116 */
117
118/// Returns \a range as a user-friendly string.
120{
121 switch (range) {
122 case ResistanceRange::_30: return Private::tr("Up to 30Ω");
123 case ResistanceRange::_75: return Private::tr("Up to 75Ω");
124 case ResistanceRange::_400: return Private::tr("Up to 400Ω");
125 case ResistanceRange::_5K: return Private::tr("Up to 5KΩ");
126 case ResistanceRange::_10K: return Private::tr("Up to 10KΩ");
127 case ResistanceRange::_15K: return Private::tr("Up to 15KΩ");
128 case ResistanceRange::_40K: return Private::tr("Up to 40KΩ");
129 case ResistanceRange::_500K: return Private::tr("Up to 500KΩ");
130 case ResistanceRange::_700K: return Private::tr("Up to 700KΩ");
131 case ResistanceRange::_1M: return Private::tr("Up to 1MΩ");
132 case ResistanceRange::_3M: return Private::tr("Up to 3MΩ");
133 case ResistanceRange::AutoRange: return Private::tr("Auto-range");
134 default: return QString();
135 }
136}
137
138/*!
139 * Returns the maximum value for \a range in ohms, or 0 if \a range is not a known value for Pokit Pro devices.
140 */
141quint32 maxValue(const ResistanceRange &range)
142{
143 switch (range) {
144 case ResistanceRange::_30: return 30;
145 case ResistanceRange::_75: return 75;
146 case ResistanceRange::_400: return 400;
147 case ResistanceRange::_5K: return 5'000;
148 case ResistanceRange::_10K: return 10'000;
149 case ResistanceRange::_15K: return 15'000;
150 case ResistanceRange::_40K: return 40'000;
151 case ResistanceRange::_500K: return 500'000;
152 case ResistanceRange::_700K: return 700'000;
153 case ResistanceRange::_1M: return 1'000'000;
154 case ResistanceRange::_3M: return 3'000'000;
155 case ResistanceRange::AutoRange: return 3'000'000;
156 default:
157 qCWarning(lc).noquote() << Private::tr("Unknown ResistanceRange value: %1").arg((int)range);
158 return 0;
159 }
160}
161
162/*!
163 * \cond internal
164 * \enum VoltageRange
165 * \pokitApi These Pokit Pro enumeration values are as-yet undocumented by Pokit Innovations.
166 * [\@pcolby](https://github.com/pcolby) reverse-engineered them as part of the
167 * [dokit](https://github.com/pcolby/dokit) project.
168 * \endcond
169 */
170
171/// Returns \a range as a user-friendly string.
173{
174 switch (range) {
175 case VoltageRange::_250mV: return Private::tr("Up to 250mV");
176 case VoltageRange::_2V: return Private::tr("Up to 2V");
177 case VoltageRange::_10V: return Private::tr("Up to 10V");
178 case VoltageRange::_30V: return Private::tr("Up to 30V");
179 case VoltageRange::_60V: return Private::tr("Up to 60V");
180 case VoltageRange::_125V: return Private::tr("Up to 125V");
181 case VoltageRange::_400V: return Private::tr("Up to 400V");
182 case VoltageRange::_600V: return Private::tr("Up to 600V");
183 case VoltageRange::AutoRange: return Private::tr("Auto-range");
184 default: return QString();
185 }
186}
187
188/*!
189 * Returns the maximum value for \a range in millivolts, or 0 if \a range is not a known value for Pokit Pro devices.
190 */
191quint32 maxValue(const VoltageRange &range)
192{
193 switch (range) {
194 case VoltageRange::_250mV: return 250;
195 case VoltageRange::_2V: return 2'000;
196 case VoltageRange::_10V: return 10'000;
197 case VoltageRange::_30V: return 30'000;
198 case VoltageRange::_60V: return 60'000;
199 case VoltageRange::_125V: return 125'000;
200 case VoltageRange::_400V: return 400'000;
201 case VoltageRange::_600V: return 600'000;
202 case VoltageRange::AutoRange: return 600'000;
203 default:
204 qCWarning(lc).noquote() << Private::tr("Unknown VoltageRange value: %1").arg((int)range);
205 return 0;
206 }
207}
208
209}
210
Encapsulates convenience functions for working with capacitance ranges.
Encapsulates convenience functions for working with current ranges.
Encapsulates details specific to Pokit Pro devices.
Definition pokitpro.h:17
QTPOKIT_EXPORT QString toString(const CapacitanceRange &range)
Returns range as a user-friendly string.
Definition pokitpro.cpp:37
@ AutoRange
Auto-range.
Definition pokitpro.h:72
@ _250mV
Up to 250mV.
Definition pokitpro.h:64
@ _400V
Up to 400V.
Definition pokitpro.h:70
@ _600V
Up to 600V.
Definition pokitpro.h:71
@ _125V
Up to 125V.
Definition pokitpro.h:69
@ _500uA
Up to 5µA.
Definition pokitpro.h:32
@ AutoRange
Auto-range.
Definition pokitpro.h:39
@ _10mA
Up to 10mA.
Definition pokitpro.h:34
@ _300mA
Up to 300mA.
Definition pokitpro.h:36
@ _125mA
Up to 125mA.
Definition pokitpro.h:35
@ _500K
Up to 500KΩ.
Definition pokitpro.h:53
@ AutoRange
Auto-range.
Definition pokitpro.h:57
@ _700K
Up to 700KΩ.
Definition pokitpro.h:54
static Q_LOGGING_CATEGORY(lc, "dokit.pokit.products.pro", QtInfoMsg)
Logging category for this file.
QTPOKIT_EXPORT quint32 maxValue(const CapacitanceRange &range)
Returns the maximum value for range in nanofarads, or 0 if range is not a known value for Pokit Pro d...
Definition pokitpro.cpp:51
Encapsulates convenience functions for working with resistance ranges.
Encapsulates convenience functions for working with voltage ranges.
Declares the PokitPro namespace.
#define QTPOKIT_BEGIN_NAMESPACE
Macro for starting the QtPokit library's top-most namespace (if one is defined).
#define QTPOKIT_END_NAMESPACE
Macro for ending the QtPokit library's top-most namespace (if one is defined).