00001 #pragma ident "$Id: Synchronize.cpp 3140 2012-06-18 15:03:02Z susancummins $"
00002
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "Synchronize.hpp"
00032
00033
00034 namespace gpstk
00035 {
00036
00037
00038 std::string Synchronize::getClassName() const
00039 { return "Synchronize"; }
00040
00041
00042
00043
00044
00045
00046
00047 Synchronize& Synchronize::setTolerance(const double tol)
00048 {
00049
00050
00051 if( tol >= 0.0 )
00052 {
00053 tolerance = tol;
00054 }
00055
00056 return (*this);
00057
00058 }
00059
00060
00061
00062
00063
00064
00065
00066
00067 gnssRinex& Synchronize::Process(gnssRinex& gData)
00068 throw(SynchronizeException)
00069 {
00070 CommonTime time = dynamic_cast<gnssRinex*>(pgRov1)->header.epoch;
00071 Process(time,gData);
00072
00073 return gData;
00074
00075 }
00076
00077
00078
00079
00080
00081
00082
00083
00084 gnssSatTypeValue& Synchronize::Process(gnssSatTypeValue& gData)
00085 throw(SynchronizeException)
00086 {
00087 CommonTime time(pgRov1->header.epoch);
00088
00089 gnssRinex gRin;
00090 Process(time,gRin);
00091
00092 gData.header = gRin.header;
00093 gData.body = gRin.body;
00094
00095 return gData;
00096
00097 }
00098
00099
00100 gnssRinex& Synchronize::Process(CommonTime time, gnssRinex& gData)
00101 throw(SynchronizeException)
00102 {
00103
00104 if (firstTime)
00105 {
00106 (*pRinexRef) >> gData;
00107
00108 gnssRinexBuffer.clear();
00109 gnssRinexBuffer.push_back(gData);
00110
00111 firstTime = false;
00112 }
00113
00114 gData = gnssRinexBuffer.front();
00115
00116 if( (gData.header.epoch > time) &&
00117 (std::abs( gData.header.epoch - time ) > tolerance ))
00118 {
00119
00120 SynchronizeException e( "Unable to synchronize data at epoch "
00121 + time.asString() );
00122 GPSTK_THROW(e);
00123 }
00124
00125
00126
00127
00128
00129
00130 while ( ( gData.header.epoch < time ) &&
00131 (std::abs( gData.header.epoch - time ) > tolerance ) )
00132 {
00133 (*pRinexRef) >> gData;
00134 }
00135
00136
00137
00138
00139 if ( std::abs( gData.header.epoch - time ) > tolerance )
00140 {
00141
00142 SynchronizeException e( "Unable to synchronize data at epoch "
00143 + time.asString() );
00144 GPSTK_THROW(e);
00145 }
00146
00147
00148 return gData;
00149 }
00150
00151 }