Exemple #1
0
 /* encode "type=<type> ..." into long value */
 public static long EncodeFault(RTProperties rtp) {
   String type = rtp.getString(PROP_TYPE, null);
   if (type.equalsIgnoreCase(NAME_J1708)) {
     int mid = rtp.getInt(PROP_MID, 0);
     int sid = rtp.getInt(PROP_SID, -1);
     int pid = rtp.getInt(PROP_PID, -1);
     int pidSid = (sid >= 0) ? sid : pid;
     int fmi = rtp.getInt(PROP_FMI, 0);
     int count = rtp.getInt(PROP_COUNT, 0);
     boolean active = rtp.getBoolean(PROP_ACTIVE, true);
     return EncodeFault_J1708(mid, (sid >= 0), pidSid, fmi, count, active);
   } else if (type.equalsIgnoreCase(NAME_J1939)) {
     int spn = rtp.getInt(PROP_SPN, 0);
     int fmi = rtp.getInt(PROP_FMI, 0);
     int count = rtp.getInt(PROP_COUNT, 0);
     boolean active = rtp.getBoolean(PROP_ACTIVE, true);
     return EncodeFault_J1939(spn, fmi, count);
   } else if (type.equalsIgnoreCase(NAME_OBDII)) {
     String dtc = rtp.getString(PROP_DTC, ""); // "P0071"
     return EncodeFault_OBDII(dtc);
   } else {
     return 0L;
   }
 }
Exemple #2
0
 /**
  * ** Returns a new URIArg with this URIArg's arguments decoded from a ** single RTProperties
  * added a specified key [CHECK] ** @param rtpKey The key of the RTProperties to decode the
  * encoded args from ** @return A new URIArg with non excluded arguments encoded
  */
 public URIArg rtpDecode(String rtpKey) {
   URIArg cpyUrl = new URIArg(this.getURI());
   for (KeyVal kv : this.getKeyValList()) {
     String kn = kv.getKey();
     if (!kn.equals(rtpKey)) {
       cpyUrl.addArg(kv);
     } else {
       RTProperties rtp = URIArg.parseRTP(kv.getValue());
       for (Object rpk : rtp.getPropertyKeys()) {
         String rk = rpk.toString();
         String rv = rtp.getString(rk, "");
         cpyUrl.addArg(rk, rv);
       }
     }
   }
   return cpyUrl;
 }
Exemple #3
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 "";
 }
Exemple #4
0
 public static boolean IsOBDII(RTProperties rtpFault) {
   return ((rtpFault != null) && rtpFault.getString(PROP_TYPE, "").equalsIgnoreCase(NAME_OBDII));
 }
Exemple #5
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 "";
 }