Ejemplo n.º 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();
 }
Ejemplo n.º 2
0
 public boolean equals(Object other) {
   if (other instanceof DTOBDFault) {
     DTOBDFault jf = (DTOBDFault) other;
     return (this.getFaultCode() == jf.getFaultCode());
   } else {
     return false;
   }
 }
Ejemplo n.º 3
0
 /* encode "type=<type> ..." into long value */
 public static long EncodeFault(String faultProps) {
   if (!StringTools.isBlank(faultProps)) {
     return DTOBDFault.EncodeFault(new RTProperties(faultProps));
   } else {
     return 0L;
   }
 }
Ejemplo n.º 4
0
 public static boolean DecodeActive(long fault) {
   if (DTOBDFault.IsJ1708(fault)) {
     return ((fault & ACTIVE_MASK) != 0L);
   } else {
     return true;
   }
 }
Ejemplo n.º 5
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 "";
   }
 }
Ejemplo n.º 6
0
 public boolean isOBDII() {
   return DTOBDFault.IsOBDII(this.getFaultCode());
 }
Ejemplo n.º 7
0
 public boolean isJ1939() {
   return DTOBDFault.IsJ1939(this.getFaultCode());
 }
Ejemplo n.º 8
0
 /* return multi-line description */
 public String getDescription() {
   return DTOBDFault.GetFaultDescription(this.getFaultCode(), null);
 }
Ejemplo n.º 9
0
 public DTOBDFault(String dtc) {
   this.faultCode = DTOBDFault.EncodeFault_OBDII(dtc);
 }
Ejemplo n.º 10
0
 public DTOBDFault(int spn, int fmi, int count) {
   this.faultCode = DTOBDFault.EncodeFault_J1939(spn, fmi, count);
 }
Ejemplo n.º 11
0
 public DTOBDFault(int mid, boolean isSid, int pidSid, int fmi, int count, boolean active) {
   this.faultCode = DTOBDFault.EncodeFault_J1708(mid, isSid, pidSid, fmi, count, active);
 }
Ejemplo n.º 12
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 "";
 }
Ejemplo n.º 13
0
 public static boolean IsJ1708_PID(RTProperties rtpFault) {
   return DTOBDFault.IsJ1708(rtpFault) && rtpFault.hasProperty(PROP_PID);
 }
Ejemplo n.º 14
0
 /* return true if long value represents a SID */
 public static boolean IsJ1708_PID(long fault) {
   return DTOBDFault.IsJ1708(fault) && ((fault & SID_MASK) == 0L);
 }
Ejemplo n.º 15
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 "";
 }