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 180 : QString toString(const CapacitanceRange &range)
26 : {
27 180 : switch (range) {
28 36 : case CapacitanceRange::_100nF: return QCoreApplication::translate("PokitPro", "Up to 100nF", "CapacitanceRange");
29 18 : case CapacitanceRange::_10uF: return QCoreApplication::translate("PokitPro", "Up to 10μF", "CapacitanceRange");
30 108 : case CapacitanceRange::_1mF: return QCoreApplication::translate("PokitPro", "Up to 1mF", "CapacitanceRange");
31 18 : 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 126 : QVariant maxValue(const CapacitanceRange &range)
41 : {
42 126 : switch (range) {
43 36 : case CapacitanceRange::_100nF: return 100;
44 18 : case CapacitanceRange::_10uF: return 10'000;
45 54 : case CapacitanceRange::_1mF: return 1'000'000;
46 22 : 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 270 : QString toString(const CurrentRange &range)
62 : {
63 270 : switch (range) {
64 144 : case CurrentRange::_500uA: return QCoreApplication::translate("PokitPro", "Up to 500μA", "CurrentRange");
65 18 : case CurrentRange::_2mA: return QCoreApplication::translate("PokitPro", "Up to 2mA", "CurrentRange");
66 18 : case CurrentRange::_10mA: return QCoreApplication::translate("PokitPro", "Up to 10mA", "CurrentRange");
67 18 : case CurrentRange::_125mA: return QCoreApplication::translate("PokitPro", "Up to 125mA", "CurrentRange");
68 18 : case CurrentRange::_300mA: return QCoreApplication::translate("PokitPro", "Up to 300mA", "CurrentRange");
69 18 : case CurrentRange::_3A: return QCoreApplication::translate("PokitPro", "Up to 3A", "CurrentRange");
70 18 : case CurrentRange::_10A: return QCoreApplication::translate("PokitPro", "Up to 10A", "CurrentRange");
71 18 : 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 270 : QVariant maxValue(const CurrentRange &range)
81 : {
82 270 : switch (range) {
83 144 : case CurrentRange::_500uA: return 500;
84 18 : case CurrentRange::_2mA: return 2'000;
85 18 : case CurrentRange::_10mA: return 10'000;
86 18 : case CurrentRange::_125mA: return 125'000;
87 18 : case CurrentRange::_300mA: return 300'000;
88 18 : case CurrentRange::_3A: return 3'000'000;
89 18 : case CurrentRange::_10A: return 10'000'000;
90 22 : 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 270 : QString toString(const ResistanceRange &range)
106 : {
107 270 : switch (range) {
108 18 : case ResistanceRange::_30: return QCoreApplication::translate("PokitPro", "Up to 30Ω", "ResistanceRange");
109 18 : case ResistanceRange::_75: return QCoreApplication::translate("PokitPro", "Up to 75Ω", "ResistanceRange");
110 18 : case ResistanceRange::_400: return QCoreApplication::translate("PokitPro", "Up to 400Ω", "ResistanceRange");
111 18 : case ResistanceRange::_5K: return QCoreApplication::translate("PokitPro", "Up to 5KΩ", "ResistanceRange");
112 18 : case ResistanceRange::_10K: return QCoreApplication::translate("PokitPro", "Up to 10KΩ", "ResistanceRange");
113 18 : case ResistanceRange::_15K: return QCoreApplication::translate("PokitPro", "Up to 15KΩ", "ResistanceRange");
114 18 : case ResistanceRange::_40K: return QCoreApplication::translate("PokitPro", "Up to 40KΩ", "ResistanceRange");
115 18 : case ResistanceRange::_500K: return QCoreApplication::translate("PokitPro", "Up to 500KΩ", "ResistanceRange");
116 18 : case ResistanceRange::_700K: return QCoreApplication::translate("PokitPro", "Up to 700KΩ", "ResistanceRange");
117 18 : case ResistanceRange::_1M: return QCoreApplication::translate("PokitPro", "Up to 1MΩ", "ResistanceRange");
118 72 : case ResistanceRange::_3M: return QCoreApplication::translate("PokitPro", "Up to 3MΩ", "ResistanceRange");
119 18 : 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 270 : QVariant maxValue(const ResistanceRange &range)
129 : {
130 270 : switch (range) {
131 18 : case ResistanceRange::_30: return 30;
132 18 : case ResistanceRange::_75: return 75;
133 18 : case ResistanceRange::_400: return 400;
134 18 : case ResistanceRange::_5K: return 5'000;
135 18 : case ResistanceRange::_10K: return 10'000;
136 18 : case ResistanceRange::_15K: return 15'000;
137 18 : case ResistanceRange::_40K: return 40'000;
138 18 : case ResistanceRange::_500K: return 500'000;
139 18 : case ResistanceRange::_700K: return 700'000;
140 18 : case ResistanceRange::_1M: return 1'000'000;
141 72 : case ResistanceRange::_3M: return 3'000'000;
142 22 : 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 288 : QString toString(const VoltageRange &range)
158 : {
159 288 : switch (range) {
160 18 : case VoltageRange::_250mV: return QCoreApplication::translate("PokitPro", "Up to 250mV", "VoltageRange");
161 18 : case VoltageRange::_2V: return QCoreApplication::translate("PokitPro", "Up to 2V", "VoltageRange");
162 18 : case VoltageRange::_10V: return QCoreApplication::translate("PokitPro", "Up to 10V", "VoltageRange");
163 18 : case VoltageRange::_30V: return QCoreApplication::translate("PokitPro", "Up to 30V", "VoltageRange");
164 18 : case VoltageRange::_60V: return QCoreApplication::translate("PokitPro", "Up to 60V", "VoltageRange");
165 18 : case VoltageRange::_125V: return QCoreApplication::translate("PokitPro", "Up to 125V", "VoltageRange");
166 18 : case VoltageRange::_400V: return QCoreApplication::translate("PokitPro", "Up to 400V", "VoltageRange");
167 144 : case VoltageRange::_600V: return QCoreApplication::translate("PokitPro", "Up to 600V", "VoltageRange");
168 18 : 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 288 : QVariant maxValue(const VoltageRange &range)
178 : {
179 288 : switch (range) {
180 18 : case VoltageRange::_250mV: return 250;
181 18 : case VoltageRange::_2V: return 2'000;
182 18 : case VoltageRange::_10V: return 10'000;
183 18 : case VoltageRange::_30V: return 30'000;
184 18 : case VoltageRange::_60V: return 60'000;
185 18 : case VoltageRange::_125V: return 125'000;
186 18 : case VoltageRange::_400V: return 400'000;
187 144 : case VoltageRange::_600V: return 600'000;
188 22 : case VoltageRange::AutoRange: return QCoreApplication::translate("PokitPro", "Auto", "VoltageRange");
189 : default: return QVariant();
190 : }
191 : }
192 :
193 : }
|