Esempio n. 1
0
 /* return fault header */
 public static String GetFaultHeader(RTProperties fault) {
   if (fault != null) {
     String type = fault.getString(PROP_TYPE, "");
     if (type.equalsIgnoreCase(NAME_J1708)) {
       if (fault.hasProperty(PROP_SID)) {
         return NAME_MID + "/" + NAME_SID + "/" + NAME_FMI;
       } else {
         return NAME_MID + "/" + NAME_PID + "/" + NAME_FMI;
       }
     } else if (type.equalsIgnoreCase(NAME_J1939)) {
       return NAME_SPN + "/" + NAME_FMI;
     } else if (type.equalsIgnoreCase(NAME_OBDII)) {
       return NAME_DTC;
     } else {
       return "";
     }
   }
   return "";
 }
Esempio n. 2
0
 public static boolean IsJ1708_PID(RTProperties rtpFault) {
   return DTOBDFault.IsJ1708(rtpFault) && rtpFault.hasProperty(PROP_PID);
 }
Esempio n. 3
0
 /* return string representation of fault code */
 public static String GetFaultString(RTProperties fault) {
   if (fault != null) {
     StringBuffer sb = new StringBuffer();
     String type = fault.getString(PROP_TYPE, "");
     if (type.equalsIgnoreCase(NAME_J1708)) {
       // J1708: type=j1708 mil=1 mid=123 pid=123 fmi=1 count=1 active=false
       // SID: "128/s123/1"
       // PID: "128/123/1"
       boolean active = fault.getBoolean(PROP_ACTIVE, true);
       int mid = fault.getInt(PROP_MID, 0);
       int fmi = fault.getInt(PROP_FMI, 0);
       if (!active) {
         sb.append("[");
       }
       sb.append(mid); // MID
       sb.append("/");
       if (fault.hasProperty(PROP_SID)) {
         int sid = fault.getInt(PROP_SID, 0);
         sb.append("s").append(sid); // SID "128/s123/1"
       } else {
         int pid = fault.getInt(PROP_PID, 0);
         sb.append(pid); // PID "128/123/1"
       }
       sb.append("/");
       sb.append(fmi); // FMI
       if (!active) {
         sb.append("]");
       }
       return sb.toString();
     } else if (type.equalsIgnoreCase(NAME_J1939)) {
       // J1939: type=i1939 mil=1 spn=1234 fmi=12 count=1 active=false
       // SPN: "128/1"
       boolean active = fault.getBoolean(PROP_ACTIVE, true);
       int spn = fault.getInt(PROP_SPN, 0);
       int fmi = fault.getInt(PROP_FMI, 0);
       if (!active) {
         sb.append("[");
       }
       sb.append(spn); // SPN
       sb.append("/");
       sb.append(fmi); // FMI
       if (!active) {
         sb.append("]");
       }
       return sb.toString();
     } else if (type.equalsIgnoreCase(NAME_OBDII)) {
       // OBDII: type=obdii mil=1 dtc=P0071
       // DTC: "P0071" [was "024C"]
       boolean active = fault.getBoolean(PROP_ACTIVE, true);
       String dtcStr = fault.getString(PROP_DTC, ""); // ie "P0123,P0321,P1234"
       if (!StringTools.isBlank(dtcStr)) {
         if (!active) {
           sb.append("[");
         }
         sb.append(dtcStr);
         if (!active) {
           sb.append("]");
         }
       }
       return sb.toString();
     } else {
       // unrecognized
     }
   }
   return "";
 }