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


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