Exemplo n.º 1
0
 /**
  * ** Gets the Localized value for the specified key. The default String text is returned ** if
  * the specified key does not exist ** @param key The LocalStrings key ** @param dft The default
  * String text to return if the LocalStrings key does not exist ** @return The Localized String
  * text
  */
 public String getString(String key, String dft) {
   if (!StringTools.isBlank(key) && (this.resBundle != null)) {
     RTProperties cfgProps = RTConfig.getConfigFileProperties();
     if (!cfgProps.hasProperty(key) || cfgProps.getBoolean(key, true)) {
       try {
         String s = this.resBundle.getString(key);
         if (s != null) {
           return I18N.decodeNewLine(s);
         }
       } catch (Throwable th) {
         // Print.logException("",th);
         // MissingResourceException - if no object for the given key can be found
         // ClassCastException - if the object found for the given key is not a string
       }
     }
   }
   return I18N.decodeNewLine(dft);
 }
Exemplo n.º 2
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 "";
 }
Exemplo n.º 3
0
 public static boolean IsJ1708_PID(RTProperties rtpFault) {
   return DTOBDFault.IsJ1708(rtpFault) && rtpFault.hasProperty(PROP_PID);
 }
Exemplo n.º 4
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 "";
 }