Пример #1
0
 public static String GetPropertyString(long fault) {
   StringBuffer sb = new StringBuffer();
   if ((fault & TYPE_MASK) == TYPE_J1708) {
     int mid = DecodeSystem(fault);
     int fmi = DecodeFMI(fault);
     int count = DecodeCount(fault);
     boolean active = DecodeActive(fault);
     sb.append(PROP_TYPE[0]).append("=").append(NAME_J1708);
     sb.append(" ");
     sb.append(PROP_MIL[0]).append("=").append(active ? "1" : "0");
     sb.append(" ");
     sb.append(PROP_MID[0]).append("=").append(mid);
     if (DTOBDFault.IsJ1708_SID(fault)) {
       int sid = DecodePidSid(fault);
       sb.append(" ");
       sb.append(PROP_SID[0]).append("=").append(sid);
     } else {
       int pid = DecodePidSid(fault);
       sb.append(" ");
       sb.append(PROP_PID[0]).append("=").append(pid);
     }
     sb.append(" ").append(PROP_FMI[0]).append("=").append(fmi);
     if (count > 1) {
       sb.append(" ");
       sb.append(PROP_COUNT[0]).append("=" + count);
     }
     if (!active) {
       sb.append(" ");
       sb.append(PROP_ACTIVE[0]).append("=false");
     }
   } else if ((fault & TYPE_MASK) == TYPE_J1939) {
     int spn = DecodeSystem(fault);
     int fmi = DecodeFMI(fault);
     int count = DecodeCount(fault);
     boolean active = true;
     sb.append(PROP_TYPE[0]).append("=").append(NAME_J1939);
     sb.append(" ");
     sb.append(PROP_MIL[0]).append("=").append(active ? "1" : "0");
     sb.append(" ");
     sb.append(PROP_SPN[0]).append("=").append(spn);
     sb.append(" ");
     sb.append(PROP_FMI[0]).append("=").append(DecodeFMI(fault));
     if (count > 1) {
       sb.append(" ");
       sb.append(PROP_COUNT[0]).append("=" + count);
     }
     if (!active) {
       sb.append(" ");
       sb.append(PROP_ACTIVE[0]).append("=false");
     }
   } else if ((fault & TYPE_MASK) == TYPE_OBDII) {
     String dtc = DTOBDFault.GetFaultString(fault); // Powertrain
     sb.append(GetPropertyString_OBDII(new String[] {dtc}));
   } else {
     // unrecognized/empty
     sb.append(PROP_MIL[0]).append("=").append("0");
   }
   return sb.toString();
 }
Пример #2
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 "";
 }