Line data Source code
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 :
14 : namespace PokitPro {
15 :
16 0 : static Q_LOGGING_CATEGORY(lc, "dokit.pokit.products.pro", QtInfoMsg); ///< Logging category for this file.
17 :
18 : namespace {
19 : class Private
20 : {
21 0 : 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.
35 1040 : QString toString(const CapacitanceRange &range)
36 1132 : {
37 2172 : switch (range) {
38 522 : case CapacitanceRange::_100nF: return Private::tr("Up to 100nF");
39 435 : case CapacitanceRange::_10uF: return Private::tr("Up to 10μF");
40 780 : case CapacitanceRange::_1mF: return Private::tr("Up to 1mF");
41 435 : case CapacitanceRange::AutoRange: return Private::tr("Auto-range");
42 0 : default: return QString();
43 1132 : }
44 1132 : }
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 : */
49 1000 : quint32 maxValue(const CapacitanceRange &range)
50 1175 : {
51 2175 : switch (range) {
52 470 : case CapacitanceRange::_100nF: return 100;
53 609 : case CapacitanceRange::_10uF: return 10'000;
54 329 : case CapacitanceRange::_1mF: return 1'000'000;
55 47 : case CapacitanceRange::AutoRange: return 1'000'000;
56 0 : default:
57 0 : qCWarning(lc).noquote() << Private::tr("Unknown CapacitanceRange value: %1").arg((int)range);
58 0 : return 0;
59 1175 : }
60 1175 : }
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.
72 1880 : QString toString(const CurrentRange &range)
73 2209 : {
74 4089 : switch (range) {
75 1044 : case CurrentRange::_500uA: return Private::tr("Up to 500μA");
76 435 : case CurrentRange::_2mA: return Private::tr("Up to 2mA");
77 435 : case CurrentRange::_10mA: return Private::tr("Up to 10mA");
78 435 : case CurrentRange::_125mA: return Private::tr("Up to 125mA");
79 435 : case CurrentRange::_300mA: return Private::tr("Up to 300mA");
80 435 : case CurrentRange::_3A: return Private::tr("Up to 3A");
81 435 : case CurrentRange::_10A: return Private::tr("Up to 10A");
82 435 : case CurrentRange::AutoRange: return Private::tr("Auto-range");
83 0 : default: return QString();
84 2209 : }
85 2209 : }
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 : */
90 3280 : quint32 maxValue(const CurrentRange &range)
91 3854 : {
92 7134 : switch (range) {
93 1128 : case CurrentRange::_500uA: return 500;
94 1305 : case CurrentRange::_2mA: return 2'000;
95 1131 : case CurrentRange::_10mA: return 10'000;
96 957 : case CurrentRange::_125mA: return 125'000;
97 696 : case CurrentRange::_300mA: return 300'000;
98 522 : case CurrentRange::_3A: return 3'000'000;
99 188 : case CurrentRange::_10A: return 10'000'000;
100 47 : case CurrentRange::AutoRange: return 10'000'000;
101 0 : default:
102 0 : qCWarning(lc).noquote() << Private::tr("Unknown CurrentRange value: %1").arg((int)range);
103 0 : return 0;
104 3854 : }
105 3854 : }
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.
117 2520 : QString toString(const ResistanceRange &range)
118 2961 : {
119 5481 : switch (range) {
120 435 : case ResistanceRange::_30: return Private::tr("Up to 30Ω");
121 435 : case ResistanceRange::_75: return Private::tr("Up to 75Ω");
122 435 : case ResistanceRange::_400: return Private::tr("Up to 400Ω");
123 435 : case ResistanceRange::_5K: return Private::tr("Up to 5KΩ");
124 435 : case ResistanceRange::_10K: return Private::tr("Up to 10KΩ");
125 435 : case ResistanceRange::_15K: return Private::tr("Up to 15KΩ");
126 435 : case ResistanceRange::_40K: return Private::tr("Up to 40KΩ");
127 435 : case ResistanceRange::_500K: return Private::tr("Up to 500KΩ");
128 435 : case ResistanceRange::_700K: return Private::tr("Up to 700KΩ");
129 435 : case ResistanceRange::_1M: return Private::tr("Up to 1MΩ");
130 696 : case ResistanceRange::_3M: return Private::tr("Up to 3MΩ");
131 435 : case ResistanceRange::AutoRange: return Private::tr("Auto-range");
132 0 : default: return QString();
133 2961 : }
134 2961 : }
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 : */
139 6640 : quint32 maxValue(const ResistanceRange &range)
140 7802 : {
141 14442 : switch (range) {
142 1175 : case ResistanceRange::_30: return 30;
143 2001 : case ResistanceRange::_75: return 75;
144 1827 : case ResistanceRange::_400: return 400;
145 1653 : case ResistanceRange::_5K: return 5'000;
146 1479 : case ResistanceRange::_10K: return 10'000;
147 1305 : case ResistanceRange::_15K: return 15'000;
148 1131 : case ResistanceRange::_40K: return 40'000;
149 957 : case ResistanceRange::_500K: return 500'000;
150 696 : case ResistanceRange::_700K: return 700'000;
151 522 : case ResistanceRange::_1M: return 1'000'000;
152 329 : case ResistanceRange::_3M: return 3'000'000;
153 47 : case ResistanceRange::AutoRange: return 3'000'000;
154 0 : default:
155 0 : qCWarning(lc).noquote() << Private::tr("Unknown ResistanceRange value: %1").arg((int)range);
156 0 : return 0;
157 7802 : }
158 7802 : }
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.
170 2080 : QString toString(const VoltageRange &range)
171 2444 : {
172 4524 : switch (range) {
173 435 : case VoltageRange::_250mV: return Private::tr("Up to 250mV");
174 435 : case VoltageRange::_2V: return Private::tr("Up to 2V");
175 435 : case VoltageRange::_10V: return Private::tr("Up to 10V");
176 435 : case VoltageRange::_30V: return Private::tr("Up to 30V");
177 435 : case VoltageRange::_60V: return Private::tr("Up to 60V");
178 435 : case VoltageRange::_125V: return Private::tr("Up to 125V");
179 435 : case VoltageRange::_400V: return Private::tr("Up to 400V");
180 1044 : case VoltageRange::_600V: return Private::tr("Up to 600V");
181 435 : case VoltageRange::AutoRange: return Private::tr("Auto-range");
182 0 : default: return QString();
183 2444 : }
184 2444 : }
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 : */
189 4080 : quint32 maxValue(const VoltageRange &range)
190 4794 : {
191 8874 : switch (range) {
192 893 : case VoltageRange::_250mV: return 250;
193 1479 : case VoltageRange::_2V: return 2'000;
194 1305 : case VoltageRange::_10V: return 10'000;
195 1131 : case VoltageRange::_30V: return 30'000;
196 957 : case VoltageRange::_60V: return 60'000;
197 783 : case VoltageRange::_125V: return 125'000;
198 522 : case VoltageRange::_400V: return 400'000;
199 517 : case VoltageRange::_600V: return 600'000;
200 47 : case VoltageRange::AutoRange: return 600'000;
201 0 : default:
202 0 : qCWarning(lc).noquote() << Private::tr("Unknown VoltageRange value: %1").arg((int)range);
203 0 : return 0;
204 4794 : }
205 4794 : }
206 :
207 : }
|