Exemplo n.º 1
0
  /**
   * Internal helper method to aid in the subclass architecture. Overwrites the superclass method
   * and calls it internally.
   *
   * @param header
   * @param s
   */
  protected void sentenceChooser(String header, String s) {
    if (header.equals(RMCSentence.HEADER)) {
      rmcSentence.setSentence(s);
      notifyListeners(this.rmcSentence);
    } else if (header.equals(GSVSentence.HEADER)) {
      // TODO: I wonder what happens if say 2 of 4 are received and parse is called?
      // Because 2 would be new data, 2 would be old data.
      // Can't happen because parse() only called when not null.
      // BUT what if it is in the middle of parsing and new data comes in?
      // Solution: Sync GSVSentence.parse()? checkRefresh() is already synced though.

      // 0. Get StringTokenizer to read info from NMEASentence:
      StringTokenizer st = new StringTokenizer(s, ",");
      st.nextToken(); // Skip header $GPGSV
      // 1.1 Find out how many sentences in sequence.
      gsvSentenceTotal = Integer.parseInt(st.nextToken());
      // 1.2 Find out which sentence this is.
      gsvSentenceNumber = Integer.parseInt(st.nextToken());
      // 2. Assign sentence to GSVSentence in order.
      gsvSentence.setSentence(s, gsvSentenceNumber, gsvSentenceTotal);
      // 3. If last sentence:
      if (gsvSentenceTotal == gsvSentenceNumber) {
        // 3a. setSentence() to last one so it is not null
        gsvSentence.setSentence(s);
        // 3b. Notify GPSListener
        notifyListeners(this.gsvSentence);
      }
    } else super.sentenceChooser(header, s); // Check superclass sentences.
  }
Exemplo n.º 2
0
  /** Update Date values */
  private void updateDate() {
    int dateStamp = rmcSentence.getDate();

    if (dateStamp > 0) {
      String rd = Integer.toString(dateStamp);
      int dd = Integer.parseInt(rd.substring(0, rd.length() - 4));
      int mm = Integer.parseInt(rd.substring(rd.length() - 4, rd.length() - 2));
      int yy = Integer.parseInt(rd.substring(rd.length() - 2, rd.length()));

      date.setDay(dd);
      date.setMonth(mm);
      date.setYear(yy);
    }
  }
Exemplo n.º 3
0
 /**
  * Return Compass Degrees in a range: 0.0-359.9
  *
  * @return the compass degrees
  */
 public float getCompassDegrees() {
   return rmcSentence.getCompassDegrees();
 }