Example #1
0
 /* return string representation of fault code */
 public static String GetFaultString(long fault) {
   if (fault > 0L) {
     StringBuffer sb = new StringBuffer();
     if ((fault & TYPE_MASK) == TYPE_J1708) {
       // SID: "128/s123/1"
       // PID: "128/123/1"
       boolean active = DTOBDFault.DecodeActive(fault);
       int mid = DTOBDFault.DecodeSystem(fault);
       int fmi = DTOBDFault.DecodeFMI(fault);
       if (!active) {
         sb.append("[");
       }
       sb.append(mid); // MID
       sb.append("/");
       if (DTOBDFault.IsJ1708_SID(fault)) {
         int sid = DTOBDFault.DecodePidSid(fault);
         sb.append("s").append(sid); // SID "128/s123/1"
       } else {
         int pid = DTOBDFault.DecodePidSid(fault);
         sb.append(pid); // PID "128/123/1"
       }
       sb.append("/");
       sb.append(fmi); // FMI
       if (!active) {
         sb.append("]");
       }
       return sb.toString();
     } else if ((fault & TYPE_MASK) == TYPE_J1939) {
       // SPN: "128/1"
       boolean active = DTOBDFault.DecodeActive(fault);
       int spn = DTOBDFault.DecodeSystem(fault);
       int fmi = DTOBDFault.DecodeFMI(fault);
       sb.append(spn); // SPN
       sb.append("/");
       sb.append(fmi); // FMI
       return sb.toString();
     } else if ((fault & TYPE_MASK) == TYPE_OBDII) {
       // DTC: "P0071" [was "024C"]
       boolean active = DTOBDFault.DecodeActive(fault);
       int sysChar = DTOBDFault.DecodeSystem(fault); // System: powertrain
       int subSys = DTOBDFault.DecodeSPID(fault); // Mfg/Subsystem/Problem
       if (Character.isLetter((char) sysChar)) {
         sb.append((char) sysChar);
       } else {
         sb.append("U");
       }
       if ((subSys & 0x8000) != 0) {
         sb.append("1");
       } else {
         sb.append("0");
       }
       String subSysStr = String.valueOf(1000 + ((subSys & 0xFFF) % 1000));
       sb.append(subSysStr.substring(1));
       return sb.toString();
     } else {
       // unrecognized
     }
   }
   return "";
 }
Example #2
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();
 }
Example #3
0
 /* return fault header */
 public static String GetFaultHeader(long fault) {
   if ((fault & TYPE_MASK) == TYPE_J1708) {
     if (DTOBDFault.IsJ1708_SID(fault)) {
       return NAME_MID + "/" + NAME_SID + "/" + NAME_FMI;
     } else {
       return NAME_MID + "/" + NAME_PID + "/" + NAME_FMI;
     }
   } else if ((fault & TYPE_MASK) == TYPE_J1939) {
     return NAME_SPN + "/" + NAME_FMI;
   } else if ((fault & TYPE_MASK) == TYPE_OBDII) {
     return NAME_DTC;
   } else {
     return "";
   }
 }
Example #4
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 "";
 }