122 lines
4.2 KiB
Java
122 lines
4.2 KiB
Java
package com.ubtrobot.jimu.exception;
|
|
|
|
import android.content.Context;
|
|
import com.ubtrobot.jimu.robotapi.R$string;
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.Comparator;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class EngineProtectException extends RobotActiveException {
|
|
public static final int CODE_ELECTRICITY = 2;
|
|
public static final int CODE_FUSE_ENCRYPT = 64;
|
|
public static final int CODE_LOCK = 1;
|
|
public static final int CODE_OTHERS = 32;
|
|
public static final int CODE_OVER_VOLTAGE = 8;
|
|
public static final int CODE_TEMPERATURE = 4;
|
|
public static final int CODE_UNDER_VOLTAGE = 16;
|
|
private int engineType;
|
|
private Map<Integer, List<Integer>> errorMap;
|
|
|
|
public EngineProtectException(int i, String str, int i2, Map<Integer, List<Integer>> map) {
|
|
super(i, str);
|
|
this.engineType = i2;
|
|
this.errorMap = map;
|
|
}
|
|
|
|
private String getIdString(List<Integer> list) {
|
|
if (list == null || list.size() <= 0) {
|
|
return "";
|
|
}
|
|
StringBuilder sb = new StringBuilder();
|
|
for (int i = 0; i < list.size(); i++) {
|
|
sb.append(list.get(i));
|
|
if (i < list.size() - 1) {
|
|
sb.append(",");
|
|
}
|
|
}
|
|
return sb.toString();
|
|
}
|
|
|
|
public boolean canUnlock() {
|
|
return (getHigherExceptionCode() & 1) > 0;
|
|
}
|
|
|
|
public int getEngineType() {
|
|
return this.engineType;
|
|
}
|
|
|
|
public Map<Integer, List<Integer>> getErrorMap() {
|
|
return this.errorMap;
|
|
}
|
|
|
|
public List<Integer> getErrorMapByCode(int i) {
|
|
Map<Integer, List<Integer>> map = this.errorMap;
|
|
if (map == null || map.size() <= 0) {
|
|
return null;
|
|
}
|
|
return this.errorMap.get(Integer.valueOf(i));
|
|
}
|
|
|
|
public String getErrorMessage(Context context, int i, List<Integer> list) {
|
|
if (list == null || list.size() <= 0) {
|
|
return null;
|
|
}
|
|
String idString = getIdString(list);
|
|
int i2 = this.engineType;
|
|
if (i2 != 128) {
|
|
if (i2 != 10) {
|
|
return null;
|
|
}
|
|
if (i == 1) {
|
|
return String.format(context.getResources().getString(R$string.engine_protect_motor_lock), idString);
|
|
}
|
|
if (i != 32) {
|
|
return null;
|
|
}
|
|
return String.format(context.getResources().getString(R$string.engine_protect_motor_other), idString);
|
|
}
|
|
if (i == 1) {
|
|
return String.format(context.getResources().getString(R$string.engine_protect_lock), idString);
|
|
}
|
|
if (i != 2) {
|
|
if (i == 4) {
|
|
return String.format(context.getResources().getString(R$string.engine_protect_temp), idString);
|
|
}
|
|
if (i != 8 && i != 16) {
|
|
if (i == 32) {
|
|
return String.format(context.getResources().getString(R$string.engine_protect_other), idString);
|
|
}
|
|
if (i != 64) {
|
|
return null;
|
|
}
|
|
return String.format(context.getResources().getString(R$string.engine_protect_encrypt), idString);
|
|
}
|
|
}
|
|
return String.format(context.getResources().getString(R$string.engine_protect_electricity), idString);
|
|
}
|
|
|
|
public int getHigherExceptionCode() {
|
|
Map<Integer, List<Integer>> map = this.errorMap;
|
|
if (map == null || map.size() <= 0) {
|
|
return 0;
|
|
}
|
|
ArrayList arrayList = new ArrayList(this.errorMap.entrySet());
|
|
Collections.sort(arrayList, new Comparator() { // from class: com.ubtrobot.jimu.exception.a
|
|
@Override // java.util.Comparator
|
|
public final int compare(Object obj, Object obj2) {
|
|
int compareTo;
|
|
compareTo = ((Integer) ((Map.Entry) obj).getKey()).compareTo((Integer) ((Map.Entry) obj2).getKey());
|
|
return compareTo;
|
|
}
|
|
});
|
|
return ((Integer) ((Map.Entry) arrayList.get(0)).getKey()).intValue();
|
|
}
|
|
|
|
public boolean needHandUp() {
|
|
return getHigherExceptionCode() == 32 || getHigherExceptionCode() == 64;
|
|
}
|
|
}
|