NavOrderFilter.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 "NavOrderFilter.hpp"
40 #include "GPSWeekZcount.hpp"
41 #include "TimeString.hpp"
42 
43 namespace gnsstk
44 {
46  NavOrderFilter(unsigned depth, unsigned epoch)
47  : procDepth(depth),
48  epochInSeconds(epoch)
49  {
50  }
51 
52 
54  validate(NavMsgList& msgBitsIn, NavMsgList& msgBitsOut)
55  {
56  NavMsgList::const_iterator nmli;
57  CommonTime oldestAllowed; // default to super old i.e. any data is ok
59  if (!orderedNav.empty())
60  {
61  SubframeSet::reverse_iterator rssi = orderedNav.rbegin();
62  CommonTime newest = (*rssi)->timeStamp;
63  oldestAllowed = newest - (epochInSeconds * procDepth);
64  }
65  for (nmli = msgBitsIn.begin(); nmli != msgBitsIn.end(); nmli++)
66  {
67  // Do not add anything that's too old. We do the checking
68  // here instead of in examineSubframes so that if the nav
69  // timestamp jumps forward more than one epoch, it doesn't
70  // cause perfectly valid nav data to be rejected.
71  if ((*nmli)->timeStamp < oldestAllowed)
72  {
73  reject(*nmli);
74  continue;
75  }
76  NavFilterKey *fd = dynamic_cast<NavFilterKey*>(*nmli);
77  orderedNav.insert(fd);
78  }
79  examineSubframes(msgBitsOut);
80  }
81 
82 
84  finalize(NavMsgList& msgBitsOut)
85  {
86  std::copy(orderedNav.begin(), orderedNav.end(),
87  std::back_inserter(msgBitsOut));
88  orderedNav.clear();
89  }
90 
91 
94  {
95  using gnsstk::printTime;
96  if (orderedNav.empty())
97  return; // nothing to do
98 
99  SubframeSet::iterator ssi, oldIt = orderedNav.end();
100  SubframeSet::reverse_iterator rssi = orderedNav.rbegin();
101  CommonTime newest = (*rssi)->timeStamp;
102  CommonTime oldestAllowed = newest - (epochInSeconds * procDepth);
103  SubframeSet::iterator oldestIt = orderedNav.begin();
104  GPSWeekZcount oldestTime = (*oldestIt)->timeStamp;
105  /*
106  std::cerr << "NavOrderFilter"
107  << " n=" << printTime(newest,"%Fw%Zz")
108  << " o=" << printTime(oldestTime,"%Fw%Zz")
109  << " oa=" << printTime(oldestAllowed,"%Fw%Zz")
110  << std::endl;
111  */
112 
113  for (ssi = orderedNav.begin(); ssi != orderedNav.end(); ssi++)
114  {
115  if ((*ssi)->timeStamp <= oldestAllowed)
116  {
117  accept(*ssi, msgBitsOut);
118  // This subframe is being accepted, so include it as
119  // one to be erased from the set when we're done.
120  oldIt = ssi;
121  }
122  else
123  {
124  // Since we're processing in time order and we've
125  // reached data newer than the oldest allowed, we don't
126  // have any more processing to do.
127  break;
128  }
129  }
130  // if oldIt is end() then we don't have anything to erase.
131  if (oldIt != orderedNav.end())
132  {
133  // erase is up to BUT NOT INCLUDING the second iterator,
134  // so increment oldIt to make sure to erase the last
135  // element we need to erase.
136  orderedNav.erase(orderedNav.begin(), ++oldIt);
137  }
138  }
139 
140 }
GPSWeekZcount.hpp
gnsstk::NavOrderFilter::orderedNav
SubframeSet orderedNav
Ordered set of nav message subframes.
Definition: NavOrderFilter.hpp:128
gnsstk::NavOrderFilter::epochInSeconds
unsigned epochInSeconds
Definition: NavOrderFilter.hpp:95
gnsstk::NavFilter::reject
void reject(NavFilterKey *data)
Definition: NavFilter.hpp:185
gnsstk::TimeSystem::Any
@ Any
wildcard; allows comparison with any other type
gnsstk::CommonTime::setTimeSystem
CommonTime & setTimeSystem(TimeSystem timeSystem)
Definition: CommonTime.hpp:195
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::NavOrderFilter::examineSubframes
void examineSubframes(NavMsgList &msgBitsOut)
Definition: NavOrderFilter.cpp:93
gnsstk::NavOrderFilter::NavOrderFilter
NavOrderFilter(unsigned depth=3, unsigned epoch=6)
Initialize internal structures and set the processing depth.
Definition: NavOrderFilter.cpp:46
gnsstk::NavOrderFilter::procDepth
unsigned procDepth
Definition: NavOrderFilter.hpp:122
gnsstk::CommonTime
Definition: CommonTime.hpp:84
example5.epoch
epoch
Definition: example5.py:24
gnsstk::NavOrderFilter::finalize
virtual void finalize(NavMsgList &msgBitsOut)
Definition: NavOrderFilter.cpp:84
gnsstk::GPSWeekZcount
Definition: GPSWeekZcount.hpp:55
example6.ssi
ssi
Definition: example6.py:124
gnsstk::printTime
std::string printTime(const CommonTime &t, const std::string &fmt)
Definition: TimeString.cpp:64
gnsstk::NavOrderFilter::validate
virtual void validate(NavMsgList &msgBitsIn, NavMsgList &msgBitsOut)
Definition: NavOrderFilter.cpp:54
gnsstk::NavFilter::NavMsgList
std::list< NavFilterKey * > NavMsgList
Definition: NavFilter.hpp:58
NavOrderFilter.hpp
gnsstk::NavFilter::accept
void accept(NavFilterKey *data, NavMsgList &msgBitsOut)
Definition: NavFilter.hpp:172
TimeString.hpp
gnsstk::NavFilterKey
Definition: NavFilterKey.hpp:66


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