LCOV - code coverage report
Current view: top level - src/lib - pokitpro.cpp (source / functions) Coverage Total Hit
Project: Dokit Lines: 93.0 % 114 106
Version: Functions: 100.0 % 8 8

            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          988 : QString toString(const CapacitanceRange &range)
      26         1060 : {
      27         2048 :     switch (range) {
      28          492 :     case CapacitanceRange::_100nF:    return QCoreApplication::translate("PokitPro", "Up to 100nF", "CapacitanceRange");
      29          410 :     case CapacitanceRange::_10uF:     return QCoreApplication::translate("PokitPro", "Up to 10μF",  "CapacitanceRange");
      30          736 :     case CapacitanceRange::_1mF:      return QCoreApplication::translate("PokitPro", "Up to 1mF",   "CapacitanceRange");
      31          410 :     case CapacitanceRange::AutoRange: return QCoreApplication::translate("PokitPro", "Auto-range",  "CapacitanceRange");
      32            0 :     default:                          return QString();
      33         1060 :     }
      34         1060 : }
      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          950 : QVariant maxValue(const CapacitanceRange &range)
      41         1100 : {
      42         2050 :     switch (range) {
      43          820 :     case CapacitanceRange::_100nF:    return       100;
      44          574 :     case CapacitanceRange::_10uF:     return    10'000;
      45          574 :     case CapacitanceRange::_1mF:      return 1'000'000;
      46           97 :     case CapacitanceRange::AutoRange: return QCoreApplication::translate("PokitPro", "Auto", "CapacitanceRange");
      47            0 :     default:                          return QVariant();
      48         1100 :     }
      49         1100 : }
      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         1786 : QString toString(const CurrentRange &range)
      62         2068 : {
      63         3854 :     switch (range) {
      64          984 :     case CurrentRange::_500uA:    return QCoreApplication::translate("PokitPro", "Up to 500μA", "CurrentRange");
      65          410 :     case CurrentRange::_2mA:      return QCoreApplication::translate("PokitPro", "Up to 2mA",   "CurrentRange");
      66          410 :     case CurrentRange::_10mA:     return QCoreApplication::translate("PokitPro", "Up to 10mA",  "CurrentRange");
      67          410 :     case CurrentRange::_125mA:    return QCoreApplication::translate("PokitPro", "Up to 125mA", "CurrentRange");
      68          410 :     case CurrentRange::_300mA:    return QCoreApplication::translate("PokitPro", "Up to 300mA", "CurrentRange");
      69          410 :     case CurrentRange::_3A:       return QCoreApplication::translate("PokitPro", "Up to 3A",    "CurrentRange");
      70          410 :     case CurrentRange::_10A:      return QCoreApplication::translate("PokitPro", "Up to 10A",   "CurrentRange");
      71          410 :     case CurrentRange::AutoRange: return QCoreApplication::translate("PokitPro", "Auto-range",  "CurrentRange");
      72            0 :     default:                      return QString();
      73         2068 :     }
      74         2068 : }
      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         3116 : QVariant maxValue(const CurrentRange &range)
      81         3608 : {
      82         6724 :     switch (range) {
      83         1968 :     case CurrentRange::_500uA:    return        500;
      84         1230 :     case CurrentRange::_2mA:      return      2'000;
      85         1066 :     case CurrentRange::_10mA:     return     10'000;
      86          902 :     case CurrentRange::_125mA:    return    125'000;
      87          656 :     case CurrentRange::_300mA:    return    300'000;
      88          492 :     case CurrentRange::_3A:       return  3'000'000;
      89          328 :     case CurrentRange::_10A:      return 10'000'000;
      90           97 :     case CurrentRange::AutoRange: return QCoreApplication::translate("PokitPro", "Auto", "CurrentRange");
      91            0 :     default:                      return QVariant();
      92         3608 :     }
      93         3608 : }
      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         2394 : QString toString(const ResistanceRange &range)
     106         2772 : {
     107         5166 :     switch (range) {
     108          410 :     case ResistanceRange::_30:       return QCoreApplication::translate("PokitPro", "Up to 30Ω",   "ResistanceRange");
     109          410 :     case ResistanceRange::_75:       return QCoreApplication::translate("PokitPro", "Up to 75Ω",   "ResistanceRange");
     110          410 :     case ResistanceRange::_400:      return QCoreApplication::translate("PokitPro", "Up to 400Ω",  "ResistanceRange");
     111          410 :     case ResistanceRange::_5K:       return QCoreApplication::translate("PokitPro", "Up to 5KΩ",   "ResistanceRange");
     112          410 :     case ResistanceRange::_10K:      return QCoreApplication::translate("PokitPro", "Up to 10KΩ",  "ResistanceRange");
     113          410 :     case ResistanceRange::_15K:      return QCoreApplication::translate("PokitPro", "Up to 15KΩ",  "ResistanceRange");
     114          410 :     case ResistanceRange::_40K:      return QCoreApplication::translate("PokitPro", "Up to 40KΩ",  "ResistanceRange");
     115          410 :     case ResistanceRange::_500K:     return QCoreApplication::translate("PokitPro", "Up to 500KΩ", "ResistanceRange");
     116          410 :     case ResistanceRange::_700K:     return QCoreApplication::translate("PokitPro", "Up to 700KΩ", "ResistanceRange");
     117          410 :     case ResistanceRange::_1M:       return QCoreApplication::translate("PokitPro", "Up to 1MΩ",   "ResistanceRange");
     118          656 :     case ResistanceRange::_3M:       return QCoreApplication::translate("PokitPro", "Up to 3MΩ",   "ResistanceRange");
     119          410 :     case ResistanceRange::AutoRange: return QCoreApplication::translate("PokitPro", "Auto-range",  "ResistanceRange");
     120            0 :     default:                         return QString();
     121         2772 :     }
     122         2772 : }
     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         6308 : QVariant maxValue(const ResistanceRange &range)
     129         7304 : {
     130        13612 :     switch (range) {
     131         2050 :     case ResistanceRange::_30:       return        30;
     132         1886 :     case ResistanceRange::_75:       return        75;
     133         1722 :     case ResistanceRange::_400:      return       400;
     134         1558 :     case ResistanceRange::_5K:       return     5'000;
     135         1394 :     case ResistanceRange::_10K:      return    10'000;
     136         1230 :     case ResistanceRange::_15K:      return    15'000;
     137         1066 :     case ResistanceRange::_40K:      return    40'000;
     138          902 :     case ResistanceRange::_500K:     return   500'000;
     139          656 :     case ResistanceRange::_700K:     return   700'000;
     140          492 :     case ResistanceRange::_1M:       return 1'000'000;
     141          574 :     case ResistanceRange::_3M:       return 3'000'000;
     142           97 :     case ResistanceRange::AutoRange: return QCoreApplication::translate("PokitPro", "Auto", "ResistanceRange");
     143            0 :     default:                         return QVariant();
     144         7304 :     }
     145         7304 : }
     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         1976 : QString toString(const VoltageRange &range)
     158         2288 : {
     159         4264 :     switch (range) {
     160          410 :     case VoltageRange::_250mV:    return QCoreApplication::translate("PokitPro", "Up to 250mV", "VoltageRange");
     161          410 :     case VoltageRange::_2V:       return QCoreApplication::translate("PokitPro", "Up to 2V",    "VoltageRange");
     162          410 :     case VoltageRange::_10V:      return QCoreApplication::translate("PokitPro", "Up to 10V",   "VoltageRange");
     163          410 :     case VoltageRange::_30V:      return QCoreApplication::translate("PokitPro", "Up to 30V",   "VoltageRange");
     164          410 :     case VoltageRange::_60V:      return QCoreApplication::translate("PokitPro", "Up to 60V",   "VoltageRange");
     165          410 :     case VoltageRange::_125V:     return QCoreApplication::translate("PokitPro", "Up to 125V",  "VoltageRange");
     166          410 :     case VoltageRange::_400V:     return QCoreApplication::translate("PokitPro", "Up to 400V",  "VoltageRange");
     167          984 :     case VoltageRange::_600V:     return QCoreApplication::translate("PokitPro", "Up to 600V",  "VoltageRange");
     168          410 :     case VoltageRange::AutoRange: return QCoreApplication::translate("PokitPro", "Auto-range",  "VoltageRange");
     169            0 :     default:                      return QString();
     170         2288 :     }
     171         2288 : }
     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         3876 : QVariant maxValue(const VoltageRange &range)
     178         4488 : {
     179         8364 :     switch (range) {
     180         1558 :     case VoltageRange::_250mV:    return     250;
     181         1394 :     case VoltageRange::_2V:       return   2'000;
     182         1230 :     case VoltageRange::_10V:      return  10'000;
     183         1066 :     case VoltageRange::_30V:      return  30'000;
     184          902 :     case VoltageRange::_60V:      return  60'000;
     185          738 :     case VoltageRange::_125V:     return 125'000;
     186          492 :     case VoltageRange::_400V:     return 400'000;
     187          902 :     case VoltageRange::_600V:     return 600'000;
     188           97 :     case VoltageRange::AutoRange: return QCoreApplication::translate("PokitPro", "Auto", "VoltageRange");
     189            0 :     default:                      return QVariant();
     190         4488 :     }
     191         4488 : }
     192              : 
     193              : }
        

Generated by: LCOV version 2.0-1