コード例 #1
0
  /** Small utility method to interpret the contents of a Pid_ */
  public static String positionData(int[] packet) {
    StringBuffer res = new StringBuffer();

    int[] data = new int[8];
    for (int i = 0; i < 8; i++) {
      data[i] = packet[i + 3];
    }

    double pos = toDouble(data);
    double deg = toDegrees(pos);
    int degrees = (int) deg;
    double minutes = deg - degrees;
    minutes *= 60;
    res.append("Pos: " + degrees + "°" + minutes + "'\n");

    for (int i = 0; i < 8; i++) {
      data[i] = packet[i + 11];
    }

    pos = toDouble(data);
    deg = toDegrees(pos);
    degrees = (int) deg;
    minutes = deg - degrees;
    minutes *= 60;
    res.append("Pos: " + degrees + "°" + minutes + "'\n");

    return res.toString();
  }
コード例 #2
0
 /** Small utility method to interpret the contents of a Pid_Protocol_Array-packet. */
 public static String protocolArray(int[] packet) {
   StringBuffer res = new StringBuffer();
   char tag;
   int data;
   for (int i = 0; i < packet[2]; i += 3) {
     tag = (char) packet[3 + i];
     data = toWord(packet[i + 5], packet[i + 4]);
     res.append("\'" + tag + "\'" + " " + data + "\n");
   }
   return res.toString();
 }
コード例 #3
0
  /** Small utility method to interpret the contents of a Pid_Product_Data-packet. */
  public static String productData(int[] packet) {
    StringBuffer res = new StringBuffer();
    res.append("Product ID: ");
    res.append(toWord(packet[4], packet[3]));
    res.append('\n');

    res.append("Software version: ");
    res.append(toWord(packet[6], packet[4]));
    res.append('\n');

    for (int i = 7; packet[i] != 0; i++) {
      res.append((char) packet[i]);
    }
    return res.toString();
  }
コード例 #4
0
  /** Small utility method to pretty-print the contents of a date-time-packet. */
  public static String datetime(int[] packet) {
    StringBuffer res = new StringBuffer();
    res.append("Month: ");
    res.append(packet[3]);
    res.append('\n');

    res.append("Day: ");
    res.append(packet[4]);
    res.append('\n');

    res.append("Year: ");
    res.append(toWord(packet[6], packet[5]));
    res.append('\n');

    res.append("Time: ");
    res.append(toWord(packet[8], packet[7]));
    res.append(':');

    res.append(packet[9]);
    res.append(':');
    res.append(packet[10]);

    return res.toString();
  }