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

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

Generated by: LCOV version 2.2-1