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

          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             :  * \enum CapacitanceRange
      17             :  * \brief Values supported by the Pokit Pro's `Range` attributes in `Capacitance` mode.
      18             :  *
      19             :  * \cond internal
      20             :  * \pokitApi These Pokit Pro enumeration values are as-yet undocumented by Pokit Innovations.
      21             :  * [\@pcolby](https://github.com/pcolby) reverse-engineered them as part of the
      22             :  * [dokit](https://github.com/pcolby/dokit) project.
      23             :  * \endcond
      24             :  */
      25             : 
      26             : /// Returns \a range as a user-friendly string.
      27         180 : QString toString(const CapacitanceRange &range)
      28             : {
      29         180 :     switch (range) {
      30          36 :     case CapacitanceRange::_100nF:    return QCoreApplication::translate("PokitPro", "Up to 100nF", "CapacitanceRange");
      31          18 :     case CapacitanceRange::_10uF:     return QCoreApplication::translate("PokitPro", "Up to 10μF",  "CapacitanceRange");
      32         108 :     case CapacitanceRange::_1mF:      return QCoreApplication::translate("PokitPro", "Up to 1mF",   "CapacitanceRange");
      33          18 :     case CapacitanceRange::AutoRange: return QCoreApplication::translate("PokitPro", "Auto-range",  "CapacitanceRange");
      34             :     default:                          return QString();
      35             :     }
      36             : }
      37             : 
      38             : /*!
      39             :  *  Returns the maximum value for \a range in (integer) nanofarads, or the string "Auto".
      40             :  *  If \a range is not a known valid value, then an null QVariant is returned.
      41             :  */
      42         126 : QVariant maxValue(const CapacitanceRange &range)
      43             : {
      44         126 :     switch (range) {
      45          36 :     case CapacitanceRange::_100nF:    return     100;
      46          18 :     case CapacitanceRange::_10uF:     return   10000;
      47          54 :     case CapacitanceRange::_1mF:      return 1000000;
      48          22 :     case CapacitanceRange::AutoRange: return QCoreApplication::translate("PokitPro", "Auto", "CapacitanceRange");
      49             :     default:                          return QVariant();
      50             :     }
      51             : }
      52             : 
      53             : /*!
      54             :  * \enum CurrentRange
      55             :  * \brief Values supported by the Pokit Pro's `Range` attributes in `*Current` modes.
      56             :  *
      57             :  * \cond internal
      58             :  * \pokitApi These Pokit Pro enumeration values are as-yet undocumented by Pokit Innovations.
      59             :  * [\@pcolby](https://github.com/pcolby) reverse-engineered them as part of the
      60             :  * [dokit](https://github.com/pcolby/dokit) project.
      61             :  * \endcond
      62             :  */
      63             : 
      64             : /// Returns \a range as a user-friendly string.
      65         270 : QString toString(const CurrentRange &range)
      66             : {
      67         270 :     switch (range) {
      68         144 :     case CurrentRange::_500uA:    return QCoreApplication::translate("PokitPro", "Up to 500μA", "CurrentRange");
      69          18 :     case CurrentRange::_2mA:      return QCoreApplication::translate("PokitPro", "Up to 2mA",   "CurrentRange");
      70          18 :     case CurrentRange::_10mA:     return QCoreApplication::translate("PokitPro", "Up to 10mA",  "CurrentRange");
      71          18 :     case CurrentRange::_125mA:    return QCoreApplication::translate("PokitPro", "Up to 125mA", "CurrentRange");
      72          18 :     case CurrentRange::_300mA:    return QCoreApplication::translate("PokitPro", "Up to 300mA", "CurrentRange");
      73          18 :     case CurrentRange::_3A:       return QCoreApplication::translate("PokitPro", "Up to 3A",    "CurrentRange");
      74          18 :     case CurrentRange::_10A:      return QCoreApplication::translate("PokitPro", "Up to 10A",   "CurrentRange");
      75          18 :     case CurrentRange::AutoRange: return QCoreApplication::translate("PokitPro", "Auto-range",  "CurrentRange");
      76             :     default:                      return QString();
      77             :     }
      78             : }
      79             : 
      80             : /*!
      81             :  *  Returns the maximum value for \a range in (integer) microamps, or the string "Auto".
      82             :  *  If \a range is not a known valid value, then an null QVariant is returned.
      83             :  */
      84         270 : QVariant maxValue(const CurrentRange &range)
      85             : {
      86         270 :     switch (range) {
      87         144 :     case CurrentRange::_500uA:    return      500;
      88          18 :     case CurrentRange::_2mA:      return     2000;
      89          18 :     case CurrentRange::_10mA:     return    10000;
      90          18 :     case CurrentRange::_125mA:    return   125000;
      91          18 :     case CurrentRange::_300mA:    return   300000;
      92          18 :     case CurrentRange::_3A:       return  3000000;
      93          18 :     case CurrentRange::_10A:      return 10000000;
      94          22 :     case CurrentRange::AutoRange: return QCoreApplication::translate("PokitPro", "Auto", "CurrentRange");
      95             :     default:                      return QVariant();
      96             :     }
      97             : }
      98             : 
      99             : /*!
     100             :  * \enum ResistanceRange
     101             :  * \brief Values supported by the Pokit Pro's `Range` attributes in `Resistance` mode.
     102             :  *
     103             :  * \cond internal
     104             :  * \pokitApi These Pokit Pro enumeration values are as-yet undocumented by Pokit Innovations.
     105             :  * [\@pcolby](https://github.com/pcolby) reverse-engineered them as part of the
     106             :  * [dokit](https://github.com/pcolby/dokit) project.
     107             :  * \endcond
     108             :  */
     109             : 
     110             : /// Returns \a range as a user-friendly string.
     111         270 : QString toString(const ResistanceRange &range)
     112             : {
     113         270 :     switch (range) {
     114          18 :     case ResistanceRange::_30:       return QCoreApplication::translate("PokitPro", "Up to 30Ω",   "ResistanceRange");
     115          18 :     case ResistanceRange::_75:       return QCoreApplication::translate("PokitPro", "Up to 75Ω",   "ResistanceRange");
     116          18 :     case ResistanceRange::_400:      return QCoreApplication::translate("PokitPro", "Up to 400Ω",  "ResistanceRange");
     117          18 :     case ResistanceRange::_5K:       return QCoreApplication::translate("PokitPro", "Up to 5KΩ",   "ResistanceRange");
     118          18 :     case ResistanceRange::_10K:      return QCoreApplication::translate("PokitPro", "Up to 10KΩ",  "ResistanceRange");
     119          18 :     case ResistanceRange::_15K:      return QCoreApplication::translate("PokitPro", "Up to 15KΩ",  "ResistanceRange");
     120          18 :     case ResistanceRange::_40K:      return QCoreApplication::translate("PokitPro", "Up to 40KΩ",  "ResistanceRange");
     121          18 :     case ResistanceRange::_500K:     return QCoreApplication::translate("PokitPro", "Up to 500KΩ", "ResistanceRange");
     122          18 :     case ResistanceRange::_700K:     return QCoreApplication::translate("PokitPro", "Up to 700KΩ", "ResistanceRange");
     123          18 :     case ResistanceRange::_1M:       return QCoreApplication::translate("PokitPro", "Up to 1MΩ",   "ResistanceRange");
     124          72 :     case ResistanceRange::_3M:       return QCoreApplication::translate("PokitPro", "Up to 3MΩ",   "ResistanceRange");
     125          18 :     case ResistanceRange::AutoRange: return QCoreApplication::translate("PokitPro", "Auto-range",  "ResistanceRange");
     126             :     default:                         return QString();
     127             :     }
     128             : }
     129             : 
     130             : /*!
     131             :  *  Returns the maximum value for \a range in (integer) ohms, or the string "Auto".
     132             :  *  If \a range is not a known valid value, then an null QVariant is returned.
     133             :  */
     134         270 : QVariant maxValue(const ResistanceRange &range)
     135             : {
     136         270 :     switch (range) {
     137          18 :     case ResistanceRange::_30:       return      30;
     138          18 :     case ResistanceRange::_75:       return      75;
     139          18 :     case ResistanceRange::_400:      return     400;
     140          18 :     case ResistanceRange::_5K:       return    5000;
     141          18 :     case ResistanceRange::_10K:      return   10000;
     142          18 :     case ResistanceRange::_15K:      return   15000;
     143          18 :     case ResistanceRange::_40K:      return   40000;
     144          18 :     case ResistanceRange::_500K:     return  500000;
     145          18 :     case ResistanceRange::_700K:     return  700000;
     146          18 :     case ResistanceRange::_1M:       return 1000000;
     147          72 :     case ResistanceRange::_3M:       return 3000000;
     148          22 :     case ResistanceRange::AutoRange: return QCoreApplication::translate("PokitPro", "Auto", "ResistanceRange");
     149             :     default:                         return QVariant();
     150             :     }
     151             : }
     152             : 
     153             : /*!
     154             :  * \enum VoltageRange
     155             :  * \brief Values supported by the Pokit Pro's `Range` attributes in `*Voltage` modes.
     156             :  *
     157             :  * \cond internal
     158             :  * \pokitApi These Pokit Pro enumeration values are as-yet undocumented by Pokit Innovations.
     159             :  * [\@pcolby](https://github.com/pcolby) reverse-engineered them as part of the
     160             :  * [dokit](https://github.com/pcolby/dokit) project.
     161             :  * \endcond
     162             :  */
     163             : 
     164             : /// Returns \a range as a user-friendly string.
     165         288 : QString toString(const VoltageRange &range)
     166             : {
     167         288 :     switch (range) {
     168          18 :     case VoltageRange::_250mV:    return QCoreApplication::translate("PokitPro", "Up to 250mV", "VoltageRange");
     169          18 :     case VoltageRange::_2V:       return QCoreApplication::translate("PokitPro", "Up to 2V",    "VoltageRange");
     170          18 :     case VoltageRange::_10V:      return QCoreApplication::translate("PokitPro", "Up to 10V",   "VoltageRange");
     171          18 :     case VoltageRange::_30V:      return QCoreApplication::translate("PokitPro", "Up to 30V",   "VoltageRange");
     172          18 :     case VoltageRange::_60V:      return QCoreApplication::translate("PokitPro", "Up to 60V",   "VoltageRange");
     173          18 :     case VoltageRange::_125V:     return QCoreApplication::translate("PokitPro", "Up to 125V",  "VoltageRange");
     174          18 :     case VoltageRange::_400V:     return QCoreApplication::translate("PokitPro", "Up to 400V",  "VoltageRange");
     175         144 :     case VoltageRange::_600V:     return QCoreApplication::translate("PokitPro", "Up to 600V",  "VoltageRange");
     176          18 :     case VoltageRange::AutoRange: return QCoreApplication::translate("PokitPro", "Auto-range",  "VoltageRange");
     177             :     default:                      return QString();
     178             :     }
     179             : }
     180             : 
     181             : /*!
     182             :  *  Returns the maximum value for \a range in (integer) millivolts, or the string "Auto".
     183             :  *  If \a range is not a known valid value, then an null QVariant is returned.
     184             :  */
     185         288 : QVariant maxValue(const VoltageRange &range)
     186             : {
     187         288 :     switch (range) {
     188          18 :     case VoltageRange::_250mV:    return    250;
     189          18 :     case VoltageRange::_2V:       return   2000;
     190          18 :     case VoltageRange::_10V:      return  10000;
     191          18 :     case VoltageRange::_30V:      return  30000;
     192          18 :     case VoltageRange::_60V:      return  60000;
     193          18 :     case VoltageRange::_125V:     return 125000;
     194          18 :     case VoltageRange::_400V:     return 400000;
     195         144 :     case VoltageRange::_600V:     return 600000;
     196          22 :     case VoltageRange::AutoRange: return QCoreApplication::translate("PokitPro", "Auto", "VoltageRange");
     197             :     default:                      return QVariant();
     198             :     }
     199             : }
     200             : 
     201             : }

Generated by: LCOV version 1.14