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