GpsMeasurement.java revision 2102dd725540bcf51bf324a2775fbcffe45dd32f
1/* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License 15 */ 16 17package android.location; 18 19import android.os.Parcel; 20import android.os.Parcelable; 21import android.util.Log; 22 23/** 24 * A class representing a GPS satellite measurement, containing raw and computed information. 25 * 26 * @hide 27 */ 28public class GpsMeasurement implements Parcelable { 29 private static final String TAG = "GpsMeasurement"; 30 31 private int mFlags; 32 private byte mPrn; 33 private double mTimeOffsetInNs; 34 private short mState; 35 private long mReceivedGpsTowInNs; 36 private double mCn0InDbHz; 37 private double mPseudorangeRateInMetersPerSec; 38 private double mPseudorangeRateUncertaintyInMetersPerSec; 39 private short mAccumulatedDeltaRangeState; 40 private double mAccumulatedDeltaRangeInMeters; 41 private double mAccumulatedDeltaRangeUncertaintyInMeters; 42 private double mPseudorangeInMeters; 43 private double mPseudorangeUncertaintyInMeters; 44 private double mCodePhaseInChips; 45 private double mCodePhaseUncertaintyInChips; 46 private float mCarrierFrequencyInHz; 47 private long mCarrierCycles; 48 private double mCarrierPhase; 49 private double mCarrierPhaseUncertainty; 50 private byte mLossOfLock; 51 private short mBitNumber; 52 private short mTimeFromLastBitInMs; 53 private double mDopplerShiftInHz; 54 private double mDopplerShiftUncertaintyInHz; 55 private byte mMultipathIndicator; 56 private double mSnrInDb; 57 private double mElevationInDeg; 58 private double mElevationUncertaintyInDeg; 59 private double mAzimuthInDeg; 60 private double mAzimuthUncertaintyInDeg; 61 private boolean mUsedInFix; 62 63 // The following enumerations must be in sync with the values declared in gps.h 64 65 private static final int HAS_NO_FLAGS = 0; 66 private static final int HAS_SNR = (1<<0); 67 private static final int HAS_ELEVATION = (1<<1); 68 private static final int HAS_ELEVATION_UNCERTAINTY = (1<<2); 69 private static final int HAS_AZIMUTH = (1<<3); 70 private static final int HAS_AZIMUTH_UNCERTAINTY = (1<<4); 71 private static final int HAS_PSEUDORANGE = (1<<5); 72 private static final int HAS_PSEUDORANGE_UNCERTAINTY = (1<<6); 73 private static final int HAS_CODE_PHASE = (1<<7); 74 private static final int HAS_CODE_PHASE_UNCERTAINTY = (1<<8); 75 private static final int HAS_CARRIER_FREQUENCY = (1<<9); 76 private static final int HAS_CARRIER_CYCLES = (1<<10); 77 private static final int HAS_CARRIER_PHASE = (1<<11); 78 private static final int HAS_CARRIER_PHASE_UNCERTAINTY = (1<<12); 79 private static final int HAS_BIT_NUMBER = (1<<13); 80 private static final int HAS_TIME_FROM_LAST_BIT = (1<<14); 81 private static final int HAS_DOPPLER_SHIFT = (1<<15); 82 private static final int HAS_DOPPLER_SHIFT_UNCERTAINTY = (1<<16); 83 84 /** 85 * The indicator is not available or it is unknown. 86 */ 87 public static final byte LOSS_OF_LOCK_UNKNOWN = 0; 88 89 /** 90 * The measurement does not present any indication of 'loss of lock'. 91 */ 92 public static final byte LOSS_OF_LOCK_OK = 1; 93 94 /** 95 * 'Loss of lock' detected between the previous and current observation: cycle slip possible. 96 */ 97 public static final byte LOSS_OF_LOCK_CYCLE_SLIP = 2; 98 99 /** 100 * The indicator is not available or it is unknown. 101 */ 102 public static final byte MULTIPATH_INDICATOR_UNKNOWN = 0; 103 104 /** 105 * The measurement has been indicated to use multi-path. 106 */ 107 public static final byte MULTIPATH_INDICATOR_DETECTED = 1; 108 109 /** 110 * The measurement has been indicated not tu use multi-path. 111 */ 112 public static final byte MULTIPATH_INDICATOR_NOT_USED = 2; 113 114 /** 115 * The state of GPS receiver the measurement is invalid or unknown. 116 */ 117 public static final short STATE_UNKNOWN = 0; 118 119 /** 120 * The state of the GPS receiver is ranging code lock. 121 */ 122 public static final short STATE_CODE_LOCK = (1<<0); 123 124 /** 125 * The state of the GPS receiver is in bit sync. 126 */ 127 public static final short STATE_BIT_SYNC = (1<<1); 128 129 /** 130 *The state of the GPS receiver is in sub-frame sync. 131 */ 132 public static final short STATE_SUBFRAME_SYNC = (1<<2); 133 134 /** 135 * The state of the GPS receiver has TOW decoded. 136 */ 137 public static final short STATE_TOW_DECODED = (1<<3); 138 139 /** 140 * The state of the 'Accumulated Delta Range' is invalid or unknown. 141 */ 142 public static final short ADR_STATE_UNKNOWN = 0; 143 144 /** 145 * The state of the 'Accumulated Delta Range' is valid. 146 */ 147 public static final short ADR_STATE_VALID = (1<<0); 148 149 /** 150 * The state of the 'Accumulated Delta Range' has detected a reset. 151 */ 152 public static final short ADR_STATE_RESET = (1<<1); 153 154 /** 155 * The state of the 'Accumulated Delta Range' has a cycle slip detected. 156 */ 157 public static final short ADR_STATE_CYCLE_SLIP = (1<<2); 158 159 // End enumerations in sync with gps.h 160 161 GpsMeasurement() { 162 initialize(); 163 } 164 165 /** 166 * Sets all contents to the values stored in the provided object. 167 */ 168 public void set(GpsMeasurement measurement) { 169 mFlags = measurement.mFlags; 170 mPrn = measurement.mPrn; 171 mTimeOffsetInNs = measurement.mTimeOffsetInNs; 172 mState = measurement.mState; 173 mReceivedGpsTowInNs = measurement.mReceivedGpsTowInNs; 174 mCn0InDbHz = measurement.mCn0InDbHz; 175 mPseudorangeRateInMetersPerSec = measurement.mPseudorangeRateInMetersPerSec; 176 mPseudorangeRateUncertaintyInMetersPerSec = 177 measurement.mPseudorangeRateUncertaintyInMetersPerSec; 178 mAccumulatedDeltaRangeState = measurement.mAccumulatedDeltaRangeState; 179 mAccumulatedDeltaRangeInMeters = measurement.mAccumulatedDeltaRangeInMeters; 180 mAccumulatedDeltaRangeUncertaintyInMeters = 181 measurement.mAccumulatedDeltaRangeUncertaintyInMeters; 182 mPseudorangeInMeters = measurement.mPseudorangeInMeters; 183 mPseudorangeUncertaintyInMeters = measurement.mPseudorangeUncertaintyInMeters; 184 mCodePhaseInChips = measurement.mCodePhaseInChips; 185 mCodePhaseUncertaintyInChips = measurement.mCodePhaseUncertaintyInChips; 186 mCarrierFrequencyInHz = measurement.mCarrierFrequencyInHz; 187 mCarrierCycles = measurement.mCarrierCycles; 188 mCarrierPhase = measurement.mCarrierPhase; 189 mCarrierPhaseUncertainty = measurement.mCarrierPhaseUncertainty; 190 mLossOfLock = measurement.mLossOfLock; 191 mBitNumber = measurement.mBitNumber; 192 mTimeFromLastBitInMs = measurement.mTimeFromLastBitInMs; 193 mDopplerShiftInHz = measurement.mDopplerShiftInHz; 194 mDopplerShiftUncertaintyInHz = measurement.mDopplerShiftUncertaintyInHz; 195 mMultipathIndicator = measurement.mMultipathIndicator; 196 mSnrInDb = measurement.mSnrInDb; 197 mElevationInDeg = measurement.mElevationInDeg; 198 mElevationUncertaintyInDeg = measurement.mElevationUncertaintyInDeg; 199 mAzimuthInDeg = measurement.mAzimuthInDeg; 200 mAzimuthUncertaintyInDeg = measurement.mAzimuthUncertaintyInDeg; 201 mUsedInFix = measurement.mUsedInFix; 202 } 203 204 /** 205 * Resets all the contents to its original state. 206 */ 207 public void reset() { 208 initialize(); 209 } 210 211 /** 212 * Gets the Pseudo-random number (PRN). 213 * Range: [1, 32] 214 */ 215 public byte getPrn() { 216 return mPrn; 217 } 218 219 /** 220 * Sets the Pseud-random number (PRN). 221 */ 222 public void setPrn(byte value) { 223 mPrn = value; 224 } 225 226 /** 227 * Gets the time offset at which the measurement was taken in nanoseconds. 228 * The reference receiver's time is specified by {@link GpsClock#getTimeInNs()} and should be 229 * interpreted in the same way as indicated by {@link GpsClock#getType()}. 230 * 231 * The sign of this value is given by the following equation: 232 * measurement time = time_ns + time_offset_ns 233 * 234 * The value provides an individual time-stamp for the measurement, and allows sub-nanosecond 235 * accuracy. 236 */ 237 public double getTimeOffsetInNs() { 238 return mTimeOffsetInNs; 239 } 240 241 /** 242 * Sets the time offset at which the measurement was taken in nanoseconds. 243 */ 244 public void setTimeOffsetInNs(double value) { 245 mTimeOffsetInNs = value; 246 } 247 248 /** 249 * Gets per-satellite sync state. 250 * It represents the current sync state for the associated satellite. 251 * 252 * This value helps interpret {@link #getReceivedGpsTowInNs()}. 253 */ 254 public short getState() { 255 return mState; 256 } 257 258 /** 259 * Sets the sync state. 260 */ 261 public void setState(short value) { 262 switch (value) { 263 case STATE_UNKNOWN: 264 case STATE_BIT_SYNC: 265 case STATE_CODE_LOCK: 266 case STATE_SUBFRAME_SYNC: 267 case STATE_TOW_DECODED: 268 mState = value; 269 break; 270 default: 271 Log.d(TAG, "Sanitizing invalid 'sync state': " + value); 272 mState = STATE_UNKNOWN; 273 break; 274 } 275 } 276 277 /** 278 * Gets a string representation of the 'sync state'. 279 * For internal and logging use only. 280 */ 281 private String getStateString() { 282 switch (mState) { 283 case STATE_UNKNOWN: 284 return "Unknown"; 285 case STATE_BIT_SYNC: 286 return "BitSync"; 287 case STATE_CODE_LOCK: 288 return "CodeLock"; 289 case STATE_SUBFRAME_SYNC: 290 return "SubframeSync"; 291 case STATE_TOW_DECODED: 292 return "TowDecoded"; 293 default: 294 return "<Invalid>"; 295 } 296 } 297 298 /** 299 * Gets the received GPS Time-of-Week at the measurement time, in nanoseconds. 300 * The value is relative to the beginning of the current GPS week. 301 * 302 * Given {@link #getState()} of the GPS receiver, the range of this field can be: 303 * Searching : [ 0 ] : {@link #STATE_UNKNOWN} is set 304 * Ranging code lock : [ 0 1 ms ] : {@link #STATE_CODE_LOCK} is set 305 * Bit sync : [ 0 20 ms ] : {@link #STATE_BIT_SYNC} is set 306 * Subframe sync : [ 0 6 ms ] : {@link #STATE_SUBFRAME_SYNC} is set 307 * TOW decoded : [ 0 1 week ] : {@link #STATE_TOW_DECODED} is set 308 */ 309 public long getReceivedGpsTowInNs() { 310 return mReceivedGpsTowInNs; 311 } 312 313 /** 314 * Sets the received GPS time-of-week in nanoseconds. 315 */ 316 public void setReceivedGpsTowInNs(long value) { 317 mReceivedGpsTowInNs = value; 318 } 319 320 /** 321 * Gets the Carrier-to-noise density in dB-Hz. 322 * Range: [0, 63]. 323 * 324 * The value contains the measured C/N0 for the signal at the antenna input. 325 */ 326 public double getCn0InDbHz() { 327 return mCn0InDbHz; 328 } 329 330 /** 331 * Sets the carrier-to-noise density in dB-Hz. 332 */ 333 public void setCn0InDbHz(double value) { 334 mCn0InDbHz = value; 335 } 336 337 /** 338 * Gets the Pseudorange rate at the timestamp in m/s. 339 * The reported value includes {@link #getPseudorangeRateUncertaintyInMetersPerSec()}. 340 */ 341 public double getPseudorangeRateInMetersPerSec() { 342 return mPseudorangeRateInMetersPerSec; 343 } 344 345 /** 346 * Sets the pseudorange rate at the timestamp in m/s. 347 */ 348 public void setPseudorangeRateInMetersPerSec(double value) { 349 mPseudorangeRateInMetersPerSec = value; 350 } 351 352 /** 353 * Gets the pseudorange's rate uncertainty (1-Sigma) in m/s. 354 * The uncertainty is represented as an absolute (single sided) value. 355 */ 356 public double getPseudorangeRateUncertaintyInMetersPerSec() { 357 return mPseudorangeRateUncertaintyInMetersPerSec; 358 } 359 360 /** 361 * Sets the pseudorange's rate uncertainty (1-Sigma) in m/s. 362 */ 363 public void setPseudorangeRateUncertaintyInMetersPerSec(double value) { 364 mPseudorangeRateUncertaintyInMetersPerSec = value; 365 } 366 367 /** 368 * Gets 'Accumulated Delta Range' state. 369 * It indicates whether {@link #getAccumulatedDeltaRangeInMeters()} is reset or there is a 370 * cycle slip (indicating 'loss of lock'). 371 */ 372 public short getAccumulatedDeltaRangeState() { 373 return mAccumulatedDeltaRangeState; 374 } 375 376 /** 377 * Sets the 'Accumulated Delta Range' state. 378 */ 379 public void setAccumulatedDeltaRangeState(short value) { 380 switch (value) { 381 case ADR_STATE_UNKNOWN: 382 case ADR_STATE_VALID: 383 case ADR_STATE_RESET: 384 case ADR_STATE_CYCLE_SLIP: 385 mAccumulatedDeltaRangeState = value; 386 break; 387 default: 388 Log.d(TAG, "Sanitizing invalid 'Accumulated Delta Range state': " + value); 389 mAccumulatedDeltaRangeState = ADR_STATE_UNKNOWN; 390 break; 391 } 392 } 393 394 /** 395 * Gets a string representation of the 'Accumulated Delta Range state'. 396 * For internal and logging use only. 397 */ 398 private String getAccumulatedDeltaRangeStateString() { 399 switch (mAccumulatedDeltaRangeState) { 400 case ADR_STATE_UNKNOWN: 401 return "Unknown"; 402 case ADR_STATE_VALID: 403 return "Valid"; 404 case ADR_STATE_RESET: 405 return "Reset"; 406 case ADR_STATE_CYCLE_SLIP: 407 return "CycleSlip"; 408 default: 409 return "<Invalid>"; 410 } 411 } 412 413 /** 414 * Gets the accumulated delta range since the last channel reset, in meters. 415 * The reported value includes {@link #getAccumulatedDeltaRangeUncertaintyInMeters()}. 416 * 417 * The availability of the value is represented by {@link #getAccumulatedDeltaRangeState()}. 418 */ 419 public double getAccumulatedDeltaRangeInMeters() { 420 return mAccumulatedDeltaRangeInMeters; 421 } 422 423 /** 424 * Sets the accumulated delta range in meters. 425 */ 426 public void setAccumulatedDeltaRangeInMeters(double value) { 427 mAccumulatedDeltaRangeInMeters = value; 428 } 429 430 /** 431 * Gets the accumulated delta range's uncertainty (1-Sigma) in meters. 432 * The uncertainty is represented as an absolute (single sided) value. 433 */ 434 public double getAccumulatedDeltaRangeUncertaintyInMeters() { 435 return mAccumulatedDeltaRangeUncertaintyInMeters; 436 } 437 438 /** 439 * Sets the accumulated delta range's uncertainty (1-sigma) in meters. 440 * 441 * The availability of the value is represented by {@link #getAccumulatedDeltaRangeState()}. 442 */ 443 public void setAccumulatedDeltaRangeUncertaintyInMeters(double value) { 444 mAccumulatedDeltaRangeUncertaintyInMeters = value; 445 } 446 447 /** 448 * Returns true if {@link #getPseudorangeInMeters()} is available, false otherwise. 449 */ 450 public boolean hasPseudorangeInMeters() { 451 return isFlagSet(HAS_PSEUDORANGE); 452 } 453 454 /** 455 * Gets the best derived pseudorange by the chipset, in meters. 456 * The reported pseudorange includes {@link #getPseudorangeUncertaintyInMeters()}. 457 * 458 * The value is only available if {@link #hasPseudorangeInMeters()} is true. 459 */ 460 public double getPseudorangeInMeters() { 461 return mPseudorangeInMeters; 462 } 463 464 /** 465 * Sets the Pseudo-range in meters. 466 */ 467 public void setPseudorangeInMeters(double value) { 468 setFlag(HAS_PSEUDORANGE); 469 mPseudorangeInMeters = value; 470 } 471 472 /** 473 * Resets the Pseudo-range in meters. 474 */ 475 public void resetPseudorangeInMeters() { 476 resetFlag(HAS_PSEUDORANGE); 477 mPseudorangeInMeters = Double.NaN; 478 } 479 480 /** 481 * Returns true if {@link #getPseudorangeUncertaintyInMeters()} is available, false otherwise. 482 */ 483 public boolean hasPseudorangeUncertaintyInMeters() { 484 return isFlagSet(HAS_PSEUDORANGE_UNCERTAINTY); 485 } 486 487 /** 488 * Gets the pseudorange's uncertainty (1-Sigma) in meters. 489 * The value contains the 'pseudorange' and 'clock' uncertainty in it. 490 * The uncertainty is represented as an absolute (single sided) value. 491 * 492 * The value is only available if {@link #hasPseudorangeUncertaintyInMeters()} is true. 493 */ 494 public double getPseudorangeUncertaintyInMeters() { 495 return mPseudorangeUncertaintyInMeters; 496 } 497 498 /** 499 * Sets the pseudo-range's uncertainty (1-Sigma) in meters. 500 */ 501 public void setPseudorangeUncertaintyInMeters(double value) { 502 setFlag(HAS_PSEUDORANGE_UNCERTAINTY); 503 mPseudorangeUncertaintyInMeters = value; 504 } 505 506 /** 507 * Resets the pseudo-range's uncertainty (1-Sigma) in meters. 508 */ 509 public void resetPseudorangeUncertaintyInMeters() { 510 resetFlag(HAS_PSEUDORANGE_UNCERTAINTY); 511 mPseudorangeUncertaintyInMeters = Double.NaN; 512 } 513 514 /** 515 * Returns true if {@link #getCodePhaseInChips()} is available, false otherwise. 516 */ 517 public boolean hasCodePhaseInChips() { 518 return isFlagSet(HAS_CODE_PHASE); 519 } 520 521 /** 522 * Gets the fraction of the current C/A code cycle. 523 * Range: [0, 1023] 524 * The reference frequency is given by the value of {@link #getCarrierFrequencyInHz()}. 525 * The reported code-phase includes {@link #getCodePhaseUncertaintyInChips()}. 526 * 527 * The value is only available if {@link #hasCodePhaseInChips()} is true. 528 */ 529 public double getCodePhaseInChips() { 530 return mCodePhaseInChips; 531 } 532 533 /** 534 * Sets the Code-phase in chips. 535 */ 536 public void setCodePhaseInChips(double value) { 537 setFlag(HAS_CODE_PHASE); 538 mCodePhaseInChips = value; 539 } 540 541 /** 542 * Resets the Code-phase in chips. 543 */ 544 public void resetCodePhaseInChips() { 545 resetFlag(HAS_CODE_PHASE); 546 mCodePhaseInChips = Double.NaN; 547 } 548 549 /** 550 * Returns true if {@link #getCodePhaseUncertaintyInChips()} is available, false otherwise. 551 */ 552 public boolean hasCodePhaseUncertaintyInChips() { 553 return isFlagSet(HAS_CODE_PHASE_UNCERTAINTY); 554 } 555 556 /** 557 * Gets the code-phase's uncertainty (1-Sigma) as a fraction of chips. 558 * The uncertainty is represented as an absolute (single sided) value. 559 * 560 * The value is only available if {@link #hasCodePhaseUncertaintyInChips()} is true. 561 */ 562 public double getCodePhaseUncertaintyInChips() { 563 return mCodePhaseUncertaintyInChips; 564 } 565 566 /** 567 * Sets the Code-phase's uncertainty (1-Sigma) in fractions of chips. 568 */ 569 public void setCodePhaseUncertaintyInChips(double value) { 570 setFlag(HAS_CODE_PHASE_UNCERTAINTY); 571 mCodePhaseUncertaintyInChips = value; 572 } 573 574 /** 575 * Resets the Code-phase's uncertainty (1-Sigma) in fractions of chips. 576 */ 577 public void resetCodePhaseUncertaintyInChips() { 578 resetFlag(HAS_CODE_PHASE_UNCERTAINTY); 579 mCodePhaseUncertaintyInChips = Double.NaN; 580 } 581 582 /** 583 * Returns true if {@link #getCarrierFrequencyInHz()} is available, false otherwise. 584 */ 585 public boolean hasCarrierFrequencyInHz() { 586 return isFlagSet(HAS_CARRIER_FREQUENCY); 587 } 588 589 /** 590 * Gets the carrier frequency at which codes and messages are modulated, it can be L1 or L2. 591 * If the field is not set, the carrier frequency corresponds to L1. 592 * 593 * The value is only available if {@link #hasCarrierFrequencyInHz()} is true. 594 */ 595 public float getCarrierFrequencyInHz() { 596 return mCarrierFrequencyInHz; 597 } 598 599 /** 600 * Sets the Carrier frequency (L1 or L2) in Hz. 601 */ 602 public void setCarrierFrequencyInHz(float carrierFrequencyInHz) { 603 setFlag(HAS_CARRIER_FREQUENCY); 604 mCarrierFrequencyInHz = carrierFrequencyInHz; 605 } 606 607 /** 608 * Resets the Carrier frequency (L1 or L2) in Hz. 609 */ 610 public void resetCarrierFrequencyInHz() { 611 resetFlag(HAS_CARRIER_FREQUENCY); 612 mCarrierFrequencyInHz = Float.NaN; 613 } 614 615 /** 616 * Returns true if {@link #getCarrierCycles()} is available, false otherwise. 617 */ 618 public boolean hasCarrierCycles() { 619 return isFlagSet(HAS_CARRIER_CYCLES); 620 } 621 622 /** 623 * The number of full carrier cycles between the satellite and the receiver. 624 * The reference frequency is given by the value of {@link #getCarrierFrequencyInHz()}. 625 * 626 * The value is only available if {@link #hasCarrierCycles()} is true. 627 */ 628 public long getCarrierCycles() { 629 return mCarrierCycles; 630 } 631 632 /** 633 * Sets the number of full carrier cycles between the satellite and the receiver. 634 */ 635 public void setCarrierCycles(long value) { 636 setFlag(HAS_CARRIER_CYCLES); 637 mCarrierCycles = value; 638 } 639 640 /** 641 * Resets the number of full carrier cycles between the satellite and the receiver. 642 */ 643 public void resetCarrierCycles() { 644 resetFlag(HAS_CARRIER_CYCLES); 645 mCarrierCycles = Long.MIN_VALUE; 646 } 647 648 /** 649 * Returns true if {@link #getCarrierPhase()} is available, false otherwise. 650 */ 651 public boolean hasCarrierPhase() { 652 return isFlagSet(HAS_CARRIER_PHASE); 653 } 654 655 /** 656 * Gets the RF phase detected by the receiver. 657 * Range: [0.0, 1.0]. 658 * This is usually the fractional part of the complete carrier phase measurement. 659 * 660 * The reference frequency is given by the value of {@link #getCarrierFrequencyInHz()}. 661 * The reported carrier-phase includes {@link #getCarrierPhaseUncertainty()}. 662 * 663 * The value is only available if {@link #hasCarrierPhase()} is true. 664 */ 665 public double getCarrierPhase() { 666 return mCarrierPhase; 667 } 668 669 /** 670 * Sets the RF phase detected by the receiver. 671 */ 672 public void setCarrierPhase(double value) { 673 setFlag(HAS_CARRIER_PHASE); 674 mCarrierPhase = value; 675 } 676 677 /** 678 * Resets the RF phase detected by the receiver. 679 */ 680 public void resetCarrierPhase() { 681 resetFlag(HAS_CARRIER_PHASE); 682 mCarrierPhase = Double.NaN; 683 } 684 685 /** 686 * Returns true if {@link #getCarrierPhaseUncertainty()} is available, false otherwise. 687 */ 688 public boolean hasCarrierPhaseUncertainty() { 689 return isFlagSet(HAS_CARRIER_PHASE_UNCERTAINTY); 690 } 691 692 /** 693 * Gets the carrier-phase's uncertainty (1-Sigma). 694 * The uncertainty is represented as an absolute (single sided) value. 695 * 696 * The value is only available if {@link #hasCarrierPhaseUncertainty()} is true. 697 */ 698 public double getCarrierPhaseUncertainty() { 699 return mCarrierPhaseUncertainty; 700 } 701 702 /** 703 * Sets the Carrier-phase's uncertainty (1-Sigma) in cycles. 704 */ 705 public void setCarrierPhaseUncertainty(double value) { 706 setFlag(HAS_CARRIER_PHASE_UNCERTAINTY); 707 mCarrierPhaseUncertainty = value; 708 } 709 710 /** 711 * Resets the Carrier-phase's uncertainty (1-Sigma) in cycles. 712 */ 713 public void resetCarrierPhaseUncertainty() { 714 resetFlag(HAS_CARRIER_PHASE_UNCERTAINTY); 715 mCarrierPhaseUncertainty = Double.NaN; 716 } 717 718 /** 719 * Gets a value indicating the 'loss of lock' state of the event. 720 */ 721 public byte getLossOfLock() { 722 return mLossOfLock; 723 } 724 725 /** 726 * Sets the 'loss of lock' status. 727 */ 728 public void setLossOfLock(byte value) { 729 switch (value) { 730 case LOSS_OF_LOCK_UNKNOWN: 731 case LOSS_OF_LOCK_OK: 732 case LOSS_OF_LOCK_CYCLE_SLIP: 733 mLossOfLock = value; 734 break; 735 default: 736 Log.d(TAG, "Sanitizing invalid 'loss of lock': " + value); 737 mLossOfLock = LOSS_OF_LOCK_UNKNOWN; 738 break; 739 } 740 } 741 742 /** 743 * Gets a string representation of the 'loss of lock'. 744 * For internal and logging use only. 745 */ 746 private String getLossOfLockString() { 747 switch (mLossOfLock) { 748 case LOSS_OF_LOCK_UNKNOWN: 749 return "Unknown"; 750 case LOSS_OF_LOCK_OK: 751 return "Ok"; 752 case LOSS_OF_LOCK_CYCLE_SLIP: 753 return "CycleSlip"; 754 default: 755 return "<Invalid>"; 756 } 757 } 758 759 /** 760 * Returns true if {@link #getBitNumber()} is available, false otherwise. 761 */ 762 public boolean hasBitNumber() { 763 return isFlagSet(HAS_BIT_NUMBER); 764 } 765 766 /** 767 * Gets the number of GPS bits transmitted since Sat-Sun midnight (GPS week). 768 * 769 * The value is only available if {@link #hasBitNumber()} is true. 770 */ 771 public short getBitNumber() { 772 return mBitNumber; 773 } 774 775 /** 776 * Sets the bit number within the broadcast frame. 777 */ 778 public void setBitNumber(short bitNumber) { 779 setFlag(HAS_BIT_NUMBER); 780 mBitNumber = bitNumber; 781 } 782 783 /** 784 * Resets the bit number within the broadcast frame. 785 */ 786 public void resetBitNumber() { 787 resetFlag(HAS_BIT_NUMBER); 788 mBitNumber = Short.MIN_VALUE; 789 } 790 791 /** 792 * Returns true if {@link #getTimeFromLastBitInMs()} is available, false otherwise. 793 */ 794 public boolean hasTimeFromLastBitInMs() { 795 return isFlagSet(HAS_TIME_FROM_LAST_BIT); 796 } 797 798 /** 799 * Gets the elapsed time since the last received bit in milliseconds. 800 * Range: [0, 20]. 801 * 802 * The value is only available if {@link #hasTimeFromLastBitInMs()} is true. 803 */ 804 public short getTimeFromLastBitInMs() { 805 return mTimeFromLastBitInMs; 806 } 807 808 /** 809 * Sets the elapsed time since the last received bit in milliseconds. 810 */ 811 public void setTimeFromLastBitInMs(short value) { 812 setFlag(HAS_TIME_FROM_LAST_BIT); 813 mTimeFromLastBitInMs = value; 814 } 815 816 /** 817 * Resets the elapsed time since the last received bit in milliseconds. 818 */ 819 public void resetTimeFromLastBitInMs() { 820 resetFlag(HAS_TIME_FROM_LAST_BIT); 821 mTimeFromLastBitInMs = Short.MIN_VALUE; 822 } 823 824 /** 825 * Returns true if {@link #getDopplerShiftInHz()} is available, false otherwise. 826 */ 827 public boolean hasDopplerShiftInHz() { 828 return isFlagSet(HAS_DOPPLER_SHIFT); 829 } 830 831 /** 832 * Gets the Doppler Shift in Hz. 833 * A positive value indicates that the SV is moving toward the receiver. 834 * 835 * The reference frequency is given by the value of {@link #getCarrierFrequencyInHz()}. 836 * The reported doppler shift includes {@link #getDopplerShiftUncertaintyInHz()}. 837 * 838 * The value is only available if {@link #hasDopplerShiftInHz()} is true. 839 */ 840 public double getDopplerShiftInHz() { 841 return mDopplerShiftInHz; 842 } 843 844 /** 845 * Sets the Doppler shift in Hz. 846 */ 847 public void setDopplerShiftInHz(double value) { 848 setFlag(HAS_DOPPLER_SHIFT); 849 mDopplerShiftInHz = value; 850 } 851 852 /** 853 * Resets the Doppler shift in Hz. 854 */ 855 public void resetDopplerShiftInHz() { 856 resetFlag(HAS_DOPPLER_SHIFT); 857 mDopplerShiftInHz = Double.NaN; 858 } 859 860 /** 861 * Returns true if {@link #getDopplerShiftUncertaintyInHz()} is available, false otherwise. 862 */ 863 public boolean hasDopplerShiftUncertaintyInHz() { 864 return isFlagSet(HAS_DOPPLER_SHIFT_UNCERTAINTY); 865 } 866 867 /** 868 * Gets the Doppler's Shift uncertainty (1-Sigma) in Hz. 869 * The uncertainty is represented as an absolute (single sided) value. 870 * 871 * The value is only available if {@link #hasDopplerShiftUncertaintyInHz()} is true. 872 */ 873 public double getDopplerShiftUncertaintyInHz() { 874 return mDopplerShiftUncertaintyInHz; 875 } 876 877 /** 878 * Sets the Doppler's shift uncertainty (1-Sigma) in Hz. 879 */ 880 public void setDopplerShiftUncertaintyInHz(double value) { 881 setFlag(HAS_DOPPLER_SHIFT_UNCERTAINTY); 882 mDopplerShiftUncertaintyInHz = value; 883 } 884 885 /** 886 * Resets the Doppler's shift uncertainty (1-Sigma) in Hz. 887 */ 888 public void resetDopplerShiftUncertaintyInHz() { 889 resetFlag(HAS_DOPPLER_SHIFT_UNCERTAINTY); 890 mDopplerShiftUncertaintyInHz = Double.NaN; 891 } 892 893 /** 894 * Gets a value indicating the 'multipath' state of the event. 895 */ 896 public byte getMultipathIndicator() { 897 return mMultipathIndicator; 898 } 899 900 /** 901 * Sets the 'multi-path' indicator. 902 */ 903 public void setMultipathIndicator(byte value) { 904 switch (value) { 905 case MULTIPATH_INDICATOR_UNKNOWN: 906 case MULTIPATH_INDICATOR_DETECTED: 907 case MULTIPATH_INDICATOR_NOT_USED: 908 mMultipathIndicator = value; 909 break; 910 default: 911 Log.d(TAG, "Sanitizing invalid 'muti-path indicator': " + value); 912 mMultipathIndicator = MULTIPATH_INDICATOR_UNKNOWN; 913 break; 914 } 915 } 916 917 /** 918 * Gets a string representation of the 'multi-path indicator'. 919 * For internal and logging use only. 920 */ 921 private String getMultipathIndicatorString() { 922 switch(mMultipathIndicator) { 923 case MULTIPATH_INDICATOR_UNKNOWN: 924 return "Unknown"; 925 case MULTIPATH_INDICATOR_DETECTED: 926 return "Detected"; 927 case MULTIPATH_INDICATOR_NOT_USED: 928 return "NotUsed"; 929 default: 930 return "<Invalid>"; 931 } 932 } 933 934 /** 935 * Returns true if {@link #getSnrInDb()} is available, false otherwise. 936 */ 937 public boolean hasSnrInDb() { 938 return isFlagSet(HAS_SNR); 939 } 940 941 /** 942 * Gets the Signal-to-Noise ratio (SNR) in dB. 943 * 944 * The value is only available if {@link #hasSnrInDb()} is true. 945 */ 946 public double getSnrInDb() { 947 return mSnrInDb; 948 } 949 950 /** 951 * Sets the Signal-to-noise ratio (SNR) in dB. 952 */ 953 public void setSnrInDb(double snrInDb) { 954 setFlag(HAS_SNR); 955 mSnrInDb = snrInDb; 956 } 957 958 /** 959 * Resets the Signal-to-noise ratio (SNR) in dB. 960 */ 961 public void resetSnrInDb() { 962 resetFlag(HAS_SNR); 963 mSnrInDb = Double.NaN; 964 } 965 966 /** 967 * Returns true if {@link #getElevationInDeg()} is available, false otherwise. 968 */ 969 public boolean hasElevationInDeg() { 970 return isFlagSet(HAS_ELEVATION); 971 } 972 973 /** 974 * Gets the Elevation in degrees. 975 * Range: [-90, 90] 976 * The reported elevation includes {@link #getElevationUncertaintyInDeg()}. 977 * 978 * The value is only available if {@link #hasElevationInDeg()} is true. 979 */ 980 public double getElevationInDeg() { 981 return mElevationInDeg; 982 } 983 984 /** 985 * Sets the Elevation in degrees. 986 */ 987 public void setElevationInDeg(double elevationInDeg) { 988 setFlag(HAS_ELEVATION); 989 mElevationInDeg = elevationInDeg; 990 } 991 992 /** 993 * Resets the Elevation in degrees. 994 */ 995 public void resetElevationInDeg() { 996 resetFlag(HAS_ELEVATION); 997 mElevationInDeg = Double.NaN; 998 } 999 1000 /** 1001 * Returns true if {@link #getElevationUncertaintyInDeg()} is available, false otherwise. 1002 */ 1003 public boolean hasElevationUncertaintyInDeg() { 1004 return isFlagSet(HAS_ELEVATION_UNCERTAINTY); 1005 } 1006 1007 /** 1008 * Gets the elevation's uncertainty (1-Sigma) in degrees. 1009 * Range: [0, 90] 1010 * 1011 * The uncertainty is represented as an absolute (single sided) value. 1012 * 1013 * The value is only available if {@link #hasElevationUncertaintyInDeg()} is true. 1014 */ 1015 public double getElevationUncertaintyInDeg() { 1016 return mElevationUncertaintyInDeg; 1017 } 1018 1019 /** 1020 * Sets the elevation's uncertainty (1-Sigma) in degrees. 1021 */ 1022 public void setElevationUncertaintyInDeg(double value) { 1023 setFlag(HAS_ELEVATION_UNCERTAINTY); 1024 mElevationUncertaintyInDeg = value; 1025 } 1026 1027 /** 1028 * Resets the elevation's uncertainty (1-Sigma) in degrees. 1029 */ 1030 public void resetElevationUncertaintyInDeg() { 1031 resetFlag(HAS_ELEVATION_UNCERTAINTY); 1032 mElevationUncertaintyInDeg = Double.NaN; 1033 } 1034 1035 /** 1036 * Returns true if {@link #getAzimuthInDeg()} is available, false otherwise. 1037 */ 1038 public boolean hasAzimuthInDeg() { 1039 return isFlagSet(HAS_AZIMUTH); 1040 } 1041 1042 /** 1043 * Gets the azimuth in degrees. 1044 * Range: [0, 360). 1045 * 1046 * The reported azimuth includes {@link #getAzimuthUncertaintyInDeg()}. 1047 * 1048 * The value is only available if {@link #hasAzimuthInDeg()} is true. 1049 */ 1050 public double getAzimuthInDeg() { 1051 return mAzimuthInDeg; 1052 } 1053 1054 /** 1055 * Sets the Azimuth in degrees. 1056 */ 1057 public void setAzimuthInDeg(double value) { 1058 setFlag(HAS_AZIMUTH); 1059 mAzimuthInDeg = value; 1060 } 1061 1062 /** 1063 * Resets the Azimuth in degrees. 1064 */ 1065 public void resetAzimuthInDeg() { 1066 resetFlag(HAS_AZIMUTH); 1067 mAzimuthInDeg = Double.NaN; 1068 } 1069 1070 /** 1071 * Returns true if {@link #getAzimuthUncertaintyInDeg()} is available, false otherwise. 1072 */ 1073 public boolean hasAzimuthUncertaintyInDeg() { 1074 return isFlagSet(HAS_AZIMUTH_UNCERTAINTY); 1075 } 1076 1077 /** 1078 * Gets the azimuth's uncertainty (1-Sigma) in degrees. 1079 * Range: [0, 180]. 1080 * 1081 * The uncertainty is represented as an absolute (single sided) value. 1082 * 1083 * The value is only available if {@link #hasAzimuthUncertaintyInDeg()} is true. 1084 */ 1085 public double getAzimuthUncertaintyInDeg() { 1086 return mAzimuthUncertaintyInDeg; 1087 } 1088 1089 /** 1090 * Sets the Azimuth's uncertainty (1-Sigma) in degrees. 1091 */ 1092 public void setAzimuthUncertaintyInDeg(double value) { 1093 setFlag(HAS_AZIMUTH_UNCERTAINTY); 1094 mAzimuthUncertaintyInDeg = value; 1095 } 1096 1097 /** 1098 * Resets the Azimuth's uncertainty (1-Sigma) in degrees. 1099 */ 1100 public void resetAzimuthUncertaintyInDeg() { 1101 resetFlag(HAS_AZIMUTH_UNCERTAINTY); 1102 mAzimuthUncertaintyInDeg = Double.NaN; 1103 } 1104 1105 /** 1106 * Gets a flag indicating whether the GPS represented by the measurement was used for computing 1107 * the most recent fix. 1108 * 1109 * @return A non-null value if the data is available, null otherwise. 1110 */ 1111 public boolean isUsedInFix() { 1112 return mUsedInFix; 1113 } 1114 1115 /** 1116 * Sets the Used-in-Fix flag. 1117 */ 1118 public void setUsedInFix(boolean value) { 1119 mUsedInFix = value; 1120 } 1121 1122 public static final Creator<GpsMeasurement> CREATOR = new Creator<GpsMeasurement>() { 1123 @Override 1124 public GpsMeasurement createFromParcel(Parcel parcel) { 1125 GpsMeasurement gpsMeasurement = new GpsMeasurement(); 1126 1127 gpsMeasurement.mFlags = parcel.readInt(); 1128 gpsMeasurement.mPrn = parcel.readByte(); 1129 gpsMeasurement.mTimeOffsetInNs = parcel.readDouble(); 1130 gpsMeasurement.mState = (short) parcel.readInt(); 1131 gpsMeasurement.mReceivedGpsTowInNs = parcel.readLong(); 1132 gpsMeasurement.mCn0InDbHz = parcel.readDouble(); 1133 gpsMeasurement.mPseudorangeRateInMetersPerSec = parcel.readDouble(); 1134 gpsMeasurement.mPseudorangeRateUncertaintyInMetersPerSec = parcel.readDouble(); 1135 gpsMeasurement.mAccumulatedDeltaRangeState = (short) parcel.readInt(); 1136 gpsMeasurement.mAccumulatedDeltaRangeInMeters = parcel.readDouble(); 1137 gpsMeasurement.mAccumulatedDeltaRangeUncertaintyInMeters = parcel.readDouble(); 1138 gpsMeasurement.mPseudorangeInMeters = parcel.readDouble(); 1139 gpsMeasurement.mPseudorangeUncertaintyInMeters = parcel.readDouble(); 1140 gpsMeasurement.mCodePhaseInChips = parcel.readDouble(); 1141 gpsMeasurement.mCodePhaseUncertaintyInChips = parcel.readDouble(); 1142 gpsMeasurement.mCarrierFrequencyInHz = parcel.readFloat(); 1143 gpsMeasurement.mCarrierCycles = parcel.readLong(); 1144 gpsMeasurement.mCarrierPhase = parcel.readDouble(); 1145 gpsMeasurement.mCarrierPhaseUncertainty = parcel.readDouble(); 1146 gpsMeasurement.mLossOfLock = parcel.readByte(); 1147 gpsMeasurement.mBitNumber = (short) parcel.readInt(); 1148 gpsMeasurement.mTimeFromLastBitInMs = (short) parcel.readInt(); 1149 gpsMeasurement.mDopplerShiftInHz = parcel.readDouble(); 1150 gpsMeasurement.mDopplerShiftUncertaintyInHz = parcel.readDouble(); 1151 gpsMeasurement.mMultipathIndicator = parcel.readByte(); 1152 gpsMeasurement.mSnrInDb = parcel.readDouble(); 1153 gpsMeasurement.mElevationInDeg = parcel.readDouble(); 1154 gpsMeasurement.mElevationUncertaintyInDeg = parcel.readDouble(); 1155 gpsMeasurement.mAzimuthInDeg = parcel.readDouble(); 1156 gpsMeasurement.mAzimuthUncertaintyInDeg = parcel.readDouble(); 1157 gpsMeasurement.mUsedInFix = parcel.readInt() != 0; 1158 1159 return gpsMeasurement; 1160 } 1161 1162 @Override 1163 public GpsMeasurement[] newArray(int i) { 1164 return new GpsMeasurement[i]; 1165 } 1166 }; 1167 1168 public void writeToParcel(Parcel parcel, int flags) { 1169 parcel.writeInt(mFlags); 1170 parcel.writeByte(mPrn); 1171 parcel.writeDouble(mTimeOffsetInNs); 1172 parcel.writeInt(mState); 1173 parcel.writeLong(mReceivedGpsTowInNs); 1174 parcel.writeDouble(mCn0InDbHz); 1175 parcel.writeDouble(mPseudorangeRateInMetersPerSec); 1176 parcel.writeDouble(mPseudorangeRateUncertaintyInMetersPerSec); 1177 parcel.writeInt(mAccumulatedDeltaRangeState); 1178 parcel.writeDouble(mAccumulatedDeltaRangeInMeters); 1179 parcel.writeDouble(mAccumulatedDeltaRangeUncertaintyInMeters); 1180 parcel.writeDouble(mPseudorangeInMeters); 1181 parcel.writeDouble(mPseudorangeUncertaintyInMeters); 1182 parcel.writeDouble(mCodePhaseInChips); 1183 parcel.writeDouble(mCodePhaseUncertaintyInChips); 1184 parcel.writeFloat(mCarrierFrequencyInHz); 1185 parcel.writeLong(mCarrierCycles); 1186 parcel.writeDouble(mCarrierPhase); 1187 parcel.writeDouble(mCarrierPhaseUncertainty); 1188 parcel.writeByte(mLossOfLock); 1189 parcel.writeInt(mBitNumber); 1190 parcel.writeInt(mTimeFromLastBitInMs); 1191 parcel.writeDouble(mDopplerShiftInHz); 1192 parcel.writeDouble(mDopplerShiftUncertaintyInHz); 1193 parcel.writeByte(mMultipathIndicator); 1194 parcel.writeDouble(mSnrInDb); 1195 parcel.writeDouble(mElevationInDeg); 1196 parcel.writeDouble(mElevationUncertaintyInDeg); 1197 parcel.writeDouble(mAzimuthInDeg); 1198 parcel.writeDouble(mAzimuthUncertaintyInDeg); 1199 parcel.writeInt(mUsedInFix ? 1 : 0); 1200 } 1201 1202 @Override 1203 public int describeContents() { 1204 return 0; 1205 } 1206 1207 @Override 1208 public String toString() { 1209 final String format = " %-29s = %s\n"; 1210 final String formatWithUncertainty = " %-29s = %-25s %-40s = %s\n"; 1211 StringBuilder builder = new StringBuilder("GpsMeasurement:\n"); 1212 1213 builder.append(String.format(format, "Prn", mPrn)); 1214 1215 builder.append(String.format(format, "TimeOffsetInNs", mTimeOffsetInNs)); 1216 1217 builder.append(String.format(format, "State", getStateString())); 1218 1219 builder.append(String.format(format, "ReceivedGpsTowInNs", mReceivedGpsTowInNs)); 1220 1221 builder.append(String.format(format, "Cn0InDbHz", mCn0InDbHz)); 1222 1223 builder.append(String.format( 1224 formatWithUncertainty, 1225 "PseudorangeRateInMetersPerSec", 1226 mPseudorangeRateInMetersPerSec, 1227 "PseudorangeRateUncertaintyInMetersPerSec", 1228 mPseudorangeRateUncertaintyInMetersPerSec)); 1229 1230 builder.append(String.format( 1231 format, 1232 "AccumulatedDeltaRangeState", 1233 getAccumulatedDeltaRangeStateString())); 1234 1235 builder.append(String.format( 1236 formatWithUncertainty, 1237 "AccumulatedDeltaRangeInMeters", 1238 mAccumulatedDeltaRangeInMeters, 1239 "AccumulatedDeltaRangeUncertaintyInMeters", 1240 mAccumulatedDeltaRangeUncertaintyInMeters)); 1241 1242 builder.append(String.format( 1243 formatWithUncertainty, 1244 "PseudorangeInMeters", 1245 hasPseudorangeInMeters() ? mPseudorangeInMeters : null, 1246 "PseudorangeUncertaintyInMeters", 1247 hasPseudorangeUncertaintyInMeters() ? mPseudorangeUncertaintyInMeters : null)); 1248 1249 builder.append(String.format( 1250 formatWithUncertainty, 1251 "CodePhaseInChips", 1252 hasCodePhaseInChips() ? mCodePhaseInChips : null, 1253 "CodePhaseUncertaintyInChips", 1254 hasCodePhaseUncertaintyInChips() ? mCodePhaseUncertaintyInChips : null)); 1255 1256 builder.append(String.format( 1257 format, 1258 "CarrierFrequencyInHz", 1259 hasCarrierFrequencyInHz() ? mCarrierFrequencyInHz : null)); 1260 1261 builder.append(String.format( 1262 format, 1263 "CarrierCycles", 1264 hasCarrierCycles() ? mCarrierCycles : null)); 1265 1266 builder.append(String.format( 1267 formatWithUncertainty, 1268 "CarrierPhase", 1269 hasCarrierPhase() ? mCarrierPhase : null, 1270 "CarrierPhaseUncertainty", 1271 hasCarrierPhaseUncertainty() ? mCarrierPhaseUncertainty : null)); 1272 1273 builder.append(String.format(format, "LossOfLock", getLossOfLockString())); 1274 1275 builder.append(String.format( 1276 format, 1277 "BitNumber", 1278 hasBitNumber() ? mBitNumber : null)); 1279 1280 builder.append(String.format( 1281 format, 1282 "TimeFromLastBitInMs", 1283 hasTimeFromLastBitInMs() ? mTimeFromLastBitInMs : null)); 1284 1285 builder.append(String.format( 1286 formatWithUncertainty, 1287 "DopplerShiftInHz", 1288 hasDopplerShiftInHz() ? mDopplerShiftInHz : null, 1289 "DopplerShiftUncertaintyInHz", 1290 hasDopplerShiftUncertaintyInHz() ? mDopplerShiftUncertaintyInHz : null)); 1291 1292 builder.append(String.format(format, "MultipathIndicator", getMultipathIndicatorString())); 1293 1294 builder.append(String.format( 1295 format, 1296 "SnrInDb", 1297 hasSnrInDb() ? mSnrInDb : null)); 1298 1299 builder.append(String.format( 1300 formatWithUncertainty, 1301 "ElevationInDeg", 1302 hasElevationInDeg() ? mElevationInDeg : null, 1303 "ElevationUncertaintyInDeg", 1304 hasElevationUncertaintyInDeg() ? mElevationUncertaintyInDeg : null)); 1305 1306 builder.append(String.format( 1307 formatWithUncertainty, 1308 "AzimuthInDeg", 1309 hasAzimuthInDeg() ? mAzimuthInDeg : null, 1310 "AzimuthUncertaintyInDeg", 1311 hasAzimuthUncertaintyInDeg() ? mAzimuthUncertaintyInDeg : null)); 1312 1313 builder.append(String.format(format, "UsedInFix", mUsedInFix)); 1314 1315 return builder.toString(); 1316 } 1317 1318 private void initialize() { 1319 mFlags = HAS_NO_FLAGS; 1320 setPrn(Byte.MIN_VALUE); 1321 setTimeOffsetInNs(Long.MIN_VALUE); 1322 setState(STATE_UNKNOWN); 1323 setReceivedGpsTowInNs(Long.MIN_VALUE); 1324 setCn0InDbHz(Double.MIN_VALUE); 1325 setPseudorangeRateInMetersPerSec(Double.MIN_VALUE); 1326 setPseudorangeRateUncertaintyInMetersPerSec(Double.MIN_VALUE); 1327 setAccumulatedDeltaRangeState(ADR_STATE_UNKNOWN); 1328 setAccumulatedDeltaRangeInMeters(Double.MIN_VALUE); 1329 setAccumulatedDeltaRangeUncertaintyInMeters(Double.MIN_VALUE); 1330 resetPseudorangeInMeters(); 1331 resetPseudorangeUncertaintyInMeters(); 1332 resetCodePhaseInChips(); 1333 resetCodePhaseUncertaintyInChips(); 1334 resetCarrierFrequencyInHz(); 1335 resetCarrierCycles(); 1336 resetCarrierPhase(); 1337 resetCarrierPhaseUncertainty(); 1338 setLossOfLock(LOSS_OF_LOCK_UNKNOWN); 1339 resetBitNumber(); 1340 resetTimeFromLastBitInMs(); 1341 resetDopplerShiftInHz(); 1342 resetDopplerShiftUncertaintyInHz(); 1343 setMultipathIndicator(MULTIPATH_INDICATOR_UNKNOWN); 1344 resetSnrInDb(); 1345 resetElevationInDeg(); 1346 resetElevationUncertaintyInDeg(); 1347 resetAzimuthInDeg(); 1348 resetAzimuthUncertaintyInDeg(); 1349 setUsedInFix(false); 1350 } 1351 1352 private void setFlag(int flag) { 1353 mFlags |= flag; 1354 } 1355 1356 private void resetFlag(int flag) { 1357 mFlags &= ~flag; 1358 } 1359 1360 private boolean isFlagSet(int flag) { 1361 return (mFlags & flag) == flag; 1362 } 1363} 1364