00001 #pragma ident "$Id: EngNav.cpp 876 2007-11-06 14:16:30Z renfroba $"
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00051 #include <cstdlib>
00052 #include <iostream>
00053 #include <cmath>
00054 #include "EngNav.hpp"
00055 #include "icd_200_constants.hpp"
00056
00057 #ifdef _MSC_VER
00058 #define LDEXP(x,y) ldexp(x,y)
00059 #else
00060 #define LDEXP(x,y) std::ldexp(x,y)
00061 #endif
00062
00063 namespace gpstk
00064 {
00066 struct DecodeBits
00067 {
00068 short startBit;
00069 short numBits;
00070 };
00071
00075 struct DecodeQuant
00076 {
00077 short outIndex;
00078 short pow2;
00079 short powPI;
00080 double scale;
00081 short signq;
00082 DecodeBits fmt[2];
00083 DecodeQuant *nxtq;
00084 };
00085
00088 static DecodeQuant *subframeList[11];
00089
00091 static double PItab[7] = {0,0,0,0,0,0,0};
00092
00093 static DecodeQuant formats[] = {
00094 { 0, 0, 0, 1.0L, 0,{ { 1, 8} , { 0, 0} }, 0 },
00095 { 1, 0, 0, 1.0L, 0,{ { 9, 14}, { 0, 0} }, 0 },
00096 { 2, 0, 0, 6.0L, 0,{ { 31,17}, { 0, 0} }, 0 },
00097 { 3, 0, 0, 1.0L, 0,{ { 48, 2}, { 0, 0} }, 0 },
00098 { 4, 0, 0, 1.0L, 0,{ { 50, 3}, { 0, 0} }, 0 },
00099 { 5, 0, 0, 1.0L, 0,{ { 61, 10},{ 0, 0} }, 0 },
00100 { 6, 0, 0, 1.0L, 0,{ { 71, 2},{ 0, 0} }, 0},
00101 { 7, 0, 0, 1.0L, 0,{ { 73, 4},{ 0, 0} }, 0},
00102 { 8, 0, 0, 1.0L, 0,{ { 77, 6},{ 0, 0} }, 0},
00103 { 9, 11, 0, 1.0L, 0,{ { 83, 2},{ 211,8}}, 0},
00104 { 10, 0, 0, 1.0L, 0,{ { 91, 1},{ 0, 0}}, 0},
00105 { 11, -31, 0, 1.0L, 1,{ {197, 8},{ 0, 0}}, 0},
00106 { 12, 4, 0, 1.0L, 0,{ {219, 16},{ 0, 0}}, 0},
00107 { 13, -55, 0, 1.0L, 1,{ {241, 8},{ 0, 0}}, 0},
00108 { 14, -43, 0, 1.0L, 1,{ {249, 16},{ 0, 0}}, 0},
00109 { 15, -31, 0, 1.0L, 1,{ {271, 22}, {0, 0}}, 0},
00110
00111 {0, 0, 0, 1.0L, 0,{ { 1 , 8}, {0, 0 }}, 0 },
00112 {1, 0, 0, 1.0L, 0,{ { 9, 14}, { 0, 0 }}, 0 },
00113 {2, 0, 0, 6.0L, 0,{ { 31,17}, { 0, 0 }}, 0 },
00114 {3, 0, 0, 1.0L, 0,{ { 48, 2}, { 0, 0 }}, 0 },
00115 {4, 0, 0, 1.0L, 0,{ { 50, 3}, { 0, 0 }}, 0 },
00116 {5, 11, 0, 1.0L, 0,{ { 61, 8 }, { 0, 0 }}, 0 },
00117 {6, -5, 0, 1.0L, 1,{ { 69, 16 }, { 0, 0 }}, 0 },
00118 {7, -43, 1, 1.0L, 1,{ { 91,16 }, { 0, 0 }}, 0 },
00119 {8, -31, 1, 1.0L, 1,{ { 107, 8 }, {121,24 }}, 0 },
00120 {9, -29, 0, 1.0L, 1,{ { 151, 16}, { 0, 0 }}, 0},
00121 {10, -33, 0, 1.0L, 0,{ { 167, 8}, {181,24 }}, 0},
00122 {11, -29, 0, 1.0L, 1,{ { 211,16}, { 0, 0 }}, 0},
00123 {12, -19, 0, 1.0L, 0,{ { 227, 8}, {241, 24 }}, 0},
00124 {13, 4, 0, 1.0L, 0,{ { 271,16}, { 0, 0 }}, 0},
00125 {14, 0, 0, 1.0L, 0,{ { 287, 1}, { 0, 0 }}, 0},
00126 {15, 0, 0, 900.0L, 0,{ { 288, 5}, { 0, 0 }}, 0},
00127
00128 {0, 0, 0, 1.0L, 0,{ { 1, 8}, { 0, 0 }}, 0},
00129 {1, 0, 0, 1.0L, 0,{ { 9, 14}, { 0, 0 }}, 0},
00130 {2, 0, 0, 6.0L, 0,{ { 31,17}, { 0, 0 }}, 0},
00131 {3, 0, 0, 1.0L, 0,{ { 48, 2}, { 0, 0 }}, 0},
00132 {4, 0, 0, 1.0L, 0,{ { 50, 3}, { 0, 0 }}, 0},
00133 {5, -29, 0, 1.0L, 1,{ { 61,16}, { 0, 0 }}, 0},
00134 {6, -31, 1, 1.0L, 1,{ { 77,8}, { 91, 24}}, 0},
00135 {7, -29, 0, 1.0L, 1,{ { 121,16}, { 0, 0 }}, 0},
00136 {8, -31, 1, 1.0L, 1,{ { 137, 8}, {151, 24}}, 0},
00137 {9, -5, 0, 1.0L, 1,{ { 181,16}, { 0, 0 }}, 0},
00138 {10, -31, 1, 1.0L, 1,{ { 197, 8}, {211, 24}}, 0},
00139 {11, -43, 1, 1.0L, 1,{ { 241,24}, { 0, 0 }}, 0},
00140 {12, 11, 0, 1.0L, 0,{ { 271, 8}, { 0, 0 }}, 0},
00141 {13, -43, 1, 1.0L, 1,{ { 279,14}, { 0, 0 }}, 0},
00142
00143 {0, 0, 0, 1.0L, 0,{ { 1, 8}, { 0, 0}}, 0 },
00144 {1, 0, 0, 1.0L, 0,{ { 9, 14}, { 0, 0}}, 0},
00145 {2, 0, 0, 6.0L, 0,{ { 31,17}, { 0, 0}}, 0},
00146 {3, 0, 0, 1.0L, 0,{ { 48, 2}, { 0, 0}}, 0},
00147 {4, 0, 0, 1.0L, 0,{ { 50, 3}, { 0, 0}}, 0},
00148 {5, 0, 0, 1.0L, 0,{ { 61, 2}, { 0, 0}}, 0},
00149 {6, 0, 0, 1.0L, 0,{ { 63, 6}, { 0, 0}}, 0},
00150 {7, -21, 0, 1.0L, 0,{ { 69,16}, { 0, 0}}, 0},
00151 {8, 12, 0, 1.0L, 0,{ { 91, 8}, { 0, 0}}, 0},
00152 {9, -19, 1, 1.0L, 1,{ { 99,16}, { 0, 0}}, 0},
00153 {10, -38, 1, 1.0L, 1,{ {121,16}, { 0, 0}}, 0},
00154 {11, 0, 0, 1.0L, 0,{ {137, 8}, { 0, 0}}, 0},
00155 {12, -11, 0, 1.0L, 0,{ {151,24}, { 0, 0}}, 0},
00156 {13, -23, 1, 1.0L, 1,{ {181,24}, { 0, 0}}, 0},
00157 {14, -23, 1, 1.0L, 1,{ {211,24}, { 0, 0}}, 0},
00158 {15, -23, 1, 1.0L, 1,{ {241,24}, { 0, 0}}, 0},
00159 {16, -20, 0, 1.0L, 1,{ {271, 8}, {290, 3}}, 0},
00160 {17, -38, 0, 1.0L, 1,{ {279,11}, { 0, 0}}, 0},
00161 {18, 0, 0, 1.0L, 0,{ { 0, 0}, { 0, 0}}, 0},
00162 {19, 0, 0, 1.0L, 0,{ { 63, 6}, { 0, 0}}, 0},
00163
00164
00165 {0, 0, 0, 1.0L, 0,{ { 1, 8}, { 0, 0}}, 0},
00166 {1, 0, 0, 1.0L, 0,{ { 9, 14}, { 0, 0}}, 0},
00167 {2, 0, 0, 6.0L, 0,{ {31, 17}, { 0, 0}}, 0},
00168 {3, 0, 0, 1.0L, 0,{ {48, 2}, { 0, 0}}, 0},
00169 {4, 0, 0, 1.0L, 0,{ {50, 3}, { 0, 0}}, 0},
00170 {5, 0, 0, 1.0L, 0,{ { 61, 2}, { 0, 0}}, 0},
00171 {6, 0, 0, 1.0L, 0,{ { 63, 6}, { 0, 0}}, 0},
00172 {7, 0, 0, 1.0L, 0,{ { 77, 8}, { 0, 0}}, 0},
00173 {8, 0, 0, 1.0L, 0,{ { 91, 6}, { 0, 0}}, 0},
00174 {9, 0, 0, 1.0L, 0,{ { 97, 6}, { 0, 0}}, 0},
00175 {10, 0, 0, 1.0L, 0,{ { 103,6}, { 0, 0}}, 0},
00176 {11, 0, 0, 1.0L, 0,{ { 109,6}, { 0, 0}}, 0},
00177 {12, 0, 0, 1.0L, 0,{ { 121,6}, { 0, 0}}, 0},
00178 {13, 0, 0, 1.0L, 0,{ { 127,6}, { 0, 0}}, 0},
00179 {14, 0, 0, 1.0L, 0,{ { 133,6}, { 0, 0}}, 0},
00180 {15, 0, 0, 1.0L, 0,{ { 139,6}, { 0, 0}}, 0},
00181 {16, 0, 0, 1.0L, 0,{ { 151,6}, { 0, 0}}, 0},
00182 {17, 0, 0, 1.0L, 0,{ { 157,6}, { 0, 0}}, 0},
00183 {18, 0, 0, 1.0L, 0,{ { 163,6}, { 0, 0}}, 0},
00184 {19, 0, 0, 1.0L, 0,{ { 169,6}, { 0, 0}}, 0},
00185 {20, 0, 0, 1.0L, 0,{ { 181,6}, { 0, 0}}, 0},
00186 {21, 0, 0, 1.0L, 0,{ { 187,6}, { 0, 0}}, 0},
00187 {22, 0, 0, 1.0L, 0,{ { 193,6}, { 0, 0}}, 0},
00188 {23, 0, 0, 1.0L, 0,{ { 199,6}, { 0, 0}}, 0},
00189 {24, 0, 0, 1.0L, 0,{ { 211,6}, { 0, 0}}, 0},
00190 {25, 0, 0, 1.0L, 0,{ { 217,6}, { 0, 0}}, 0},
00191 {26, 0, 0, 1.0L, 0,{ { 223,6}, { 0, 0}}, 0},
00192 {27, 0, 0, 1.0L, 0,{ { 229,6}, { 0, 0}}, 0},
00193 {28, 0, 0, 1.0L, 0,{ { 241,6}, { 0, 0}}, 0},
00194 {29, 0, 0, 1.0L, 0,{ { 247,6}, { 0, 0}}, 0},
00195 {30, 0, 0, 1.0L, 0,{ { 253,6}, { 0, 0}}, 0},
00196 {31, 0, 0, 1.0L, 0,{ { 259,6}, { 0, 0}}, 0},
00197
00198 {0, 0, 0, 1.0L, 0, { { 1, 8},{ 0, 0}}, 0},
00199 {1, 0, 0, 1.0L, 0, { { 9, 14},{ 0, 0}}, 0},
00200 {2, 0, 0, 6.0L, 0, { { 31, 17},{ 0, 0}}, 0},
00201 {3, 0, 0, 1.0L, 0, { { 48, 2},{ 0, 0}}, 0},
00202 {4, 0, 0, 1.0L, 0, { { 50, 3},{ 0, 0}}, 0},
00203 {5, 0, 0, 1.0L, 0, { { 61, 2},{ 0, 0}}, 0},
00204 {6, 0, 0, 1.0L, 0, { { 63, 6},{ 0, 0}}, 0},
00205 {7, 0, 0, 1.0L, 0, { { 69, 16},{ 0, 0}}, 0},
00206 {8, 0, 0, 1.0L, 0, { { 91, 24},{ 0, 0}}, 0},
00207 {9, 0, 0, 1.0L, 0, { { 121, 24},{ 0, 0}}, 0},
00208 {10, 0, 0, 1.0L, 0, { { 151, 24},{ 0, 0}}, 0},
00209 {11, 0, 0, 1.0L, 0, { { 181, 24},{ 0, 0}}, 0},
00210 {12, 0, 0, 1.0L, 0, { { 211, 24},{ 0, 0}}, 0},
00211 {13, 0, 0, 1.0L, 0, { { 241, 8},{ 0, 0}}, 0},
00212 {14, 0, 0, 1.0L, 0, { { 249,16},{ 0, 0}}, 0},
00213
00214 {0, 0, 0, 1.0L, 0, { { 1, 8}, { 0, 0} }, 0},
00215 {1, 0, 0, 1.0L, 0, { { 9, 14}, { 0, 0} }, 0},
00216 {2, 0, 0, 6.0L, 0, { { 31, 17}, { 0, 0} }, 0},
00217 {3, 0, 0, 1.0L, 0, { { 48, 2}, { 0, 0} }, 0},
00218 {4, 0, 0, 1.0L, 0, { { 50, 3}, { 0, 0} }, 0},
00219 {5, 0, 0, 1.0L, 0, { { 61, 2}, { 0, 0} }, 0},
00220 {6, 0, 0, 1.0L, 0, { { 63, 6}, { 0, 0} }, 0},
00221 {7, 0, 0, 1.0L, 0, { { 69, 16}, { 0, 0} }, 0},
00222 {8, 0, 0, 1.0L, 0, { { 91, 24}, { 0, 0} }, 0},
00223 {9, 0, 0, 1.0L, 0, { {121, 24}, { 0, 0} }, 0},
00224 {10, 0, 0, 1.0L, 0, { {151, 24}, { 0, 0} }, 0},
00225 {11, 0, 0, 1.0L, 0, { {181, 24}, { 0, 0} }, 0},
00226 {12, 0, 0, 1.0L, 0, { {211, 24}, { 0, 0} }, 0},
00227 {13, 0, 0, 1.0L, 0, { {241, 8}, { 0, 0} }, 0},
00228 {14, 0, 0, 1.0L, 0, { {249, 16}, { 0, 0} }, 0},
00229
00230 {0, 0, 0, 1.0L, 0,{ { 1, 8},{ 0, 0}}, 0},
00231 {1, 0, 0, 1.0L, 0,{ { 9, 14},{ 0, 0}}, 0},
00232 {2, 0, 0, 6.0L, 0,{ { 31, 17},{ 0, 0}}, 0},
00233 {3, 0, 0, 1.0L, 0,{ { 48, 2},{ 0, 0}}, 0},
00234 {4, 0, 0, 1.0L, 0,{ { 50, 3},{ 0, 0}}, 0},
00235 {5, 0, 0, 1.0L, 0,{ { 61, 2},{ 0, 0}}, 0},
00236 {6, 0, 0, 1.0L, 0,{ { 63, 6},{ 0, 0}}, 0},
00237 {7, -30, 0, 1.0L, 1,{ { 69, 8},{ 0, 0}}, 0},
00238 {8, -27, -1, 1.0L, 1,{ { 77, 8},{ 0, 0}}, 0},
00239 {9, -24, -2, 1.0L, 1,{ { 91, 8},{ 0, 0}}, 0},
00240 {10, -24, -3, 1.0L, 1,{ { 99, 8},{ 0, 0}}, 0},
00241 {11, 11, 0, 1.0L, 1,{ { 107, 8},{ 0, 0}}, 0},
00242 {12, 14, -1, 1.0L, 1,{ { 121, 8},{ 0, 0}}, 0},
00243 {13, 16, -2, 1.0L, 1,{ { 129, 8},{ 0, 0}}, 0},
00244 {14, 16, -3, 1.0L, 1,{ { 137, 8},{ 0, 0}}, 0},
00245 {15, -30, 0, 1.0L, 1,{ { 181,24},{211, 8}}, 0},
00246 {16, -50, 0, 1.0L, 1,{ { 151,24},{ 0, 0}}, 0},
00247 {17, 12, 0, 1.0L, 0,{ { 219, 8},{ 0, 0}}, 0},
00248 {18, 0, 0, 1.0L, 0,{ { 227, 8},{ 0, 0}}, 0},
00249 {19, 0, 0, 1.0L, 1,{ { 241, 8},{ 0, 0}}, 0},
00250 {20, 0, 0, 1.0L, 0,{ { 249, 8},{ 0, 0}}, 0},
00251 {21, 0, 0, 1.0L, 0,{ { 257, 8},{ 0, 0}}, 0},
00252 {22, 0, 0, 1.0L, 1,{ { 271, 8},{ 0, 0}}, 0},
00253
00254 {0, 0, 0, 1.0L, 0, { { 1, 8}, { 0, 0}}, 0},
00255 {1, 0, 0, 1.0L, 0, { { 9, 14}, { 0, 0}}, 0},
00256 {2, 0, 0, 6.0L, 0, { { 31, 17}, { 0, 0}}, 0},
00257 {3, 0, 0, 1.0L, 0, { { 48, 2}, { 0, 0}}, 0},
00258 {4, 0, 0, 1.0L, 0, { { 50, 3}, { 0, 0}}, 0},
00259 {5, 0, 0, 1.0L, 0, { { 61, 2}, { 0, 0}}, 0},
00260 {6, 0, 0, 1.0L, 0, { { 63, 6}, { 0, 0}}, 0},
00261 {7, 0, 0, 1.0L, 0, { { 69, 4}, { 0, 0}}, 0},
00262 {8, 0, 0, 1.0L, 0, { { 73, 4}, { 0, 0}}, 0},
00263 {9, 0, 0, 1.0L, 0, { { 77, 4}, { 0, 0}}, 0},
00264 {10, 0, 0, 1.0L, 0, { { 81, 4}, { 0, 0}}, 0},
00265 {11, 0, 0, 1.0L, 0, { { 91, 4}, { 0, 0}}, 0},
00266 {12, 0, 0, 1.0L, 0, { { 95, 4}, { 0, 0}}, 0},
00267 {13, 0, 0, 1.0L, 0, { { 99, 4}, { 0, 0}}, 0},
00268 {14, 0, 0, 1.0L, 0, { { 103, 4}, { 0, 0}}, 0},
00269 {15, 0, 0, 1.0L, 0, { { 107, 4}, { 0, 0}}, 0},
00270 {16, 0, 0, 1.0L, 0, { { 111, 4}, { 0, 0}}, 0},
00271 {17, 0, 0, 1.0L, 0, { { 121, 4}, { 0, 0}}, 0},
00272 {18, 0, 0, 1.0L, 0, { { 125, 4}, { 0, 0}}, 0},
00273 {19, 0, 0, 1.0L, 0, { { 129, 4}, { 0, 0}}, 0},
00274 {20, 0, 0, 1.0L, 0, { { 133, 4}, { 0, 0}}, 0},
00275 {21, 0, 0, 1.0L, 0, { { 137, 4}, { 0, 0}}, 0},
00276 {22, 0, 0, 1.0L, 0, { { 141, 4}, { 0, 0}}, 0},
00277 {23, 0, 0, 1.0L, 0, { { 151, 4}, { 0, 0}}, 0},
00278 {24, 0, 0, 1.0L, 0, { { 155, 4}, { 0, 0}}, 0},
00279 {25, 0, 0, 1.0L, 0, { { 159, 4}, { 0, 0}}, 0},
00280 {26, 0, 0, 1.0L, 0, { { 163, 4}, { 0, 0}}, 0},
00281 {27, 0, 0, 1.0L, 0, { { 167, 4}, { 0, 0}}, 0},
00282 {28, 0, 0, 1.0L, 0, { { 171, 4}, { 0, 0}}, 0},
00283 {29, 0, 0, 1.0L, 0, { { 181, 4}, { 0, 0}}, 0},
00284 {30, 0, 0, 1.0L, 0, { { 185, 4}, { 0, 0}}, 0},
00285 {31, 0, 0, 1.0L, 0, { { 189, 4}, { 0, 0}}, 0},
00286 {32, 0, 0, 1.0L, 0, { { 193, 4}, { 0, 0}}, 0},
00287 {33, 0, 0, 1.0L, 0, { { 197, 4}, { 0, 0}}, 0},
00288 {34, 0, 0, 1.0L, 0, { { 201, 4}, { 0, 0}}, 0},
00289 {35, 0, 0, 1.0L, 0, { { 211, 4}, { 0, 0}}, 0},
00290 {36, 0, 0, 1.0L, 0, { { 215, 4}, { 0, 0}}, 0},
00291 {37, 0, 0, 1.0L, 0, { { 219, 4}, { 0, 0}}, 0},
00292 {38, 0, 0, 1.0L, 0, { { 223, 4}, { 0, 0}}, 0},
00293 {39, 0, 0, 1.0L, 0, { { 229, 6}, { 0, 0}}, 0},
00294 {40, 0, 0, 1.0L, 0, { { 241, 6}, { 0, 0}}, 0},
00295 {41, 0, 0, 1.0L, 0, { { 247, 6}, { 0, 0}}, 0},
00296 {42, 0, 0, 1.0L, 0, { { 253, 6}, { 0, 0}}, 0},
00297 {43, 0, 0, 1.0L, 0, { { 259, 6}, { 0, 0}}, 0},
00298 {44, 0, 0, 1.0L, 0, { { 271, 6}, { 0, 0}}, 0},
00299 {45, 0, 0, 1.0L, 0, { { 277, 6}, { 0, 0}}, 0},
00300 {46, 0, 0, 1.0L, 0, { { 283, 6}, { 0, 0}}, 0},
00301
00302 {0, 0, 0, 1.0L, 0,{ { 1, 8}, { 0, 0}}, 0},
00303 {1, 0, 0, 1.0L, 0,{ { 9, 14}, { 0, 0}}, 0},
00304 {2, 0, 0, 6.0L, 0,{ { 31, 17}, { 0, 0}}, 0},
00305 {3, 0, 0, 1.0L, 0,{ { 48, 2}, { 0, 0}}, 0},
00306 {4, 0, 0, 1.0L, 0,{ { 50, 3}, { 0, 0}}, 0},
00307 {5, 0, 0, 1.0L, 0,{ { 61, 2}, { 0, 0}}, 0},
00308 {6, 0, 0, 1.0L, 0,{ { 63, 6}, { 0, 0}}, 0},
00309 {7, 0, 0, 1.0L, 0,{ { 69, 8}, { 0, 0}}, 0},
00310 {8, 0, 0, 1.0L, 0,{ { 77, 8}, { 0, 0}}, 0},
00311 {9, 0, 0, 1.0L, 0,{ { 91, 8}, { 0, 0}}, 0},
00312 {10, 0, 0, 1.0L, 0,{ { 99, 8}, { 0, 0}}, 0},
00313 {11, 0, 0, 1.0L, 0,{ { 107, 8}, { 0, 0}}, 0},
00314 {12, 0, 0, 1.0L, 0,{ { 121, 8}, { 0, 0}}, 0},
00315 {13, 0, 0, 1.0L, 0,{ { 129, 8}, { 0, 0}}, 0},
00316 {14, 0, 0, 1.0L, 0,{ { 137, 8}, { 0, 0}}, 0},
00317 {15, 0, 0, 1.0L, 0,{ { 151, 8}, { 0, 0}}, 0},
00318 {16, 0, 0, 1.0L, 0,{ { 159, 8}, { 0, 0}}, 0},
00319 {17, 0, 0, 1.0L, 0,{ { 167, 8}, { 0, 0}}, 0},
00320 {18, 0, 0, 1.0L, 0,{ { 181, 8}, { 0, 0}}, 0},
00321 {19, 0, 0, 1.0L, 0,{ { 189, 8}, { 0, 0}}, 0},
00322 {20, 0, 0, 1.0L, 0,{ { 197, 8}, { 0, 0}}, 0},
00323 {21, 0, 0, 1.0L, 0,{ { 211, 8}, { 0, 0}}, 0},
00324 {22, 0, 0, 1.0L, 0,{ { 219, 8}, { 0, 0}}, 0},
00325 {23, 0, 0, 1.0L, 0,{ { 227, 8}, { 0, 0}}, 0},
00326 {24, 0, 0, 1.0L, 0,{ { 241, 8}, { 0, 0}}, 0},
00327 {25, 0, 0, 1.0L, 0,{ { 249, 8}, { 0, 0}}, 0},
00328 {26, 0, 0, 1.0L, 0,{ { 257, 8}, { 0, 0}}, 0},
00329 {27, 0, 0, 1.0L, 0,{ { 271, 8}, { 0, 0}}, 0},
00330 {28, 0, 0, 1.0L, 0,{ { 279, 8}, { 0, 0}}, 0},
00331
00332 {0, 0, 0, 1.0L, 0,{{ 0, 0}, { 0, 0}}, 0}
00333 };
00334
00335
00336 EngNav::EngNav()
00337 throw()
00338 {
00339 short i=0, n=0;
00340 static short initialized = 0;
00341
00342 if (initialized)
00343 return;
00344
00345
00346 for (i=1; i<=10; i++)
00347 {
00348 subframeList[i] = &formats[n];
00349 while (formats[n+1].outIndex != 0)
00350 {
00351 formats[n].nxtq = &formats[n+1];
00352 n++;
00353 }
00354 formats[n].nxtq = NULL;
00355 n++;
00356 }
00357
00358
00359 PItab[3] = 1.0L;
00360 for (i=0;i<=2;i++)
00361 {
00362 PItab[4+i] = PItab[3+i] * PI;
00363 PItab[2-i] = PItab[3-i] / PI;
00364 }
00365
00366 initialized = 1;
00367 }
00368
00369
00370 bool EngNav :: subframeConvert(const long input[10],
00371 int gpsWeek,
00372 double output[60])
00373 throw()
00374 {
00375 uint32_t tinput[10];
00376 for (int n=0;n<10;++n)
00377 tinput[n] = static_cast<uint32_t>( input[n] );
00378 short tgpsWeek = gpsWeek;
00379 return( subframeConvert( tinput, tgpsWeek, output ));
00380 }
00381
00382 bool EngNav :: subframeConvert(const uint32_t input[10],
00383 short gpsWeek,
00384 double output[60])
00385 throw()
00386 {
00387 short patId = -2, i = 2;
00388 struct DecodeQuant *p=NULL;
00389
00390 for (i=0; i< 20; i++)
00391 output[i] = 0.0L;
00392
00393
00394 if ((patId = getSubframePattern(input)) == 0)
00395 return false;
00396
00397
00398 p = subframeList[patId];
00399 while (p != NULL)
00400 {
00401 convertQuant(input, output, p);
00402 if(p->nxtq)
00403 p = p->nxtq;
00404 else
00405 p = NULL;
00406 }
00407
00408
00409
00410 if (patId==4)
00411 {
00412 output[18]= static_cast<double>( gpsWeek );
00413 }
00414
00415
00416 if (patId == 8)
00417 {
00418 if (!convert8bit(gpsWeek, &output[18]))
00419 return false;
00420
00421 if (!convert8bit(gpsWeek, &output[20]))
00422 return false;
00423 }
00424
00425
00426 if (patId == 1)
00427 {
00428 short week10Bit = static_cast<uint32_t>( output[5] );
00429 output[5] =
00430 static_cast<double>( convertXBit(gpsWeek, week10Bit, BITS10) );
00431 }
00432 return true;
00433 }
00434
00435
00436 bool EngNav :: convert8bit(int gpsWeek, double *output)
00437 throw()
00438 {
00439 short tgpsWeek = static_cast<short>( gpsWeek );
00440 short toutput = static_cast<short> ( *output );
00441 short retArg = convertXBit( tgpsWeek, toutput, BITS8 );
00442 *output = static_cast<double>(retArg);
00443
00444 return true;
00445 }
00446
00447
00448 bool EngNav :: convert10bit(int gpsWeek, double *output)
00449 throw()
00450 {
00451 short tgpsWeek = static_cast<short>( gpsWeek );
00452 short toutput = static_cast<short> ( *output );
00453 short retArg = convertXBit( tgpsWeek, toutput, BITS10 );
00454 *output = static_cast<double>(retArg);
00455 return true;
00456 }
00457
00458 static short LIMIT[] = { 127, 511 };
00459 static short RANGE[] = { 256, 1024 };
00460
00461 short EngNav :: convertXBit(short fullGPSWeek,
00462 short incompleteGPSWeek,
00463 BitConvertType type)
00464 {
00465 short extension = fullGPSWeek - (fullGPSWeek % RANGE[type]);
00466 short target = extension + incompleteGPSWeek;
00467
00468 short diff = target - fullGPSWeek;
00469 if (diff>LIMIT[type])
00470 target -= RANGE[type];
00471 else if (diff< -LIMIT[type])
00472 target += RANGE[type];
00473
00474 return( target );
00475 }
00476
00477
00478 short EngNav :: getSubframePattern(const long input[10])
00479 throw()
00480 {
00481 uint32_t tinput[10];
00482 for (int n=0;n<10;++n)
00483 tinput[n] = static_cast<uint32_t>( input[n] );
00484 return( getSubframePattern( tinput ));
00485 }
00486
00487 short EngNav :: getSubframePattern(const uint32_t input[10])
00488 throw()
00489 {
00490 short iret, svid;
00491 long itemp;
00492
00493 short patId[]
00494 = { 5, 6, 6, 6, 10, 8, 6, 7, 7, 7, 7, 7, 9 };
00495
00496
00497
00498
00499 itemp = input[1];
00500 itemp >>= 8;
00501 itemp &= 0x00000007L;
00502 iret = static_cast<short>( itemp );
00503
00504 if ( iret < 1 || iret > 5 )
00505 return(0);
00506 if ( iret < 4 )
00507 return(iret);
00508
00509
00510
00511 itemp = input[2];
00512 itemp >>= 22;
00513 itemp &= 0x0000003FL;
00514 svid = static_cast<short>( itemp );
00515 if ( svid <= 32 )
00516 iret = 4;
00517 else
00518 iret = patId[svid-51];
00519
00520 return iret;
00521 }
00522
00523 uint32_t EngNav :: computeParity(uint32_t sfword,
00524 uint32_t psfword,
00525 bool knownUpright)
00526 {
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547 uint32_t bmask[6] = { 0x3B1F3480L, 0x1D8F9A40L, 0x2EC7CD00L,
00548 0x1763E680L, 0x2BB1F340L, 0x0B7A89C0L };
00549
00550 uint32_t D = 0;
00551 uint32_t d = sfword;
00552 uint32_t D29 = getd29(psfword);
00553 uint32_t D30 = getd30(psfword);
00554
00555
00556
00557
00558
00559 if (D30 && !knownUpright)
00560 d = ~d;
00561 D |= ((D29 + BinUtils::countBits(bmask[0] & d)) % 2) << 5;
00562 D |= ((D30 + BinUtils::countBits(bmask[1] & d)) % 2) << 4;
00563 D |= ((D29 + BinUtils::countBits(bmask[2] & d)) % 2) << 3;
00564 D |= ((D30 + BinUtils::countBits(bmask[3] & d)) % 2) << 2;
00565 D |= ((D30 + BinUtils::countBits(bmask[4] & d)) % 2) << 1;
00566 D |= ((D29 + BinUtils::countBits(bmask[5] & d)) % 2);
00567
00568 return D;
00569 }
00570
00571 uint32_t EngNav :: fixParity(uint32_t sfword,
00572 uint32_t psfword,
00573 bool nib)
00574 {
00575 uint32_t bmask[6] = { 0x3B1F3480L, 0x1D8F9A40L, 0x2EC7CD00L,
00576 0x1763E680L, 0x2BB1F340L, 0x0B7A89C0L };
00577
00578 uint32_t D = 0;
00579 uint32_t d = sfword;
00580 uint32_t D29 = getd29(psfword);
00581 uint32_t D30 = getd30(psfword);
00582
00583 if (nib)
00584 {
00585
00586 d &= 0xffffff00;
00587 if ((D30 + BinUtils::countBits(bmask[4] & d)) % 2)
00588 d |= 0x00000040;
00589 if ((D29 + BinUtils::countBits(bmask[5] & d)) % 2)
00590 d |= 0x00000080;
00591 }
00592
00593 D = computeParity(d, psfword);
00594
00595 return D | d;
00596 }
00597
00599 bool EngNav :: subframeParity(const long input[10])
00600 {
00601 uint32_t temp[10];
00602 for (int n=0;n<10;++n) temp[n] = input[n];
00603 return(checkParity( temp ));
00604 }
00605
00606
00607 bool EngNav :: checkParity(const std::vector<uint32_t>& sf, bool knownUpright)
00608 {
00609 return (((sf[0] & 0x0000003f) == computeParity(sf[0], 0, knownUpright)) &&
00610 ((sf[1] & 0x0000003f) == computeParity(sf[1], sf[0], knownUpright)) &&
00611 ((sf[2] & 0x0000003f) == computeParity(sf[2], sf[1], knownUpright)) &&
00612 ((sf[3] & 0x0000003f) == computeParity(sf[3], sf[2], knownUpright)) &&
00613 ((sf[4] & 0x0000003f) == computeParity(sf[4], sf[3], knownUpright)) &&
00614 ((sf[5] & 0x0000003f) == computeParity(sf[5], sf[4], knownUpright)) &&
00615 ((sf[6] & 0x0000003f) == computeParity(sf[6], sf[5], knownUpright)) &&
00616 ((sf[7] & 0x0000003f) == computeParity(sf[7], sf[6], knownUpright)) &&
00617 ((sf[8] & 0x0000003f) == computeParity(sf[8], sf[7], knownUpright)) &&
00618 ((sf[9] & 0x0000003f) == computeParity(sf[9], sf[8], knownUpright)));
00619 }
00620
00621 bool EngNav :: checkParity(const uint32_t sf[10], bool knownUpright)
00622 {
00623 std::vector<uint32_t> temp(10);
00624 for (size_t n=0; n<10; ++n)
00625 temp[n] = sf[n];
00626 return checkParity(temp, knownUpright);
00627 }
00628
00629 void EngNav :: convertQuant(const uint32_t input[10],
00630 double output[60],
00631 DecodeQuant *p)
00632 throw()
00633 {
00634 double dval;
00635 short i, n, bit1, nword, nbit, lsb;
00636 union equ
00637 {
00638 uint32_t u;
00639 int32_t s;
00640 } temp;
00641 uint32_t *b;
00642 uint32_t mask;
00643
00644
00645 temp.u = 0x0L;
00646 for (n=0; n<=1; n++)
00647 {
00648 if (p->fmt[n].startBit == 0)
00649 break;
00650 bit1 = p->fmt[n].startBit;
00651 nword = (bit1-1) / 30;
00652 nbit = (bit1 % 30) + 1;
00653
00654 b = const_cast<uint32_t *>( input ) + nword;
00655 for (i=0;i<p->fmt[n].numBits;i++)
00656 {
00657 temp.u <<= 1;
00658 mask = 0x80000000L >> nbit++;
00659 if (*b & mask)
00660 temp.u++;
00661 if (nbit>=32)
00662 {
00663 b++;
00664 nbit = 0;
00665 }
00666 }
00667 }
00668
00669
00670 if (p->signq)
00671 {
00672 nbit = 32 - (p->fmt[0].numBits + p->fmt[1].numBits);
00673 temp.u <<= nbit;
00674 temp.s >>= nbit;
00675 dval = temp.s;
00676 }
00677 else
00678 {
00679 dval = temp.u;
00680 }
00681 dval = dval * p->scale;
00682 dval = dval * PItab[ p->powPI+3 ];
00683 dval = LDEXP(dval,p->pow2);
00684 output[p->outIndex] = dval;
00685 }
00686
00687 }