Merge remote-tracking branch 'origin/dev2_aiSdk' into dev2_aiSdk

This commit is contained in:
董宏宇
2021-03-26 16:52:46 +08:00
50 changed files with 16933 additions and 5192 deletions

View File

@@ -54,7 +54,6 @@ public class OchBusProvider implements IMogoOCH {
public void init(Context context) {
MogoApisHandler.getInstance().getApis().getStatusManagerApi().registerStatusChangedListener("OchBus", StatusDescriptor.VR_MODE, statusChangedListener);
MogoApisHandler.getInstance().getApis().getStatusManagerApi().registerStatusChangedListener("OchBus", StatusDescriptor.TOP_VIEW, statusChangedListener);
MogoApisHandler.getInstance().getApis().getSocketManagerApi(context).registerOnMessageListener(401017, messageListener);
}
private void showFragment() {
@@ -92,17 +91,4 @@ public class OchBusProvider implements IMogoOCH {
}
};
private final IMogoOnMessageListener<List<OchBusStation>> messageListener = new IMogoOnMessageListener<List<OchBusStation>>() {
@Override
public Class<List<OchBusStation>> target() {
return null;
}
@Override
public void onMsgReceived(List<OchBusStation> obj) {
// 刷新列表
busFragment.getPresenter().getStationListFromSocket(obj);
}
};
}

View File

@@ -37,7 +37,7 @@ public class OchBusStationAdapter extends RecyclerView.Adapter<OchBusStationAdap
this.stationList.addAll(stationList);
for (int i = 0; i < stationList.size(); i++) {
OchBusStation station = stationList.get(i);
if (station.getIsCurrentSite() == OchBusConst.STATION_STATUS_ARRIVING || station.getIsCurrentSite() == OchBusConst.STATION_STATUS_STOPED) {
if (station.getIsCurrentSite() == OchBusConst.STATION_STATUS_ARRIVING || station.getIsCurrentSite() == OchBusConst.STATION_STATUS_STOPPED ) {
currentStation = i;
break;
}

View File

@@ -0,0 +1,15 @@
package com.mogo.och.bus.bean;
import java.util.List;
public
/**
* @author congtaowang
* @since 2021/3/23
* <p>
* 小巴达到站点,推送需要下车的乘客列表
*/
class OchBusArriveAtStationMsg {
}

View File

@@ -0,0 +1,32 @@
package com.mogo.och.bus.bean;
import com.mogo.commons.network.Utils;
import com.mogo.utils.network.utils.Util;
public
/**
* @author congtaowang
* @since 2021/3/22
*
* 小巴车运营状态请求参数
*/
class OchBusOperationStatusRequest {
public String sn;
// 0 - 关闭、1 - 启动
public String status;
public OchBusOperationStatusRequest() {
this.sn = Utils.getSn();
}
public OchBusOperationStatusRequest shutdown() {
status = "0";
return this;
}
public OchBusOperationStatusRequest launch() {
status = "1";
return this;
}
}

View File

@@ -0,0 +1,24 @@
package com.mogo.och.bus.bean;
import com.mogo.commons.data.BaseData;
public
/**
* @author congtaowang
* @since 2021/3/22
*
* 小巴车运营状态请求参数
*/
class OchBusOperationStatusResponse extends BaseData {
public Result result;
public static class Result {
public String id;
public String sn;
public String areaCode;
public String plateNumber;
public int status;
}
}

View File

@@ -0,0 +1,227 @@
package com.mogo.och.bus.bean;
import java.util.List;
public
/**
* @author congtaowang
* @since 2021/3/23
* <p>
* 小巴订单
*/
class OchBusOrder {
/**
* _id : bf014b186a0d417e8086f324e5cbcd1d
* orderNo : XB20210324000002
* orderType : 10
* userName : 星期一
* userPhone : 15555555555
* startStationId : 1
* startStation : 万集东门站
* startStationCoordinate : [116.7354579447,40.1974932972]
* endStationId : 2
* endStation : 顺密路口站
* endStationCoordinate : [116.7215386924,40.194019209]
* orderDispatchType : 1
* carNum : 京NB007
* sn : F803BB2037EZD00088
* orderStartTime : Mar 24, 2021 12:51:51 PM
* orderEndTime : Mar 24, 2021 1:38:13 PM
* cityCode : 010
* areaCode : 1001
* createTime : Mar 24, 2021 12:51:51 PM
* updateTime : Mar 24, 2021 1:38:13 PM
* travelDistance : 1.2
*/
private String _id;
private String orderNo;
private int orderType;
private String userName;
private String userPhone;
private int startStationId;
private String startStation;
private int endStationId;
private String endStation;
private int orderDispatchType;
private String carNum;
private String sn;
private String orderStartTime;
private String orderEndTime;
private String cityCode;
private String areaCode;
private String createTime;
private String updateTime;
private double travelDistance;
private List< Double > startStationCoordinate;
private List< Double > endStationCoordinate;
public String get_id() {
return _id;
}
public void set_id( String _id ) {
this._id = _id;
}
public String getOrderNo() {
return orderNo;
}
public void setOrderNo( String orderNo ) {
this.orderNo = orderNo;
}
public int getOrderType() {
return orderType;
}
public void setOrderType( int orderType ) {
this.orderType = orderType;
}
public String getUserName() {
return userName;
}
public void setUserName( String userName ) {
this.userName = userName;
}
public String getUserPhone() {
return userPhone;
}
public void setUserPhone( String userPhone ) {
this.userPhone = userPhone;
}
public int getStartStationId() {
return startStationId;
}
public void setStartStationId( int startStationId ) {
this.startStationId = startStationId;
}
public String getStartStation() {
return startStation;
}
public void setStartStation( String startStation ) {
this.startStation = startStation;
}
public int getEndStationId() {
return endStationId;
}
public void setEndStationId( int endStationId ) {
this.endStationId = endStationId;
}
public String getEndStation() {
return endStation;
}
public void setEndStation( String endStation ) {
this.endStation = endStation;
}
public int getOrderDispatchType() {
return orderDispatchType;
}
public void setOrderDispatchType( int orderDispatchType ) {
this.orderDispatchType = orderDispatchType;
}
public String getCarNum() {
return carNum;
}
public void setCarNum( String carNum ) {
this.carNum = carNum;
}
public String getSn() {
return sn;
}
public void setSn( String sn ) {
this.sn = sn;
}
public String getOrderStartTime() {
return orderStartTime;
}
public void setOrderStartTime( String orderStartTime ) {
this.orderStartTime = orderStartTime;
}
public String getOrderEndTime() {
return orderEndTime;
}
public void setOrderEndTime( String orderEndTime ) {
this.orderEndTime = orderEndTime;
}
public String getCityCode() {
return cityCode;
}
public void setCityCode( String cityCode ) {
this.cityCode = cityCode;
}
public String getAreaCode() {
return areaCode;
}
public void setAreaCode( String areaCode ) {
this.areaCode = areaCode;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime( String createTime ) {
this.createTime = createTime;
}
public String getUpdateTime() {
return updateTime;
}
public void setUpdateTime( String updateTime ) {
this.updateTime = updateTime;
}
public double getTravelDistance() {
return travelDistance;
}
public void setTravelDistance( double travelDistance ) {
this.travelDistance = travelDistance;
}
public List< Double > getStartStationCoordinate() {
return startStationCoordinate;
}
public void setStartStationCoordinate( List< Double > startStationCoordinate ) {
this.startStationCoordinate = startStationCoordinate;
}
public List< Double > getEndStationCoordinate() {
return endStationCoordinate;
}
public void setEndStationCoordinate( List< Double > endStationCoordinate ) {
this.endStationCoordinate = endStationCoordinate;
}
}

View File

@@ -19,7 +19,15 @@ public class OchBusStation {
private int isCurrentSite;
private int siteColor;
private String peoples;
private int ifStop; // 是否需要停靠、1需要、0不需要
public int getIfStop() {
return ifStop;
}
public void setIfStop( int ifStop ) {
this.ifStop = ifStop;
}
public int getLineId() {
return lineId;

View File

@@ -0,0 +1,15 @@
package com.mogo.och.bus.bean;
import java.util.List;
public
/**
* @author congtaowang
* @since 2021/3/25
*
* 小巴站点信息变更:停靠状态等
*/
class OchBusStationsChangedMsg {
public List< OchBusStation > data;
}

View File

@@ -0,0 +1,19 @@
package com.mogo.och.bus.bean;
import com.mogo.commons.network.Utils;
public
/**
* @author congtaowang
* @since 2021/3/22
*
* 小巴车运营状态请求参数
*/
class QueryOchBusOperationStatusRequest {
public String sn;
public QueryOchBusOperationStatusRequest() {
this.sn = Utils.getSn();
}
}

View File

@@ -0,0 +1,23 @@
package com.mogo.och.bus.bean;
import com.mogo.commons.network.Utils;
public
/**
* @author congtaowang
* @since 2021/3/22
*
* 小巴车运营状态请求参数
*/
class UpdateSiteStatusRequest {
public String sn;
// 0 - 关闭、1 - 启动
public int siteId;
public UpdateSiteStatusRequest( int siteId ) {
this.sn = Utils.getSn();
this.siteId = siteId;
}
}

View File

@@ -6,11 +6,12 @@ package com.mogo.och.bus.constant;
* @author tongchenfei
*/
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_STOPPED = 1;
// 离开某一站
public static final int STATION_STATUS_LEAVING = 2;
/**
* 服务端没有记录此状态,由本地直接维护此状态,方便使用
*/
// 下一站
public static final int STATION_STATUS_ARRIVING = 3;
}

View File

@@ -1,5 +1,6 @@
package com.mogo.och.bus.fragment;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
@@ -7,6 +8,7 @@ import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.och.BaseOchFragment;
import com.mogo.och.bus.R;
@@ -19,7 +21,6 @@ import com.mogo.service.adas.IMogoAdasOCHCallback;
import com.mogo.utils.TipToast;
import com.mogo.utils.logger.Logger;
import java.util.ArrayList;
import java.util.List;
@@ -28,135 +29,55 @@ import java.util.List;
*
* @author tongchenfei
*/
public class OchBusFragment extends BaseOchFragment<OchBusFragment, OchBusPresenter> implements SlidePanelView.OnSlidePanelMoveToEndListener {
public class OchBusFragment extends BaseOchFragment< OchBusFragment, OchBusPresenter > implements SlidePanelView.OnSlidePanelMoveToEndListener {
private static final String TAG = "OchBusFragment";
private TextView tvStationNotice;
private TextView tvStationName;
private RecyclerView rvStationList;
private TextView mCurrentStationName;
private TextView mStartStationFlag;
private TextView mNextStationName;
private TextView mEndStationFlag;
private OchBusStationAdapter adapter;
private View mBus;
private int stationSizeLevel = 2;
// private OchBusStationAdapter adapter;
@Override
protected void initViews() {
super.initViews();
tvStationNotice = findViewById(R.id.module_mogo_och_bus_current_station_notice);
tvStationName = findViewById(R.id.module_mogo_och_bus_current_station_name);
rvStationList = findViewById(R.id.module_mogo_och_bus_rv_station_list);
mBus = findViewById( R.id.module_och_bus_tag );
mCurrentStationName = findViewById( R.id.module_och_bus_current_station );
mStartStationFlag = findViewById( R.id.module_och_bus_start_station_tag );
mNextStationName = findViewById( R.id.module_och_bus_order_end_station );
mEndStationFlag = findViewById( R.id.module_och_bus_end_station_tag );
adapter = new OchBusStationAdapter(getContext());
rvStationList.setAdapter(adapter);
rvStationList.setLayoutManager(new LinearLayoutManager(getContext()));
// adapter = new OchBusStationAdapter( getContext() );
// rvStationList.setAdapter( adapter );
// rvStationList.setLayoutManager( new LinearLayoutManager( getContext() ) );
tvStationName.setOnLongClickListener(view -> {
TipToast.shortTip("重置了车站状态");
mPresenter.debugResetStationStatus();
return true;
});
if ( DebugConfig.isDebug() ) {
mBus.setOnClickListener( view -> {
TipToast.shortTip( "重置了车站状态" );
mPresenter.debugResetStationStatus();
} );
tvStationNotice.setOnLongClickListener(view -> {
getActivity().finish();
return true;
});
// tvStationNotice.setOnClickListener(view -> {
// // todo debug code
// List<OchBusStation> stationList = new ArrayList<>();
// OchBusStation station;
// switch (stationSizeLevel) {
// case 2:
// stationSizeLevel++;
// station = new OchBusStation();
// station.setSiteName("第一站");
// station.setIsCurrentSite(OchBusConst.STATION_STATUS_STOPED);
// stationList.add(station);
// station = new OchBusStation();
// station.setSiteName("第二站");
// station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE);
// stationList.add(station);
// break;
// case 3:
// stationSizeLevel++;
// station = new OchBusStation();
// station.setSiteName("第一站");
// station.setIsCurrentSite(OchBusConst.STATION_STATUS_STOPED);
// stationList.add(station);
// station = new OchBusStation();
// station.setSiteName("第二站");
// station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE);
// stationList.add(station);
// station = new OchBusStation();
// station.setSiteName("第三站");
// station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE);
// stationList.add(station);
// break;
// case 4:
// stationSizeLevel++;
// station = new OchBusStation();
// station.setSiteName("第一站");
// station.setIsCurrentSite(OchBusConst.STATION_STATUS_STOPED);
// stationList.add(station);
// station = new OchBusStation();
// station.setSiteName("第二站");
// station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE);
// stationList.add(station);
// station = new OchBusStation();
// station.setSiteName("第三站");
// station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE);
// stationList.add(station);
// station = new OchBusStation();
// station.setSiteName("第四站");
// station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE);
// stationList.add(station);
// break;
// default:
// stationSizeLevel = 2;
// station = new OchBusStation();
// station.setSiteName("第一站");
// station.setIsCurrentSite(OchBusConst.STATION_STATUS_STOPED);
// stationList.add(station);
// station = new OchBusStation();
// station.setSiteName("第二站");
// station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE);
// stationList.add(station);
// station = new OchBusStation();
// station.setSiteName("第三站");
// station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE);
// stationList.add(station);
// station = new OchBusStation();
// station.setSiteName("第四站");
// station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE);
// stationList.add(station);
// station = new OchBusStation();
// station.setSiteName("第五站");
// station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE);
// stationList.add(station);
// station = new OchBusStation();
// station.setSiteName("第五站");
// station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE);
// stationList.add(station);
// station = new OchBusStation();
// station.setSiteName("第五站");
// station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE);
// stationList.add(station);
// break;
// }
// refreshBusStations(stationList);
// });
mBus.setOnLongClickListener( view -> {
getActivity().finish();
return true;
} );
}
Logger.d(TAG, "initView: " + MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus());
switch (MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus()) {
Logger.d( TAG, "initView: " + MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus() );
switch ( MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus() ) {
case IMogoAdasOCHCallback.STATUS_AUTOPILOT_DISABLE:
hideAutopilotBiz();
break;
case IMogoAdasOCHCallback.STATUS_AUTOPILOT_ENABLE:
showAutopilotBiz();
onAutopilotStatusChanged(false);
onAutopilotStatusChanged( false );
break;
case IMogoAdasOCHCallback.STATUS_AUTOPILOT_RUNNING:
showAutopilotBiz();
onAutopilotStatusChanged(true);
onAutopilotStatusChanged( true );
break;
default:
break;
@@ -166,27 +87,12 @@ public class OchBusFragment extends BaseOchFragment<OchBusFragment, OchBusPresen
@NonNull
@Override
protected OchBusPresenter createPresenter() {
return new OchBusPresenter(this);
}
public void showOchBus() {
MogoApisHandler.getInstance().getApis().getTopViewManager().removeAllViewInVrMode();
return new OchBusPresenter( this );
}
@Override
public void onResume() {
super.onResume();
queryStationListIfNecessary();
}
@Override
public void onHiddenChanged(boolean hidden) {
super.onHiddenChanged(hidden);
Logger.d(TAG, "onHiddenChanged: " + hidden);
if (!hidden) {
// 判断是否需要请求接口
queryStationListIfNecessary();
}
}
/**
@@ -194,87 +100,84 @@ public class OchBusFragment extends BaseOchFragment<OchBusFragment, OchBusPresen
*
* @param stationList 车站列表信息
*/
public void refreshBusStations(List<OchBusStation> stationList) {
if (getActivity() == null) {
public void refreshBusStations( List< OchBusStation > stationList, int currentStation, int nextStation ) {
if ( getActivity() == null ) {
return;
}
getActivity().runOnUiThread(() -> {
if (stationList == null) {
getActivity().runOnUiThread( () -> {
if ( stationList == null ) {
// 获取小巴数据失败
return;
}
// 根据车站数量调整面板高度分为23>3
ViewGroup.LayoutParams params = rvStationList.getLayoutParams();
switch (stationList.size()) {
case 2:
params.height = getResources().getDimensionPixelSize(R.dimen.module_mogo_och_bus_two_station_list_height);
break;
case 3:
params.height = getResources().getDimensionPixelSize(R.dimen.module_mogo_och_bus_three_station_list_height);
break;
default:
params.height = getResources().getDimensionPixelSize(R.dimen.module_mogo_och_bus_station_list_height);
break;
}
rvStationList.setLayoutParams(params);
// 渲染小巴路线数据
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_STOPED) {
currPos = i;
tvStationNotice.setText("当前车站");
tvStationName.setText(station.getSiteName());
if (i == stationList.size() - 1) {
showNotice("行程结束,请携带好随身物品,注意侧后方来车,感谢体验蘑菇智行自动驾驶车!");
tvStationNotice.setText("终点");
showSlidePanle("单程结束");
} else if (i == 0) {
hideNotice();
showSlidePanle("准备出发");
} else {
showNotice("行程结束,请携带好随身物品,注意侧后方来车,感谢体验蘑菇智行自动驾驶车!");
showSlidePanle("乘客已上车,准备出发");
}
break;
}else if (station.getIsCurrentSite() == OchBusConst.STATION_STATUS_ARRIVING) {
tvStationName.setText(station.getSiteName());
tvStationNotice.setText("下一站");
currPos = i;
break;
}
}
// smoothMove
if (stationList.size() < 5) {
//数量太少不进行smooth move
return;
}
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);
});
// 渲染小巴路线数据
renderCurrentStationStatus( stationList, currentStation, nextStation );
} );
}
/**
* 重新刷新站点信息
*/
private void renderCurrentStationStatus( List< OchBusStation > stationList, int currentStation, int nextStation ) {
String currentStationName = null;
String nextStationName = null;
int startStationFlagVisibility = View.INVISIBLE;
int endStationFlagVisibility = View.INVISIBLE;
boolean isArriveEndStation = false;
boolean isArriveAtStation = false;
boolean isArriveAtStartStation = false;
for ( OchBusStation ochBusStation : stationList ) {
int index = stationList.indexOf( ochBusStation );
switch ( ochBusStation.getIsCurrentSite() ) {
case OchBusConst.STATION_STATUS_STOPPED:
isArriveEndStation = index == stationList.size() - 1;
isArriveAtStation = true;
case OchBusConst.STATION_STATUS_LEAVING:
break;
case OchBusConst.STATION_STATUS_ARRIVING:
break;
}
}
if ( currentStation == 0 ) {
startStationFlagVisibility = View.VISIBLE;
isArriveAtStartStation = true;
}
if ( nextStation == stationList.size() - 1 ) {
endStationFlagVisibility = View.VISIBLE;
}
currentStationName = stationList.get( currentStation ).getSiteName();
if ( nextStation < stationList.size() ) {
nextStationName = stationList.get( nextStation ).getSiteName();
}
if ( isArriveEndStation ) {
showNotice( "行程结束,请携带好随身物品,注意侧后方来车,感谢体验蘑菇智行自动驾驶车!" );
showSlidePanle( "单程结束" );
} else if ( isArriveAtStartStation ) {
showSlidePanle( "准备出发" );
} else if ( isArriveAtStation ) {
showNotice( "行程结束,请携带好随身物品,注意侧后方来车,感谢体验蘑菇智行自动驾驶车!" );
showSlidePanle( "乘客已上车,准备出发" );
}
mCurrentStationName.setText( currentStationName );
mNextStationName.setText( nextStationName );
mStartStationFlag.setVisibility( startStationFlagVisibility );
mEndStationFlag.setVisibility( endStationFlagVisibility );
}
public void hideOchBus() {
// tvNotice.setVisibility(View.GONE);
}
private void queryStationListIfNecessary() {
if (adapter.getItemCount() == 0) {
mPresenter.queryBusRoutes();
}
}
@Override
public int getStationPanelViewId() {
return R.layout.fragment_och_bus;
@@ -283,7 +186,7 @@ public class OchBusFragment extends BaseOchFragment<OchBusFragment, OchBusPresen
@Override
public void restartAutopilot() {
// 如果能自动驾驶,就自动驾驶,不能就提示
if (MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus() == IMogoAdasOCHCallback.STATUS_AUTOPILOT_ENABLE) {
if ( MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus() == IMogoAdasOCHCallback.STATUS_AUTOPILOT_ENABLE ) {
mPresenter.restartAutopilot();
}
}
@@ -298,12 +201,25 @@ public class OchBusFragment extends BaseOchFragment<OchBusFragment, OchBusPresen
mPresenter.autoDriveToNextStation();
}
public void onAutopilotEnableChange(boolean isEnable) {
if (isEnable) {
public void onAutopilotEnableChange( boolean isEnable ) {
if ( isEnable ) {
showAutopilotBiz();
} else {
hideAutopilotBiz();
}
}
@Override
protected void onChangeOperationStatus() {
super.onChangeOperationStatus();
mPresenter.onChangeOperationStatus();
}
public void changeOperationStatus( boolean launch ) {
if ( launch ) {
tvOperationStatus.setText( "关闭" );
} else {
tvOperationStatus.setText( "开启" );
}
}
}

View File

@@ -1,7 +1,11 @@
package com.mogo.och.bus.net;
import com.mogo.commons.data.BaseData;
import com.mogo.och.bus.bean.OchBusOperationStatusRequest;
import com.mogo.och.bus.bean.OchBusOperationStatusResponse;
import com.mogo.och.bus.bean.OchBusRoutesResponse;
import com.mogo.och.bus.bean.QueryOchBusOperationStatusRequest;
import com.mogo.och.bus.bean.UpdateSiteStatusRequest;
import io.reactivex.Observable;
import okhttp3.RequestBody;
@@ -13,38 +17,70 @@ import retrofit2.http.POST;
* 小巴车相关接口
*
* @author tongchenfei
* <p>
* wiki: http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=48970072
*/
public interface IOchBusApiService {
/**
* 根据车机坐标获取所在区域全部站点信息
* <p>
* wiki: http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=48970072
*
* @param requestBody 请求参数
* @return 接口返回数据
*/
@Headers({"Content-Type:application/json;charset=UTF-8"})
@POST("/yycp-onlinecar-hailing/onlineCarHailing/site/querySiteByCoordinate/v1")
Observable<OchBusRoutesResponse> querySiteByCoordinate(@Body RequestBody requestBody);
@Headers( {"Content-Type:application/json;charset=UTF-8"} )
@POST( "/yycp-onlinecar-hailing/onlineCarHailing/site/querySiteByCoordinate/v1" )
Observable< OchBusRoutesResponse > querySiteByCoordinate( @Body RequestBody requestBody );
/**
* 公交车驶离车站时,通知服务端
*
* @param requestBody 请求参数 {"sn":"","siteId":"车站id"}
* @return 无返回值
*/
@Headers({"Content-Type:application/json;charset=UTF-8"})
@POST("/yycp-onlinecar-hailing/onlineCarHailing/site/siteCrashCheck/v1")
Observable<BaseData> leaveStation(@Body RequestBody requestBody);
@Headers( {"Content-Type:application/json;charset=UTF-8"} )
@POST( "/yycp-onlinecar-hailing/onlineCarHailing/site/siteCrashCheck/v1" )
Observable< BaseData > leaveStation( @Body RequestBody requestBody );
/**
* 调试用重置接口
*
* @param requestBody 请求参数{"siteId":1,"sn":"F803EB2046PZD00229"}
* @return 返回值是重置后的车站列表
*/
@Headers({"Content-Type:application/json;charset=UTF-8"})
@POST("/yycp-onlinecar-hailing/onlineCarHailing/site/resetSiteByCoordinate/v1")
Observable<OchBusRoutesResponse> debugResetStationStatus(@Body RequestBody requestBody);
@Headers( {"Content-Type:application/json;charset=UTF-8"} )
@POST( "/yycp-onlinecar-hailing/onlineCarHailing/site/resetSiteByCoordinate/v1" )
Observable< OchBusRoutesResponse > debugResetStationStatus( @Body RequestBody requestBody );
/**
* 修改小巴运营状态
*
* @param request
* @return
*/
@Headers( {"Content-type:application/json;charset=UTF-8"} )
@POST( "/yycp-onlinecar-hailing/onlineCarHailing/busOrder/updateBusStatus/v1" )
Observable< BaseData > changeOperationStatus( @Body OchBusOperationStatusRequest request );
/**
* 查询小巴运营状态
*
* @param request
* @return
*/
@Headers( {"Content-type:application/json;charset=UTF-8"} )
@POST( "/yycp-onlinecar-hailing/onlineCarHailing/busOrder/queryBusStatus/v1" )
Observable< OchBusOperationStatusResponse > queryOperationStatus( @Body QueryOchBusOperationStatusRequest request );
/**
* 更新到站信息
*
* @param request
* @return
*/
@Headers( {"Content-type:application/json;charset=UTF-8"} )
@POST( "/yycp-onlinecar-hailing/onlineCarHailing/site/siteDynamic/v1" )
Observable< OchBusRoutesResponse > updateSiteStation( @Body UpdateSiteStatusRequest request );
}

View File

@@ -0,0 +1,156 @@
package com.mogo.och.bus.presenter;
import android.content.Context;
import android.os.Looper;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.och.bus.bean.OchBusArriveAtStationMsg;
import com.mogo.och.bus.bean.OchBusOrder;
import com.mogo.och.bus.bean.OchBusStation;
import com.mogo.och.bus.bean.OchBusStationsChangedMsg;
import com.mogo.service.connection.IMogoOnMessageListener;
import com.mogo.utils.UiThreadHandler;
import java.util.List;
public
/**
* @author congtaowang
* @since 2021/3/23
*
* 小巴订单管理
*/
class OchBusOrderModel {
private static volatile OchBusOrderModel sInstance;
public static OchBusOrderModel getInstance() {
if ( sInstance == null ) {
synchronized ( OchBusOrderModel.class ) {
if ( sInstance == null ) {
sInstance = new OchBusOrderModel();
}
}
}
return sInstance;
}
public void init() {
mContext = AbsMogoApplication.getApp();
MogoApisHandler.getInstance().getApis().getSocketManagerApi( mContext ).registerOnMessageListener( 401021, mOnOrderListener );
MogoApisHandler.getInstance().getApis().getSocketManagerApi( mContext ).registerOnMessageListener( 401020, mOnBusStationsChangedMsg );
}
private Object readResolve() {
// 阻止反序列化,必须实现 Serializable 接口
return sInstance;
}
private Context mContext;
/**
* 小巴订单
* <p>
* 1. 新订单
*/
private IMogoOnMessageListener< OchBusOrder > mOnOrderListener = new IMogoOnMessageListener< OchBusOrder >() {
@Override
public Class< OchBusOrder > target() {
return OchBusOrder.class;
}
@Override
public void onMsgReceived( OchBusOrder obj ) {
if ( obj == null ) {
return;
}
runOnUiThread( () -> {
if ( mOnBusOrderChangedListener != null ) {
mOnBusOrderChangedListener.onBusOrderChanged( obj );
}
} );
}
};
/**
* 小巴达到站点,推送需要下车的乘客列表
*/
private IMogoOnMessageListener< OchBusArriveAtStationMsg > mOnBusArriveAtStationMsg = new IMogoOnMessageListener< OchBusArriveAtStationMsg >() {
@Override
public Class< OchBusArriveAtStationMsg > target() {
return OchBusArriveAtStationMsg.class;
}
@Override
public void onMsgReceived( OchBusArriveAtStationMsg obj ) {
onArriveAtStation();
}
};
/**
* 站点信息变更推送
*/
private IMogoOnMessageListener< OchBusStationsChangedMsg > mOnBusStationsChangedMsg = new IMogoOnMessageListener< OchBusStationsChangedMsg >() {
@Override
public Class< OchBusStationsChangedMsg > target() {
return OchBusStationsChangedMsg.class;
}
@Override
public void onMsgReceived( OchBusStationsChangedMsg obj ) {
if ( obj == null ) {
return;
}
runOnUiThread( () -> {
if ( mOnBusStationsChangedListener != null ) {
mOnBusStationsChangedListener.onBusStationsChanged( obj.data );
}
} );
}
};
private OnBusStationsChangedListener mOnBusStationsChangedListener;
private OnBusOrderChangedListener mOnBusOrderChangedListener;
private OchBusOrderModel() {
}
/**
* 小巴到站
*/
public void onArriveAtStation() {
}
public void setOnBusStationsChangedListener( OnBusStationsChangedListener onBusStationsChangedListener ) {
this.mOnBusStationsChangedListener = onBusStationsChangedListener;
}
public void setOnBusOrderChangedListener( OnBusOrderChangedListener mOnBusOrderChangedListener ) {
this.mOnBusOrderChangedListener = mOnBusOrderChangedListener;
}
/**
* 站点信息
*/
public interface OnBusStationsChangedListener {
void onBusStationsChanged( List< OchBusStation > data );
}
/**
* 站点信息
*/
public interface OnBusOrderChangedListener {
void onBusOrderChanged( OchBusOrder order );
}
private void runOnUiThread( Runnable runnable ) {
if ( Looper.myLooper() == Looper.getMainLooper() ) {
runnable.run();
} else {
UiThreadHandler.postDelayed( runnable, 0 );
}
}
}

View File

@@ -2,19 +2,29 @@ package com.mogo.och.bus.presenter;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.lifecycle.LifecycleOwner;
import com.mogo.commons.data.BaseData;
import com.mogo.commons.mvp.Presenter;
import com.mogo.commons.network.SubscribeImpl;
import com.mogo.commons.network.Utils;
import com.mogo.commons.voice.AIAssist;
import com.mogo.map.location.MogoLocation;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.constants.HostConst;
import com.mogo.och.bus.bean.OchBusLeaveStationRequest;
import com.mogo.och.bus.bean.OchBusOperationStatusRequest;
import com.mogo.och.bus.bean.OchBusOperationStatusResponse;
import com.mogo.och.bus.bean.OchBusOrder;
import com.mogo.och.bus.bean.OchBusResetRequest;
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.bean.QueryOchBusOperationStatusRequest;
import com.mogo.och.bus.bean.UpdateSiteStatusRequest;
import com.mogo.och.bus.fragment.OchBusFragment;
import com.mogo.och.bus.net.IOchBusApiService;
import com.mogo.service.adas.IMogoAdasOCHCallback;
@@ -35,309 +45,464 @@ import okhttp3.RequestBody;
import static com.mogo.och.bus.constant.OchBusConst.STATION_STATUS_ARRIVING;
import static com.mogo.och.bus.constant.OchBusConst.STATION_STATUS_IDLE;
import static com.mogo.och.bus.constant.OchBusConst.STATION_STATUS_LEAVING;
import static com.mogo.och.bus.constant.OchBusConst.STATION_STATUS_STOPED;
import static com.mogo.och.bus.constant.OchBusConst.STATION_STATUS_STOPPED;
/**
* 网约车小巴
*
* @author tongchenfei
*/
public class OchBusPresenter extends Presenter<OchBusFragment> implements IMogoAdasOCHCallback, Handler.Callback {
public class OchBusPresenter extends Presenter< OchBusFragment > implements IMogoAdasOCHCallback,
Handler.Callback,
OchBusOrderModel.OnBusStationsChangedListener,
OchBusOrderModel.OnBusOrderChangedListener {
private static final String TAG = "OchBusPresenter";
private static final int VEHICAL_TYPE = 10;
private static final int MSG_REQUERY_BUS_STATION = 1001;
private static final long REQUERY_BUS_STATION_DELAY = 5000;
// 运营类型
private static final int VEHICLE_TYPE = 10;
private static final int MSG_QUERY_BUS_STATION = 1001;
private static final long QUERY_BUS_STATION_DELAY = 5000;
/**
* 用来表示是否正在开往下一站
*/
private boolean isGoingToNextStation = false;
public OchBusPresenter(OchBusFragment view) {
super(view);
MogoApisHandler.getInstance().getApis().getAdasControllerApi().addAdasOCHCallback(this);
private IOchBusApiService mService;
/**
* 运营状态
*/
private boolean mIsWorking = false;
public OchBusPresenter( OchBusFragment view ) {
super( view );
mService = MogoApisHandler.getInstance().getApis().getNetworkApi().create( IOchBusApiService.class, HostConst.OCH_DOMAIN );
MogoApisHandler.getInstance().getApis().getAdasControllerApi().addAdasOCHCallback( this );
OchBusOrderModel.getInstance().init();
OchBusOrderModel.getInstance().setOnBusStationsChangedListener( this );
OchBusOrderModel.getInstance().setOnBusOrderChangedListener( this );
}
private final Handler handler = new Handler(this);
private final Handler handler = new Handler( this );
private final List<OchBusStation> stationList = new ArrayList<>();
private final List< OchBusStation > stationList = new ArrayList<>();
private int currentStationIndex = 0;
@Override
public void onCreate( @NonNull LifecycleOwner owner ) {
super.onCreate( owner );
queryOperationStatus();
queryBusRoutes();
}
/**
* 查询小巴路线
*/
public void queryBusRoutes() {
double lat = 0;
double lon = 0;
MogoLocation lastLocation = MogoApisHandler.getInstance().getApis().getMapServiceApi().getSingletonLocationClient(getContext()).getLastKnowLocation();
if (lastLocation != null) {
lat = lastLocation.getLatitude();
lon = lastLocation.getLongitude();
double lat = 40.1974932972;
double lon = 116.7354579447;
MogoLocation lastLocation = MogoApisHandler.getInstance().getApis().getMapServiceApi().getSingletonLocationClient( getContext() ).getLastKnowLocation();
if ( lastLocation != null ) {
// lat = lastLocation.getLatitude();
// lon = lastLocation.getLongitude();
}
OchBusRoutesRequest request = new OchBusRoutesRequest(Utils.getSn(), lat, lon);
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(request));
MogoApisHandler.getInstance().getApis().getNetworkApi()
.create(IOchBusApiService.class, HostConst.OCH_DOMAIN)
.querySiteByCoordinate(requestBody)
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<OchBusRoutesResponse>(RequestOptions.create(getContext())) {
OchBusRoutesRequest request = new OchBusRoutesRequest( Utils.getSn(), lat, lon );
RequestBody requestBody = RequestBody.create( MediaType.get( "application/json;charset=UTF-8" ), GsonUtil.jsonFromObject( request ) );
mService.querySiteByCoordinate( requestBody )
.subscribeOn( Schedulers.io() ).observeOn( AndroidSchedulers.mainThread() )
.subscribe( new SubscribeImpl< OchBusRoutesResponse >( RequestOptions.create( getContext() ) ) {
@Override
public void onSuccess(OchBusRoutesResponse o) {
super.onSuccess(o);
Logger.d(TAG, "获取到小巴路线数据: " + o);
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++) {
OchBusStation s = stationList.get(i);
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();
mView.refreshBusStations(stationList);
public void onSuccess( OchBusRoutesResponse o ) {
super.onSuccess( o );
if ( o == null
|| o.getResult() == null
|| o.getResult().getSite() == null
|| o.getResult().getSite().isEmpty() ) {
return;
}
Logger.d( TAG, "获取到小巴路线数据: " + o );
renderBusStationsStatus( o.getResult().getSite() );
}
@Override
public void onError(Throwable e) {
super.onError(e);
Logger.e(TAG, e, "获取小巴路线图失败");
public void onError( Throwable e ) {
super.onError( e );
Logger.e( TAG, e, "获取小巴路线图失败" );
// 重复请求小巴路线,直至成功
requeryBusStation();
queryBusStationDelay();
}
@Override
public void onError(String message, int code) {
super.onError(message, code);
Logger.e(TAG, "获取小巴路线失败 code: " + code + " msg: " + message);
public void onError( String message, int code ) {
super.onError( message, code );
Logger.e( TAG, "获取小巴路线失败 code: " + code + " msg: " + message );
// 重复请求小巴路线,直至成功
requeryBusStation();
queryBusStationDelay();
}
});
} );
}
public void getStationListFromSocket(List<OchBusStation> stations) {
// 接收长连接消息好像没啥用
/**
* 渲染站点信息
*
* @param site
*/
private void renderBusStationsStatus( List< OchBusStation > site ) {
stationList.clear();
stationList.addAll( site );
for ( int i = 0; i < stationList.size(); i++ ) {
OchBusStation s = stationList.get( i );
if ( s.getIsCurrentSite() == STATION_STATUS_LEAVING ) {
isGoingToNextStation = true;
mView.hideSlidePanel();
}
if ( s.getIsCurrentSite() == STATION_STATUS_LEAVING
|| s.getIsCurrentSite() == STATION_STATUS_STOPPED ) {
currentStationIndex = i;
}
}
mView.refreshBusStations( stationList, currentStationIndex, getNextStopStation() );
}
private void requeryBusStation() {
handler.sendEmptyMessageDelayed(MSG_REQUERY_BUS_STATION, REQUERY_BUS_STATION_DELAY);
/**
* 根据订单状态、获取下一站靠站的的站点
*
* @return -1 当前已是最后一个站点
*/
private int getNextStopStation() {
if ( currentStationIndex >= stationList.size() - 1 ) {
return -1;
}
int nextStationIndex = currentStationIndex + 1;
for ( ; nextStationIndex < stationList.size() - 1; nextStationIndex++ ) {
if ( stationList.get( nextStationIndex ).getIfStop() == 1 ) {
break;
}
}
return nextStationIndex;
}
private void queryBusStationDelay() {
handler.sendEmptyMessageDelayed( MSG_QUERY_BUS_STATION, QUERY_BUS_STATION_DELAY );
}
public void restartAutopilot() {
Logger.d(TAG, "重启自动驾驶===" + isGoingToNextStation);
if (isGoingToNextStation) {
Logger.d( TAG, "重启自动驾驶===" + isGoingToNextStation );
if ( isGoingToNextStation ) {
autoDriveToNextStation();
}
}
public void debugResetStationStatus(){
OchBusResetRequest request = new OchBusResetRequest(Utils.getSn(), 1);
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(request));
MogoApisHandler.getInstance().getApis().getNetworkApi()
.create(IOchBusApiService.class, HostConst.OCH_DOMAIN)
.debugResetStationStatus(requestBody)
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<OchBusRoutesResponse>(RequestOptions.create(getContext())) {
/**
* 测试
*/
public void debugResetStationStatus() {
OchBusResetRequest request = new OchBusResetRequest( Utils.getSn(), 1 );
RequestBody requestBody = RequestBody.create( MediaType.get( "application/json;charset=UTF-8" ), GsonUtil.jsonFromObject( request ) );
mService.debugResetStationStatus( requestBody )
.subscribeOn( Schedulers.io() ).observeOn( AndroidSchedulers.mainThread() )
.subscribe( new SubscribeImpl< OchBusRoutesResponse >( RequestOptions.create( getContext() ) ) {
@Override
public void onSuccess(OchBusRoutesResponse o) {
super.onSuccess(o);
Logger.d(TAG, "获取到小巴路线数据: " + o);
public void onSuccess( OchBusRoutesResponse o ) {
super.onSuccess( o );
Logger.d( TAG, "获取到小巴路线数据: " + o );
isGoingToNextStation = false;
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++) {
OchBusStation s = stationList.get(i);
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();
mView.refreshBusStations(stationList);
if ( o.getResult() == null || o.getResult().getSite() == null || o.getResult().getSite().isEmpty() ) {
return;
}
renderBusStationsStatus( o.getResult().getSite() );
}
@Override
public void onError(Throwable e) {
super.onError(e);
Logger.e(TAG, e, "获取小巴路线图失败");
public void onError( Throwable e ) {
super.onError( e );
Logger.e( TAG, e, "获取小巴路线图失败" );
// 重复请求小巴路线,直至成功
requeryBusStation();
queryBusStationDelay();
}
@Override
public void onError(String message, int code) {
super.onError(message, code);
Logger.e(TAG, "获取小巴路线失败 code: " + code + " msg: " + message);
public void onError( String message, int code ) {
super.onError( message, code );
Logger.e( TAG, "获取小巴路线失败 code: " + code + " msg: " + message );
// 重复请求小巴路线,直至成功
requeryBusStation();
queryBusStationDelay();
}
});
} );
}
/**
* 开启自动驾驶到下一站
*/
public void autoDriveToNextStation() {
if (currentStationIndex >= stationList.size() - 1) {
if ( currentStationIndex >= stationList.size() - 1 ) {
// 当前站是最后一站,结束当前行程
travelOver();
return;
}
OchBusStation currentStation = stationList.get(currentStationIndex);
OchBusStation nextStation = stationList.get(currentStationIndex + 1);
currentStation.setIsCurrentSite(STATION_STATUS_LEAVING);
nextStation.setIsCurrentSite(STATION_STATUS_ARRIVING);
RemoteControlAutoPilotParameters currentAutopilot = new RemoteControlAutoPilotParameters();
currentAutopilot.startLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat(currentStation.getLat(), currentStation.getLon());
currentAutopilot.endLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat(nextStation.getLat(), nextStation.getLon());
currentAutopilot.vehicleType = VEHICAL_TYPE;
Logger.d(TAG, "开启自动驾驶====" + currentAutopilot);
MogoApisHandler.getInstance().getApis().getAdasControllerApi().aiCloudToAdasData(currentAutopilot);
OchBusStation currentStation = stationList.get( currentStationIndex );
if (mView != null) {
mView.refreshBusStations(stationList);
int nextStationIndex = getNextStopStation();
OchBusStation nextStation = stationList.get( nextStationIndex );
currentStation.setIsCurrentSite( STATION_STATUS_LEAVING );
nextStation.setIsCurrentSite( STATION_STATUS_ARRIVING );
RemoteControlAutoPilotParameters currentAutopilot = new RemoteControlAutoPilotParameters();
currentAutopilot.startLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat( currentStation.getLat(), currentStation.getLon() );
currentAutopilot.endLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat( nextStation.getLat(), nextStation.getLon() );
currentAutopilot.vehicleType = VEHICLE_TYPE;
Logger.d( TAG, "开启自动驾驶====" + currentAutopilot );
MogoApisHandler.getInstance().getApis().getAdasControllerApi().aiCloudToAdasData( currentAutopilot );
if ( mView != null ) {
mView.refreshBusStations( stationList, currentStationIndex, getNextStopStation() );
}
mView.hideSlidePanel();
mView.hideNotice();
if (isGoingToNextStation) {
if ( isGoingToNextStation ) {
// 为了避免恢复自动驾驶时重复的接口请求
return;
}
isGoingToNextStation = true;
RequestBody request = RequestBody.create(MediaType.get("application/json"), GsonUtil.jsonFromObject(new OchBusLeaveStationRequest(Utils.getSn(), stationList.get(currentStationIndex).getSiteId())));
MogoApisHandler.getInstance().getApis().getNetworkApi()
.create(IOchBusApiService.class, HostConst.OCH_DOMAIN)
.leaveStation(request).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(getContext())) {
AIAssist.getInstance( getContext() ).speakTTSVoice( "欢迎乘坐蘑菇智行无人驾驶小巴车,请您坐好,注意乘车安全,行程即将开始" );
RequestBody request = RequestBody.create( MediaType.get( "application/json" ), GsonUtil.jsonFromObject( new OchBusLeaveStationRequest( Utils.getSn(), stationList.get( currentStationIndex ).getSiteId() ) ) );
mService.leaveStation( request ).subscribeOn( Schedulers.io() )
.observeOn( AndroidSchedulers.mainThread() )
.subscribe( new SubscribeImpl< BaseData >( RequestOptions.create( getContext() ) ) {
@Override
public void onSuccess(BaseData o) {
super.onSuccess(o);
public void onSuccess( BaseData o ) {
super.onSuccess( o );
}
@Override
public void onError(String message, int code) {
super.onError(message, code);
Logger.d(TAG, "leave station error: " + message);
public void onError( String message, int code ) {
super.onError( message, code );
Logger.d( TAG, "leave station error: " + message );
}
@Override
public void onError(Throwable e) {
super.onError(e);
Logger.e(TAG, e, "leave station exception");
public void onError( Throwable e ) {
super.onError( e );
Logger.e( TAG, e, "leave station exception" );
}
});
}
private void refreshCurrentStation() {
currentStationIndex = 0;
for (OchBusStation station : stationList) {
// 如果数据表发生更新,获取当前所在车站
if (station.getIsCurrentSite() == STATION_STATUS_STOPED || station.getIsCurrentSite() == STATION_STATUS_LEAVING) {
// 处于停靠或驶离时,是当前车站
break;
}
currentStationIndex++;
}
} );
}
@Override
public void onArriveAt(AdasOCHData data) {
if (currentStationIndex >= stationList.size() - 1) {
Logger.e(TAG,"到站异常,取消后续操作");
public void onArriveAt( AdasOCHData data ) {
if ( currentStationIndex >= stationList.size() - 1 ) {
Logger.e( TAG, "到站异常,取消后续操作" );
return;
}
Logger.d(TAG, "到站====");
// 当前站改为IDLE下一站改为STATION_STATUS_STOPEDcurrentStationIndex增加1
Logger.d( TAG, "到站====" );
isGoingToNextStation = false;
stationList.get(currentStationIndex++).setIsCurrentSite(STATION_STATUS_IDLE);
stationList.get(currentStationIndex).setIsCurrentSite(STATION_STATUS_STOPED);
if (mView != null) {
mView.refreshBusStations(stationList);
}
// 到达站点后,更新站点状态
currentStationIndex = getNextStopStation();
mService.updateSiteStation( new UpdateSiteStatusRequest( stationList.get( currentStationIndex ).getSiteId() ) )
.subscribeOn( Schedulers.io() )
.observeOn( AndroidSchedulers.mainThread() )
.subscribe( new SubscribeImpl< OchBusRoutesResponse >( RequestOptions.create( getContext() ) ) {
@Override
public void onSuccess( OchBusRoutesResponse o ) {
super.onSuccess( o );
if ( o.getResult() == null && o.getResult().getSite() == null || o.getResult().getSite().isEmpty() ) {
return;
}
renderBusStationsStatus( o.getResult().getSite() );
}
@Override
public void onError( String message, int code ) {
super.onError( message, code );
Logger.d( TAG, "leave station error: " + message );
}
@Override
public void onError( Throwable e ) {
super.onError( e );
Logger.e( TAG, e, "leave station exception" );
}
} );
// stationList.get( nextStation ).setIsCurrentSite( STATION_STATUS_STOPPED );
// stationList.get( currentStationIndex ).setIsCurrentSite( STATION_STATUS_IDLE );
// if ( mView != null ) {
// mView.refreshBusStations( stationList, currentStationIndex, nextStation );
// }
}
/**
* 行程结束
*/
private void travelOver() {
if (currentStationIndex >= stationList.size()) {
Logger.e(TAG, "travel over index out of station list");
if ( currentStationIndex >= stationList.size() ) {
Logger.e( TAG, "travel over index out of station list" );
return;
}
Logger.d(TAG, "单程结束====");
Logger.d( TAG, "单程结束====" );
MogoApisHandler.getInstance().getApis().getAdasControllerApi().cancelAutopilot();
RequestBody request = RequestBody.create(MediaType.get("application/json"), GsonUtil.jsonFromObject(new OchBusLeaveStationRequest(Utils.getSn(), stationList.get(currentStationIndex).getSiteId())));
MogoApisHandler.getInstance().getApis().getNetworkApi()
.create(IOchBusApiService.class, HostConst.OCH_DOMAIN)
.leaveStation(request).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(getContext())) {
AIAssist.getInstance( getContext() ).speakTTSVoice( "感谢您体验蘑菇出行无人驾驶小巴车,请您携带好随身物品,我们下次再见" );
RequestBody request = RequestBody.create( MediaType.get( "application/json" ), GsonUtil.jsonFromObject( new OchBusLeaveStationRequest( Utils.getSn(), stationList.get( currentStationIndex ).getSiteId() ) ) );
mService.leaveStation( request ).subscribeOn( Schedulers.io() )
.observeOn( AndroidSchedulers.mainThread() )
.subscribe( new SubscribeImpl< BaseData >( RequestOptions.create( getContext() ) ) {
@Override
public void onSuccess(BaseData o) {
super.onSuccess(o);
public void onSuccess( BaseData o ) {
super.onSuccess( o );
// 始发站改为Stoped其他站改为Idle
Logger.d(TAG, "单程真的结束了====");
stationList.get(currentStationIndex).setIsCurrentSite(STATION_STATUS_IDLE);
Logger.d( TAG, "单程真的结束了====" );
stationList.get( currentStationIndex ).setIsCurrentSite( STATION_STATUS_IDLE );
currentStationIndex = 0;
stationList.get(currentStationIndex).setIsCurrentSite(STATION_STATUS_STOPED);
if (mView != null) {
mView.refreshBusStations(stationList);
stationList.get( currentStationIndex ).setIsCurrentSite( STATION_STATUS_STOPPED );
stationList.get( currentStationIndex++ ).setIsCurrentSite( STATION_STATUS_ARRIVING );
if ( mView != null ) {
mView.refreshBusStations( stationList, currentStationIndex, getNextStopStation() );
}
}
@Override
public void onError(String message, int code) {
super.onError(message, code);
Logger.d(TAG, "leave station error: " + message);
public void onError( String message, int code ) {
super.onError( message, code );
Logger.d( TAG, "leave station error: " + message );
}
@Override
public void onError(Throwable e) {
super.onError(e);
Logger.e(TAG, e, "leave station exception");
public void onError( Throwable e ) {
super.onError( e );
Logger.e( TAG, e, "leave station exception" );
}
});
} );
}
@Override
public void onStateChanged(int state, String reason) {
Logger.d(TAG, "onStateChange: " + state);
switch (state) {
public void onStateChanged( int state, String reason ) {
Logger.d( TAG, "onStateChange: " + state );
switch ( state ) {
case IMogoAdasOCHCallback.STATUS_AUTOPILOT_ENABLE:
mView.onAutopilotEnableChange(true);
mView.onAutopilotStatusChanged(false);
if (isGoingToNextStation) {
mView.onAutopilotEnableChange( true );
mView.onAutopilotStatusChanged( false );
if ( isGoingToNextStation ) {
mView.hideSlidePanel();
}
break;
case IMogoAdasOCHCallback.STATUS_AUTOPILOT_RUNNING:
mView.onAutopilotStatusChanged(true);
mView.onAutopilotStatusChanged( true );
break;
default:
mView.onAutopilotEnableChange(false);
mView.onAutopilotEnableChange( false );
break;
}
}
@Override
public boolean handleMessage(Message msg) {
if (msg.what == MSG_REQUERY_BUS_STATION) {
public boolean handleMessage( Message msg ) {
if ( msg.what == MSG_QUERY_BUS_STATION ) {
queryBusRoutes();
return true;
}
return false;
}
public boolean isWorking() {
return mIsWorking;
}
/**
* 修改小巴运营状态
*/
public void onChangeOperationStatus() {
mService.changeOperationStatus( isWorking() ? new OchBusOperationStatusRequest().shutdown() : new OchBusOperationStatusRequest().launch() )
.subscribeOn( Schedulers.io() )
.observeOn( AndroidSchedulers.mainThread() )
.subscribe( new SubscribeImpl< BaseData >( RequestOptions.create( getContext() ) ) {
@Override
public void onSuccess( BaseData o ) {
super.onSuccess( o );
mIsWorking = !mIsWorking;
if ( mIsWorking ) {
if ( stationList != null && stationList.size() > 0 ) {
AIAssist.getInstance( getContext() ).speakTTSVoice( "车辆已整备完毕,请前往" + stationList.get( 0 ).getSiteName() + "站点" );
}
}
if ( mView != null ) {
mView.changeOperationStatus( isWorking() );
}
}
@Override
public void onError( String message, int code ) {
super.onError( message, code );
Logger.d( TAG, "leave station error: " + message );
}
@Override
public void onError( Throwable e ) {
super.onError( e );
Logger.e( TAG, e, "leave station exception" );
}
} );
}
/**
* 查询运营状态
*/
public void queryOperationStatus() {
mService.queryOperationStatus( new QueryOchBusOperationStatusRequest() )
.subscribeOn( Schedulers.io() )
.observeOn( AndroidSchedulers.mainThread() )
.subscribe( new SubscribeImpl< OchBusOperationStatusResponse >( RequestOptions.create( getContext() ) ) {
@Override
public void onSuccess( OchBusOperationStatusResponse o ) {
super.onSuccess( o );
if ( o.result != null ) {
mIsWorking = o.result.status == 1;
}
if ( mView != null ) {
mView.changeOperationStatus( isWorking() );
}
}
@Override
public void onError( String message, int code ) {
super.onError( message, code );
Logger.d( TAG, "leave station error: " + message );
}
@Override
public void onError( Throwable e ) {
super.onError( e );
Logger.e( TAG, e, "leave station exception" );
}
} );
}
@Override
public void onBusStationsChanged( List< OchBusStation > data ) {
renderBusStationsStatus( data );
}
@Override
public void onBusOrderChanged( OchBusOrder order ) {
if ( order == null ) {
return;
}
if ( TextUtils.isEmpty( order.getUserPhone() ) ) {
return;
}
try {
String tailNum = order.getUserPhone().substring( order.getUserPhone().length() - 4 );
AIAssist.getInstance( getContext() ).speakTTSVoice( "接到新订单,尾号" + tailNum + "上车站点为" + order.getStartStation() );
} catch ( Exception e ) {
e.printStackTrace();
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 323 B

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#2B6EFF"/>
<corners android:radius="33px"/>
</shape>

View File

@@ -3,10 +3,7 @@
<item>
<shape>
<corners android:radius="17px" />
<gradient
android:angle="270"
android:endColor="#FF1C306F"
android:startColor="#FF354E8A" />
<solid android:color="#3B4577"/>
</shape>
</item>
<item
@@ -16,10 +13,7 @@
android:top="3px">
<shape>
<corners android:radius="17px" />
<gradient
android:angle="270"
android:endColor="#FF162552"
android:startColor="#FF2C3B71" />
<solid android:color="#3B4577"/>
</shape>
</item>
</layer-list>

View File

@@ -1,60 +1,143 @@
<?xml version="1.0" encoding="utf-8"?>
<com.mogo.och.bus.view.NoTouchConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="@dimen/module_mogo_och_bus_station_panel_width"
android:layout_height="wrap_content"
android:clickable="true"
android:maxHeight="@dimen/module_mogo_och_bus_station_panel_height"
android:background="@drawable/module_och_bus_panel_bkg">
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="@dimen/module_och_bus_panel_width"
android:layout_height="@dimen/module_och_bus_panel_height"
android:background="@drawable/module_och_bus_panel_bkg"
android:orientation="vertical">
<TextView
android:id="@+id/module_mogo_och_bus_current_station_name"
android:id="@+id/module_och_bus_tag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/module_mogo_och_bus_station_panel_guide_offset_left"
android:layout_marginTop="@dimen/module_mogo_och_bus_station_panel_padding_top"
android:text="顺义政府站"
android:textColor="@color/module_mogo_och_bus_current_station_name_text_color"
android:textSize="@dimen/module_mogo_och_bus_current_station_name_text_size"
app:layout_constraintLeft_toLeftOf="@id/vGuide"
app:layout_constraintTop_toTopOf="parent" />
android:layout_gravity="right"
android:layout_marginTop="16px"
android:layout_marginRight="16px"
android:background="@drawable/module_och_bus_panel_anchor_bkg"
android:paddingLeft="8px"
android:paddingTop="1px"
android:paddingRight="8px"
android:paddingBottom="1px"
android:text="小巴车"
android:textColor="#FFF"
android:textSize="16px"
android:textStyle="bold" />
<View
android:id="@+id/vGuide"
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/module_och_bus_order_status_stationInfo"
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_marginStart="@dimen/module_mogo_och_bus_station_panel_padding_left"
android:layout_marginTop="@dimen/module_mogo_och_bus_station_panel_guide_offset_top"
android:layout_marginEnd="@dimen/module_mogo_och_bus_station_panel_padding_right"
android:background="#FF151B37"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/module_mogo_och_bus_current_station_name" />
android:layout_height="match_parent"
android:paddingLeft="@dimen/module_och_bus_order_status_stationInfo_paddingLeft"
android:paddingTop="@dimen/module_och_bus_order_status_stationInfo_paddingTop"
android:paddingRight="@dimen/module_och_bus_order_status_stationInfo_paddingRight"
android:paddingBottom="@dimen/module_och_bus_order_status_stationInfo_paddingBottom">
<TextView
android:id="@+id/module_mogo_och_bus_current_station_notice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/module_mogo_och_bus_station_panel_guide_offset_right"
android:text="站点信息"
android:textColor="#fff"
android:textSize="@dimen/module_mogo_och_bus_station_notice_text_size"
app:layout_constraintBottom_toBottomOf="@id/module_mogo_och_bus_current_station_name"
app:layout_constraintRight_toRightOf="@id/vGuide"
app:layout_constraintTop_toTopOf="@id/module_mogo_och_bus_current_station_name" />
<TextView
android:id="@+id/module_och_bus_current_station_anchor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="14px"
android:text="当前站点:"
android:textColor="#8E9DD4"
android:textSize="20px"
android:textStyle="bold"
app:layout_constraintLeft_toRightOf="@+id/greenDot"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/module_mogo_och_bus_rv_station_list"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="@dimen/module_mogo_och_bus_station_panel_guide_offset_left"
android:layout_marginTop="@dimen/module_mogo_och_bus_station_panel_guide_offset_top"
android:layout_marginEnd="@dimen/module_mogo_och_bus_station_panel_guide_offset_right"
android:layout_marginBottom="@dimen/module_mogo_och_bus_station_panel_padding_bottom"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="@id/vGuide"
app:layout_constraintRight_toRightOf="@id/vGuide"
app:layout_constraintTop_toBottomOf="@id/vGuide" />
<TextView
android:id="@+id/module_och_bus_current_station"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6px"
android:textColor="#FFF"
android:textSize="26px"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="@+id/module_och_bus_current_station_anchor"
app:layout_constraintTop_toBottomOf="@+id/module_och_bus_current_station_anchor"
tools:text="后路站" />
</com.mogo.och.bus.view.NoTouchConstraintLayout>
<TextView
android:id="@+id/module_och_bus_start_station_tag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="始"
android:textColor="#8E9DD4"
android:textSize="20px"
android:textStyle="bold"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@+id/module_och_bus_current_station"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/module_och_bus_current_station"
tools:visibility="visible" />
<TextView
android:id="@+id/module_och_bus_next_station_anchor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="27px"
android:text="下一站:"
android:textColor="#8E9DD4"
android:textSize="20px"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="@+id/module_och_bus_current_station"
app:layout_constraintTop_toBottomOf="@+id/module_och_bus_current_station" />
<TextView
android:id="@+id/module_och_bus_order_end_station"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFF"
android:textSize="@dimen/module_och_bus_order_start_station_textSize"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="@+id/module_och_bus_next_station_anchor"
app:layout_constraintTop_toBottomOf="@+id/module_och_bus_next_station_anchor"
tools:text="后路站1" />
<TextView
android:id="@+id/module_och_bus_end_station_tag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="终"
android:textColor="#8E9DD4"
android:textSize="20px"
android:textStyle="bold"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@+id/module_och_bus_order_end_station"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/module_och_bus_order_end_station"
tools:visibility="visible" />
<ImageView
android:id="@+id/greenDot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="14px"
android:src="@drawable/module_mogo_och_bus_icon_arrived_station"
app:layout_constraintBottom_toBottomOf="@+id/module_och_bus_current_station"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="@+id/module_och_bus_current_station" />
<ImageView
android:id="@+id/dotLine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/module_och_bus_dot_line"
app:layout_constraintLeft_toLeftOf="@+id/greenDot"
app:layout_constraintRight_toRightOf="@+id/greenDot"
app:layout_constraintTop_toBottomOf="@+id/greenDot" />
<ImageView
android:id="@+id/blueDot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/module_mogo_och_bus_icon_arriving_station"
app:layout_constraintBottom_toBottomOf="@+id/module_och_bus_order_end_station"
app:layout_constraintLeft_toLeftOf="@+id/greenDot"
app:layout_constraintTop_toTopOf="@+id/module_och_bus_order_end_station" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- 本套资源适配分体机xhdpi -->
<dimen name="module_mogo_och_bus_station_panel_width">464px</dimen>
<dimen name="module_mogo_och_bus_station_panel_width">300px</dimen>
<dimen name="module_mogo_och_bus_station_panel_height">348px</dimen>
<dimen name="module_mogo_och_bus_two_station_panel_height">211px</dimen>
<dimen name="module_mogo_och_bus_three_station_panel_height">276px</dimen>
@@ -29,4 +29,29 @@
<dimen name="module_mogo_och_bus_station_panel_guide_offset_bottom">17px</dimen>
<dimen name="module_och_bus_panel_width">300px</dimen>
<dimen name="module_och_bus_panel_height">270px</dimen>
<dimen name="module_och_bus_order_status_marginLeft">30px</dimen>
<dimen name="module_och_bus_order_status_marginTop">24px</dimen>
<dimen name="module_och_bus_order_status_textSize">24px</dimen>
<dimen name="module_och_bus_order_status_divider_height">1px</dimen>
<dimen name="module_och_bus_order_status_divider_marginLeft">30px</dimen>
<dimen name="module_och_bus_order_status_divider_marginTop">23px</dimen>
<dimen name="module_och_bus_order_status_divider_marginRight">30px</dimen>
<dimen name="module_och_bus_order_status_stationInfo_height">146px</dimen>
<dimen name="module_och_bus_order_status_stationInfo_paddingLeft">20px</dimen>
<dimen name="module_och_bus_order_status_stationInfo_paddingTop">23px</dimen>
<dimen name="module_och_bus_order_status_stationInfo_paddingRight">30px</dimen>
<dimen name="module_och_bus_order_status_stationInfo_paddingBottom">23px</dimen>
<dimen name="module_och_bus_order_start_station_textSize">26px</dimen>
<dimen name="module_och_bus_order_start_station_anchor_textSize">20px</dimen>
<dimen name="module_och_bus_order_end_station_anchor_textSize">20px</dimen>
<dimen name="module_och_bus_order_distance_container_height">80px</dimen>
<dimen name="module_och_bus_order_distance_container_marginLeft">3px</dimen>
<dimen name="module_och_bus_order_distance_anchor_marginLeft">27px</dimen>
<dimen name="module_och_bus_order_distance_anchor_textSize">20px</dimen>
<dimen name="module_och_bus_order_distance_textSize">28px</dimen>
<dimen name="module_och_bus_order_distance_marginRight">27px</dimen>
</resources>

View File

@@ -35,6 +35,7 @@ public abstract class BaseOchFragment<V extends IView, P extends Presenter<V>> e
private View tvNoticeContainer;
private TextView tvNotice;
private CheckedTextView ctvAutopilotStatus;
protected TextView tvOperationStatus;
private FrameLayout flStationPanelContainer;
private FrameAnimImageView fivNoticeHead;
@@ -60,6 +61,8 @@ public abstract class BaseOchFragment<V extends IView, P extends Presenter<V>> e
flStationPanelContainer = findViewById(R.id.module_mogo_och_station_panel_container);
fivNoticeHead = findViewById(R.id.module_mogo_och_notice_head);
tvOperationStatus = findViewById( R.id.module_mogo_och_operation_status );
panelView = LayoutInflater.from(getContext()).inflate(getStationPanelViewId(), flStationPanelContainer);
slidePanelView.setOnSlidePanelMoveToEndListener(onSlideToEndListener);
fivNoticeHead.setAnimRes(sHappy1);
@@ -68,8 +71,6 @@ public abstract class BaseOchFragment<V extends IView, P extends Presenter<V>> e
@Override
public void onClickImpl(View v) {
// 如果能自动驾驶,就自动驾驶,不能就提示
// if (MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus() == IMogoAdasOCHCallback.STATUS_AUTOPILOT_ENABLE) {
// }
restartAutopilot();
}
});
@@ -86,6 +87,14 @@ public abstract class BaseOchFragment<V extends IView, P extends Presenter<V>> e
findViewById(R.id.btnAutopilotRunning).setOnClickListener(view -> MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockOchStatus(IMogoAdasOCHCallback.STATUS_AUTOPILOT_RUNNING, "Running"));
findViewById(R.id.btnAutopilotArrive).setOnClickListener(view -> MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockOchStatus(-1, "Running"));
tvOperationStatus.setOnClickListener( view -> {
onChangeOperationStatus();
} );
}
protected void onChangeOperationStatus(){
}
private void checkCallView(boolean isShown) {
@@ -102,9 +111,6 @@ public abstract class BaseOchFragment<V extends IView, P extends Presenter<V>> e
public void showSlidePanle(String text) {
getActivity().runOnUiThread(() -> {
slidePanelView.setText(text);
if (MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus() == IMogoAdasOCHCallback.STATUS_AUTOPILOT_DISABLE) {
return;
}
slidePanelView.setVisibility(View.VISIBLE);
});
}
@@ -118,9 +124,6 @@ public abstract class BaseOchFragment<V extends IView, P extends Presenter<V>> e
public void showNotice(String notice) {
getActivity().runOnUiThread(() -> {
tvNotice.setText(notice);
if (MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus() == IMogoAdasOCHCallback.STATUS_AUTOPILOT_DISABLE) {
return;
}
AIAssist.getInstance(getContext()).speakTTSVoice(notice);
tvNoticeContainer.setVisibility(View.VISIBLE);
fivNoticeHead.setVisibility(View.VISIBLE);
@@ -149,8 +152,8 @@ public abstract class BaseOchFragment<V extends IView, P extends Presenter<V>> e
public void hideAutopilotBiz() {
getActivity().runOnUiThread(() -> {
ctvAutopilotStatus.setVisibility(View.GONE);
slidePanelView.setVisibility(View.GONE);
// ctvAutopilotStatus.setVisibility(View.GONE);
// slidePanelView.setVisibility(View.GONE);
});
}

View File

@@ -1,10 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="@dimen/module_mogo_och_autopilot_status_bg_corner" />
<corners
android:bottomLeftRadius="20px"
android:bottomRightRadius="45px"
android:topLeftRadius="45px"
android:topRightRadius="20px" />
<gradient
android:startColor="#FF405591"
android:angle="315"
android:endColor="#FF28376B"
android:angle="315"/>
android:startColor="#FF405591" />
</shape>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="@dimen/module_mogo_och_autopilot_status_bg_corner" />
<gradient
android:startColor="#FF405591"
android:endColor="#FF28376B"
android:angle="315"/>
</shape>

View File

@@ -1,34 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:paddingStart="@dimen/module_mogo_och_margin_left"
android:paddingTop="@dimen/module_mogo_och_margin_top"
android:paddingEnd="@dimen/module_mogo_och_margin_right"
android:paddingBottom="@dimen/module_mogo_och_margin_bottom">
<FrameLayout
android:id="@+id/module_mogo_och_station_panel_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/module_mogo_och_station_panel_container_margin_top_no_call"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<CheckedTextView
android:id="@+id/module_mogo_och_autopilot_status"
android:layout_width="@dimen/module_mogo_och_autopilot_status_bg_width"
android:layout_height="@dimen/module_mogo_och_autopilot_status_bg_height"
android:layout_marginTop="@dimen/module_mogo_och_station_panel_container_margin_top_no_call"
android:background="@drawable/module_mogo_och_autopilot_status_bg"
android:drawableTop="@drawable/module_mogo_och_base_autopilot_status_icon_selector"
android:drawableLeft="@drawable/module_mogo_och_base_autopilot_status_icon_selector"
android:gravity="center"
android:paddingLeft="35px"
android:text="自动驾驶"
android:textAlignment="center"
android:paddingTop="@dimen/module_mogo_och_autopilot_status_text_padding_top"
android:text="自动"
android:textColor="@color/module_mogo_och_autopilot_text_color_selector"
android:textSize="@dimen/module_mogo_och_autopilot_status_text_size"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible"/>
<FrameLayout
android:id="@+id/module_mogo_och_station_panel_container"
android:layout_width="300px"
android:layout_height="270px"
android:layout_marginTop="10px"
app:layout_constraintLeft_toLeftOf="@+id/module_mogo_och_autopilot_status"
app:layout_constraintTop_toBottomOf="@id/module_mogo_och_autopilot_status"
app:layout_goneMarginTop="@dimen/module_mogo_och_station_panel_container_margin_top_no_call" />
<CheckedTextView
android:id="@+id/module_mogo_och_operation_status"
android:layout_width="@dimen/module_mogo_och_operation_status_bg_width"
android:layout_height="@dimen/module_mogo_och_operation_status_bg_height"
android:layout_marginBottom="10px"
android:background="@drawable/module_mogo_och_operation_status_bg"
android:gravity="center"
android:text="开启"
android:textAlignment="center"
android:textColor="@color/module_mogo_och_autopilot_text_color_selector"
android:textSize="@dimen/module_mogo_och_autopilot_status_text_size"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent" />
@@ -43,84 +62,86 @@
<FrameLayout
android:id="@+id/module_mogo_och_notice_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/module_mogo_och_base_notice_box_bg"
android:visibility="gone"
tools:visibility = "visible"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="wrap_content"
android:background="@drawable/module_mogo_och_base_notice_box_bg"
android:layout_height="wrap_content">
tools:visibility="visible">
<TextView
android:id="@+id/module_mogo_och_notice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:lineSpacingExtra="5px"
android:maxWidth="@dimen/module_mogo_och_notice_text_max_width"
android:text="请携带好随身物品\n注意侧后方来车\n感谢体验蘑菇智行自动驾驶车"
android:textColor="#fff"
android:textSize="@dimen/module_mogo_och_notice_text_size"
android:textStyle="bold"
android:lineSpacingExtra="5px" />
android:textStyle="bold" />
</FrameLayout>
<com.mogo.och.view.FrameAnimImageView
android:id="@+id/module_mogo_och_notice_head"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/module_mogo_och_notice_head"
android:layout_marginTop="185px"
android:src="@drawable/ic_happy1_00000"
android:visibility="gone"
android:layout_marginTop="185px"
app:layout_constraintRight_toRightOf="@id/module_mogo_och_notice_container"
app:layout_constraintTop_toTopOf="@id/module_mogo_och_notice_container"/>
app:layout_constraintTop_toTopOf="@id/module_mogo_och_notice_container" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnAutopilotDisable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#f00"
android:text="Disable"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:textSize="30sp"
android:background="#f00" />
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnAutopilotEnable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#0f0"
android:text="Enable"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnAutopilotDisable"
app:layout_constraintRight_toRightOf="parent"
android:textSize="30sp"
android:background="#0f0" />
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnAutopilotDisable" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnAutopilotRunning"
android:text="Running"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnAutopilotEnable"
app:layout_constraintRight_toRightOf="parent"
android:textSize="30sp"
android:background="#00f" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnAutopilotArrive"
android:text="Arrived"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnAutopilotRunning"
app:layout_constraintRight_toRightOf="parent"
android:background="#00f"
android:text="Running"
android:textSize="30sp"
android:background="#f00" />
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnAutopilotEnable" />
<Button
android:id="@+id/btnAutopilotArrive"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#f00"
android:text="Arrived"
android:textSize="30sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnAutopilotRunning" />
<androidx.constraintlayout.widget.Group
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:constraint_referenced_ids="btnAutopilotArrive,btnAutopilotDisable,btnAutopilotEnable,btnAutopilotRunning"
android:visibility="gone" />
android:visibility="gone"
app:constraint_referenced_ids="btnAutopilotArrive,btnAutopilotDisable,btnAutopilotEnable,btnAutopilotRunning" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="module_mogo_och_autopilot_text_color_normal">#B2FFFFFF</color>
<color name="module_mogo_och_autopilot_text_color_normal">#FFFFFF</color>
<color name="module_mogo_och_autopilot_text_color_checked">#FF52BBFF</color>
</resources>

View File

@@ -6,14 +6,16 @@
<dimen name="module_mogo_och_margin_bottom">40px</dimen>
<dimen name="module_mogo_och_margin_top">24px</dimen>
<dimen name="module_mogo_och_station_panel_container_margin_top_no_call">346px</dimen>
<dimen name="module_mogo_och_station_panel_container_margin_top_no_call">400px</dimen>
<dimen name="module_mogo_och_station_panel_container_margin_top_with_call">492px</dimen>
<dimen name="module_mogo_och_autopilot_status_bg_corner">24px</dimen>
<dimen name="module_mogo_och_autopilot_status_bg_width">120px</dimen>
<dimen name="module_mogo_och_autopilot_status_bg_height">120px</dimen>
<dimen name="module_mogo_och_autopilot_status_bg_width">300px</dimen>
<dimen name="module_mogo_och_autopilot_status_bg_height">100px</dimen>
<dimen name="module_mogo_och_operation_status_bg_width">108px</dimen>
<dimen name="module_mogo_och_operation_status_bg_height">108px</dimen>
<dimen name="module_mogo_och_autopilot_status_text_size">20px</dimen>
<dimen name="module_mogo_och_autopilot_status_text_size">30px</dimen>
<dimen name="module_mogo_och_autopilot_status_text_padding_top">13px</dimen>
<dimen name="module_mogo_och_autopilot_status_text_drawable_padding">12px</dimen>

View File

@@ -67,7 +67,7 @@ dependencies {
implementation project(':foudations:mogo-commons')
}
implementation 'com.zhidaoauto.machine:map:1.0.0-vr-8.4.2'
implementation 'com.zhidaoauto.machine:map:1.0.0-vr-8.4.6'
// implementation 'com.zhidaoauto.machine:map:1.0.0-vr-test-3.4'
}

View File

@@ -1002,7 +1002,6 @@ public class AMapViewWrapper implements IMogoMapView,
}
if (data == null) {
Logger.d(TAG, "停止使用rtk定位数据");
mMapView.getLocationClient().stopAutoPilotRTK();
return;
}
double lon = data.optDouble("lon", -1);

View File

@@ -215,7 +215,11 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
marker.setRotateAngle( ( ( float ) recognizedListResult.heading ) );
marker.setPosition( recognizedListResult.lat, recognizedListResult.lon );
}
marker.setAnchorColor( getModelRenderColor( recognizedListResult.speed, recognizedListResult.lon, recognizedListResult.lat, recognizedListResult.heading ) );
String carColor = recognizedListResult.color;
if ( TextUtils.isEmpty( carColor ) ) {
carColor = getModelRenderColor( recognizedListResult.type, recognizedListResult.speed, recognizedListResult.lon, recognizedListResult.lat, recognizedListResult.heading );
}
marker.setAnchorColor( carColor );
if ( shouldShowSpeed( recognizedListResult.type ) ) {
Message msg = mRenderThreadHandler.obtainMessage();
@@ -243,12 +247,17 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
String resIdVal = null;
int resId = getModelRes( recognizedListResult.type );
resIdVal = resId + "";
String carColor = recognizedListResult.color;
if ( TextUtils.isEmpty( carColor ) ) {
carColor = getModelRenderColor( recognizedListResult.type, recognizedListResult.speed, recognizedListResult.lon, recognizedListResult.lat, recognizedListResult.heading );
}
MogoMarkerOptions options = new MogoMarkerOptions()
.owner( DataTypes.TYPE_MARKER_ADAS )
.anchor( 0.5f, 0.5f )
.set3DMode( true )
.gps( true )
.anchorColor( getModelRenderColor( recognizedListResult.speed, recognizedListResult.lon, recognizedListResult.lat, recognizedListResult.heading ) )
.anchorColor( carColor )
.controlAngle( true )
.resName( mMarkerCachesResMd5Values.get( resIdVal ) )
.icon3DRes( resId )

View File

@@ -10,24 +10,17 @@ import android.util.Log;
import android.view.ViewGroup;
import android.widget.TextView;
import com.mogo.cloud.commons.utils.CoordinateUtils;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.map.MogoLatLng;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.R;
import com.mogo.module.common.constants.AdasRecognizedType;
import com.mogo.module.common.uploadintime.SnapshotLocationController;
import com.mogo.realtime.entity.ADASRecognizedResult;
import com.mogo.realtime.entity.CloudRoadData;
import com.mogo.utils.WorkThreadHandler;
import com.mogo.utils.logger.Logger;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
@@ -226,15 +219,16 @@ class BaseDrawer {
/**
* 获取3D锚点模型资源
*
* @param type
* @param type {@link AdasRecognizedType}
* @return
*/
public int getModelRes( int type ) {
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom( type );
if ( recognizedType == AdasRecognizedType.classIdCar
|| recognizedType == AdasRecognizedType.classIdTrafficBus
|| recognizedType == AdasRecognizedType.classIdTrafficTruck ) {
return R.raw.othercar2;
return R.raw.othercar;
} else if ( recognizedType == AdasRecognizedType.classIdTrafficBus ) {
return R.raw.bus;
} else if ( recognizedType == AdasRecognizedType.classIdBicycle
|| recognizedType == AdasRecognizedType.classIdMoto ) {
return R.raw.motorbike;
@@ -250,29 +244,33 @@ class BaseDrawer {
* @param lat 纬度
* @return 实际车辆颜色
*/
protected String getModelRenderColor( double speed, double lon, double lat, double angle ) {
protected String getModelRenderColor( int type, double speed, double lon, double lat, double angle ) {
// 距离策略
double coordinates[] = getCurCoordinates();
double distance = CoordinateUtils.calculateLineDistance( lon, lat, coordinates[0], coordinates[1] ) * 100;
if ( distance < 50 ) {
return Car3DModelColor.Dangerous.color;
} else if ( distance < 100 && distance >= 50 ) {
return Car3DModelColor.Warming.color;
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom( type );
if ( recognizedType == AdasRecognizedType.classIdTrafficBus ) {
return "#D8D8D8FF";
}
// 距离策略
// double coordinates[] = getCurCoordinates();
// double distance = CoordinateUtils.calculateLineDistance( lon, lat, coordinates[0], coordinates[1] ) * 100;
// if ( distance < 50 ) {
// return Car3DModelColor.Dangerous.color;
// } else if ( distance < 100 && distance >= 50 ) {
// return Car3DModelColor.Warming.color;
// }
// 他车车速和自车车速对比速度策略
// 自车速度 >= 50% 危险
// 10% < 自车速度 < 50% 警告
double curSpeed = getCurSpeed();
if ( curSpeed > 0 && speed > curSpeed ) {
double rate = ( ( speed - curSpeed ) / curSpeed ) * 100;
if ( rate >= 50 ) {
return Car3DModelColor.Dangerous.color;
} else if ( rate > 10 && rate < 50 ) {
return Car3DModelColor.Warming.color;
}
}
// double curSpeed = getCurSpeed();
// if ( curSpeed > 0 && speed > curSpeed ) {
// double rate = ( ( speed - curSpeed ) / curSpeed ) * 100;
// if ( rate >= 50 ) {
// return Car3DModelColor.Dangerous.color;
// } else if ( rate > 10 && rate < 50 ) {
// return Car3DModelColor.Warming.color;
// }
// }
// 默认颜色
return Car3DModelColor.Normal.color;

View File

@@ -290,7 +290,8 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
marker.setPosition( cloudRoadData.getWgslat(), cloudRoadData.getWgslon() );
}
marker.setAnchorColor( getModelRenderColor( cloudRoadData.getSpeed(), cloudRoadData.getWgslon(), cloudRoadData.getWgslat(), cloudRoadData.getHeading() ) );
// TODO: 2021/3/23 后端算法提供显示颜色
marker.setAnchorColor( getModelRenderColor( cloudRoadData.getType(), cloudRoadData.getSpeed(), cloudRoadData.getWgslon(), cloudRoadData.getWgslat(), cloudRoadData.getHeading() ) );
if ( shouldShowSpeed( cloudRoadData.getType() ) ) {
Message msg = mRenderThreadHandler.obtainMessage();
@@ -370,7 +371,8 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
String resIdVal = null;
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
options.set3DMode( true );
options.anchorColor( getModelRenderColor( data.getSpeed(), data.getWgslon(), data.getWgslat(), data.getHeading() ) );
// TODO: 2021/3/23 后端算法提供显示颜色
options.anchorColor( getModelRenderColor( data.getType(), data.getSpeed(), data.getWgslon(), data.getWgslat(), data.getHeading() ) );
int resId = getModelRes( data.getType() );
resIdVal = resId + "";
options.resName( mMarkerCachesResMd5Values.get( resIdVal ) );

Binary file not shown.

View File

@@ -0,0 +1,150 @@
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public
/**
* @author congtaowang
* @since 2021/3/26
*
* 描述
*/
class LocParse {
public static void main( String[] args ) {
new Thread( new Runnable() {
@Override
public void run() {
try {
LocParse.run();
} catch ( Exception e ) {
e.printStackTrace();
}
}
} ).run();
}
private static void run() throws Exception {
InputStreamReader isr = new InputStreamReader( new FileInputStream( "loc.csv" ) );
BufferedReader br = new BufferedReader( isr );
File loc = new File( "loc.txt" );
if ( loc.exists() ) {
loc.delete();
}
loc.createNewFile();
OutputStreamWriter locOsw = new OutputStreamWriter( new FileOutputStream( loc ) );
BufferedWriter locWr = new BufferedWriter( locOsw );
final int adasRecAmount = 10;
final int intervalLineAmount = 50;
BufferedWriter writers[] = new BufferedWriter[adasRecAmount];
for ( int i = 0; i < adasRecAmount; i++ ) {
File file = new File( "adas" + i + ".txt" );
if ( file.exists() ) {
file.delete();
}
file.createNewFile();
OutputStreamWriter osw = new OutputStreamWriter( new FileOutputStream( file ) );
writers[i] = new BufferedWriter( osw );
}
String line = null;
final int pLon = 1;
final int pLat = 2;
final int pAlt = 3;
final int pHeading = 4;
final int pSpeed = 6;
final int pDistance = 7;
final int pReceiverDataTime = 8;
final int pAdasSatelliteTime = 9;
final int pSystemTime = 10;
final int pSatelliteTime = 11;
int counter = 0;
while ( ( line = br.readLine() ) != null ) {
line = line.replace( " ", "" );
String seg[] = line.split( "," );
double lon = Double.parseDouble( seg[pLon] );
double lat = Double.parseDouble( seg[pLat] );
double alt = Double.parseDouble( seg[pAlt] );
double heading = Double.parseDouble( seg[pHeading] );
double speed = Double.parseDouble( seg[pSpeed] );
double distance = Double.parseDouble( seg[pDistance] );
long receiverDataTime = Long.parseLong( seg[pReceiverDataTime] );
long adasSatelliteTime = Long.parseLong( seg[pAdasSatelliteTime] );
long systemTime = Long.parseLong( seg[pSystemTime] );
long satelliteTime = Long.parseLong( seg[pSatelliteTime] );
// 定位
StringBuilder locJson = new StringBuilder( "{" );
locJson.append( "\"lon\":" + lon );
locJson.append( ",\"lat\":" + lat );
locJson.append( ",\"alt\":" + alt );
locJson.append( ",\"heading\":" + heading );
locJson.append( ",\"speed\":" + speed );
locJson.append( ",\"systemTime\":" + systemTime );
locJson.append( ",\"receiverDataTime\":" + receiverDataTime );
locJson.append( ",\"adasSatelliteTime\":" + adasSatelliteTime );
locJson.append( ",\"satelliteTime\":" + satelliteTime );
locJson.append( "}\n" );
locWr.write( locJson.toString() );
int writersCount = counter++ / intervalLineAmount;
if ( writersCount > adasRecAmount ) {
writersCount = adasRecAmount;
}
for ( int i = 0; i < writersCount; i++ ) {
int type = 3;
switch ( i ) {
case 1:
case 2:
case 3:
case 4:
case 6:
type = i;
break;
case 0:
case 5:
case 7:
case 8:
case 9:
type = 3;
break;
}
StringBuilder adasJson = new StringBuilder( "{" );
adasJson.append( "\"type\":" + type );
adasJson.append( ",\"uuid\":" + "\"2_" + i + "\"" );
adasJson.append( ",\"lon\":" + lon );
adasJson.append( ",\"lat\":" + lat );
adasJson.append( ",\"alt\":" + alt );
adasJson.append( ",\"heading\":" + heading );
adasJson.append( ",\"distance\":" + distance );
adasJson.append( ",\"speed\":" + speed );
adasJson.append( ",\"systemTime\":" + systemTime );
adasJson.append( ",\"satelliteTime\":" + satelliteTime );
adasJson.append( ",\"dataAccuracy\":" + 1 );
adasJson.append( "}\n" );
writers[i].write( adasJson.toString() );
}
// adas
}
locWr.flush();
locWr.close();
for ( BufferedWriter writer : writers ) {
writer.flush();
writer.close();
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -558,14 +558,7 @@ public class MockIntentHandler implements IntentHandler {
SnapshotSetDataDrawer.getInstance().renderSnapshotData( GsonUtil.objectFromJson( json, MogoSnapshotSetData.class ) );
break;
case 47:
// mLocationMockHandler1.sendEmptyMessageDelayed( 1, 4000L );
// mLocationMockHandler.sendEmptyMessageDelayed( 2, 0 );
// mLocationMockHandler.sendEmptyMessageDelayed( 21, 200 );
// mLocationMockHandler.sendEmptyMessageDelayed( 3, 0L );
mTimeTickHandler.sendEmptyMessageDelayed( 1, 0L );
// mLocationMockHandler.sendEmptyMessageDelayed( 31, 2000L );
// mLocationMockHandler.sendEmptyMessageDelayed( 5, 0L );
break;
case 48:
MogoMarkerOptions options = new MogoMarkerOptions()
@@ -629,7 +622,7 @@ public class MockIntentHandler implements IntentHandler {
break;
case 53:
boolean isUseAdasRecognize = intent.getBooleanExtra( "status", false );
DebugConfig.setUseAdasRecognize(isUseAdasRecognize);
DebugConfig.setUseAdasRecognize( isUseAdasRecognize );
break;
}
}
@@ -703,17 +696,6 @@ public class MockIntentHandler implements IntentHandler {
}
br = null;
}
} else if ( msg.what == 2 ) {
try {
handleMockSnapshotIntent();
} catch ( Exception e ) {
try {
br2.close();
} catch ( IOException ex ) {
ex.printStackTrace();
}
br2 = null;
}
} else if ( msg.what == 21 ) {
try {
handleMockSnapshotIntent2();
@@ -730,51 +712,15 @@ public class MockIntentHandler implements IntentHandler {
handleMockAdasIntent();
} catch ( Exception e ) {
try {
br3.close();
br31.close();
br32.close();
br33.close();
br34.close();
br35.close();
br36.close();
br37.close();
br38.close();
br39.close();
if ( readers != null ) {
for ( BufferedReader reader : readers ) {
reader.close();
}
}
} catch ( IOException ex ) {
ex.printStackTrace();
}
br3 = null;
br31 = null;
br32 = null;
br33 = null;
br34 = null;
br35 = null;
br36 = null;
br37 = null;
br38 = null;
br39 = null;
}
} else if ( msg.what == 31 ) {
try {
handleMockAdasIntent3();
} catch ( Exception e ) {
try {
br31.close();
} catch ( IOException ex ) {
ex.printStackTrace();
}
br31 = null;
}
} else if ( msg.what == 48 ) {
try {
handleMockLocationIntent48();
} catch ( Exception e ) {
try {
br48.close();
} catch ( IOException ex ) {
ex.printStackTrace();
}
br48 = null;
readers = null;
}
} else if ( msg.what == 100 ) {
try {
@@ -837,7 +783,7 @@ public class MockIntentHandler implements IntentHandler {
private boolean handleMockLocationIntent() throws Exception {
if ( br == null ) {
br = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "loc5.txt" ) ) );
br = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "loc.txt" ) ) );
}
final long start = System.currentTimeMillis();
String line = br.readLine();
@@ -845,8 +791,6 @@ public class MockIntentHandler implements IntentHandler {
throw new Exception( "end of file." );
}
JSONObject jo = new JSONObject( line );
jo.put( "satelliteTime", System.currentTimeMillis() );
jo.put( "systemTime", System.currentTimeMillis() );
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map( jo );
Log.i( "mock-timer-loc-map", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
SnapshotLocationController.getInstance().syncAdasLocationInfo( jo );
@@ -854,59 +798,6 @@ public class MockIntentHandler implements IntentHandler {
return true;
}
private BufferedReader br48;
int count = 0;
private boolean handleMockLocationIntent48() throws Exception {
if ( br48 == null ) {
br48 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "loc3.txt" ) ) );
}
final long start = System.currentTimeMillis();
String line = br48.readLine();
if ( line == null ) {
throw new Exception( "end of file." );
}
JSONObject jo = new JSONObject( line );
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map( jo );
Logger.i( "mock-timer-loc", "cost " + ( System.currentTimeMillis() - start ) + "ms: count=%s", ++count );
mLocationMockHandler.sendEmptyMessageDelayed( 48, 100L );
return true;
}
private BufferedReader br2;
private long last = 0;
private boolean handleMockSnapshotIntent() throws Exception {
if ( br2 == null ) {
br2 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas6.txt" ) ) );
}
String line = br2.readLine();
if ( line == null ) {
throw new Exception( "end of file 2." );
}
MogoSnapshotSetData data = new MogoSnapshotSetData();
List< CloudRoadData > allList = new ArrayList<>();
CloudRoadData cloudRoadData = GsonUtil.objectFromJson( line, CloudRoadData.class );
if ( cloudRoadData == null ) {
return false;
}
cloudRoadData.setWgslat( cloudRoadData.getLat() );
cloudRoadData.setWgslon( cloudRoadData.getLon() );
allList.add( cloudRoadData );
data.setAllList( allList );
final long start = System.currentTimeMillis();
SnapshotSetDataDrawer.getInstance().renderSnapshotData( data );
Log.i( "mock-timer-snapshot", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
long delay = 100;
if ( last != 0 ) {
delay = cloudRoadData.getSystemTime() - last;
}
last = cloudRoadData.getSystemTime();
mLocationMockHandler.sendEmptyMessageDelayed( 2, 50L );
return true;
}
private BufferedReader br4;
@@ -937,278 +828,29 @@ public class MockIntentHandler implements IntentHandler {
return true;
}
private BufferedReader br3;
private BufferedReader br31;
private BufferedReader[] readers = null;
private boolean handleMockAdasIntent() throws Exception {
final long start = System.currentTimeMillis();
if ( br3 == null ) {
br3 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas2.txt" ) ) );
}
if ( br31 == null ) {
br31 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas3.txt" ) ) );
}
if ( br32 == null ) {
br32 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas4.txt" ) ) );
}
if ( br33 == null ) {
br33 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas5.txt" ) ) );
}
if ( br34 == null ) {
br34 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas6.txt" ) ) );
if ( readers == null ) {
readers = new BufferedReader[10];
for ( int i = 0; i < 10; i++ ) {
readers[i] = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas" + i + ".txt" ) ) );
}
}
if ( br35 == null ) {
br35 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas3-2.txt" ) ) );
}
if ( br36 == null ) {
br36 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas4-2.txt" ) ) );
}
if ( br37 == null ) {
br37 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas4-4.txt" ) ) );
}
if ( br38 == null ) {
br38 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas5-2.txt" ) ) );
}
if ( br39 == null ) {
br39 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas5-4.txt" ) ) );
}
String line = br3.readLine();
if ( line == null ) {
throw new Exception( "end of file 3." );
}
List< ADASRecognizedResult > allList = new ArrayList<>();
ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class );
if ( adasRecognizedResult == null ) {
return false;
}
allList.add( adasRecognizedResult );
ADASRecognizedResult next = handleMockAdasIntent3();
if ( next != null ) {
allList.add( next );
}
next = handleMockAdasIntent4();
if ( next != null ) {
allList.add( next );
}
next = handleMockAdasIntent5();
if ( next != null ) {
allList.add( next );
}
next = handleMockAdasIntent6();
if ( next != null ) {
allList.add( next );
}
next = handleMockAdasIntent7();
if ( next != null ) {
allList.add( next );
}
next = handleMockAdasIntent8();
if ( next != null ) {
allList.add( next );
}
next = handleMockAdasIntent9();
if ( next != null ) {
allList.add( next );
}
next = handleMockAdasIntent10();
if ( next != null ) {
allList.add( next );
}
next = handleMockAdasIntent11();
if ( next != null ) {
allList.add( next );
for ( BufferedReader reader : readers ) {
String line = reader.readLine();
ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class );
if ( adasRecognizedResult != null ) {
allList.add( adasRecognizedResult );
}
}
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( allList );
Log.i( "mock-timer-adas", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
long delay = 100;
if ( last != 0 ) {
delay = adasRecognizedResult.satelliteTime - last;
}
last = adasRecognizedResult.satelliteTime;
Log.d( "send-delay", "delay: " + delay );
return true;
}
private ADASRecognizedResult handleMockAdasIntent3() {
String line = null;
try {
line = br31.readLine();
} catch ( IOException e ) {
e.printStackTrace();
}
if ( line == null ) {
return null;
}
ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class );
if ( adasRecognizedResult == null ) {
return null;
}
adasRecognizedResult.uuid = "2_2";
return adasRecognizedResult;
}
private BufferedReader br32;
private ADASRecognizedResult handleMockAdasIntent4() {
String line = null;
try {
line = br32.readLine();
} catch ( IOException e ) {
e.printStackTrace();
}
if ( line == null ) {
return null;
}
ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class );
if ( adasRecognizedResult == null ) {
return null;
}
adasRecognizedResult.uuid = "2_3";
return adasRecognizedResult;
}
private BufferedReader br33;
private ADASRecognizedResult handleMockAdasIntent5() {
String line = null;
try {
line = br33.readLine();
} catch ( IOException e ) {
e.printStackTrace();
}
if ( line == null ) {
return null;
}
ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class );
if ( adasRecognizedResult == null ) {
return null;
}
adasRecognizedResult.uuid = "2_4";
return adasRecognizedResult;
}
private BufferedReader br34;
private ADASRecognizedResult handleMockAdasIntent6() {
String line = null;
try {
line = br34.readLine();
} catch ( IOException e ) {
e.printStackTrace();
}
if ( line == null ) {
return null;
}
ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class );
if ( adasRecognizedResult == null ) {
return null;
}
adasRecognizedResult.uuid = "2_5";
return adasRecognizedResult;
}
private BufferedReader br35;
private ADASRecognizedResult handleMockAdasIntent7() {
String line = null;
try {
line = br35.readLine();
} catch ( IOException e ) {
e.printStackTrace();
}
if ( line == null ) {
return null;
}
ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class );
if ( adasRecognizedResult == null ) {
return null;
}
adasRecognizedResult.uuid = "2_6";
return adasRecognizedResult;
}
private BufferedReader br36;
private ADASRecognizedResult handleMockAdasIntent8() {
String line = null;
try {
line = br36.readLine();
} catch ( IOException e ) {
e.printStackTrace();
}
if ( line == null ) {
return null;
}
ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class );
if ( adasRecognizedResult == null ) {
return null;
}
adasRecognizedResult.uuid = "2_7";
return adasRecognizedResult;
}
private BufferedReader br37;
private ADASRecognizedResult handleMockAdasIntent9() {
String line = null;
try {
line = br37.readLine();
} catch ( IOException e ) {
e.printStackTrace();
}
if ( line == null ) {
return null;
}
ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class );
if ( adasRecognizedResult == null ) {
return null;
}
adasRecognizedResult.uuid = "2_8";
return adasRecognizedResult;
}
private BufferedReader br38;
private ADASRecognizedResult handleMockAdasIntent10() {
String line = null;
try {
line = br38.readLine();
} catch ( IOException e ) {
e.printStackTrace();
}
if ( line == null ) {
return null;
}
ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class );
if ( adasRecognizedResult == null ) {
return null;
}
adasRecognizedResult.uuid = "2_9";
return adasRecognizedResult;
}
private BufferedReader br39;
private ADASRecognizedResult handleMockAdasIntent11() {
String line = null;
try {
line = br39.readLine();
} catch ( IOException e ) {
e.printStackTrace();
}
if ( line == null ) {
return null;
}
ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class );
if ( adasRecognizedResult == null ) {
return null;
}
adasRecognizedResult.uuid = "2_10";
return adasRecognizedResult;
}
}