FactoryCounter.hpp
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // This file is part of GNSSTk, the ARL:UT GNSS Toolkit.
4 //
5 // The GNSSTk is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published
7 // by the Free Software Foundation; either version 3.0 of the License, or
8 // any later version.
9 //
10 // The GNSSTk 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
13 // GNU 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 GNSSTk; if not, write to the Free Software Foundation,
17 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 //
19 // This software was developed by Applied Research Laboratories at the
20 // University of Texas at Austin.
21 // Copyright 2004-2022, The Board of Regents of The University of Texas System
22 //
23 //==============================================================================
24 
25 
26 //==============================================================================
27 //
28 // This software was developed by Applied Research Laboratories at the
29 // University of Texas at Austin, under contract to an agency or agencies
30 // within the U.S. Department of Defense. The U.S. Government retains all
31 // rights to use, duplicate, distribute, disclose, or release this software.
32 //
33 // Pursuant to DoD Directive 523024
34 //
35 // DISTRIBUTION STATEMENT A: This software has been approved for public
36 // release, distribution is unlimited.
37 //
38 //==============================================================================
39 
40 #ifndef GNSSTK_TEST_FACTORYCOUNTER_HPP
41 #define GNSSTK_TEST_FACTORYCOUNTER_HPP
42 
43 #include "NavData.hpp"
44 #include "NavMessageType.hpp"
45 #include "TestUtil.hpp"
46 
47 // similar to TUASSERTE except requires a source line and counted data
48 // type name to be specified
49 #define FCASSERTE(TYPE,COUNTER,EXP,GOT,LINE) \
50  try \
51  { \
52  std::ostringstream ostr; \
53  ostr << std::boolalpha << "Expected " << COUNTER << "=" << EXP \
54  << ", but got " << COUNTER << "=" << GOT; \
55  testFramework.assert_equals<TYPE>(EXP, GOT, LINE, ostr.str()); \
56  } \
57  catch (gnsstk::Exception &exc) \
58  { \
59  std::cerr << exc << std::endl; \
60  testFramework.assert(false, \
61  "Exception evaluating " #EXP " or " #GOT, \
62  LINE); \
63  } \
64  catch (...) \
65  { \
66  testFramework.assert(false, \
67  "Exception evaluating " #EXP " or " #GOT, \
68  LINE); \
69  }
70 
73 template <class Alm, class Eph, class TimeOffs, class Health, class Iono,
74  class GrpDelay>
76 {
77 public:
79  : testFramework(tf), almInc(true), ephInc(true), toInc(true),
80  heaInc(true), ionoInc(true), iscInc(true)
81  { resetCount(); }
82 
83 
84  void resetCount()
85  {
86  almCount = 0;
87  ephCount = 0;
88  toCount = 0;
89  heaCount = 0;
90  ionoCount = 0;
91  iscCount = 0;
92  otherCount = 0;
93  }
94 
95 
97  {
98  almInc = (nmts.count(gnsstk::NavMessageType::Almanac) > 0);
99  ephInc = (nmts.count(gnsstk::NavMessageType::Ephemeris) > 0);
100  toInc = (nmts.count(gnsstk::NavMessageType::TimeOffset) > 0);
101  heaInc = (nmts.count(gnsstk::NavMessageType::Health) > 0);
102  ionoInc = (nmts.count(gnsstk::NavMessageType::Iono) > 0);
103  iscInc = (nmts.count(gnsstk::NavMessageType::ISC) > 0);
104  }
105 
106 
108  {
109  resetCount();
110  for (const auto& i : navOut)
111  {
112  if (dynamic_cast<Alm*>(i.get()) != nullptr)
113  {
114  almCount++;
115  }
116  else if (dynamic_cast<Eph*>(i.get()) != nullptr)
117  {
118  ephCount++;
119  }
120  else if (dynamic_cast<TimeOffs*>(i.get()) != nullptr)
121  {
122  toCount++;
123  }
124  else if (dynamic_cast<Health*>(i.get()) != nullptr)
125  {
126  heaCount++;
127  }
128  else if (dynamic_cast<Iono*>(i.get()) != nullptr)
129  {
130  ionoCount++;
131  }
132  else if (dynamic_cast<GrpDelay*>(i.get()) != nullptr)
133  {
134  iscCount++;
135  }
136  else
137  {
138  otherCount++;
139  }
140  }
141  }
142 
143 
145  unsigned lineNo,
146  size_t totalExp = 0,
147  unsigned almExp = 0,
148  unsigned ephExp = 0,
149  unsigned toExp = 0,
150  unsigned heaExp = 0,
151  unsigned ionoExp = 0,
152  unsigned iscExp = 0,
153  unsigned otherExp = 0)
154  {
155  countResults(navOut);
156  // sanity check.
157  FCASSERTE(unsigned, "summed total", totalExp,
158  almExp+ephExp+toExp+heaExp+ionoExp+iscExp+otherExp, lineNo);
159  // Get an expected total based on what's included and what isn't.
160  totalExp = ((almInc ? almExp : 0) + (ephInc ? ephExp : 0) +
161  (toInc ? toExp : 0) + (heaInc ? heaExp : 0) +
162  (ionoInc ? ionoExp : 0) + (iscInc ? iscExp : 0) + otherExp);
163  FCASSERTE(size_t, "total", totalExp, navOut.size(), lineNo);
164  FCASSERTE(unsigned, "almCount", (almInc ? almExp : 0), almCount, lineNo);
165  FCASSERTE(unsigned, "ephCount", (ephInc ? ephExp : 0), ephCount, lineNo);
166  FCASSERTE(unsigned, "toCount", (toInc ? toExp : 0), toCount, lineNo);
167  FCASSERTE(unsigned, "heaCount", (heaInc ? heaExp : 0), heaCount, lineNo);
168  FCASSERTE(unsigned, "ionoCount", (ionoInc ? ionoExp : 0), ionoCount,
169  lineNo);
170  FCASSERTE(unsigned, "iscCount", (iscInc ? iscExp : 0), iscCount, lineNo);
171  FCASSERTE(unsigned, "otherCount", otherExp, otherCount, lineNo);
172  navOut.clear();
173  }
174 
185 };
186 
187 #endif // GNSSTK_TEST_FACTORYCOUNTER_HPP
gnsstk::NavMessageTypeSet
std::set< NavMessageType > NavMessageTypeSet
Set of message types, used by NavLibrary and NavDataFactory.
Definition: NavMessageType.hpp:76
FactoryCounter::almCount
unsigned almCount
Counts of messages, set by countResults.
Definition: FactoryCounter.hpp:178
gnsstk::NavMessageType::ISC
@ ISC
Inter-signal corrections.
FactoryCounter::resetCount
void resetCount()
Definition: FactoryCounter.hpp:84
FactoryCounter::toInc
bool toInc
Definition: FactoryCounter.hpp:184
FactoryCounter::otherCount
unsigned otherCount
Definition: FactoryCounter.hpp:179
FactoryCounter::setInc
void setInc(const gnsstk::NavMessageTypeSet &nmts)
Definition: FactoryCounter.hpp:96
FactoryCounter::iscInc
bool iscInc
Definition: FactoryCounter.hpp:184
gnsstk::NavMessageType::Health
@ Health
SV health status information message.
gnsstk::NavDataPtrList
std::list< NavDataPtr > NavDataPtrList
Definition: NavData.hpp:75
FactoryCounter::validateResults
void validateResults(gnsstk::NavDataPtrList &navOut, unsigned lineNo, size_t totalExp=0, unsigned almExp=0, unsigned ephExp=0, unsigned toExp=0, unsigned heaExp=0, unsigned ionoExp=0, unsigned iscExp=0, unsigned otherExp=0)
Definition: FactoryCounter.hpp:144
FactoryCounter::toCount
unsigned toCount
Definition: FactoryCounter.hpp:178
NavMessageType.hpp
FactoryCounter::countResults
void countResults(const gnsstk::NavDataPtrList &navOut)
Definition: FactoryCounter.hpp:107
FactoryCounter
Definition: FactoryCounter.hpp:75
TestUtil.hpp
FactoryCounter::ephInc
bool ephInc
Definition: FactoryCounter.hpp:184
FactoryCounter::testFramework
gnsstk::TestUtil & testFramework
TestUtil object to use when assertions are integrated.
Definition: FactoryCounter.hpp:176
FactoryCounter::ionoCount
unsigned ionoCount
Definition: FactoryCounter.hpp:178
NavData.hpp
gnsstk::NavMessageType::Iono
@ Iono
Ionospheric correction data.
FactoryCounter::heaCount
unsigned heaCount
Definition: FactoryCounter.hpp:178
FactoryCounter::heaInc
bool heaInc
Definition: FactoryCounter.hpp:184
gnsstk::NavMessageType::TimeOffset
@ TimeOffset
Message containing information about time system offsets.
gnsstk::NavMessageType::Ephemeris
@ Ephemeris
Precision orbits for the transmitting SV.
FCASSERTE
#define FCASSERTE(TYPE, COUNTER, EXP, GOT, LINE)
Definition: FactoryCounter.hpp:49
FactoryCounter::ephCount
unsigned ephCount
Definition: FactoryCounter.hpp:178
FactoryCounter::ionoInc
bool ionoInc
Definition: FactoryCounter.hpp:184
FactoryCounter::FactoryCounter
FactoryCounter(gnsstk::TestUtil &tf)
Definition: FactoryCounter.hpp:78
FactoryCounter::almInc
bool almInc
Definition: FactoryCounter.hpp:184
gnsstk::TestUtil
Definition: TestUtil.hpp:265
FactoryCounter::iscCount
unsigned iscCount
Definition: FactoryCounter.hpp:178
gnsstk::NavMessageType::Almanac
@ Almanac
Low-precision orbits for other than the transmitting SV.


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:39