[sonar] code bug
This commit is contained in:
@@ -128,55 +128,52 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
|
||||
//设置左下角四个按钮监听事件
|
||||
setBottomBtnListener();
|
||||
// 模拟 下发启动自驾命令
|
||||
findViewById(R.id.btnStartAutopilot).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!FunctionBuildConfig.isDemoMode && !OCHAdasAbilityManager.getInstance().getAutopilotAbilityStatus()) {
|
||||
ToastUtils.showLong(OCHAdasAbilityManager.getInstance().getAutopilotUnAbilityReason() + ", 请稍候重试");
|
||||
return;
|
||||
}
|
||||
new AutopilotModeConfigManager(new AutopilotModeConfigManager.OnReadAutopilotModeConfigListener() {
|
||||
@Override
|
||||
public void onReadFailed(String err) {
|
||||
ThreadUtils.runOnUiThread(() -> {
|
||||
ToastUtils.showLong("读取失败=" + err);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onParseFailed(String err) {
|
||||
ToastUtils.showLong("解析失败=" + err);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onParse(MessagePad.SetAutopilotModeReq bean) {
|
||||
ToastUtils.showLong("下发命令\n" + TextFormat.printer().escapingNonAscii(false).printToString(bean));
|
||||
AutopilotControlParameters parameters = new AutopilotControlParameters();
|
||||
MessagePad.RouteInfo routeInfo = bean.getRouteInfo();
|
||||
if (routeInfo.getRouteID() > 0) {
|
||||
parameters.routeID = routeInfo.getRouteID();
|
||||
}
|
||||
parameters.routeName = routeInfo.getRouteName();
|
||||
parameters.startName = routeInfo.getStartName();//拼音
|
||||
parameters.endName = routeInfo.getEndName();//拼音
|
||||
parameters.startLatLon = new AutopilotControlParameters
|
||||
.AutoPilotLonLat(routeInfo.getStartLocation().getLatitude(), routeInfo.getStartLocation().getLongitude());
|
||||
parameters.endLatLon = new AutopilotControlParameters
|
||||
.AutoPilotLonLat(routeInfo.getEndLocation().getLatitude(), routeInfo.getEndLocation().getLongitude());
|
||||
parameters.vehicleType = 10;
|
||||
MessagePad.Line line = routeInfo.getLine();
|
||||
parameters.autoPilotLine = new AutopilotControlParameters.AutoPilotLine(
|
||||
line.getLineId(), line.getLineName(),
|
||||
line.getTrajUrl(), line.getTrajMd5(),
|
||||
line.getStopUrl(), line.getStopMd5(),
|
||||
line.getTimestamp(), line.getVehicleModel(),
|
||||
line.getTrajUrlDpqp(), line.getTrajMd5Dpqp(),
|
||||
line.getStopUrlDpqp(), line.getStopMd5Dpqp(),
|
||||
line.getTimestampDpqp());
|
||||
CallerAutoPilotControlManager.INSTANCE.startAutoPilot(parameters);
|
||||
}
|
||||
}).read();
|
||||
findViewById(R.id.btnStartAutopilot).setOnClickListener(v -> {
|
||||
if (!FunctionBuildConfig.isDemoMode && !OCHAdasAbilityManager.getInstance().getAutopilotAbilityStatus()) {
|
||||
ToastUtils.showLong(OCHAdasAbilityManager.getInstance().getAutopilotUnAbilityReason() + ", 请稍候重试");
|
||||
return;
|
||||
}
|
||||
new AutopilotModeConfigManager(new AutopilotModeConfigManager.OnReadAutopilotModeConfigListener() {
|
||||
@Override
|
||||
public void onReadFailed(String err) {
|
||||
ThreadUtils.runOnUiThread(() -> {
|
||||
ToastUtils.showLong("读取失败=" + err);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onParseFailed(String err) {
|
||||
ToastUtils.showLong("解析失败=" + err);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onParse(MessagePad.SetAutopilotModeReq bean) {
|
||||
ToastUtils.showLong("下发命令\n" + TextFormat.printer().escapingNonAscii(false).printToString(bean));
|
||||
AutopilotControlParameters parameters = new AutopilotControlParameters();
|
||||
MessagePad.RouteInfo routeInfo = bean.getRouteInfo();
|
||||
if (routeInfo.getRouteID() > 0) {
|
||||
parameters.routeID = routeInfo.getRouteID();
|
||||
}
|
||||
parameters.routeName = routeInfo.getRouteName();
|
||||
parameters.startName = routeInfo.getStartName();//拼音
|
||||
parameters.endName = routeInfo.getEndName();//拼音
|
||||
parameters.startLatLon = new AutopilotControlParameters
|
||||
.AutoPilotLonLat(routeInfo.getStartLocation().getLatitude(), routeInfo.getStartLocation().getLongitude());
|
||||
parameters.endLatLon = new AutopilotControlParameters
|
||||
.AutoPilotLonLat(routeInfo.getEndLocation().getLatitude(), routeInfo.getEndLocation().getLongitude());
|
||||
parameters.vehicleType = 10;
|
||||
MessagePad.Line line = routeInfo.getLine();
|
||||
parameters.autoPilotLine = new AutopilotControlParameters.AutoPilotLine(
|
||||
line.getLineId(), line.getLineName(),
|
||||
line.getTrajUrl(), line.getTrajMd5(),
|
||||
line.getStopUrl(), line.getStopMd5(),
|
||||
line.getTimestamp(), line.getVehicleModel(),
|
||||
line.getTrajUrlDpqp(), line.getTrajMd5Dpqp(),
|
||||
line.getStopUrlDpqp(), line.getStopMd5Dpqp(),
|
||||
line.getTimestampDpqp());
|
||||
CallerAutoPilotControlManager.INSTANCE.startAutoPilot(parameters);
|
||||
}
|
||||
}).read();
|
||||
});
|
||||
// 模拟 查询当前任务
|
||||
findViewById(R.id.btnQueryCurrentTask).setOnClickListener(view ->
|
||||
@@ -437,7 +434,6 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
|
||||
}
|
||||
});
|
||||
mSettingBtn.setOnClickListener(v -> {
|
||||
// TODO: 2021/12/9
|
||||
CallerHmiManager.INSTANCE.showToolsView();
|
||||
});
|
||||
if (mCardBtn != null) {
|
||||
@@ -458,8 +454,8 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
|
||||
if (isShow) {
|
||||
mFlWeltMapOverView.setVisibility(View.VISIBLE);
|
||||
if (mWeltMapOverViewFragment == null) {
|
||||
mWeltMapOverViewFragment = mWeltMapOverViewFragment.newInstance(
|
||||
(IWeltMapSwitchToSmallCallback) this,
|
||||
mWeltMapOverViewFragment = WeltMapOverViewFragment.newInstance(
|
||||
this,
|
||||
mCurrentTaskEndStation,
|
||||
mWeltDataBeanList,
|
||||
mSubTaskCoordinates,
|
||||
@@ -565,7 +561,7 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
|
||||
}
|
||||
|
||||
public static String format(double value) {
|
||||
BigDecimal bd = new BigDecimal(value);
|
||||
BigDecimal bd = BigDecimal.valueOf(value);
|
||||
bd = bd.setScale(2, RoundingMode.HALF_UP);
|
||||
return bd.toString();
|
||||
}
|
||||
|
||||
@@ -59,7 +59,6 @@ import java.util.List;
|
||||
|
||||
import chassis.ChassisStatesOuterClass;
|
||||
import io.reactivex.exceptions.UndeliverableException;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import io.reactivex.plugins.RxJavaPlugins;
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
import mogo_msg.MogoReportMsg;
|
||||
@@ -110,7 +109,7 @@ public class SweeperTaskModel implements IMoGoSweeperFutianCloudTaskListener, IM
|
||||
private boolean isHasTaskInfo = false;//判断是否有任务数据
|
||||
|
||||
//用于对应messageType和reqNo绑定在一起,保证请求的reqNo和响应的reqNo一致
|
||||
private HashMap<Integer, String> msgTypeAndReqNo = new HashMap<>();
|
||||
private final HashMap<Integer, String> msgTypeAndReqNo = new HashMap<>();
|
||||
|
||||
public static SweeperTaskModel getInstance() {
|
||||
if (sInstance == null) {
|
||||
@@ -149,38 +148,35 @@ public class SweeperTaskModel implements IMoGoSweeperFutianCloudTaskListener, IM
|
||||
//2022.1.28
|
||||
// 调用Disposable.dispose() 时候会出现InterruptedException 导致出现崩溃
|
||||
// The exception could not be delivered to the consumer because it has already canceled/disposed
|
||||
// the flow or the excTeption has nowhere to go to begin with
|
||||
RxJavaPlugins.setErrorHandler(new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(Throwable e) {
|
||||
if (e instanceof UndeliverableException) {
|
||||
e = e.getCause();
|
||||
CallerLogger.d(M_SWEEPER + TAG, "UndeliverableException");
|
||||
}
|
||||
if ((e instanceof IOException)) {//
|
||||
// fine, irrelevant network problem or API that throws on cancellation
|
||||
CallerLogger.d(M_SWEEPER + TAG, "IOException");
|
||||
return;
|
||||
}
|
||||
if (e instanceof InterruptedException) {
|
||||
// fine, some blocking code was interrupted by a dispose call
|
||||
CallerLogger.d(M_SWEEPER + TAG, "InterruptedException");
|
||||
return;
|
||||
}
|
||||
if ((e instanceof NullPointerException) || (e instanceof IllegalArgumentException)) {
|
||||
// that's likely a bug in the application
|
||||
CallerLogger.d(M_SWEEPER + TAG, "NullPointerException or IllegalArgumentException");
|
||||
Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
|
||||
return;
|
||||
}
|
||||
if (e instanceof IllegalStateException) {
|
||||
// that's a bug in RxJava or in a custom operator
|
||||
CallerLogger.d(M_SWEEPER + TAG, "IllegalStateException");
|
||||
Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
|
||||
return;
|
||||
}
|
||||
CallerLogger.d(M_SWEEPER + TAG, "Undeliverable exception");
|
||||
// the flow or the exception has nowhere to go to begin with
|
||||
RxJavaPlugins.setErrorHandler(e -> {
|
||||
if (e instanceof UndeliverableException) {
|
||||
e = e.getCause();
|
||||
CallerLogger.d(M_SWEEPER + TAG, "UndeliverableException");
|
||||
}
|
||||
if ((e instanceof IOException)) {//
|
||||
// fine, irrelevant network problem or API that throws on cancellation
|
||||
CallerLogger.d(M_SWEEPER + TAG, "IOException");
|
||||
return;
|
||||
}
|
||||
if (e instanceof InterruptedException) {
|
||||
// fine, some blocking code was interrupted by a dispose call
|
||||
CallerLogger.d(M_SWEEPER + TAG, "InterruptedException");
|
||||
return;
|
||||
}
|
||||
if ((e instanceof NullPointerException) || (e instanceof IllegalArgumentException)) {
|
||||
// that's likely a bug in the application
|
||||
CallerLogger.d(M_SWEEPER + TAG, "NullPointerException or IllegalArgumentException");
|
||||
Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
|
||||
return;
|
||||
}
|
||||
if (e instanceof IllegalStateException) {
|
||||
// that's a bug in RxJava or in a custom operator
|
||||
CallerLogger.d(M_SWEEPER + TAG, "IllegalStateException");
|
||||
Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
|
||||
return;
|
||||
}
|
||||
CallerLogger.d(M_SWEEPER + TAG, "Undeliverable exception");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -279,11 +275,6 @@ public class SweeperTaskModel implements IMoGoSweeperFutianCloudTaskListener, IM
|
||||
OCHAdasAbilityManager.getInstance().setAdasStartFailureCallback(null);
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private final IMogoStatusChangedListener mMogoStatusChangedListener = new IMogoStatusChangedListener() {
|
||||
// VR mode变更回调
|
||||
@Override
|
||||
@@ -424,9 +415,6 @@ public class SweeperTaskModel implements IMoGoSweeperFutianCloudTaskListener, IM
|
||||
|
||||
@Override
|
||||
public void onSweeperFutianCleanSystemState(@NonNull ChassisStatesOuterClass.SweeperFuTianTaskSystemStates cleanSystemState) {
|
||||
if (cleanSystemState == null) {
|
||||
return;
|
||||
}
|
||||
long current = System.currentTimeMillis();
|
||||
if (current - mVehicleStateCurrentTimeMillis <= VEHICLE_STATE_INTERVAL_MILLIS) {
|
||||
return;
|
||||
@@ -506,7 +494,7 @@ public class SweeperTaskModel implements IMoGoSweeperFutianCloudTaskListener, IM
|
||||
}
|
||||
|
||||
private static String format(double value) {
|
||||
BigDecimal bd = new BigDecimal(value);
|
||||
BigDecimal bd = BigDecimal.valueOf(value);
|
||||
bd = bd.setScale(2, RoundingMode.HALF_UP);
|
||||
return bd.toString();
|
||||
}
|
||||
@@ -688,18 +676,18 @@ public class SweeperTaskModel implements IMoGoSweeperFutianCloudTaskListener, IM
|
||||
if (mControllerStatusCallback != null) {
|
||||
mControllerStatusCallback.onAutopilotState(state);
|
||||
}
|
||||
switch (state) {
|
||||
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE://不可自动驾驶
|
||||
break;
|
||||
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE://人工驾驶
|
||||
break;
|
||||
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING://自动驾驶中
|
||||
break;
|
||||
case IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING://平行驾驶
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// switch (state) {
|
||||
// case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE://不可自动驾驶
|
||||
// break;
|
||||
// case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE://人工驾驶
|
||||
// break;
|
||||
// case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING://自动驾驶中
|
||||
// break;
|
||||
// case IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING://平行驾驶
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user