1 //==============================================================================
2 //
3 //  This file is part of GPSTk, the GPS Toolkit.
4 //
5 //  The GPSTk 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 GPSTk 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 GPSTk; 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-2020, 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  /*********************************************************************
40 *
41 *  Test program for gpstk/core/lib/GNSSEph/OrbElemRinex.computeBeginValid()
42 *  and computeEndValid().
43 *  The last line of output will calculate how many tests fail.
44 *
45 *********************************************************************/
46 #include <iostream>
47 #include <cmath>
48 #include <string>
49 
50 #include "CommonTime.hpp"
51 #include "CivilTime.hpp"
52 #include "GNSSconstants.hpp"
53 #include "SatID.hpp"
54 #include "TimeString.hpp"
55 
56 #include "TestUtil.hpp"
57 
58 #include "OrbElemRinex.hpp"
59 
60 using namespace gpstk;
61 
main()62 int main()
63 {
64    TUDEF( "OrbElemLNav_valid", "" );
65 
66    /***********************************************/
67    //  Test a variety of hand-picked cases to verify that
68    //  the beginning of validity time and end of
69    //  validity time are being correctly
70    //  determined.  This bacame more challenging with GPS III
71    //  and it is anticiapted that the list of test cases will
72    //  expand over time and with experience.
73    //
74    testFramework.changeSourceMethod( "compute(Begin|End)Valid" );
75 
76    int fitHours = 4;
77 
78    SatID gpsSatId = SatID(1,SatelliteSystem::GPS);
79    SatID qzsSatId = SatID(MIN_PRN_QZS,SatelliteSystem::QZSS);
80 
81       // Data set cutover without upload cutover.
82    CommonTime xmit = CivilTime(2019, 1, 11, 2, 0, 0.0, TimeSystem::GPS);
83    CommonTime toe = CivilTime(2019, 1, 11, 4, 00, 0.0, TimeSystem::GPS);
84    CommonTime result = OrbElemRinex::computeBeginValid(gpsSatId,xmit,toe);
85    TUASSERTE( CommonTime, xmit, result );
86 
87    result = OrbElemRinex::computeBeginValid(qzsSatId,xmit,toe);
88    TUASSERTE( CommonTime, xmit, result );
89 
90    CommonTime endValid = toe + OrbElemRinex::TWO_HOURS;
91    result = OrbElemRinex::computeEndValid(toe, fitHours);
92    TUASSERTE( CommonTime, endValid, result );
93 
94       // Data set cutover without upload cutover, late receipt
95    xmit = CivilTime(2019, 1, 11, 2, 12, 0.0, TimeSystem::GPS);
96    toe = CivilTime(2019, 1, 11, 4, 00, 0.0, TimeSystem::GPS);
97    CommonTime expect = CivilTime(2019, 1, 11, 2, 0, 0.0, TimeSystem::GPS);
98    result = OrbElemRinex::computeBeginValid(gpsSatId,xmit,toe);
99    TUASSERTE( CommonTime, expect, result );
100 
101    result = OrbElemRinex::computeBeginValid(qzsSatId,xmit,toe);
102    TUASSERTE( CommonTime, xmit, result );
103 
104       // Upload cutover.  Example from prior to GPS III
105    xmit = CivilTime(2019, 1, 11, 2, 36, 0.0, TimeSystem::GPS);
106    toe = CivilTime(2019, 1, 11, 3, 59, 44.0, TimeSystem::GPS);
107    result = OrbElemRinex::computeBeginValid(gpsSatId,xmit,toe);
108    TUASSERTE( CommonTime, xmit, result );
109 
110    result = OrbElemRinex::computeBeginValid(qzsSatId,xmit,toe);
111    TUASSERTE( CommonTime, xmit, result );
112 
113    endValid = toe + OrbElemRinex::TWO_HOURS + OrbElemRinex::SIXTEEN_SECONDS;
114    result = OrbElemRinex::computeEndValid(toe, fitHours);
115    TUASSERTE( CommonTime, endValid, result );
116 
117       // Upload cutover.  Example from early GPS III L1 C/A
118    xmit = CivilTime(2019, 1, 9, 22, 30, 00.0, TimeSystem::GPS);
119    toe = CivilTime(2019, 1, 10,  0, 29, 36.0, TimeSystem::GPS);
120    result = OrbElemRinex::computeBeginValid(gpsSatId,xmit,toe);
121    TUASSERTE( CommonTime, xmit, result );
122 
123    endValid = CivilTime(2019, 1, 10,  2, 30, 0.0, TimeSystem::GPS);
124    result = OrbElemRinex::computeEndValid(toe, fitHours);
125    TUASSERTE( CommonTime, endValid, result );
126 
127       // Upload cutover.  Example from GPS III presentation
128       // by Steven Brown (L-M) to 2018 Public ICWG
129    xmit = CivilTime(2019, 1, 12, 1, 01, 0.0, TimeSystem::GPS);
130    toe = CivilTime(2019, 1, 12, 2, 59, 44.0, TimeSystem::GPS);
131    result = OrbElemRinex::computeBeginValid(gpsSatId,xmit,toe);
132    TUASSERTE( CommonTime, xmit, result );
133 
134    endValid = CivilTime(2019, 1,12, 5, 0, 0.0, TimeSystem::GPS);
135    result = OrbElemRinex::computeEndValid(toe, fitHours);
136    TUASSERTE( CommonTime, endValid, result );
137 
138    xmit = CivilTime(2019, 1, 12, 1, 16, 0.0, TimeSystem::GPS);
139    result = OrbElemRinex::computeBeginValid(gpsSatId,xmit,toe);
140    TUASSERTE( CommonTime, xmit, result );
141 
142    result = OrbElemRinex::computeEndValid(toe, fitHours);
143    TUASSERTE( CommonTime, endValid, result );
144 
145       //  2
146    xmit = CivilTime(2019, 1, 12, 1, 31, 0.0, TimeSystem::GPS);
147    result = OrbElemRinex::computeBeginValid(gpsSatId,xmit,toe);
148    TUASSERTE( CommonTime, xmit, result );
149 
150    result = OrbElemRinex::computeEndValid(toe, fitHours);
151    TUASSERTE( CommonTime, endValid, result );
152 
153       //  3
154    xmit = CivilTime(2019, 1, 12, 1, 46, 0.0, TimeSystem::GPS);
155    result = OrbElemRinex::computeBeginValid(gpsSatId,xmit,toe);
156    TUASSERTE( CommonTime, xmit, result );
157 
158    result = OrbElemRinex::computeEndValid(toe, fitHours);
159    TUASSERTE( CommonTime, endValid, result );
160 
161    std::cerr << "Ending program." << std::endl;
162    std::cout << "Total Failures for " << __FILE__ << ": "
163              << testFramework.countFails() << std::endl;
164 
165    return testFramework.countFails();
166 
167 }
168 
169