Esempio n. 1
0
 /**
  * Try to get the proprietary MSSIS timestamp appended to the NMEA sentence
  *
  * @return
  */
 public static Date findMssisTimestamp(SentenceLine sentenceLine) {
   if (sentenceLine == null) {
     return null;
   }
   // Go through postfix fields
   int start = sentenceLine.getPostfixStart();
   if (start < 0) {
     return null;
   }
   for (int i = start; i < sentenceLine.getFields().size(); i++) {
     String field = sentenceLine.getFields().get(i);
     try {
       return new Date(Long.parseLong(field) * 1000);
     } catch (NumberFormatException e) {
     }
   }
   return null;
 }
Esempio n. 2
0
  /**
   * Basic parse of line into sentence parts
   *
   * @param line
   * @throws SentenceException
   */
  protected void baseParse(SentenceLine sl) throws SentenceException {
    this.orgLines.add(sl.getLine());

    // Save raw sentence
    rawSentences.add(sl.getSentence());

    // Check for comment block
    if (sl.getPrefix().length() > 0 && CommentBlock.hasCommentBlock(sl.getPrefix())) {
      addCommentBlock(sl.getPrefix());
    }

    // Check checksum
    if (!sl.isChecksumMatch()) {
      throw new SentenceException(
          "Invalid checksum for line: "
              + sl.getLine()
              + ": "
              + sl.getChecksumField()
              + " should have been: "
              + sl.getChecksumString());
    }

    if (sl.getFields().size() < 2) {
      throw new SentenceException("Invalid sentence, less than two fields");
    }

    // Check talker/formatter
    if (sl.getTalker() == null || sl.getFormatter() == null) {
      throw new SentenceException(
          "Invalid sentence, wrong talker/formatter: " + sl.getFields().get(0));
    }

    // Try to get MSSIS timestamp
    mssisTimestamp = findMssisTimestamp(sl);
  }