NavFilterMgr_T.cpp
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 // This software was developed by Applied Research Laboratories at the
28 // University of Texas at Austin, under contract to an agency or agencies
29 // within the U.S. Department of Defense. The U.S. Government retains all
30 // rights to use, duplicate, distribute, disclose, or release this software.
31 //
32 // Pursuant to DoD Directive 523024
33 //
34 // DISTRIBUTION STATEMENT A: This software has been approved for public
35 // release, distribution is unlimited.
36 //
37 //==============================================================================
38 
39 #include "TestUtil.hpp"
40 #include "NavFilterMgr.hpp"
41 #include "LNavFilterData.hpp"
42 #include "LNavParityFilter.hpp"
43 #include "LNavCookFilter.hpp"
44 #include "LNavEmptyFilter.hpp"
45 #include "LNavTLMHOWFilter.hpp"
46 #include "LNavEphMaker.hpp"
48 #include "NavOrderFilter.hpp"
49 #include "CommonTime.hpp"
50 #include "TimeString.hpp"
51 
52 using namespace std;
53 using namespace gnsstk;
54 
55 // hard-coded expectations... is there a better way?
56 
57 // Checked against mdptool.. mdptool reports 1269; this is close enough
58 unsigned long expLNavParity = 1265;
59 // Checked using mdptool -s table and grep
60 unsigned long expLNavEmpty = 225;
61 // This number has not been vetted by other means
62 unsigned long expLNavTLMHOW = 613;
63 // This number represents the union of subframes stripped by parity,
64 // empty and TLM/HOW checks.
65 unsigned long expLNavCombined = 1488;
66 // This number was vetted by getting a rough count of ephemerides in
67 // the source file (which was 5526, which is in the same ball park).
68 // /usr/bin/tail +109 test_input_NavFilterMgr.txt | head -27513 | grep ':[03]0.0, ' | wc -l
69 unsigned long expLNavEphs = 5210;
70 
71 typedef std::set<gnsstk::CommonTime> TimeSet;
72 
73 // define some classes for exercising NavFilterMgr
75 {
76 public:
78  : data(NULL)
79  {}
80  uint32_t *data; // point to a single uint32_t
81 };
82 // filter by bit pattern
83 class BunkFilter1 : public NavFilter
84 {
85 public:
87  virtual void validate(NavMsgList& msgBitsIn, NavMsgList& msgBitsOut)
88  {
89  NavMsgList::iterator nmli;
90  for (nmli = msgBitsIn.begin(); nmli != msgBitsIn.end(); nmli++)
91  {
92  // copy data with an arbitrary bit pattern
93  BunkFilterData *fd = dynamic_cast<BunkFilterData*>(*nmli);
94  if ((*(fd->data) & 0xff) == 0x000000d1)
95  msgBitsOut.push_back(*nmli);
96  }
97  }
98  virtual void finalize(NavMsgList& msgBitsOut)
99  {}
100  virtual unsigned processingDepth() const noexcept
101  { return 0; }
102  virtual std::string filterName() const noexcept
103  { return "Bunk1"; }
104 };
105 // filter with cache
106 class BunkFilter2 : public NavFilter
107 {
108 public:
110  virtual void validate(NavMsgList& msgBitsIn, NavMsgList& msgBitsOut)
111  {
112  NavMsgList::iterator nmli;
113  std::copy(msgBitsIn.begin(), msgBitsIn.end(),
114  std::back_insert_iterator<NavMsgList>(cache));
115  while (cache.size() > 4)
116  {
117  msgBitsOut.push_back(cache.front());
118  cache.pop_front();
119  }
120  }
121  virtual void finalize(NavMsgList& msgBitsOut)
122  {
123  std::copy(cache.begin(), cache.end(),
124  std::back_insert_iterator<NavMsgList>(msgBitsOut));
125  cache.clear();
126  }
127  virtual unsigned processingDepth() const noexcept
128  { return 4; }
129  virtual std::string filterName() const noexcept
130  { return "Bunk2"; }
132 };
133 
135 {
136 public:
137  NavFilterMgr_T();
138 
139  void init();
140 
141  unsigned loadData();
142 
144  unsigned noFilterTest();
146  unsigned testLNavCook();
148  unsigned testLNavParity();
150  unsigned testLNavEmpty();
152  unsigned testLNavTLMHOW();
154  unsigned testLNavEphMaker();
156  unsigned testLNavCombined();
159  template <class Filter>
160  unsigned testProcessingDepth(const std::string& filterName);
162  unsigned testCombinedDepths();
165  unsigned testProcessingDepths();
166 
168  unsigned testBunk1();
170  unsigned testBunk2();
171 
174  string refFileBunk1, refFileBunk2;
175  string outputFileBunk1, outputFileBunk2;
177  vector<LNavFilterData> dataLNAV;
179  vector<uint32_t> subframesLNAV;
181  vector<uint32_t> subframesBunk;
182  vector<BunkFilterData> dataBunk;
183 
184  unsigned long dataIdxLNAV, dataIdxBunk;
185 };
186 
187 
190  : dataIdxLNAV(0),
191  dataIdxBunk(0)
192 {
193  // about how much a day's worth of data is
194  dataLNAV.resize(40000);
195  subframesLNAV.resize(400000);
196  dataBunk.resize(40000);
197  subframesBunk.resize(400000, 0xdabbad00);
198  init();
199 }
200 
201 
204 {
205  TUDEF("NavFilterMgr", "initialize");
206  string fs = getFileSep();
207  string dp(gnsstk::getPathData() + fs);
208  string tf(gnsstk::getPathTestTemp() + fs);
209 
210  inputFileLNAV = dp + "test_input_NavFilterMgr.txt";
211  inputFileBunk = dp + "test_input_NavFilterMgr_bunk.txt";
212  refFileBunk1 = dp + "test_output_NavFilterMgr_bunk1.txt";
213  refFileBunk2 = dp + "test_output_NavFilterMgr_bunk2.txt";
214  outputFileBunk1 = tf + "test_output_NavFilterMgr_bunk1.txt";
215  outputFileBunk2 = tf + "test_output_NavFilterMgr_bunk2.txt";
216 }
217 
218 
219 unsigned NavFilterMgr_T ::
221 {
222  ifstream inf(inputFileLNAV.c_str());
223  string line, timeString, wordStr;
224  CommonTime recTime;
225  unsigned long subframeIdx = 0;
226 
227  if (!inf)
228  {
229  cerr << "Could not load input file \"" << inputFileLNAV << "\"" << endl;
230  return 1;
231  }
232  while (inf)
233  {
234  getline(inf, line);
235  if (line[0] == '#')
236  continue; // comment line
237  if (line.length() == 0)
238  continue; // blank line
239  timeString = gnsstk::StringUtils::firstWord(line, ',');
240  scanTime(recTime, timeString, "%4Y %3j %02H:%02M:%04.1f");
241 
242  // check to make sure we don't run off the end of our vector
243  if (dataIdxLNAV >= dataLNAV.size())
244  {
245  dataLNAV.resize(dataLNAV.size() + 1000);
246  subframesLNAV.resize(subframesLNAV.size() + 10000);
247  }
248 
249  LNavFilterData tmp;
250  // point at what will be the first word when loaded
251  tmp.sf = &subframesLNAV[subframeIdx];
252  for (unsigned strWord = 6; strWord <= 15; strWord++)
253  {
254  wordStr = gnsstk::StringUtils::word(line, strWord, ',');
255  subframesLNAV[subframeIdx++] = gnsstk::StringUtils::x2uint(wordStr);
256  }
258  gnsstk::StringUtils::word(line, 2, ','));
259  // note that the test file contents use enums that probably
260  // don't match ObsID's enums but that's really not important
261  // for this test.
263  gnsstk::StringUtils::word(line, 3, ','));
265  gnsstk::StringUtils::word(line, 4, ','));
266  tmp.timeStamp = recTime;
267 
268  dataLNAV[dataIdxLNAV++] = tmp;
269  }
270  inf.close();
271  cout << "Using " << dataIdxLNAV << " LNAV subframes" << endl;
272 
273  // load "bunk" data
274  BunkFilterData bunkKey;
275  subframeIdx = 0;
276  inf.open(inputFileBunk.c_str());
277  if (!inf)
278  {
279  cerr << "Could not load input file \"" << inputFileBunk << "\"" << endl;
280  return 1;
281  }
282  while (inf)
283  {
284  getline(inf, line);
285  if (line[0] == '#')
286  continue; // comment line
287  if (line.length() == 0)
288  continue; // blank line
289  for (unsigned strWord = 1; strWord <= 4; strWord++)
290  {
291  wordStr = gnsstk::StringUtils::word(line, strWord, ' ');
292  bunkKey.data = &subframesBunk[subframeIdx];
293  subframesBunk[subframeIdx++] = gnsstk::StringUtils::x2uint(wordStr);
294  // we don't really care waht the prn, carrier or code are
295  // for this test
296  dataBunk[dataIdxBunk++] = bunkKey;
297  }
298  }
299  inf.close();
300  cout << "Using " << dataIdxBunk << " \"Bunk\" subframes" << endl;
301 
302  return 0;
303 }
304 
305 
306 unsigned NavFilterMgr_T ::
308 {
309  TUDEF("NavFilterMgr", "validate");
310 
311  NavFilterMgr mgr;
312  unsigned long count = 0;
313 
314  for (unsigned i = 0; i < dataIdxLNAV; i++)
315  {
317  // We could do an assert for each record but that would be
318  // stupid. Just compare the final counts.
319  count += l.size();
320  }
321  TUASSERTE(unsigned long, dataIdxLNAV, count);
322 
323  TURETURN();
324 }
325 
326 
327 // this should be executed before any other filter tests are used as
328 // it will upright all the data in memory.
329 unsigned NavFilterMgr_T ::
331 {
332  TUDEF("LNavCookFilter", "validate");
333 
334  NavFilterMgr mgr;
335  unsigned long count = 0;
336  LNavCookFilter filtCook;
337 
338  mgr.addFilter(&filtCook);
339 
340  for (unsigned i = 0; i < dataIdxLNAV; i++)
341  {
342 /*
343  cout << "------------------" << endl
344  << " idx: " << i << endl;
345  cout << " before:";
346  for (unsigned sfword = 0; sfword < 10; sfword++)
347  cout << " " << hex << setw(8) << dataLNAV[i].sf[sfword] << dec;
348  cout << endl;
349 */
351  // We could do an assert for each record but that would be
352  // stupid. Just compare the final counts.
353 /*
354  cout << " after: ";
355  for (unsigned sfword = 0; sfword < 10; sfword++)
356  cout << " " << hex << setw(8) << dataLNAV[i].sf[sfword] << dec;
357  cout << endl;
358 */
359  count += l.size();
360 
361 /*
362  gnsstk::NavFilter::NavMsgList::const_iterator nmli;
363  for (nmli = l.begin(); nmli != l.end(); nmli++)
364  {
365  LNavFilterData *fd = dynamic_cast<LNavFilterData*>(*nmli);
366  cout << " tow: " << ((fd->sf[1] >> 13) * 6) << endl;
367  }
368 */
369  }
370  TUASSERTE(unsigned long, dataIdxLNAV, count);
371 
372  TURETURN();
373 }
374 
375 
376 unsigned NavFilterMgr_T ::
378 {
379  TUDEF("LNavParityFilter", "validate");
380 
381  NavFilterMgr mgr;
382  unsigned long rejectCount = 0;
383  LNavParityFilter filtParity;
384 
385  mgr.addFilter(&filtParity);
386 
387  for (unsigned i = 0; i < dataIdxLNAV; i++)
388  {
390  gnsstk::NavFilter::NavMsgList::const_iterator nmli;
391  /*
392  if (!filtParity.rejected.empty())
393  {
394  for (nmli = filtParity.rejected.begin();
395  nmli != filtParity.rejected.end();
396  nmli++)
397  {
398  LNavFilterData *fd = dynamic_cast<LNavFilterData*>(*nmli);
399  for (unsigned sfword = 0; sfword < 10; sfword++)
400  {
401  if ((sfword % 5) == 0)
402  cout << "nav" << (sfword+1) << ": ";
403  cout << hex << setiosflags(ios::uppercase) << setw(8)
404  << setfill('0') << fd->sf[sfword] << dec << setfill(' ')
405  << " ";
406  if ((sfword % 5) == 4)
407  cout << endl;
408  }
409  }
410  }
411  */
412  rejectCount += filtParity.rejected.size();
413 /*
414  if (!filtParity.rejected.empty())
415  cerr << "filter " << i << " parity" << endl;
416 */
417  }
418  TUASSERTE(unsigned long, expLNavParity, rejectCount);
419 
420  TURETURN();
421 }
422 
423 
424 unsigned NavFilterMgr_T ::
426 {
427  TUDEF("LNavEmptyFilter", "validate");
428 
429  uint32_t emptySF[10] = { 0,0,0,0,0,0,0,0,0,0 };
430  NavFilterMgr mgr;
431  unsigned long rejectCount = 0;
432  LNavEmptyFilter filtEmpty;
433 
434  mgr.addFilter(&filtEmpty);
435 
436  for (unsigned i = 0; i < dataIdxLNAV; i++)
437  {
439  rejectCount += filtEmpty.rejected.size();
440 /*
441  if (!filtEmpty.rejected.empty())
442  cerr << "filter " << i << " empty" << endl;
443 */
444  }
445  TUASSERTE(unsigned long, expLNavEmpty, rejectCount);
446  LNavFilterData fd;
447  fd.sf = emptySF;
449  TUASSERTE(unsigned long, 0, l.size());
450  TUASSERTE(unsigned long, 1, filtEmpty.rejected.size());
451 
452  TURETURN();
453 }
454 
455 
456 unsigned NavFilterMgr_T ::
458 {
459  TUDEF("LNavTLMHOWFilter", "validate");
460 
461  NavFilterMgr mgr;
462  unsigned long rejectCount = 0;
463  LNavTLMHOWFilter filtTLMHOW;
464 
465  mgr.addFilter(&filtTLMHOW);
466 
467  for (unsigned i = 0; i < dataIdxLNAV; i++)
468  {
469  /*
470  uint32_t sfid = ((dataLNAV[i].sf[1] >> 8) & 0x07);
471  if ((dataLNAV[i].sf[0] & 0x3fc00000) != 0x22c00000)
472  cout << (i+1) << " invalid preamble " << hex << (dataLNAV[i].sf[0] & 0x3fc00000) << dec << endl;
473  else if ((dataLNAV[i].sf[1] & 0x03) != 0)
474  cout << (i+1) << " invalid parity bits " << hex << (dataLNAV[i].sf[1] & 0x03) << dec << endl;
475  else if (((dataLNAV[i].sf[1] >> 13) & 0x1ffff) >= 100800)
476  cout << (i+1) << " invalid TOW count " << hex << ((dataLNAV[i].sf[1] >> 13) & 0x1ffff) << dec << endl;
477  else if ((sfid < 1) || (sfid > 5))
478  cout << (i+1) << " invalid SF ID " << sfid << endl;
479  */
481  rejectCount += filtTLMHOW.rejected.size();
482 /*
483  if (!filtTLMHOW.rejected.empty())
484  cerr << "filter " << i << " tlm/how" << endl;
485 */
486  }
487  TUASSERTE(unsigned long, expLNavTLMHOW, rejectCount);
488 
489  TURETURN();
490 }
491 
492 
493 // make sure the eph maker produces the expected number of complete ephemerides
494 unsigned NavFilterMgr_T ::
496 {
497  TUDEF("LNavTLMHOWFilter", "validate");
498 
499  NavFilterMgr mgr;
500  unsigned long ephCount = 0;
501  LNavEphMaker filtEph;
502 
503  mgr.addFilter(&filtEph);
504 
505  for (unsigned i = 0; i < dataIdxLNAV; i++)
506  {
508  ephCount += filtEph.completeEphs.size();
509  }
510  TUASSERTE(unsigned long, expLNavEphs, ephCount);
511 
512  TURETURN();
513 }
514 
515 
516 unsigned NavFilterMgr_T ::
518 {
519  TUDEF("NavFilterMgr", "validate");
520 
521  NavFilterMgr mgr;
522  unsigned long rejectCount = 0;
523  LNavParityFilter filtParity;
524  LNavEmptyFilter filtEmpty;
525  LNavTLMHOWFilter filtTLMHOW;
526 
527  mgr.addFilter(&filtParity);
528  mgr.addFilter(&filtEmpty);
529  mgr.addFilter(&filtTLMHOW);
530 
531  for (unsigned i = 0; i < dataIdxLNAV; i++)
532  {
533 /*
534  cerr << "checking " << i << endl;
535  if (i == 2196)
536  {
537  for (unsigned sfword = 0; sfword < 10; sfword++)
538  cerr << " " << hex << setw(8) << dataLNAV[i].sf[sfword] << dec;
539  cerr << endl;
540  }
541 */
543  // if l is empty, the subframe was rejected..
544  rejectCount += l.empty();
545 /*
546  if (l.empty())
547  cerr << "filter " << i << " combined" << endl;
548 */
549  }
550  TUASSERTE(unsigned long, expLNavCombined, rejectCount);
551 
552  TURETURN();
553 }
554 
555 
556 template <class Filter>
557 unsigned NavFilterMgr_T ::
558 testProcessingDepth(const std::string& filterName)
559 {
560  TUDEF(filterName, "processingDepth");
561  try
562  {
563  NavFilterMgr mgr;
564  Filter filt;
565  NavFilterMgr::FilterSet::iterator fsi;
566  mgr.addFilter(&filt);
567  TimeSet allTimes;
568  // 6 seconds for each subframe epoch
569  int expDelta = 6 * filt.processingDepth();
570  for (unsigned i = 0; i < dataIdxLNAV; i++)
571  {
572  TimeSet timestamps;
574  gnsstk::NavFilter::NavMsgList::iterator nmli;
575  allTimes.insert(gnsstk::CommonTime(dataLNAV[i].timeStamp));
576  for (nmli = l.begin(); nmli != l.end(); nmli++)
577  {
578  timestamps.insert(gnsstk::CommonTime((*nmli)->timeStamp));
579  }
580  for (fsi = mgr.rejected.begin(); fsi != mgr.rejected.end(); fsi++)
581  {
582  for (nmli = (*fsi)->rejected.begin(); nmli != (*fsi)->rejected.end();
583  nmli++)
584  {
585  timestamps.insert(gnsstk::CommonTime((*nmli)->timeStamp));
586  }
587  }
588  if (allTimes.size() > filt.processingDepth())
589  {
590  TUASSERTE(TimeSet::size_type, 1, timestamps.size());
591  gnsstk::CommonTime timestampsTime;
592  if (!timestamps.empty())
593  {
594  timestampsTime = (*timestamps.begin());
595  int delta = (dataLNAV[i].timeStamp - timestampsTime);
596  TUASSERTE(int, expDelta, delta);
597  }
598  // Time stamp has changed, we've done our test/check for
599  // the new time stamp, and since it's been processed,
600  // remove it from allTimes to prevent erroneous triggering
601  // of the check.
602  TimeSet::iterator tsi;
603  for (tsi = timestamps.begin(); tsi != timestamps.end(); tsi++)
604  {
605  allTimes.erase(*tsi);
606  }
607  }
608  else
609  {
610  TUASSERTE(TimeSet::size_type, 0, timestamps.size());
611  }
612  }
613  }
614  catch (...)
615  {
616  TUFAIL("Exception");
617  }
618  TURETURN();
619 }
620 
621 
622 unsigned NavFilterMgr_T ::
624 {
625  TUDEF("NavFilterMgr", "processingDepth");
626  try
627  {
628  LNavParityFilter filt1;
629  LNavCookFilter filt2;
630  LNavEmptyFilter filt3;
631  LNavTLMHOWFilter filt4;
632  LNavCrossSourceFilter filt5;
633  // No particular meaning to these values other than to have
634  // something non-default.
635  NavOrderFilter filt6(7,20);
636  NavFilterMgr mgr;
637  unsigned expProcDepth = 1;
638  TUASSERTE(unsigned, expProcDepth, mgr.processingDepth());
639  expProcDepth += filt1.processingDepth();
640  mgr.addFilter(&filt1);
641  TUASSERTE(unsigned, expProcDepth, mgr.processingDepth());
642  expProcDepth += filt2.processingDepth();
643  mgr.addFilter(&filt2);
644  TUASSERTE(unsigned, expProcDepth, mgr.processingDepth());
645  expProcDepth += filt3.processingDepth();
646  mgr.addFilter(&filt3);
647  TUASSERTE(unsigned, expProcDepth, mgr.processingDepth());
648  expProcDepth += filt4.processingDepth();
649  mgr.addFilter(&filt4);
650  TUASSERTE(unsigned, expProcDepth, mgr.processingDepth());
651  expProcDepth += filt5.processingDepth();
652  mgr.addFilter(&filt5);
653  TUASSERTE(unsigned, expProcDepth, mgr.processingDepth());
654  expProcDepth += filt6.processingDepth();
655  mgr.addFilter(&filt6);
656  TUASSERTE(unsigned, expProcDepth, mgr.processingDepth());
657  }
658  catch (...)
659  {
660  TUFAIL("Exception");
661  }
662  TURETURN();
663 }
664 
665 
666 unsigned NavFilterMgr_T ::
668 {
669  unsigned rv = 0;
670  rv += testProcessingDepth<LNavParityFilter>("LNavParityFilter");
671  rv += testProcessingDepth<LNavCookFilter>("LNavCookFilter");
672  rv += testProcessingDepth<LNavEmptyFilter>("LNavEmptyFilter");
673  rv += testProcessingDepth<LNavTLMHOWFilter>("LNavTLMHOWFilter");
674  rv += testProcessingDepth<LNavCrossSourceFilter>("LNavCrossSourceFilter");
675  rv += testProcessingDepth<NavOrderFilter>("NavOrderFilter");
676  rv += testCombinedDepths();
677  return rv;
678 }
679 
680 
681 unsigned NavFilterMgr_T ::
683 {
684  TUDEF("NavFilterMgr", "validate");
685 
686  ofstream outs(outputFileBunk1.c_str());
687  NavFilterMgr mgr;
688  BunkFilter1 filt1;
690  gnsstk::NavFilter::NavMsgList::const_iterator nmli;
691 
692  if (!outs)
693  {
694  TUFAIL("Could not open \"" + outputFileBunk1 + "\" for output");
695  TURETURN();
696  }
697 
698  mgr.addFilter(&filt1);
699  for (unsigned i = 0; i < dataIdxBunk; i++)
700  {
701  l = mgr.validate(&dataBunk[i]);
702  for (nmli = l.begin(); nmli != l.end(); nmli++)
703  {
704  BunkFilterData *fd = dynamic_cast<BunkFilterData*>(*nmli);
705  outs << hex << setw(8) << setfill('0') << *(fd->data) << setfill(' ')
706  << dec << endl;
707  }
708  }
709  l = mgr.finalize();
710  for (nmli = l.begin(); nmli != l.end(); nmli++)
711  {
712  BunkFilterData *fd = dynamic_cast<BunkFilterData*>(*nmli);
713  outs << hex << setw(8) << setfill('0') << *(fd->data) << setfill(' ')
714  << dec << endl;
715  }
716  outs.close();
717  testFramework.assert_files_equal(__LINE__, refFileBunk1, outputFileBunk1,
718  "Files differ");
719 
720  TURETURN();
721 }
722 
723 
724 unsigned NavFilterMgr_T ::
726 {
727  // the filter uses cached data because we're more interested in
728  // testing finalize here.
729  TUDEF("NavFilterMgr", "finalize");
730 
731  ofstream outs(outputFileBunk2.c_str());
732  NavFilterMgr mgr;
733  BunkFilter2 filt2;
735  gnsstk::NavFilter::NavMsgList::const_iterator nmli;
736 
737  if (!outs)
738  {
739  TUFAIL("Could not open \"" + outputFileBunk2 + "\" for output");
740  TURETURN();
741  }
742 
743  mgr.addFilter(&filt2);
744  // count of wrong filter results before and after reaching the cache size
745  unsigned wrongEarly = 0, wrongLate = 0;
746  for (unsigned i = 0; i < dataIdxBunk; i++)
747  {
748  l = mgr.validate(&dataBunk[i]);
749 /*
750  if ((i < 3) && (l.size() != 0))
751  {
752  TUFAIL("Filter expected to return no data before 4 messages input");
753  }
754  else if ((i >= 3) && (l.size() != 1))
755  {
756  TUFAIL("Filter expected to return 1 message after 4 messages input");
757  }
758 */
759  if (i <= 3)
760  {
761  if (l.size() != 0)
762  wrongEarly++;
763  }
764  else
765  {
766  if (l.size() != 1)
767  wrongLate++;
768  }
769 
770  for (nmli = l.begin(); nmli != l.end(); nmli++)
771  {
772  BunkFilterData *fd = dynamic_cast<BunkFilterData*>(*nmli);
773  outs << hex << setw(8) << setfill('0') << *(fd->data) << setfill(' ')
774  << dec << endl;
775  }
776  }
777  // just do all the assertions at once
778  testFramework.changeSourceMethod("validate");
779  TUASSERTE(unsigned,0,wrongEarly);
780  TUASSERTE(unsigned,0,wrongLate);
781 
782  l = mgr.finalize();
783  // cache of size 4 so finalize should return the last four messages
784  testFramework.changeSourceMethod("finalize");
785  TUASSERTE(size_t,4,l.size());
786  for (nmli = l.begin(); nmli != l.end(); nmli++)
787  {
788  BunkFilterData *fd = dynamic_cast<BunkFilterData*>(*nmli);
789  outs << hex << setw(8) << setfill('0') << *(fd->data) << setfill(' ')
790  << dec << endl;
791  }
792  outs.close();
793  testFramework.assert_files_equal(__LINE__, refFileBunk2, outputFileBunk2,
794  "Files differ");
795 
796  TURETURN();
797 }
798 
799 
800 int main()
801 {
802  unsigned errorTotal = 0;
803 
804  NavFilterMgr_T testClass;
805 
806  errorTotal += testClass.loadData();
807  errorTotal += testClass.noFilterTest();
808  errorTotal += testClass.testLNavCook();
809  errorTotal += testClass.testLNavParity();
810  errorTotal += testClass.testLNavEmpty();
811  errorTotal += testClass.testLNavTLMHOW();
812  errorTotal += testClass.testLNavEphMaker();
813  errorTotal += testClass.testLNavCombined();
814  errorTotal += testClass.testProcessingDepths();
815  errorTotal += testClass.testBunk1();
816  errorTotal += testClass.testBunk2();
817 
818  cout << "Total Failures for " << __FILE__ << ": " << errorTotal << endl;
819 
820  return errorTotal; // Return the total number of errors
821 }
gnsstk::LNavEmptyFilter::processingDepth
virtual unsigned processingDepth() const noexcept
No internal storage of subframe data so return 0.
Definition: LNavEmptyFilter.hpp:72
gnsstk::StringUtils::asInt
long asInt(const std::string &s)
Definition: StringUtils.hpp:713
NavFilterMgr_T::testLNavTLMHOW
unsigned testLNavTLMHOW()
Test the TLM and HOW filter.
Definition: NavFilterMgr_T.cpp:457
NavFilterMgr_T::testProcessingDepths
unsigned testProcessingDepths()
Definition: NavFilterMgr_T.cpp:667
LNavCookFilter.hpp
BunkFilter2
Definition: NavFilterMgr_T.cpp:106
BunkFilter2::BunkFilter2
BunkFilter2()
Definition: NavFilterMgr_T.cpp:109
gnsstk::NavOrderFilter
Definition: NavOrderFilter.hpp:88
BunkFilterData::data
uint32_t * data
Definition: NavFilterMgr_T.cpp:80
gnsstk::NavFilterKey::carrier
CarrierBand carrier
carrier band of navigation message
Definition: NavFilterKey.hpp:79
gnsstk::StringUtils::word
std::string word(const std::string &s, const std::string::size_type wordNum=0, const char delimiter=' ')
Definition: StringUtils.hpp:1112
gnsstk::NavFilterMgr::rejected
FilterSet rejected
Definition: NavFilterMgr.hpp:233
gnsstk::scanTime
void scanTime(TimeTag &btime, const string &str, const string &fmt)
Definition: TimeString.cpp:93
gnsstk::LNavCrossSourceFilter
Definition: LNavCrossSourceFilter.hpp:57
const
#define const
Definition: getopt.c:43
NavFilterMgr_T::refFileBunk2
string refFileBunk2
Definition: NavFilterMgr_T.cpp:174
LNavTLMHOWFilter.hpp
NavFilterMgr_T::NavFilterMgr_T
NavFilterMgr_T()
Definition: NavFilterMgr_T.cpp:189
BunkFilter2::filterName
virtual std::string filterName() const noexcept
Definition: NavFilterMgr_T.cpp:129
TUASSERTE
#define TUASSERTE(TYPE, EXP, GOT)
Definition: TestUtil.hpp:81
gnsstk::CarrierBand
CarrierBand
Definition: CarrierBand.hpp:54
TUFAIL
#define TUFAIL(MSG)
Definition: TestUtil.hpp:228
NavFilterMgr_T::testLNavEphMaker
unsigned testLNavEphMaker()
Test the ephemeris maker.
Definition: NavFilterMgr_T.cpp:495
expLNavEphs
unsigned long expLNavEphs
Definition: NavFilterMgr_T.cpp:69
gnsstk::LNavParityFilter
Definition: LNavParityFilter.hpp:53
main
int main()
Definition: NavFilterMgr_T.cpp:800
NavFilterMgr_T::subframesBunk
vector< uint32_t > subframesBunk
"subframes" for the "bunk" test classes
Definition: NavFilterMgr_T.cpp:181
expLNavEmpty
unsigned long expLNavEmpty
Definition: NavFilterMgr_T.cpp:60
NavFilterMgr_T::testProcessingDepth
unsigned testProcessingDepth(const std::string &filterName)
Definition: NavFilterMgr_T.cpp:558
gnsstk::LNavCookFilter
Definition: LNavCookFilter.hpp:54
NavFilterMgr_T::inputFileLNAV
string inputFileLNAV
Definition: NavFilterMgr_T.cpp:172
LNavFilterData.hpp
gnsstk::NavFilterMgr::finalize
virtual NavFilter::NavMsgList finalize()
Definition: NavFilterMgr.cpp:78
NULL
#define NULL
Definition: getopt1.c:64
NavFilterMgr_T::init
void init()
Definition: NavFilterMgr_T.cpp:203
BunkFilter1
Definition: NavFilterMgr_T.cpp:83
NavFilterMgr_T::dataBunk
vector< BunkFilterData > dataBunk
Definition: NavFilterMgr_T.cpp:182
gnsstk::NavFilter::rejected
NavMsgList rejected
Definition: NavFilter.hpp:137
BunkFilter2::processingDepth
virtual unsigned processingDepth() const noexcept
Definition: NavFilterMgr_T.cpp:127
expLNavTLMHOW
unsigned long expLNavTLMHOW
Definition: NavFilterMgr_T.cpp:62
gnsstk::LNavCookFilter::processingDepth
virtual unsigned processingDepth() const noexcept
No internal storage of subframe data so return 0.
Definition: LNavCookFilter.hpp:75
gnsstk::NavFilterMgr::processingDepth
unsigned processingDepth() const noexcept
Definition: NavFilterMgr.cpp:123
NavFilterMgr_T
Definition: NavFilterMgr_T.cpp:134
gnsstk::NavOrderFilter::processingDepth
virtual unsigned processingDepth() const noexcept
Internal storage includes a user-specified number of epochs.
Definition: NavOrderFilter.hpp:115
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::NavFilterMgr
Definition: NavFilterMgr.hpp:170
gnsstk::StringUtils::x2uint
unsigned int x2uint(const std::string &s)
Definition: StringUtils.hpp:1773
BunkFilter1::finalize
virtual void finalize(NavMsgList &msgBitsOut)
Definition: NavFilterMgr_T.cpp:98
expLNavParity
unsigned long expLNavParity
Definition: NavFilterMgr_T.cpp:58
gnsstk::LNavTLMHOWFilter::processingDepth
virtual unsigned processingDepth() const noexcept
No internal storage of subframe data so return 0.
Definition: LNavTLMHOWFilter.hpp:76
LNavEphMaker.hpp
TestUtil.hpp
NavFilterMgr_T::noFilterTest
unsigned noFilterTest()
Test to make sure that with no filters, no data is removed.
Definition: NavFilterMgr_T.cpp:307
NavFilterMgr_T::testBunk2
unsigned testBunk2()
test a filter with behavior like multiple input epochs
Definition: NavFilterMgr_T.cpp:725
gnsstk::NavFilterMgr::addFilter
void addFilter(NavFilter *filt)
Definition: NavFilterMgr.cpp:50
NavFilterMgr_T::subframesLNAV
vector< uint32_t > subframesLNAV
ten for each record in the input file
Definition: NavFilterMgr_T.cpp:179
TURETURN
#define TURETURN()
Definition: TestUtil.hpp:232
NavFilterMgr_T::testLNavCook
unsigned testLNavCook()
Cook the subframes.
Definition: NavFilterMgr_T.cpp:330
LNavCrossSourceFilter.hpp
BunkFilter2::finalize
virtual void finalize(NavMsgList &msgBitsOut)
Definition: NavFilterMgr_T.cpp:121
NavFilterMgr.hpp
LNavEmptyFilter.hpp
gnsstk::NavFilter
Definition: NavFilter.hpp:55
BunkFilter1::BunkFilter1
BunkFilter1()
Definition: NavFilterMgr_T.cpp:86
NavFilterMgr_T::testLNavCombined
unsigned testLNavCombined()
Test the combination of parity, empty and TLM/HOW filters.
Definition: NavFilterMgr_T.cpp:517
BunkFilter2::validate
virtual void validate(NavMsgList &msgBitsIn, NavMsgList &msgBitsOut)
Definition: NavFilterMgr_T.cpp:110
gnsstk::CommonTime
Definition: CommonTime.hpp:84
gnsstk::LNavEmptyFilter
Definition: LNavEmptyFilter.hpp:54
NavFilterMgr_T::dataLNAV
vector< LNavFilterData > dataLNAV
one for each record in the input file
Definition: NavFilterMgr_T.cpp:177
NavFilterMgr_T::testLNavEmpty
unsigned testLNavEmpty()
Test the LNAV empty subframe filter.
Definition: NavFilterMgr_T.cpp:425
BunkFilter1::filterName
virtual std::string filterName() const noexcept
Definition: NavFilterMgr_T.cpp:102
NavFilterMgr_T::testCombinedDepths
unsigned testCombinedDepths()
Test the processingDepth() method of NavFilterMgr.
Definition: NavFilterMgr_T.cpp:623
gnsstk::NavFilterKey::prn
uint32_t prn
identifier of broadcasting satellite
Definition: NavFilterKey.hpp:78
TUDEF
#define TUDEF(CLASS, METHOD)
Definition: TestUtil.hpp:56
NavFilterMgr_T::inputFileBunk
string inputFileBunk
Definition: NavFilterMgr_T.cpp:173
BunkFilter2::cache
NavMsgList cache
Definition: NavFilterMgr_T.cpp:131
example3.data
data
Definition: example3.py:22
gnsstk::StringUtils::asUnsigned
unsigned long asUnsigned(const std::string &s)
Definition: StringUtils.hpp:721
gnsstk::TrackingCode
TrackingCode
Definition: TrackingCode.hpp:64
CommonTime.hpp
std
Definition: Angle.hpp:142
BunkFilterData
Definition: NavFilterMgr_T.cpp:74
BunkFilterData::BunkFilterData
BunkFilterData()
Definition: NavFilterMgr_T.cpp:77
gnsstk::NavFilterMgr::validate
NavFilter::NavMsgList validate(NavFilterKey *msgBits)
Definition: NavFilterMgr.cpp:57
gnsstk::NavFilterKey::code
gnsstk::TrackingCode code
ranging code of navigation message
Definition: NavFilterKey.hpp:80
gnsstk::StringUtils::firstWord
std::string firstWord(const std::string &s, const char delimiter=' ')
Definition: StringUtils.hpp:2138
NavFilterMgr_T::dataIdxLNAV
unsigned long dataIdxLNAV
Definition: NavFilterMgr_T.cpp:184
NavFilterMgr_T::refFileBunk1
string refFileBunk1
Definition: NavFilterMgr_T.cpp:174
gnsstk::LNavFilterData
Definition: LNavFilterData.hpp:52
gnsstk::NavFilter::NavMsgList
std::list< NavFilterKey * > NavMsgList
Definition: NavFilter.hpp:58
gnsstk::LNavCrossSourceFilter::processingDepth
virtual unsigned processingDepth() const noexcept
Internally stores 1 epoch's worth of subframe data.
Definition: LNavCrossSourceFilter.hpp:82
NavOrderFilter.hpp
NavFilterMgr_T::testBunk1
unsigned testBunk1()
test a simple bit pattern filter
Definition: NavFilterMgr_T.cpp:682
gnsstk::LNavEphMaker::completeEphs
EphList completeEphs
Definition: LNavEphMaker.hpp:125
gnsstk::LNavParityFilter::processingDepth
virtual unsigned processingDepth() const noexcept
No internal storage of subframe data so return 0.
Definition: LNavParityFilter.hpp:71
NavFilterMgr_T::outputFileBunk2
string outputFileBunk2
Definition: NavFilterMgr_T.cpp:175
NavFilterMgr_T::outputFileBunk1
string outputFileBunk1
Definition: NavFilterMgr_T.cpp:175
TimeSet
std::set< gnsstk::CommonTime > TimeSet
Definition: NavFilterMgr_T.cpp:71
gnsstk::LNavEphMaker
Definition: LNavEphMaker.hpp:75
expLNavCombined
unsigned long expLNavCombined
Definition: NavFilterMgr_T.cpp:65
BunkFilter1::validate
virtual void validate(NavMsgList &msgBitsIn, NavMsgList &msgBitsOut)
Definition: NavFilterMgr_T.cpp:87
NavFilterMgr_T::dataIdxBunk
unsigned long dataIdxBunk
Definition: NavFilterMgr_T.cpp:184
NavFilterMgr_T::loadData
unsigned loadData()
Definition: NavFilterMgr_T.cpp:220
TimeString.hpp
gnsstk::NavFilterKey
Definition: NavFilterKey.hpp:66
NavFilterMgr_T::testLNavParity
unsigned testLNavParity()
Test the LNAV parity filter.
Definition: NavFilterMgr_T.cpp:377
gnsstk::LNavFilterData::sf
uint32_t * sf
Definition: LNavFilterData.hpp:68
gnsstk::NavFilterKey::timeStamp
gnsstk::CommonTime timeStamp
Definition: NavFilterKey.hpp:75
BunkFilter1::processingDepth
virtual unsigned processingDepth() const noexcept
Definition: NavFilterMgr_T.cpp:100
gnsstk::LNavTLMHOWFilter
Definition: LNavTLMHOWFilter.hpp:57
LNavParityFilter.hpp


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