diff --git a/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_base_fragment.xml b/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_base_fragment.xml index c5fc602d48..523a6fc82d 100644 --- a/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_base_fragment.xml +++ b/OCH/mogo-och-bus-passenger/src/main/res/layout/bus_p_base_fragment.xml @@ -6,12 +6,13 @@ + private ObjectAnimator autopilotLoadingAnimator; + public boolean isAnimateRunning = false; + /** * 滑动按钮触发的事件 */ @@ -156,47 +157,33 @@ public abstract class BaseBusTabFragment @Override public void onClickImpl(View v) { - restartAutopilot(); + if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE){ + restartAutopilot(); + }else { + TipToast.shortTip(getResources().getString(R.string.bus_auto_disable_tip)); + } } }); - // debug下调用测试面板 2022.2.25修改到 长按当前站点名字 -// if (DebugConfig.isDebug()) { -// ctvAutopilotStatus.setOnLongClickListener(v -> { -// debugTestBar(); -// return true; -// }); -// } - onAutopilotStatusChanged(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState(), false); + setAutopilotBtnStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState()); // 模拟 不可自动驾驶,目前场景是刚开机,adas还未和工控机连接 findViewById(R.id.btnAutopilotDisable).setOnClickListener(view -> -// MogoApisHandler.getInstance().getApis() -// .getAdasControllerApi() -// .mockOchStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE, "不能使用") - debugAutoPilotStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) + debugAutoPilotStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) ); // 模拟 可自动驾驶,工控机连接正常,且处于人工干预状态 findViewById(R.id.btnAutopilotEnable).setOnClickListener(view -> -// MogoApisHandler.getInstance().getApis() -// .getAdasControllerApi() -// .mockOchStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE, "能使用") - debugAutoPilotStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE) + debugAutoPilotStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE) ); // 模拟 自动驾驶能力,自动驾驶中,可能是停车,可能是行进,但是是机器在处理车的前进后退,不是人 findViewById(R.id.btnAutopilotRunning).setOnClickListener(view -> -// MogoApisHandler.getInstance().getApis() -// .getAdasControllerApi() -// .mockOchStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING, "Running") - debugAutoPilotStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) + debugAutoPilotStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) ); // 模拟 自动驾驶网约车回调数据 findViewById(R.id.btnAutopilotArrive).setOnClickListener(view -> -// MogoApisHandler.getInstance().getApis() -// .getAdasControllerApi().mockOchStatus(-1, "Arrived") - debugArrivedStation() + debugArrivedStation() ); findViewById(R.id.btnAutopilotRoute).setOnClickListener(view -> debugArrivedRoute()); @@ -298,70 +285,70 @@ public abstract class BaseBusTabFragment * * @param autopilotStatus 0:不可用 1:可用状态 2:自动驾驶中 */ - public void onAutopilotStatusChanged(int autopilotStatus, boolean isAnimateRunning) { + public void onAutopilotStatusChanged(int autopilotStatus) { getActivity().runOnUiThread(() -> { -// ctvAutopilotStatus.setChecked(isInAutopilot); changeAutopilotBtnView(autopilotStatus, isAnimateRunning); }); } - private void changeAutopilotBtnView(int autopilotStatus, boolean isAnimateRunning) { - CallerLogger.INSTANCE.d(M_BUS + TAG, "onStateChangeChangeAutopilotBtnView: " + autopilotStatus + "isAnimateRunning = " + isAnimateRunning); + public void setAutopilotBtnStatus(int autopilotStatus) { if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE == autopilotStatus) {//0不可用 - if (isAnimateRunning) { - stopAutopilotAnimation(); - ctvAutopilotStatusIv.setImageResource(R.drawable.bus_wrong_autopilot_icon); - ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_normal)); - ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_failure_tv)); - ctvAutopilotStatus.setFocusableInTouchMode(false); - ctvAutopilotStatus.setSelected(false); - } - UiThreadHandler.postDelayed(new Runnable() { - @Override - public void run() { - ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_disable)); - ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_runnig_tv)); - ctvAutopilotStatusIv.setImageResource(R.drawable.bus_disable_autopilot_icon); - ctvAutopilotStatus.setSelected(false); - ctvAutopilotStatus.setFocusableInTouchMode(true); -// ctvAutopilotStatus.setPressed(false); - } - }, 1000); + ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_disable)); + ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_runnig_tv)); + ctvAutopilotStatusIv.setImageResource(R.drawable.bus_disable_autopilot_icon); + ctvAutopilotStatus.setSelected(false); + ctvAutopilotStatus.setFocusableInTouchMode(true); - } else if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE + } else if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE == autopilotStatus + || IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING == autopilotStatus) {//1可用 - if (isAnimateRunning) { - return; - } ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_normal)); ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_runnig_tv)); ctvAutopilotStatusIv.setImageResource(R.drawable.bus_ic_autopilot); - ctvAutopilotStatus.setSelected(false); + ctvAutopilotStatus.setSelected(true); ctvAutopilotStatus.setFocusableInTouchMode(true); -// ctvAutopilotStatus.setPressed(true); - } else if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING + } + } + + public void updateAutopilotStatus(int autopilotStatus){ + if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING == autopilotStatus) {//2 running - if (isAnimateRunning) { - stopAutopilotAnimation(); - } ctvAutopilotStatusIv.setImageResource(R.drawable.bus_right_autopilot_icon); ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_normal)); ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_success_tv)); ctvAutopilotStatus.setSelected(false); ctvAutopilotStatus.setFocusableInTouchMode(false); - UiThreadHandler.postDelayed(new Runnable() { - @Override - public void run() { - ctvAutopilotStatusIv.setImageResource(R.drawable.bus_ic_autopilot); - ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_runnig_tv)); - ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_normal)); - ctvAutopilotStatus.setSelected(true); - ctvAutopilotStatus.setFocusableInTouchMode(true); -// ctvAutopilotStatus.setPressed(false); - } - }, 1000); + }else { + ctvAutopilotStatusIv.setImageResource(R.drawable.bus_wrong_autopilot_icon); + ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_normal)); + ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_failure_tv)); + ctvAutopilotStatus.setFocusableInTouchMode(false); + ctvAutopilotStatus.setSelected(false); } + UiThreadHandler.postDelayed(new Runnable() { + @Override + public void run() { + setAutopilotBtnStatus(autopilotStatus); + } + },1000); + } + + private void changeAutopilotBtnView(int autopilotStatus, boolean isAnimateRunning) { + CallerLogger.INSTANCE.d(M_BUS + TAG, "onStateChangeChangeAutopilotBtnView: " + + autopilotStatus + "isAnimateRunning = " + isAnimateRunning); + if (isAnimateRunning && IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING + != autopilotStatus) { + // 主动开启自动驾驶中,不为2(为0、1)则继续loading + return; + } + if (isAnimateRunning){ + stopAutopilotAnimation(); + updateAutopilotStatus(autopilotStatus); + }else { + setAutopilotBtnStatus(autopilotStatus); + } + } /** @@ -426,7 +413,7 @@ public abstract class BaseBusTabFragment * 开启自动驾驶中间动画 */ public void startAutopilotAnimation() { -// if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE){ + isAnimateRunning = true; ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_tv)); ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_normal)); ctvAutopilotStatus.setSelected(false); @@ -439,17 +426,34 @@ public abstract class BaseBusTabFragment autopilotLoadingAnimator.setDuration(1000);//设置持续时间 } autopilotLoadingAnimator.start();//动画开始 -// } + + startingAutoApilotCountDown(); + } + private void startingAutoApilotCountDown(){ + //10s 若自动驾驶没有开启,则结束动画 + UiThreadHandler.postDelayed(new Runnable() { + @Override + public void run() { //未启动成功做处理 + if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() + != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING && isAnimateRunning){ + stopAutopilotAnimation(); + updateAutopilotStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState()); + } + } + },TIMER_START_AUTOPILOT_INTERVAL); + + } /** * 停止自动驾驶中间动画 */ - public void stopAutopilotAnimation() { + private void stopAutopilotAnimation() { if (autopilotLoadingAnimator != null) { autopilotLoadingAnimator.end(); ctvAutopilotStatusIv.clearAnimation(); autopilotLoadingAnimator = null; + isAnimateRunning = false; } } diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BusFragment.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BusFragment.java index 083cc2bab1..38633cccd5 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BusFragment.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BusFragment.java @@ -94,11 +94,11 @@ public class BusFragment extends BaseBusTabFragment break; case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE: showAutopilotBiz(); - onAutopilotStatusChanged(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE, false); + onAutopilotStatusChanged(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE); break; case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING: showAutopilotBiz(); - onAutopilotStatusChanged(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING, false); + onAutopilotStatusChanged(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING); break; default: break; @@ -239,7 +239,9 @@ public class BusFragment extends BaseBusTabFragment @Override public void restartAutopilot() { - mPresenter.restartAutopilot(); + if (!isAnimateRunning) { + mPresenter.restartAutopilot(); + } } @Override diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/model/BusOrderModel.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/model/BusOrderModel.java index 8f8ae76b2b..e7e11b5703 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/model/BusOrderModel.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/model/BusOrderModel.java @@ -1,5 +1,9 @@ package com.mogo.och.bus.model; +import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_ALIAS_CODE_ADAS_MESSAGE_CAR_STATE; +import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_ALIAS_CODE_OCH_BUS_START_AUTOPILOT; +import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_LINK_ADAS; +import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_LINK_LOG_WEB_SOCKET_AUTOPILOT; import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS; import static com.mogo.och.bus.constant.BusConst.STATION_STATUS_STOPPED; @@ -50,6 +54,8 @@ import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil; import com.mogo.och.common.module.utils.PinYinUtil; import com.mogo.service.statusmanager.IMogoStatusChangedListener; import com.mogo.service.statusmanager.StatusDescriptor; +import com.zhjt.service.chain.ChainLog; +import com.zhjt.service.chain.TracingConstants; import java.io.IOException; import java.util.ArrayList; @@ -465,6 +471,14 @@ public class BusOrderModel { * 服务端返回的OchBusRoutesResult逻辑, 离开站为当前站, 到达下一站后才会将下一站置为当前站, * 车机端展示是离开当前站,下一站设置为当前站, 所以服务端数据回来要做处理,不能直接渲染 */ + @ChainLog( + linkChainLog = CHAIN_LINK_LOG_WEB_SOCKET_AUTOPILOT, + linkCode = CHAIN_LINK_ADAS, + endpoint = TracingConstants.Endpoint.PAD, + nodeAliasCode = CHAIN_ALIAS_CODE_OCH_BUS_START_AUTOPILOT, + paramIndexes = {0}, + clientPkFileName = "sn" + ) private void RenderLeaveStationSuccess(BusRoutesResult result, boolean isRestart) { renderBusStationsStatus(result); if (slidePannelHideCallback != null) { @@ -771,9 +785,7 @@ public class BusOrderModel { */ public void restartAutopilot() { CallerLogger.INSTANCE.d( M_BUS + TAG, "重启自动驾驶===" + isGoingToNextStation ); - if ( isGoingToNextStation ) { - autoDriveToNextStation( true ); - } + autoDriveToNextStation( true ); } /** @@ -859,7 +871,7 @@ public class BusOrderModel { CallerLogger.INSTANCE.e( M_BUS + TAG, "到站异常,取消后续操作结束" ); return; } - if (FunctionBuildConfig.isDemoMode && currentStationIndex == stationList.size() - 1){//到达最后一站结束美化 + if (FunctionBuildConfig.isDemoMode && currentStationIndex == stationList.size() - 1) {//到达最后一站结束美化 FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false; CallerLogger.INSTANCE.d(M_BUS + TAG, "美化模式-ignore:置为false(到最后一站)"); } diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java index bb714c0939..e1b6181a21 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java @@ -43,7 +43,6 @@ public class BusPresenter extends Presenter private static final String TAG = "BusPresenter"; private int currentAutopilotStatus = -1; - private boolean isAnimateRunning = false; private List mStationList = new ArrayList<>(); private int mCurrentStation = 0; @@ -83,6 +82,14 @@ public class BusPresenter extends Presenter BusOrderModel.getInstance().setControllerStatusCallback(null); } +// public void setIsAnimateRunning(boolean isAnimateRunning){ +// this.isAnimateRunning = isAnimateRunning; +// } + +// public boolean getIsAnimateRunning(){ +// return isAnimateRunning; +// } + public void queryBusRoutes() { BusOrderModel.getInstance().queryBusRoutes(); } @@ -97,8 +104,10 @@ public class BusPresenter extends Presenter } public void restartAutopilot() { - currentAutopilotStatus = -1; - BusOrderModel.getInstance().restartAutopilot(); + if (BusOrderModel.getInstance().isGoingToNextStation()){ + currentAutopilotStatus = -1; + BusOrderModel.getInstance().restartAutopilot(); + } } public void onChangeOperationStatus() { @@ -117,7 +126,7 @@ public class BusPresenter extends Presenter mStationList.clear(); mStationList.addAll(stationList); mCurrentStation = currentStation; - functionDemoModeChange(); +// functionDemoModeChange(); CallerLogger.INSTANCE.d(M_BUS + "BusOrderModel =", " mCurrentStation =" + mCurrentStation); if (mView != null) { runOnUIThread(() -> mView.refreshBusStations( @@ -132,7 +141,7 @@ public class BusPresenter extends Presenter || ((mCurrentStation == 0 || mCurrentStation == mStationList.size() - 1) && BusOrderModel.getInstance().isGoingToNextStation()))) { runOnUIThread(() -> mView.onAutopilotStatusChanged( - IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING, false)); + IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING)); } } @@ -183,18 +192,16 @@ public class BusPresenter extends Presenter return; } // 改变UI自动驾驶状态 - runOnUIThread(() -> mView.onAutopilotStatusChanged(currentAutopilotStatus, isAnimateRunning)); + runOnUIThread(() -> mView.onAutopilotStatusChanged(currentAutopilotStatus)); } break; case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING: - runOnUIThread(() -> mView.stopAutopilotAnimation()); if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING; // 改变UI自动驾驶状态 - runOnUIThread(() -> mView.onAutopilotStatusChanged(currentAutopilotStatus, isAnimateRunning)); + runOnUIThread(() -> mView.onAutopilotStatusChanged(currentAutopilotStatus)); BusOrderModel.getInstance().triggerStartServiceEvent(true); } - isAnimateRunning = false; break; case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE: if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) { @@ -215,11 +222,9 @@ public class BusPresenter extends Presenter return; } runOnUIThread(() -> { - mView.onAutopilotEnableChange(false); - mView.onAutopilotStatusChanged(currentAutopilotStatus, isAnimateRunning); + mView.onAutopilotStatusChanged(currentAutopilotStatus); }); } - isAnimateRunning = false; break; default: runOnUIThread(() -> mView.onAutopilotEnableChange(false)); @@ -241,15 +246,8 @@ public class BusPresenter extends Presenter @Override public void startOpenAutopilot() { - isAnimateRunning = true; + //非美化模式下启动动画 runOnUIThread(() -> mView.startAutopilotAnimation()); - // TODO: 2021/8/20 无工控机环境, 手动调起自动驾驶开启返回结果,有工控机环境要删除 -// UiThreadHandler.postDelayed(new Runnable() { -// @Override -// public void run() { -// debugAutoPilotStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING); -// } -// },2300); } private void runOnUIThread(Runnable executor) { diff --git a/OCH/mogo-och-bus/src/main/res/values/strings.xml b/OCH/mogo-och-bus/src/main/res/values/strings.xml index 8ebaa40023..0e7050b014 100644 --- a/OCH/mogo-och-bus/src/main/res/values/strings.xml +++ b/OCH/mogo-och-bus/src/main/res/values/strings.xml @@ -23,4 +23,5 @@ + 自动驾驶状态为0不可用 diff --git a/OCH/mogo-och-taxi-passenger/src/main/res/layout/taxi_p_base_fragment.xml b/OCH/mogo-och-taxi-passenger/src/main/res/layout/taxi_p_base_fragment.xml index 12340dcded..f38dd7ccfc 100644 --- a/OCH/mogo-och-taxi-passenger/src/main/res/layout/taxi_p_base_fragment.xml +++ b/OCH/mogo-och-taxi-passenger/src/main/res/layout/taxi_p_base_fragment.xml @@ -6,28 +6,40 @@ android:layout_height="match_parent" android:layout_marginTop="@dimen/dp_72"> - + - + + + + app:layout_constraintLeft_toLeftOf="parent" />