Ejemplo n.º 1
0
  public String toString() {
    StringBuffer sb = new StringBuffer();

    /* standard event fields */
    int sc = this.getStatusCode();
    sb.append("Event values:\n");
    sb.append("  DeviceID  : " + this.getAccountID() + "/" + this.getDeviceID() + "\n");
    sb.append("  UniqueID  : " + this.getUniqueID() + "\n");
    sb.append(
        "  Fixtime   : " + this.getTimestamp() + " [" + new DateTime(this.getTimestamp()) + "]\n");
    sb.append(
        "  StatusCode: [" + StatusCodes.GetHex(sc) + "] " + StatusCodes.GetDescription(sc, null));
    sb.append("  GPS       : " + this.getGeoPoint() + " [age " + this.getGpsAge() + " sec]\n");
    sb.append(
        "  SpeedKPH  : "
            + StringTools.format(this.getSpeedKPH(), "0.0")
            + " ["
            + this.getHeading()
            + "]\n");

    /* remaining event fields (not already displayed) */
    OrderedSet<?> fldn = new OrderedSet<Object>(this.fieldValues.getPropertyKeys());
    fldn.remove(EventData.FLD_timestamp);
    fldn.remove(EventData.FLD_statusCode);
    fldn.remove(EventData.FLD_latitude);
    fldn.remove(EventData.FLD_longitude);
    fldn.remove(EventData.FLD_gpsAge);
    fldn.remove(EventData.FLD_speedKPH);
    fldn.remove(EventData.FLD_heading);
    for (Object k : fldn) {
      Object v = this.fieldValues.getProperty(k, "?");
      sb.append("  ");
      sb.append(StringTools.leftAlign(k.toString(), 10)).append(": ");
      sb.append(v.toString()).append("\n");
    }

    /* alternate fields */
    if (this.otherValues != null) {
      for (String k : this.otherValues.keySet()) {
        String v = StringTools.trim(this.otherValues.get(k));
        sb.append("  ");
        sb.append(StringTools.leftAlign(k, 10)).append(": ");
        sb.append(v).append("\n");
      }
    }

    /* return string */
    return sb.toString();
  }
Ejemplo n.º 2
0
  protected void _initChart() throws Exception {

    /* already initialized? */
    if (this.didInitChart) {
      return;
    }

    /* axis tick counts */
    int yTickCnt = this.getTemperatureTickCount();
    int xTickCnt = this.getDateTickCount();

    /* horizontal grid */
    this.setGrid(0, yTickCnt);

    /* Y-axis labels */
    StringBuffer ya = new StringBuffer();
    double deltaC = this.maxTempC - this.minTempC;
    for (int y = 0; y <= yTickCnt; y++) {
      double C = this.minTempC + (deltaC * ((double) y / (double) yTickCnt));
      double v = (this.dispUnits == TEMP_C) ? C : C2F(C);
      ya.append("|").append(StringTools.format(v, "0.0"));
    }
    if ((this.maxTempC > 0.0) && (this.minTempC < 0.0)) {
      double sep = Math.abs(this.minTempC) / (this.maxTempC - this.minTempC);
      this.addShapeMarker(
          "r,AA4444,0,"
              + StringTools.format(sep, "0.000")
              + ","
              + StringTools.format(sep + 0.002, "0.000"));
    }

    /* X-axis labels */
    StringBuffer xat = new StringBuffer();
    StringBuffer xad = new StringBuffer();
    double deltaTS = (double) (this.maxDateTS - this.minDateTS);
    long lastDN = 0L;
    for (int x = 0; x <= xTickCnt; x++) {
      long ts = this.minDateTS + Math.round(deltaTS * ((double) x / (double) xTickCnt));
      DateTime dt = new DateTime(ts, this.timeZone);
      long dn = DateTime.getDayNumberFromDate(dt);
      xat.append("|").append(dt.format(this.getTimeFormat()));
      xad.append("|").append(dt.format(this.getDateFormat()));
      if (dn != lastDN) {
        long ds = dt.getDayStart();
        if (ds > this.minDateTS) {
          double sep = (double) (ds - this.minDateTS) / deltaTS;
          this.addShapeMarker(
              "R,444444,0,"
                  + StringTools.format(sep, "0.000")
                  + ","
                  + StringTools.format(sep + 0.001, "0.000"));
        }
        lastDN = dn;
      }
    }

    /* axis labels */
    this.setAxisLabels(
        "y,x,x", "0:" + ya.toString() + "|1:" + xad.toString() + "|2:" + xat.toString());

    /* did init */
    this.didInitChart = true;
  }
Ejemplo n.º 3
0
 public static String GetFaultDescription(long fault, Locale locale) {
   if (fault != 0L) {
     String fmt = "000";
     StringBuffer sb = new StringBuffer();
     if ((fault & TYPE_MASK) == TYPE_J1708) {
       int mid = DTOBDFault.DecodeSystem(fault); // MID
       boolean isSid = DTOBDFault.IsJ1708_SID(fault);
       int pidSid = DTOBDFault.DecodePidSid(fault); // PID|SID "128/[s]123/1"
       int fmi = DTOBDFault.DecodeFMI(fault); // FMI
       Properties p =
           (j1587DescProvider != null)
               ? j1587DescProvider.getJ1587Descriptions(fault)
               : new Properties();
       // MID
       sb.append(
           NAME_MID
               + "("
               + StringTools.format(mid, fmt)
               + ") "
               + p.getProperty(NAME_MID_DESC, "")
               + "\n");
       // PID/SID
       if (isSid) {
         sb.append(
             NAME_SID
                 + "("
                 + StringTools.format(pidSid, fmt)
                 + ") "
                 + p.getProperty(NAME_SID_DESC, "")
                 + "\n");
       } else {
         sb.append(
             NAME_PID
                 + "("
                 + StringTools.format(pidSid, fmt)
                 + ") "
                 + p.getProperty(NAME_PID_DESC, "")
                 + "\n");
       }
       // FMI
       sb.append(
           NAME_FMI
               + "("
               + StringTools.format(fmi, fmt)
               + ") "
               + p.getProperty(NAME_FMI_DESC, ""));
       return sb.toString();
     } else if ((fault & TYPE_MASK) == TYPE_J1939) {
       int spn = DTOBDFault.DecodeSystem(fault); // SPN
       int fmi = DTOBDFault.DecodeFMI(fault); // FMI
       Properties p = new Properties();
       // SPN
       sb.append(
           NAME_SPN
               + "("
               + StringTools.format(spn, fmt)
               + ") "
               + p.getProperty(NAME_SPN, "")
               + "\n");
       // FMI
       sb.append(
           NAME_FMI + "(" + StringTools.format(fmi, fmt) + ") " + p.getProperty(NAME_FMI, ""));
       return sb.toString();
     } else if ((fault & TYPE_MASK) == TYPE_OBDII) {
       String dtc = DTOBDFault.GetFaultString(fault); // DTC
       Properties p = new Properties();
       // DTC
       sb.append(NAME_DTC + "(" + dtc + ") " + p.getProperty(NAME_DTC, ""));
       return sb.toString();
     }
   }
   return "";
 }