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