00001 #pragma ident "$Id: Synchronize.cpp 2584 2011-05-04 01:58:57Z yanweignss $"
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 int Synchronize::classIndex = 8100000;
00039
00040
00041
00042 int Synchronize::getIndex(void) const
00043 { return index; }
00044
00045
00046
00047 std::string Synchronize::getClassName() const
00048 { return "Synchronize"; }
00049
00050
00051
00052
00053
00054
00055
00056 Synchronize& Synchronize::setTolerance(const double tol)
00057 {
00058
00059
00060 if( tol >= 0.0 )
00061 {
00062 tolerance = tol;
00063 }
00064
00065 return (*this);
00066
00067 }
00068
00069
00070
00071
00072
00073
00074
00075
00076 gnssRinex& Synchronize::Process(gnssRinex& gData)
00077 throw(SynchronizeException)
00078 {
00079 DayTime time = dynamic_cast<gnssRinex*>(pgRov1)->header.epoch;
00080 Process(time,gData);
00081
00082 return gData;
00083
00084 }
00085
00086
00087
00088
00089
00090
00091
00092
00093 gnssSatTypeValue& Synchronize::Process(gnssSatTypeValue& gData)
00094 throw(SynchronizeException)
00095 {
00096 DayTime time(pgRov1->header.epoch);
00097
00098 gnssRinex gRin;
00099 Process(time,gRin);
00100
00101 gData.header = gRin.header;
00102 gData.body = gRin.body;
00103
00104 return gData;
00105
00106 }
00107
00108
00109 gnssRinex& Synchronize::Process(DayTime time, gnssRinex& gData)
00110 throw(SynchronizeException)
00111 {
00112
00113 if (firstTime)
00114 {
00115 (*pRinexRef) >> gData;
00116
00117 gnssRinexBuffer.clear();
00118 gnssRinexBuffer.push_back(gData);
00119
00120 firstTime = false;
00121 }
00122
00123 gData = gnssRinexBuffer.front();
00124
00125 if( (gData.header.epoch > time) &&
00126 (std::abs( gData.header.epoch - time ) > tolerance ))
00127 {
00128
00129 SynchronizeException e( "Unable to synchronize data at epoch "
00130 + time.asString() );
00131 GPSTK_THROW(e);
00132 }
00133
00134
00135
00136
00137
00138
00139 while ( ( gData.header.epoch < time ) &&
00140 (std::abs( gData.header.epoch - time ) > tolerance ) )
00141 {
00142 (*pRinexRef) >> gData;
00143 }
00144
00145
00146
00147
00148 if ( std::abs( gData.header.epoch - time ) > tolerance )
00149 {
00150
00151 SynchronizeException e( "Unable to synchronize data at epoch "
00152 + time.asString() );
00153 GPSTK_THROW(e);
00154 }
00155
00156
00157 return gData;
00158 }
00159
00160
00161 }