LCOV - code coverage report
Current view: top level - atmosphere/ATM - ATMFrequency.cc (source / functions) Hit Total Coverage
Test: ctest_coverage.info Lines: 35 65 53.8 %
Date: 2023-11-06 10:06:49 Functions: 8 11 72.7 %

          Line data    Source code
       1             : /*******************************************************************************
       2             :  * ALMA - Atacama Large Millimiter Array
       3             :  * (c) Instituto de Estructura de la Materia, 2009
       4             :  *
       5             :  * This library is free software; you can redistribute it and/or
       6             :  * modify it under the terms of the GNU Lesser General Public
       7             :  * License as published by the Free Software Foundation; either
       8             :  * version 2.1 of the License, or (at your option) any later version.
       9             :  *
      10             :  * This library is distributed in the hope that it will be useful,
      11             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      12             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13             :  * Lesser General Public License for more details.
      14             :  *
      15             :  * You should have received a copy of the GNU Lesser General Public
      16             :  * License along with this library; if not, write to the Free Software
      17             :  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
      18             :  *
      19             :  * "@(#) $Id: ATMFrequency.cpp Exp $"
      20             :  *
      21             :  * who       when      what
      22             :  * --------  --------  ----------------------------------------------
      23             :  * pardo     24/03/09  created
      24             :  */
      25             : 
      26             : #include <stdio.h>
      27             : 
      28             : #include "ATMFrequency.h"
      29             : 
      30             : 
      31             : 
      32             : ATM_NAMESPACE_BEGIN
      33             : 
      34        1618 : Frequency::Frequency() :
      35        1618 :   valueIS_(0.0)
      36             : {
      37        1618 : }
      38             : 
      39        1708 : Frequency::Frequency(double frequency) :
      40        1708 :   valueIS_(frequency)
      41             : {
      42        1708 : }
      43             : 
      44        1618 : Frequency::Frequency(double frequency, const std::string &units)
      45             : {
      46        1618 :   valueIS_ = sput(frequency, units);
      47        1618 : }
      48             : 
      49    15268804 : Frequency::Frequency(double frequency, Frequency::Units units)
      50             : {
      51    15268804 :   valueIS_ = sput(frequency, units);
      52    15268804 : }
      53             : 
      54           0 : Frequency::Frequency(const Frequency &frequency) :
      55           0 :   valueIS_(frequency.valueIS_)
      56             : {
      57           0 : }
      58             : 
      59    15273748 : Frequency::~Frequency()
      60             : {
      61    15273748 : }
      62             : 
      63           0 : double Frequency::sget(double value, const std::string &units)
      64             : {
      65           0 :   if(units == "THz" || units == "THZ") {
      66           0 :     return 1.0E-12 * value;
      67           0 :   } else if(units == "GHz" || units == "GHz" || units == "ghz") {
      68           0 :     return 1.0E-9 * value;
      69           0 :   } else if(units == "MHz" || units == "MHZ" || units == "mhz") {
      70           0 :     return 1.0E-6 * value;
      71           0 :   } else if(units == "kHz" || units == "KHZ" || units == "khz") {
      72           0 :     return 1.0E-3 * value;
      73           0 :   } else if(units == "Hz" || units == "HZ" || units == "hz") {
      74           0 :     return value;
      75             :   } else {
      76           0 :     return value;
      77             :   }
      78             : }
      79        1618 : double Frequency::sput(double freq, const std::string &units)
      80             : {
      81        1618 :   if(units == "THz" || units == "THZ") {
      82           0 :     return 1.0E12 * freq;
      83        1618 :   } else if(units == "GHz" || units == "GHZ" || units == "ghz") {
      84        1613 :     return 1.0E9 * freq;
      85           5 :   } else if(units == "MHz" || units == "MHZ" || units == "mhz") {
      86           5 :     return 1.0E6 * freq;
      87           0 :   } else if(units == "kHz" || units == "KHZ" || units == "khz") {
      88           0 :     return 1.0E3 * freq;
      89           0 :   } else if(units == "Hz" || units == "HZ" || units == "hz") {
      90           0 :     return freq;
      91             :   } else {
      92           0 :     return freq;
      93             :   }
      94             : }
      95             : 
      96    15270512 : double Frequency::sget(double value, Frequency::Units units)
      97             : {
      98    15270512 :   if(units == Frequency::UnitTeraHertz) {
      99           0 :     return 1.0E-12 * value;
     100    15270512 :   } else if(units == Frequency::UnitGigaHertz) {
     101    15268784 :     return 1.0E-9 * value;
     102        1728 :   } else if(units == Frequency::UnitMegaHertz) {
     103           0 :     return 1.0E-6 * value;
     104        1728 :   } else if(units == Frequency::UnitKiloHertz) {
     105           0 :     return 1.0E-3 * value;
     106        1728 :   } else if(units == Frequency::UnitHertz) {
     107        1728 :     return value;
     108             :   } else {
     109           0 :     return value;
     110             :   }
     111             : }
     112    15268804 : double Frequency::sput(double freq, Frequency::Units units)
     113             : {
     114    15268804 :   if(units == Frequency::UnitTeraHertz) {
     115           0 :     return 1.0E12 * freq;
     116    15268804 :   } else if(units == Frequency::UnitGigaHertz) {
     117           0 :     return 1.0E9 * freq;
     118    15268804 :   } else if(units == Frequency::UnitMegaHertz) {
     119           0 :     return 1.0E6 * freq;
     120    15268804 :   } else if(units == Frequency::UnitKiloHertz) {
     121           0 :     return 1.0E3 * freq;
     122    15268804 :   } else if(units == Frequency::UnitHertz) {
     123    15268804 :     return freq;
     124             :   } else {
     125           0 :     return freq;
     126             :   }
     127             : }
     128             : 
     129             : ATM_NAMESPACE_END

Generated by: LCOV version 1.16