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