opt och bus
This commit is contained in:
@@ -9,5 +9,8 @@ public class OchBusConst {
|
||||
public static final int STATION_STATUS_IDLE = 0;
|
||||
public static final int STATION_STATUS_STOPED = 1;
|
||||
public static final int STATION_STATUS_LEAVING = 2;
|
||||
/**
|
||||
* 服务端没有记录此状态,由本地直接维护此状态,方便使用
|
||||
*/
|
||||
public static final int STATION_STATUS_ARRIVING = 3;
|
||||
}
|
||||
|
||||
@@ -71,8 +71,6 @@ public class OchBusFragment extends BaseOchFragment<OchBusFragment, OchBusPresen
|
||||
|
||||
public void showOchBus() {
|
||||
MogoApisHandler.getInstance().getApis().getTopViewManager().removeAllViewInVrMode();
|
||||
|
||||
// tvNotice.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,58 +89,61 @@ public class OchBusFragment extends BaseOchFragment<OchBusFragment, OchBusPresen
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据站点列表信息刷新车站面板,滑块面板
|
||||
*
|
||||
* @param stationList 车站列表信息
|
||||
*/
|
||||
public void refreshBusStations(List<OchBusStation> stationList) {
|
||||
if (getActivity() == null) {
|
||||
return;
|
||||
}
|
||||
getActivity().runOnUiThread(() -> {
|
||||
if (stationList == null) {
|
||||
// todo 获取小巴数据失败
|
||||
} else {
|
||||
// todo 渲染小巴路线数据
|
||||
adapter.refreshStationList(stationList);
|
||||
int currPos = -1;
|
||||
for (int i = 0; i < stationList.size(); i++) {
|
||||
OchBusStation station = stationList.get(i);
|
||||
if (station.getIsCurrentSite() == OchBusConst.STATION_STATUS_ARRIVING) {
|
||||
tvStationName.setText(station.getSiteName());
|
||||
tvStationNotice.setText("下一站");
|
||||
currPos = i;
|
||||
// onAutopilotStatusChanged(true);
|
||||
break;
|
||||
} else if (station.getIsCurrentSite() == OchBusConst.STATION_STATUS_STOPED) {
|
||||
currPos = i;
|
||||
tvStationNotice.setText("当前车站");
|
||||
tvStationName.setText(station.getSiteName());
|
||||
// onAutopilotStatusChanged(false);
|
||||
if (i == stationList.size() - 1) {
|
||||
showNotice("行程结束,请携带好随身物品\n注意侧后方来车\n感谢体验蘑菇智行自动驾驶车!");
|
||||
tvStationNotice.setText("终点");
|
||||
showSlidePanle("单程结束");
|
||||
} else if (i == 0) {
|
||||
hideNotice();
|
||||
showSlidePanle("准备出发");
|
||||
} else {
|
||||
showNotice("行程结束,请携带好随身物品\n注意侧后方来车\n感谢体验蘑菇智行自动驾驶车!");
|
||||
showSlidePanle("乘客已上车,准备出发");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// todo smoothMove
|
||||
int moveTo = currPos + 1;
|
||||
if (currPos < 3) {
|
||||
moveTo = 0;
|
||||
}
|
||||
if (currPos >= stationList.size() - 3) {
|
||||
moveTo = stationList.size() - 1;
|
||||
}
|
||||
if (moveTo >= stationList.size()) {
|
||||
moveTo = stationList.size() - 1;
|
||||
}
|
||||
rvStationList.smoothScrollToPosition(moveTo);
|
||||
// 获取小巴数据失败
|
||||
return;
|
||||
}
|
||||
// 渲染小巴路线数据
|
||||
adapter.refreshStationList(stationList);
|
||||
int currPos = -1;
|
||||
for (int i = 0; i < stationList.size(); i++) {
|
||||
OchBusStation station = stationList.get(i);
|
||||
if (station.getIsCurrentSite() == OchBusConst.STATION_STATUS_ARRIVING) {
|
||||
tvStationName.setText(station.getSiteName());
|
||||
tvStationNotice.setText("下一站");
|
||||
currPos = i;
|
||||
break;
|
||||
} else if (station.getIsCurrentSite() == OchBusConst.STATION_STATUS_STOPED) {
|
||||
currPos = i;
|
||||
tvStationNotice.setText("当前车站");
|
||||
tvStationName.setText(station.getSiteName());
|
||||
if (i == stationList.size() - 1) {
|
||||
showNotice("行程结束,请携带好随身物品\n注意侧后方来车\n感谢体验蘑菇智行自动驾驶车!");
|
||||
tvStationNotice.setText("终点");
|
||||
showSlidePanle("单程结束");
|
||||
} else if (i == 0) {
|
||||
hideNotice();
|
||||
showSlidePanle("准备出发");
|
||||
} else {
|
||||
showNotice("行程结束,请携带好随身物品\n注意侧后方来车\n感谢体验蘑菇智行自动驾驶车!");
|
||||
showSlidePanle("乘客已上车,准备出发");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// smoothMove
|
||||
int moveTo = currPos + 1;
|
||||
if (currPos < 3) {
|
||||
moveTo = 0;
|
||||
}
|
||||
if (currPos >= stationList.size() - 3) {
|
||||
moveTo = stationList.size() - 1;
|
||||
}
|
||||
if (moveTo >= stationList.size()) {
|
||||
moveTo = stationList.size() - 1;
|
||||
}
|
||||
rvStationList.smoothScrollToPosition(moveTo);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -10,12 +10,10 @@ import com.mogo.commons.network.Utils;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.constants.HostConst;
|
||||
import com.mogo.och.OCHConstants;
|
||||
import com.mogo.och.bus.bean.OchBusLeaveStationRequest;
|
||||
import com.mogo.och.bus.bean.OchBusRoutesRequest;
|
||||
import com.mogo.och.bus.bean.OchBusRoutesResponse;
|
||||
import com.mogo.och.bus.bean.OchBusStation;
|
||||
import com.mogo.och.bus.constant.OchBusConst;
|
||||
import com.mogo.och.bus.fragment.OchBusFragment;
|
||||
import com.mogo.och.bus.net.IOchBusApiService;
|
||||
import com.mogo.service.adas.IMogoAdasOCHCallback;
|
||||
@@ -88,14 +86,17 @@ public class OchBusPresenter extends Presenter<OchBusFragment> implements IMogoA
|
||||
if (mView != null && o.getResult() != null && o.getResult().getSite() != null) {
|
||||
stationList.clear();
|
||||
stationList.addAll(o.getResult().getSite());
|
||||
for (int i = 0;i<stationList.size();i++) {
|
||||
for (int i = 0; i < stationList.size(); i++) {
|
||||
OchBusStation s = stationList.get(i);
|
||||
if (s.getIsCurrentSite() == STATION_STATUS_ARRIVING || s.getIsCurrentSite() == STATION_STATUS_LEAVING) {
|
||||
isGoingToNextStation = true;
|
||||
mView.hideSlidePanel();
|
||||
}
|
||||
if (s.getIsCurrentSite() == STATION_STATUS_LEAVING) {
|
||||
// 服务端只记录了leaving状态,没有记录arriving状态,此处端上自己增加一个arriving状态
|
||||
isGoingToNextStation = true;
|
||||
currentStationIndex = i;
|
||||
if (i < stationList.size() - 1) {
|
||||
// 将其下一站置为arriving状态
|
||||
stationList.get(i + 1).setIsCurrentSite(STATION_STATUS_ARRIVING);
|
||||
}
|
||||
mView.hideSlidePanel();
|
||||
}
|
||||
}
|
||||
refreshCurrentStation();
|
||||
@@ -107,32 +108,22 @@ public class OchBusPresenter extends Presenter<OchBusFragment> implements IMogoA
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
Logger.e(TAG, e, "获取小巴路线图失败");
|
||||
// 重复请求小巴路线,直至成功
|
||||
requeryBusStation();
|
||||
// if (mView != null) {
|
||||
// mView.refreshBusStations(null);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
Logger.e(TAG, "获取小巴路线失败 code: " + code + " msg: " + message);
|
||||
// 重复请求小巴路线,直至成功
|
||||
requeryBusStation();
|
||||
// if (mView != null) {
|
||||
// mView.refreshBusStations(null);
|
||||
// }
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getStationListFromSocket(List<OchBusStation> stations) {
|
||||
// 接收长连接消息好像没啥用
|
||||
// stationList.clear();
|
||||
// stationList.addAll(stations);
|
||||
// refreshCurrentStation();
|
||||
// if (mView != null) {
|
||||
// mView.refreshBusStationsInUiThread(stationList);
|
||||
// }
|
||||
}
|
||||
|
||||
private void requeryBusStation() {
|
||||
@@ -275,7 +266,6 @@ public class OchBusPresenter extends Presenter<OchBusFragment> implements IMogoA
|
||||
}
|
||||
break;
|
||||
case IMogoAdasOCHCallback.STATUS_AUTOPILOT_RUNNING:
|
||||
// mView.onAutopilotEnableChange(true);
|
||||
mView.onAutopilotStatusChanged(true);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -12,19 +12,23 @@ public
|
||||
interface IMogoAdasOCHCallback {
|
||||
|
||||
/**
|
||||
* 不可自动驾驶
|
||||
* 不可自动驾驶,目前场景是刚开机,adas还未和工控机连接
|
||||
*/
|
||||
int STATUS_AUTOPILOT_DISABLE = 0;
|
||||
/**
|
||||
* 可自动驾驶
|
||||
* 可自动驾驶,工控机连接正常,且处于人工干预状态
|
||||
*/
|
||||
int STATUS_AUTOPILOT_ENABLE = 1;
|
||||
/**
|
||||
* 自动驾驶中
|
||||
* 自动驾驶中,可能是停车,可能是行进,但是是机器在处理车的前进后退,不是人
|
||||
*/
|
||||
int STATUS_AUTOPILOT_RUNNING = 2;
|
||||
|
||||
|
||||
/**
|
||||
* 到站
|
||||
* @param data 所到车站的简单信息
|
||||
*/
|
||||
void onArriveAt( AdasOCHData data );
|
||||
|
||||
/**
|
||||
|
||||
@@ -669,6 +669,9 @@ public class MogoADASController implements IMogoADASController {
|
||||
|
||||
@Override
|
||||
public int getAutopilotStatus() {
|
||||
if (mockState != -2) {
|
||||
return mockState;
|
||||
}
|
||||
int status = IMogoAdasOCHCallback.STATUS_AUTOPILOT_DISABLE;
|
||||
try {
|
||||
status = AutopilotServiceManage.getInstance().autopilotStateCall().getState();
|
||||
@@ -678,6 +681,7 @@ public class MogoADASController implements IMogoADASController {
|
||||
return status;
|
||||
}
|
||||
|
||||
private int mockState = -2;
|
||||
@Override
|
||||
public void mockOchStatus(int state, String reason) {
|
||||
if(state == -1){
|
||||
@@ -685,6 +689,7 @@ public class MogoADASController implements IMogoADASController {
|
||||
mAdasOCHCallback.onArriveAt(new AdasOCHData(1, 1d, 1d));
|
||||
}
|
||||
}else {
|
||||
mockState = state;
|
||||
if (mAdasOCHCallback != null) {
|
||||
mAdasOCHCallback.onStateChanged(state, reason);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user