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