diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/CarHeartbeatReqBean.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/CarHeartbeatReqBean.java deleted file mode 100644 index 5aa4d7205f..0000000000 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/CarHeartbeatReqBean.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.mogo.och.sweeper.bean; - -import com.mogo.och.sweeper.constant.SweeperConst; - -import java.util.UUID; - -/** - * Created on 2021/9/16 - * - * 上传车机心跳信息请求数据 - */ -public class CarHeartbeatReqBean { - public String sn; - public double lon; //经度 - public double lat; //纬度 - public String msgId; //心跳信息唯一标识 - public int interval; //上报间隔,单位秒,非必传,默认60秒 - - public CarHeartbeatReqBean(String sn, double lon, double lat) { - this.sn = sn; - this.lon = lon; - this.lat = lat; - this.msgId = UUID.randomUUID().toString(); - this.interval = (int) (SweeperConst.LOOP_PERIOD_60S / 1000); - } -} diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/QueryLeaveAwayPassengersRequest.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/QueryLeaveAwayPassengersRequest.java deleted file mode 100644 index c0a9b96dcf..0000000000 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/QueryLeaveAwayPassengersRequest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.mogo.och.sweeper.bean; - -import com.mogo.cloud.passport.MoGoAiCloudClientConfig; - -/** - * 查询下车乘客请求参数 - * - * @author tongchenfei - */ -public class QueryLeaveAwayPassengersRequest { - private String sn; - private int seq; //站点在线路中的序号 - private int siteId; //站点id - - public QueryLeaveAwayPassengersRequest(int seq, int siteId) { - this.sn = MoGoAiCloudClientConfig.getInstance().getSn(); - this.seq = seq; - this.siteId = siteId; - } - - public void setSeq(int seq) { - this.seq = seq; - } - - public void setSiteId(int siteId) { - this.siteId = siteId; - } - - public int getSeq() { - return seq; - } - - public int getSiteId() { - return siteId; - } -} diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/QueryLeaveAwayPassengersResponse.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/QueryLeaveAwayPassengersResponse.java deleted file mode 100644 index dffc722d9b..0000000000 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/QueryLeaveAwayPassengersResponse.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.mogo.och.sweeper.bean; - -import com.mogo.eagle.core.data.BaseData; - -import java.util.List; - -public -/** - * @author congtaowang - * @since 2021/3/26 - * - * 到站查询下车乘客 - */ -class QueryLeaveAwayPassengersResponse extends BaseData { - - public Result data; - - public static class Result { - - public List< LeaveAwayPassenger > orders; - } - - public static class LeaveAwayPassenger { - /** - * orderNo: 订单no - * orderStatus: 订单状态 - * orderType:订单类型:0及时,1预约 - * bookingTime:预计用车时间 - * businessType:订单运营类型 9:taxi,10:bus - * startSiteId: 起点站点id - * userPhone: 乘客联系方式 - * startSitePoint:开始站点坐标 - * startSiteAddr:开始地址 - * endSiteId:结束站点id - * endSitePoint:结束站点坐标 - * carNumber:车牌号 - * createTime: 创建时间 - * startTime:开始时间 - * startSiteGcjPoint:高精坐标 - * endSiteGcjPoint: - */ -//todo 目前是需要乘客电话来通知乘客下车 目前后台没有乘客信息userPhone - public String orderNo; - public int orderStatus; - public int orderType; - public long bookingTime; - public int businessType; - public int startSiteId; - public String passengerPhone; - public List startSitePoint; - public String startSiteAddr; - public int endSiteId; - public List endSitePoint; - public String carNumber; - public long createTime; - public long startTime; - public List< Double > startSiteGcjPoint; - public List< Double > endSiteGcjPoint; - } -} diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperOperationStatusRequest.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperOperationStatusRequest.java deleted file mode 100644 index c8b9995b24..0000000000 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperOperationStatusRequest.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.mogo.och.sweeper.bean; - -import com.mogo.cloud.passport.MoGoAiCloudClientConfig; - -public -/** - * @author congtaowang - * @since 2021/3/22 - * - * 小巴车运营状态请求参数 - */ -class SweeperOperationStatusRequest { - - private String sn; - private double lat; - private double lon; - public SweeperOperationStatusRequest(double lon, double lat) { - this.sn = MoGoAiCloudClientConfig.getInstance().getSn(); - this.lat = lat; - this.lon = lon; - } - public void setLat(double lat) { - this.lat = lat; - } - - public void setLon(double lon) { - this.lon = lon; - } - - public String getSn() { - return sn; - } - - public double getLat() { - return lat; - } - - public double getLon() { - return lon; - } - -} diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperOperationStatusResponse.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperOperationStatusResponse.java deleted file mode 100644 index 664def47df..0000000000 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperOperationStatusResponse.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.mogo.och.sweeper.bean; - -import com.mogo.eagle.core.data.BaseData; - -/** - * @author congtaowang - * @since 2021/3/22 - * - * 小巴车运营状态返回参数 - */ -public class SweeperOperationStatusResponse extends BaseData { - - public Result data; - - public static class Result { - - public int serviceStatus;//0:已收车,1:已出车 - - } -} diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperOrderBean.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperOrderBean.java deleted file mode 100644 index 14be117b5b..0000000000 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperOrderBean.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.mogo.och.sweeper.bean; - -/** - * @author congtaowang - * @since 2021/3/23 - *

- * 小巴订单 - */ -public class SweeperOrderBean { - - /** - * orderNo number - * passengerPhone string 下单用户电话 - * startStationId integer 开始站点 - * startStationName string - * endStationId integer 结束站点 - * endStationName string - */ - - private String orderNo; - private String passengerPhone; - private int startStationId;//乘客上车点 - private String startStationName; - private String endStationName; - private int endStationId;//乘客下车点 - - public void setOrderNo(String orderNo) { - this.orderNo = orderNo; - } - - public void setPassengerPhone(String passengerPhone) { - this.passengerPhone = passengerPhone; - } - - public void setStartStationId(int startStationId) { - this.startStationId = startStationId; - } - - public void setStartStationName(String startStationName) { - this.startStationName = startStationName; - } - - public void setEndStationName(String endStationName) { - this.endStationName = endStationName; - } - - public void setEndStationId(int endStationId) { - this.endStationId = endStationId; - } - - public String getOrderNo() { - return orderNo; - } - - public String getPassengerPhone() { - return passengerPhone; - } - - public int getStartStationId() { - return startStationId; - } - - public String getStartStationName() { - return startStationName; - } - - public String getEndStationName() { - return endStationName; - } - - public int getEndStationId() { - return endStationId; - } - - @Override - public String toString() { - return "BusOrderBean{" + - "orderNo=" + orderNo + - ", passengerPhone='" + passengerPhone + '\'' + - ", startStationId=" + startStationId + - ", startStationName='" + startStationName + '\'' + - ", endStationName='" + endStationName + '\'' + - ", endStationId=" + endStationId + - '}'; - } -} diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperOrdersResponse.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperOrdersResponse.java deleted file mode 100644 index 38ab2a6e4e..0000000000 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperOrdersResponse.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.mogo.och.sweeper.bean; - -import com.mogo.eagle.core.data.BaseData; - -import java.util.List; - -/** - * @author: wangmingjun - * @date: 2021/10/19 - */ -public class SweeperOrdersResponse extends BaseData { - public Result data; - public static class Result{ - public List orders; - } - - @Override - public String toString() { - return "BusOrdersResponse{" + - "data=" + data + - '}'; - } -} diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperQueryLineStationsRequest.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperQueryLineStationsRequest.java deleted file mode 100644 index 2289886b1a..0000000000 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperQueryLineStationsRequest.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.mogo.och.sweeper.bean; - -import com.mogo.cloud.passport.MoGoAiCloudClientConfig; -/** - * @author congtaowang - * @since 2021/3/22 - * - * 根据车机行驶线路站点信息 - */ -public class SweeperQueryLineStationsRequest { - - private String sn; - private double lat; - private double lon; - private boolean markDrivingStatus; // 默认false;true:是否需要返回站点的行驶状态,对应返回的drivingStatus - // 0 - 关闭、1 - 启动 -// public String status; - public SweeperQueryLineStationsRequest(double lon, double lat, boolean markDrivingStatus) { - this.sn = MoGoAiCloudClientConfig.getInstance().getSn(); - this.lat = lat; - this.lon = lon; - this.markDrivingStatus = markDrivingStatus; - } - - public boolean isMarkDrivingStatus() { - return markDrivingStatus; - } - - public void setMarkDrivingStatus(boolean markDrivingStatus) { - this.markDrivingStatus = markDrivingStatus; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public void setLon(double lon) { - this.lon = lon; - } - - public String getSn() { - return sn; - } - - public double getLat() { - return lat; - } - - public double getLon() { - return lon; - } - // public BusOperationStatusRequest shutdown() { -// status = "0"; -// return this; -// } -// -// public BusOperationStatusRequest launch() { -// status = "1"; -// return this; -// } -} diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperQueryLinesResponse.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperQueryLinesResponse.java deleted file mode 100644 index e1cf271b2d..0000000000 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperQueryLinesResponse.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.mogo.och.sweeper.bean; - -import com.mogo.eagle.core.data.BaseData; - -import java.util.List; - -/** - * @author: wangmingjun - * @date: 2022/2/9 - */ -public class SweeperQueryLinesResponse extends BaseData { - public List data; - - public static class Result { - - public int lineId;//线路id - public String name;//线路名字 - public int choose; // 1:绑定 2:未被绑定 - public String startSiteName;//始发站名称 - public String endSiteName;//终点名称 - - } -} diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperResetDrivingLineRequest.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperResetDrivingLineRequest.java deleted file mode 100644 index 718ba66504..0000000000 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperResetDrivingLineRequest.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.mogo.och.sweeper.bean; - -import com.mogo.cloud.passport.MoGoAiCloudClientConfig; - -/** - * @author: wangmingjun - * @date: 2021/10/18 - */ -public class SweeperResetDrivingLineRequest { - public String sn; - public int lineId; //切换到的线路id - - public SweeperResetDrivingLineRequest(int lineId) { - sn = MoGoAiCloudClientConfig.getInstance().getSn(); - this.lineId = lineId; - } -} diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperRoutesResponse.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperRoutesResponse.java deleted file mode 100644 index 6779f61b80..0000000000 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperRoutesResponse.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.mogo.och.sweeper.bean; - -import com.mogo.eagle.core.data.BaseData; - -/** - * 网约车小巴路线接口请求响应结果 - * - * @author tongchenfei - */ -public class SweeperRoutesResponse extends BaseData { - private SweeperRoutesResult data; - - public SweeperRoutesResult getResult() { - return data; - } - - public void setResult(SweeperRoutesResult data) { - this.data = data; - } - - @Override - public String toString() { - return "BusRoutesResponse{" + - "data=" + data + - '}'; - } -} diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperRoutesResult.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperRoutesResult.java index 545304b948..cc1abd083e 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperRoutesResult.java +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperRoutesResult.java @@ -8,7 +8,7 @@ import java.util.List; * @author tongchenfei */ public class SweeperRoutesResult { - private List sites; + private List sites; private int lineId; private String name; private int lineType; //线路类型,0:环形 @@ -36,11 +36,11 @@ public class SweeperRoutesResult { return name; } - public List getSites() { + public List getSites() { return sites; } - public void setSite(List site) { + public void setSite(List site) { this.sites = sites; } diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperStationBean.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperTaskBean.java similarity index 99% rename from OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperStationBean.java rename to OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperTaskBean.java index ad4fef2b65..43aebfc1db 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperStationBean.java +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperTaskBean.java @@ -5,7 +5,7 @@ package com.mogo.och.sweeper.bean; * * @author tongchenfei */ -public class SweeperStationBean { +public class SweeperTaskBean { // private int lineId; // private int siteId; // private String siteName; diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperUpdateSiteStatusRequest.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperUpdateSiteStatusRequest.java deleted file mode 100644 index 422d5113fa..0000000000 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/bean/SweeperUpdateSiteStatusRequest.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.mogo.och.sweeper.bean; - -import com.mogo.cloud.passport.MoGoAiCloudClientConfig; - -/** - * @author congtaowang - * @since 2021/3/22 - * - * 小巴车运营状态请求参数 - */ -public class SweeperUpdateSiteStatusRequest { - - public String sn; - public int seq;//站点序号 - public int siteId;//站点id - public double lon; - public double lat; - - public SweeperUpdateSiteStatusRequest(int seq, int siteId, double lon, double lat) { - this.sn = MoGoAiCloudClientConfig.getInstance().getSn(); - this.seq = seq; - this.siteId = siteId; - this.lon = lon; - this.lat = lat; - } -} diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/callback/ICarOperationStatusCallback.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/callback/ICarOperationStatusCallback.java deleted file mode 100644 index cdd2a06f24..0000000000 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/callback/ICarOperationStatusCallback.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.mogo.och.sweeper.callback; - -/** - * @author: wangmingjun - * @date: 2021/10/22 - */ -public interface ICarOperationStatusCallback { - void changeOperationStatus(boolean changeStatus); -} diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/callback/IRefreshSweeperStationsCallback.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/callback/IRefreshSweeperStationsCallback.java deleted file mode 100644 index f6fd3ae0ab..0000000000 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/callback/IRefreshSweeperStationsCallback.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.mogo.och.sweeper.callback; - -import com.mogo.och.sweeper.bean.SweeperStationBean; - -import java.util.List; - -/** - * @author: wangmingjun - * @date: 2021/10/22 - */ -public interface IRefreshSweeperStationsCallback { - void refreshBusStations(String lineName, List stationList, int currentStation, int nextStation, boolean isArrived); -} diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/callback/IRefreshSweeperTaskCallback.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/callback/IRefreshSweeperTaskCallback.java new file mode 100644 index 0000000000..d376980b1c --- /dev/null +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/callback/IRefreshSweeperTaskCallback.java @@ -0,0 +1,18 @@ +package com.mogo.och.sweeper.callback; + +import com.mogo.och.sweeper.bean.SweeperTaskBean; + +import java.util.List; + +/** + * @author: wangmingjun + * @date: 2021/10/22 + */ +public interface IRefreshSweeperTaskCallback { + + void updateSweeperTaskStatus(String lineName, List taskList, int currentTask,boolean isFinishedSubTask); + /** + * 结束清理一遍、选择任务后清理一遍 + */ + void clearSweeperTasksMarkers(); +} diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/callback/ISweeperADASStatusCallback.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/callback/ISweeperADASStatusCallback.java new file mode 100644 index 0000000000..995e1723af --- /dev/null +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/callback/ISweeperADASStatusCallback.java @@ -0,0 +1,11 @@ +package com.mogo.och.sweeper.callback; + +/** + * Created on 2021/9/8 + * + * Model->Presenter回调:ADAS相关(自动驾驶状态回调,到达终点等等) + */ +public interface ISweeperADASStatusCallback { + //自驾返回失败 + void onStartAdasFailure(); +} diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/constant/SweeperConst.kt b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/constant/SweeperConst.kt index 880392bdbd..ec51cbe709 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/constant/SweeperConst.kt +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/constant/SweeperConst.kt @@ -55,8 +55,13 @@ class SweeperConst { const val EVENT_PARAM_END_NAME = "end_name" const val EVENT_PARAM_LINE_ID = "line_id" const val EVENT_PARAM_START_RESULT = "start_autopilot" // true/false + const val EVENT_PARAM_START_FAILURE_CODE = "start_autopilot_failure_code" // 启动自驾失败code + const val EVENT_PARAM_START_FAILURE_MSG = "start_autopilot_failure_msg" // 启动自驾失败原因 const val EVENT_PARAM_PLATE_NUM = "plate_number" // 车牌号 const val EVENT_PARAM_ENV_ONLINE = "env_online" // 是否线上环境:true/false + // 埋点key:开启自动驾驶前已识别的异常,会导致无法开启自驾 + const val EVENT_KEY_AP_UNABLE_START_REASON = "event_key_och_bus_ap_unable_start_reason" + const val EVENT_PARAM_UNABLE_START_REASON = "unable_start_reason"; /** * 订单起终点Marker类型 diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/SweeperFragment.kt b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/SweeperFragment.kt index 81ed6495ff..f412b38040 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/SweeperFragment.kt +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/SweeperFragment.kt @@ -70,6 +70,14 @@ class SweeperFragment : BaseSweeperTabFragment { + + /** + * 获取任务列表 + * @return + */ + List getTaskList(); + + /** + * 设置任务列表 + * @param taskList + */ + void setTaskList(List taskList); + + /** + * 获取当前任务 + * @return + */ + T getCurrentTask(); + + /** + * 设置当前任务 + * @param currentTask + */ + void setCurrentTask(T currentTask); + + /** + * 开始任务 + */ + void startTask(); + + /** + * 暂停任务 + */ + void pauseTask(); + + /** + * 跳过任务 + */ + void jumpOverTask(); + + /** + * 结束任务 + */ + void endTask(); + +} diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/model/OperationalTask.kt b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/model/OperationalTask.kt new file mode 100644 index 0000000000..085afd2c72 --- /dev/null +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/model/OperationalTask.kt @@ -0,0 +1,40 @@ +package com.mogo.och.sweeper.model + +import com.mogo.och.sweeper.bean.TaskInfoBean + +/** + * 运营任务 + */ +class OperationalTask : ISweeperTask { + override fun getTaskList(): MutableList { + return mutableListOf() + } + + override fun startTask() { + + } + + override fun pauseTask() { + + } + + override fun jumpOverTask() { + + } + + override fun endTask() { + + } + + override fun setTaskList(taskList: MutableList?) { + + } + + override fun getCurrentTask(): TaskInfoBean { + return TaskInfoBean(1, "", 1) + } + + override fun setCurrentTask(currentTask: TaskInfoBean?) { + + } +} \ No newline at end of file diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/model/SweeperOrderModel.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/model/SweeperOrderModel.java deleted file mode 100644 index 4b5f8b189f..0000000000 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/model/SweeperOrderModel.java +++ /dev/null @@ -1,393 +0,0 @@ -package com.mogo.och.sweeper.model; - -import android.content.Context; - -import com.amap.api.maps.model.LatLng; -import com.elegant.network.utils.GsonUtil; -import com.mogo.cloud.commons.utils.CoordinateUtils; -import com.mogo.commons.AbsMogoApplication; -import com.mogo.commons.module.status.IMogoStatusChangedListener; -import com.mogo.commons.module.status.MogoStatusManager; -import com.mogo.commons.module.status.StatusDescriptor; -import com.mogo.eagle.core.data.BaseData; -import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters; -import com.mogo.eagle.core.data.config.FunctionBuildConfig; -import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener; -import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener; -import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager; -import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager; -import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager; -import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager; -import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager; -import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; -import com.mogo.eagle.core.utilcode.mogo.logger.Logger; -import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil; -import com.mogo.och.sweeper.bean.SweeperRoutePlanningUpdateReqBean; -import com.mogo.och.sweeper.bean.SweeperRoutesResult; -import com.mogo.och.sweeper.bean.SweeperStationBean; -import com.mogo.och.sweeper.callback.ICarOperationStatusCallback; -import com.mogo.och.sweeper.callback.IRefreshSweeperStationsCallback; -import com.mogo.och.sweeper.callback.ISweeperControllerStatusCallback; -import com.mogo.och.sweeper.constant.SweeperConst; -import com.mogo.och.sweeper.net.ISweeperServiceCallback; -import com.mogo.och.sweeper.net.SweeperServiceManager; -import com.mogo.och.sweeper.presenter.SweeperModelLoopManager; -import com.mogo.och.sweeper.util.SweeperAnalyticsManager; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import androidx.annotation.Nullable; -import io.reactivex.exceptions.UndeliverableException; -import io.reactivex.functions.Consumer; -import io.reactivex.plugins.RxJavaPlugins; -import mogo.telematics.pad.MessagePad; - -import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS; - -/** - * @author congtaowang - * @since 2021/3/23 - *

- * 小巴订单管理 - */ -public class SweeperOrderModel { - private final String TAG = SweeperOrderModel.class.getSimpleName(); - private int currentLineId = -1; - private int backgroundCurrentStationIndex = 0;//A->B 此处值是A站点索引 - private static volatile SweeperOrderModel sInstance; - public double mLongitude = 0; - public double mLatitude = 0; - private Context mContext; - private final List stationList = new ArrayList<>(); - private SweeperRoutesResult sweeperRoutesResult = null; - /** - * 用来表示是否正在开往下一站 - */ - private boolean isGoingToNextStation = false; - - private boolean mIsWorking = false; - - private ISweeperControllerStatusCallback mControllerStatusCallback; //Model->Presenter:VR mode等 - - List points = new ArrayList<>();//全路径信息 - - private boolean hadQueryLeaveAwayPassager = false; - - private volatile boolean isArrivedStation = false; - - public static SweeperOrderModel getInstance() { - if (sInstance == null) { - synchronized (SweeperOrderModel.class) { - if (sInstance == null) { - sInstance = new SweeperOrderModel(); - } - } - } - return sInstance; - } - - private SweeperOrderModel() { - - } - public boolean isGoingToNextStation() { - return isGoingToNextStation; - } - public void init() { - mContext = AbsMogoApplication.getApp(); - // 定位监听 - CallerChassisLocationGCJ20ListenerManager.INSTANCE.addListener(TAG, mMapLocationListener); - - MogoStatusManager.getInstance().registerStatusChangedListener(TAG, StatusDescriptor.VR_MODE, mMogoStatusChangedListener); - - //自动驾驶路线规划接口 - CallerPlanningRottingListenerManager.INSTANCE.addListener(TAG, moGoAutopilotPlanningListener); - - - //2022.1.28 - // 调用Disposable.dispose() 时候会出现InterruptedException 导致出现崩溃 - // The exception could not be delivered to the consumer because it has already canceled/disposed - // the flow or the excTeption has nowhere to go to begin with - RxJavaPlugins.setErrorHandler(new Consumer() { - @Override - public void accept(Throwable e) { - if (e instanceof UndeliverableException) { - e = e.getCause(); - CallerLogger.INSTANCE.d(M_BUS + TAG, "UndeliverableException"); - } - if ((e instanceof IOException)) {// - // fine, irrelevant network problem or API that throws on cancellation - CallerLogger.INSTANCE.d(M_BUS + TAG, "IOException"); - return; - } - if (e instanceof InterruptedException) { - // fine, some blocking code was interrupted by a dispose call - CallerLogger.INSTANCE.d(M_BUS + TAG, "InterruptedException"); - return; - } - if ((e instanceof NullPointerException) || (e instanceof IllegalArgumentException)) { - // that's likely a bug in the application - CallerLogger.INSTANCE.d(M_BUS + TAG, "NullPointerException or IllegalArgumentException"); - Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e); - return; - } - if (e instanceof IllegalStateException) { - // that's a bug in RxJava or in a custom operator - CallerLogger.INSTANCE.d(M_BUS + TAG, "IllegalStateException"); - Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e); - return; - } - CallerLogger.INSTANCE.d(M_BUS + TAG, "Undeliverable exception"); - } - }); - - } - public void setControllerStatusCallback(ISweeperControllerStatusCallback callback) { - this.mControllerStatusCallback = callback; - } - - private final IMoGoPlanningRottingListener moGoAutopilotPlanningListener = new IMoGoPlanningRottingListener() { - - @Override - public void onAutopilotRotting(MessagePad.GlobalPathResp routeList) { - if (null != routeList && routeList.getWayPointsList().size() > 0) { - points.clear(); - points.addAll(coordinateConverterWgsToGcjList(mContext, routeList.getWayPointsList())); - updateOrderRoute(); - } - } - - }; - - public static List coordinateConverterWgsToGcjList(Context mContext, - List mogoLatLngList) { - List points = new ArrayList<>(); - for (MessagePad.Location m : mogoLatLngList) { - LatLng mogoLatLng = CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(mContext, m); - SweeperRoutePlanningUpdateReqBean.Result result = new SweeperRoutePlanningUpdateReqBean.Result(); - result.latitude = mogoLatLng.latitude; - result.longitude = mogoLatLng.longitude; - points.add(result); - } - return points; - } - - /** - * 上报订单全路径规划数据 - */ - public void updateOrderRoute() { - if (!isGoingToNextStation || backgroundCurrentStationIndex + 1 >= stationList.size() || points.size() == 0) { - return; - } - - SweeperStationBean currentStation = stationList.get(backgroundCurrentStationIndex); - SweeperStationBean nextStation = stationList.get(backgroundCurrentStationIndex + 1); - - SweeperServiceManager.getInstance().updateOrderRoute(mContext, currentLineId, currentStation.getSiteId() - , nextStation.getSiteId(), points, new ISweeperServiceCallback() { - @Override - public void onSuccess(BaseData o) { - - } - - @Override - public void onFail(String failMsg) { - if (isGoingToNextStation) {//重试 - updateOrderRoute(); - } - } - }); - } - - public void debugUpdateOrderRoute(List list) { - points.clear(); - points.addAll(coordinateConverterWgsToGcjList(mContext, list)); - updateOrderRoute(); - } - - public void release() { - startOrStopOrderLoop(false); - MogoStatusManager.getInstance().unregisterStatusChangedListener(TAG, StatusDescriptor.VR_MODE, mMogoStatusChangedListener); - // 注销定位监听 - CallerMapLocationListenerManager.INSTANCE.removeListener(TAG, false); - - //自动驾驶路线规划接口 - CallerPlanningRottingListenerManager.INSTANCE.removeListener(moGoAutopilotPlanningListener); - } - - private Object readResolve() { - // 阻止反序列化,必须实现 Serializable 接口 - return sInstance; - } - - private final IMogoStatusChangedListener mMogoStatusChangedListener = new IMogoStatusChangedListener() { - // VR mode变更回调 - @Override - public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) { - if (StatusDescriptor.VR_MODE == descriptor) { - if (mControllerStatusCallback != null) { - mControllerStatusCallback.onVRModeChanged(isTrue); - } - } - } - }; - - // 自车定位 - private final IMoGoChassisLocationGCJ02Listener mMapLocationListener = new IMoGoChassisLocationGCJ02Listener() { - @Override - public void onChassisLocationGCJ02(@Nullable MessagePad.GnssInfo gnssInfo) { - if (null == gnssInfo) return; - mLongitude = gnssInfo.getLongitude(); - mLatitude = gnssInfo.getLatitude(); - if (mControllerStatusCallback != null) { - mControllerStatusCallback.onCarLocationChanged(gnssInfo); - } - - //是否到站的围栏判断 离站状态并且自动驾驶还未触发到站 - if (isGoingToNextStation && !isArrivedStation) { - judgeStartStation(gnssInfo); - } - } - }; - - //根据围栏判断,是否到达起点 - private void judgeStartStation(MessagePad.GnssInfo location) { - - if (backgroundCurrentStationIndex + 1 > stationList.size() - 1) { - return; - } - SweeperStationBean upcomingStation = stationList.get(backgroundCurrentStationIndex + 1); - - double startLon = upcomingStation.getGcjLon(); - double startLat = upcomingStation.getGcjLat(); - double distance = CoordinateUtils.calculateLineDistance( - startLon, startLat, - location.getLongitude(), location.getLatitude()); - - Logger.i(TAG, "judgeStartStation() distance = " + distance); - - if (distance > SweeperConst.ARRIVE_AT_END_STATION_DISTANCE) { - distance = CoordinateUtils.calculateLineDistance(startLon, startLat, - CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84Lon(), - CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84Lat()); - } - - if (distance <= SweeperConst.ARRIVE_AT_END_STATION_DISTANCE) { - //onArriveAt(null); //无自动驾驶到站信息传null - return; - } - } - - /** - * 开启自动驾驶 - * - * @param isRestart - */ - private void startAutopilot(boolean isRestart) { - - triggerStartServiceEvent(isRestart, false); - - isArrivedStation = false; -// SweeperStationBean currentStation = stationList.get( backgroundCurrentStationIndex); -// SweeperStationBean nextStation = stationList.get( backgroundCurrentStationIndex + 1); - -// if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE -// == CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState()) { -// ToastUtils.showShort("自动驾驶状态为不可用!"); -// } - AutopilotControlParameters parameters = new AutopilotControlParameters(); -// parameters.isSpeakVoice = !isRestart; -// parameters.routeID = sweeperRoutesResult.getLineId(); -// parameters.routeName = sweeperRoutesResult.getName(); -// parameters.startName = PinYinUtil.getPinYinHeadChar(currentStation.getName()); -// parameters.endName = PinYinUtil.getPinYinHeadChar(nextStation.getName()); -// parameters.startLatLon = new AutopilotControlParameters -// .AutoPilotLonLat( currentStation.getLat(), currentStation.getLon() ); -// parameters.endLatLon = new AutopilotControlParameters -// .AutoPilotLonLat( nextStation.getLat(), nextStation.getLon() ); -// parameters.vehicleType = VEHICLE_TYPE; -// if (parameters.autoPilotLine == null) { -// parameters.autoPilotLine = new AutopilotControlParameters.AutoPilotLine( -// sweeperRoutesResult.getLineId(), -// sweeperRoutesResult.csvFileUrl, sweeperRoutesResult.csvFileMd5, -// sweeperRoutesResult.txtFileUrl, sweeperRoutesResult.txtFileMd5, -// sweeperRoutesResult.contrailSaveTime, sweeperRoutesResult.carModel, -// sweeperRoutesResult.csvFileUrlDPQP, sweeperRoutesResult.csvFileMd5DPQP, -// sweeperRoutesResult.txtFileUrlDPQP, sweeperRoutesResult.txtFileMd5DPQP, -// sweeperRoutesResult.contrailSaveTimeDPQP); -// } -// CallerLogger.INSTANCE.d( M_BUS + TAG, "开启自动驾驶====" + GsonUtil.jsonFromObject(parameters) -// +" startLatLon="+currentStation.getName()+",endLatLon="+nextStation.getName()); - CallerLogger.INSTANCE.d(M_BUS + TAG, "开启自动驾驶====" + GsonUtil.jsonFromObject(parameters)); - CallerAutoPilotManager.INSTANCE.startAutoPilot(parameters); - - if (mControllerStatusCallback != null) { - mControllerStatusCallback.startOpenAutopilot(); - } - } - public boolean isWorking() { - return mIsWorking; - } - /** - * 关闭美化模式 - */ - private void closeBeautificationMode() { - if (FunctionBuildConfig.isDemoMode) {//收车结束美化 - FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false; - CallerAutoPilotManager.INSTANCE.setIPCDemoMode(false); - CallerLogger.INSTANCE.d(M_BUS + TAG, "美化模式-ignore:置为false(收车)"); - } - } - /** - * 在踩刹车、控制方向盘等操作后,会停止自动驾驶,重启自动驾驶的话相当于重新设置自动驾驶目的地 - */ - public void restartAutopilot() { -// CallerLogger.INSTANCE.d( M_BUS + TAG, "重启自动驾驶===" + isGoingToNextStation ); -// autoDriveToNextStation( true ); - //直接开启自动驾驶 - startAutopilot(true); - } - // 车机端上传心跳数据(只在出车状态时上传) - public void runCarHeartbeat() { - SweeperServiceManager.getInstance().runCarHeartbeat(mContext, mLongitude, mLatitude, - new ISweeperServiceCallback() { - @Override - public void onSuccess(BaseData data) { - - } - - @Override - public void onFail(String failMsg) { - - } - }); - } - - private void startOrStopOrderLoop(boolean start) { - CallerLogger.INSTANCE.d(M_BUS + TAG, "startOrStopOrderLoop() " + start); - if (start) { - SweeperModelLoopManager.getInstance().startHeartbeatLoop(); - } else { - SweeperModelLoopManager.getInstance().stopHeartbeatLoop(); - } - } - - public void triggerStartServiceEvent(boolean isRestart, boolean send) { - if (stationList == null || backgroundCurrentStationIndex >= stationList.size() - 1) { - return; - } - SweeperStationBean currentStation = stationList.get(backgroundCurrentStationIndex); - SweeperStationBean nextStation = stationList.get(backgroundCurrentStationIndex + 1); - SweeperAnalyticsManager.getInstance().triggerStartAutopilotEvent(isRestart, send, - currentStation.getName(), nextStation.getName(), currentLineId); - } - - public SweeperRoutesResult getBusRoutesResult() { - return sweeperRoutesResult; - } - - public int getCurrentStationIndex() { - return backgroundCurrentStationIndex; - } -} diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/model/SweeperTaskModel.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/model/SweeperTaskModel.java new file mode 100644 index 0000000000..2dde3d85d1 --- /dev/null +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/model/SweeperTaskModel.java @@ -0,0 +1,481 @@ +package com.mogo.och.sweeper.model; + +import android.content.Context; + +import com.amap.api.maps.model.LatLng; +import com.elegant.network.utils.GsonUtil; +import com.mogo.cloud.commons.utils.CoordinateUtils; +import com.mogo.commons.AbsMogoApplication; +import com.mogo.commons.module.status.IMogoStatusChangedListener; +import com.mogo.commons.module.status.MogoStatusManager; +import com.mogo.commons.module.status.StatusDescriptor; +import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters; +import com.mogo.eagle.core.data.config.FunctionBuildConfig; +import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; +import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener; +import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener; +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager; +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager; +import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager; +import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager; +import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager; +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; +import com.mogo.eagle.core.utilcode.util.ToastUtils; +import com.mogo.och.common.module.callback.OchAdasStartFailureCallback; +import com.mogo.och.common.module.manager.OCHAdasAbilityManager; +import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil; +import com.mogo.och.common.module.utils.NumberFormatUtil; +import com.mogo.och.common.module.utils.PinYinUtil; +import com.mogo.och.sweeper.bean.SweeperRoutePlanningUpdateReqBean; +import com.mogo.och.sweeper.bean.SweeperRoutesResult; +import com.mogo.och.sweeper.bean.SweeperTaskBean; +import com.mogo.och.sweeper.callback.IRefreshSweeperTaskCallback; +import com.mogo.och.sweeper.callback.ISweeperADASStatusCallback; +import com.mogo.och.sweeper.callback.ISweeperControllerStatusCallback; +import com.mogo.och.sweeper.constant.SweeperConst; +import com.mogo.och.sweeper.util.SweeperAnalyticsManager; + +import org.jetbrains.annotations.NotNull; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.reactivex.exceptions.UndeliverableException; +import io.reactivex.functions.Consumer; +import io.reactivex.plugins.RxJavaPlugins; +import mogo.telematics.pad.MessagePad; + +import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS; +/** + * @author congtaowang + * @since 2021/3/23 + *

+ * 清扫车任务管理 + */ +public class SweeperTaskModel { + private final String TAG = SweeperTaskModel.class.getSimpleName(); + private int currentLineId = -1; + private int backgroundCurrentTaskIndex = 0;//A->B 此处值是A任务索引 + private static volatile SweeperTaskModel sInstance; + public double mLongitude = 0; + public double mLatitude = 0; + private Context mContext; + private final List stationList = new ArrayList<>(); + private SweeperRoutesResult busRoutesResult = null; + /** + * 用来表示是否正在开往下一站 + */ + private boolean isGoingToNextStation = false; + // 运营类型 + private static final int VEHICLE_TYPE = 10; + private ISweeperControllerStatusCallback mControllerStatusCallback; //Model->Presenter:VR mode等 + private ISweeperADASStatusCallback mADASStatusCallback; + private IRefreshSweeperTaskCallback mRefreshSweeperTaskCallback; + + List points = new ArrayList<>();//全路径信息 + + private volatile boolean isArrivedStation = false; + + //0: 代表没有启动过 1代表是启动第一次,当>=1 代表是重试 每次到站/路线结束清空置为0 + private volatile int firstStartAutopilot = 0; + + public static SweeperTaskModel getInstance() { + if (sInstance == null) { + synchronized (SweeperTaskModel.class) { + if (sInstance == null) { + sInstance = new SweeperTaskModel(); + } + } + } + return sInstance; + } + + private SweeperTaskModel() { + + } + + public void init() { + mContext = AbsMogoApplication.getApp(); + // 定位监听 + CallerChassisLocationGCJ20ListenerManager.INSTANCE.addListener(TAG, mMapLocationListener); + + MogoStatusManager.getInstance().registerStatusChangedListener(TAG, StatusDescriptor.VR_MODE, mMogoStatusChangedListener); + + //自动驾驶路线规划接口 + CallerPlanningRottingListenerManager.INSTANCE.addListener(TAG, moGoAutopilotPlanningListener); + + //开启自驾后 异常信息返回 + OCHAdasAbilityManager.getInstance().setAdasStartFailureCallback(mAdasStartFailureListener); + + //2022.1.28 + // 调用Disposable.dispose() 时候会出现InterruptedException 导致出现崩溃 + // The exception could not be delivered to the consumer because it has already canceled/disposed + // the flow or the excTeption has nowhere to go to begin with + RxJavaPlugins.setErrorHandler(new Consumer() { + @Override + public void accept(Throwable e) { + if (e instanceof UndeliverableException) { + e = e.getCause(); + CallerLogger.INSTANCE.d(M_BUS + TAG, "UndeliverableException"); + } + if ((e instanceof IOException)) {// + // fine, irrelevant network problem or API that throws on cancellation + CallerLogger.INSTANCE.d(M_BUS + TAG, "IOException"); + return; + } + if (e instanceof InterruptedException) { + // fine, some blocking code was interrupted by a dispose call + CallerLogger.INSTANCE.d(M_BUS + TAG, "InterruptedException"); + return; + } + if ((e instanceof NullPointerException) || (e instanceof IllegalArgumentException)) { + // that's likely a bug in the application + CallerLogger.INSTANCE.d(M_BUS + TAG, "NullPointerException or IllegalArgumentException"); + Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e); + return; + } + if (e instanceof IllegalStateException) { + // that's a bug in RxJava or in a custom operator + CallerLogger.INSTANCE.d(M_BUS + TAG, "IllegalStateException"); + Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e); + return; + } + CallerLogger.INSTANCE.d(M_BUS + TAG, "Undeliverable exception"); + } + }); + } + public void setAdasStatusCallback(ISweeperADASStatusCallback callback){ + this.mADASStatusCallback = callback; + } + public void setControllerStatusCallback(ISweeperControllerStatusCallback callback) { + this.mControllerStatusCallback = callback; + } + + private final IMoGoPlanningRottingListener moGoAutopilotPlanningListener = new IMoGoPlanningRottingListener() { + + @Override + public void onAutopilotRotting(MessagePad.GlobalPathResp routeList) { + if (null != routeList && routeList.getWayPointsList().size() > 0) { + points.clear(); + points.addAll(coordinateConverterWgsToGcjList(mContext, routeList.getWayPointsList())); + } + } + + }; + + public static List coordinateConverterWgsToGcjList(Context mContext, List mogoLatLngList) { + List points = new ArrayList<>(); + for (MessagePad.Location m : mogoLatLngList) { + LatLng mogoLatLng = CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(mContext, m); + SweeperRoutePlanningUpdateReqBean.Result result = new SweeperRoutePlanningUpdateReqBean.Result(); + result.latitude = mogoLatLng.latitude; + result.longitude = mogoLatLng.longitude; + points.add(result); + } + return points; + } + public void release() { + MogoStatusManager.getInstance().unregisterStatusChangedListener(TAG, StatusDescriptor.VR_MODE, mMogoStatusChangedListener); + // 注销定位监听 + CallerMapLocationListenerManager.INSTANCE.removeListener(TAG,false); + //自动驾驶路线规划接口 + CallerPlanningRottingListenerManager.INSTANCE.removeListener(moGoAutopilotPlanningListener); + OCHAdasAbilityManager.getInstance().setAdasStartFailureCallback(null); + } + + private Object readResolve() { + // 阻止反序列化,必须实现 Serializable 接口 + return sInstance; + } + + private final IMogoStatusChangedListener mMogoStatusChangedListener = new IMogoStatusChangedListener() { + // VR mode变更回调 + @Override + public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) { + if (StatusDescriptor.VR_MODE == descriptor) { + if (mControllerStatusCallback != null) { + mControllerStatusCallback.onVRModeChanged(isTrue); + } + } + } + }; + + private final OchAdasStartFailureCallback mAdasStartFailureListener = new OchAdasStartFailureCallback() { + @Override + public void onStartAutopilotFailure(@NotNull String startFailedCode, @NonNull String startFailedMessage) { + SweeperAnalyticsManager.getInstance().triggerStartAutopilotFailureEventByAdas(startFailedCode, startFailedMessage); + if (mADASStatusCallback != null && !FunctionBuildConfig.isDemoMode){ + CallerLogger.INSTANCE.e( M_BUS + TAG, "mAdasStartFailureListener = "+startFailedMessage ); + mADASStatusCallback.onStartAdasFailure(); + } + } + }; + + // 自车定位 + private final IMoGoChassisLocationGCJ02Listener mMapLocationListener = new IMoGoChassisLocationGCJ02Listener() { + @Override + public void onChassisLocationGCJ02(@Nullable MessagePad.GnssInfo gnssInfo) { + if (null == gnssInfo) return; + mLongitude = gnssInfo.getLongitude(); + mLatitude = gnssInfo.getLatitude(); + if (mControllerStatusCallback != null) { + mControllerStatusCallback.onCarLocationChanged(gnssInfo); + } + //是否到站的围栏判断 离站状态并且自动驾驶还未触发到站 + if (isGoingToNextStation && !isArrivedStation) { + judgeArrivedStation(gnssInfo); + } + } + }; + + //根据围栏判断,是否到达站点 + private void judgeArrivedStation(MessagePad.GnssInfo location) { + + if (backgroundCurrentTaskIndex + 1 > stationList.size() - 1) { + CallerLogger.INSTANCE.e(M_BUS + TAG, "到站数组越界"); + return; + } + SweeperTaskBean upcomingStation = stationList.get(backgroundCurrentTaskIndex + 1); + + double startLon = upcomingStation.getGcjLon(); + double startLat = upcomingStation.getGcjLat(); + double distance = CoordinateUtils.calculateLineDistance( + startLon, startLat, + location.getLongitude(), location.getLatitude()); + + if (distance <= SweeperConst.ARRIVE_AT_END_STATION_DISTANCE) { + CallerLogger.INSTANCE.d(M_BUS + TAG, "行程日志-judgeArrivedStation() distance = " + distance + + " to " + upcomingStation.getName()); + onArriveAt(null); //无自动驾驶到站信息传null + return; + } + } + private void onStartAutopilot(int leaveIndex) { + //开启自动驾驶 2.10.0: 如果自动驾驶状态下开启, 非自动驾驶状态下不开启,需手动点击自动驾驶按钮开启 + isGoingToNextStation = true; + if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() + == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { + startAutopilot(false, leaveIndex); + } else { + firstStartAutopilot = 0; + } + } + /** + * 开启自动驾驶 + * + * @param isRestart + */ + private void startAutopilot(boolean isRestart, int leaveIndex) { + + if (!FunctionBuildConfig.isDemoMode && !OCHAdasAbilityManager.getInstance().getAutopilotAbilityStatus()) { + ToastUtils.showLong(OCHAdasAbilityManager.getInstance().getAutopilotUnAbilityReason() + + ", 请稍候重试"); + triggerUnableStartAPReasonEvent(); + return; + } + + firstStartAutopilot++; + + triggerStartServiceEvent(isRestart, false); + + AutopilotControlParameters parameters = initAutopilotControlParameters(leaveIndex); + if (null == parameters) { + CallerLogger.INSTANCE.e(M_BUS + TAG, "行程日志-AutopilotControlParameters is empty."); + return; + } + + CallerAutoPilotManager.INSTANCE.startAutoPilot(parameters); + + CallerLogger.INSTANCE.d(M_BUS + TAG, "行程日志-开启自动驾驶====" + GsonUtil.jsonFromObject(parameters) + + " startLatLon=" + parameters.startName + ",endLatLon=" + parameters.endName + + "isRestart = " + isRestart); + + if (mControllerStatusCallback != null) { + mControllerStatusCallback.startOpenAutopilot(); + } + } + /** + * 关闭美化模式 + */ + public void closeBeautificationMode() { + if (FunctionBuildConfig.isDemoMode) { + FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false; //是否强制绘制引导线 + CallerAutoPilotManager.INSTANCE.setIgnoreConditionDraw(false);// 同步给乘客屏 + CallerAutoPilotManager.INSTANCE.setIPCDemoMode(false);//是否自动启动自驾 + CallerLogger.INSTANCE.d(M_BUS + TAG, "美化模式-ignore:置为false"); + } + } + private void clearStartAutopilotTag() { + firstStartAutopilot = 0; + } + + /** + * 开启美化模式 + */ + private void startBeautificationMode() { + FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = true; + CallerAutoPilotManager.INSTANCE.setIPCDemoMode(true); + } + + public void clearBusStationData() { + if (mRefreshSweeperTaskCallback != null) { + mRefreshSweeperTaskCallback.clearSweeperTasksMarkers(); + } + } + /** + * 在踩刹车、控制方向盘等操作后,会停止自动驾驶,重启自动驾驶的话相当于重新设置自动驾驶目的地 + */ + public void restartAutopilot() { + CallerLogger.INSTANCE.d(M_BUS + TAG, "行程日志-重启自动驾驶===" + isGoingToNextStation); + //只去启动自动驾驶,不再去上报离站 + startAutopilot(firstStartAutopilot >= 1, -1); + } + public boolean isRestartAutopilot() { + return firstStartAutopilot > 1; + } + /** + * task正常结束 + */ + private void endTask() { + if (backgroundCurrentTaskIndex >= stationList.size()) { + CallerLogger.INSTANCE.e(M_BUS + TAG, "travel over index out of station list"); + return; + } + CallerLogger.INSTANCE.d(M_BUS + TAG, "单程结束===="); + CallerAutoPilotManager.INSTANCE.cancelAutoPilot(); + CallerLogger.INSTANCE.d(M_BUS + TAG, "任务正常走完endTask()"); + + } + /** + * 到站 + * + * @param data + */ + public void onArriveAt(MessagePad.ArrivalNotification data) { + if (backgroundCurrentTaskIndex + 1 > stationList.size() - 1) { + CallerLogger.INSTANCE.e(M_BUS + TAG, "行程日志-到站异常,取消后续操作结束"); + return; + } + + //MAP 280 每隔100ms左右返回一次到站, 导致在到达中间站后再次滑动出发后会有时间差,收到一次到站,出现问题 + //此处比对 自驾告诉的到站站点坐标和本地应到站站点坐标, 一致时才能到站 + if (data != null && data.getEndLocation() != null) { + + String latitude = NumberFormatUtil.cutOutNumber(data.getEndLocation().getLatitude(), 5); //wgs + String longitude = NumberFormatUtil.cutOutNumber(data.getEndLocation().getLongitude(), 5); + + int arrivedStationIndex = backgroundCurrentTaskIndex + 1; + SweeperTaskBean arriveStation = stationList.get(arrivedStationIndex); + String arriveLat = NumberFormatUtil.cutOutNumber(arriveStation.getLat(), 5); + String arriveLon = NumberFormatUtil.cutOutNumber(arriveStation.getLon(), 5); + + if (!latitude.equals(arriveLat) || !longitude.equals(arriveLon)) { + CallerLogger.INSTANCE.e(M_BUS + TAG, "行程日志-到站拦截,到站坐标不一致"); + return; + } + } + + if (isArrivedStation) return; + + CallerLogger.INSTANCE.d(M_BUS + TAG, "行程日志-当前==backgroundCurrentTaskIndex=" + + backgroundCurrentTaskIndex); + } + + public boolean isGoingToNextStation() { + return isGoingToNextStation; + } + public void triggerStartServiceEvent(boolean isRestart, boolean send) { + if (stationList == null || backgroundCurrentTaskIndex >= stationList.size() - 1) { + return; + } + SweeperTaskBean currentStation = stationList.get(backgroundCurrentTaskIndex); + SweeperTaskBean nextStation = stationList.get(backgroundCurrentTaskIndex + 1); + SweeperAnalyticsManager.getInstance().triggerStartAutopilotEvent(isRestart, send, + currentStation.getName(), nextStation.getName(), currentLineId); + } + + public void triggerUnableStartAPReasonEvent() { + if (stationList == null || backgroundCurrentTaskIndex >= stationList.size() - 1) { + return; + } + SweeperTaskBean currentStation = stationList.get(backgroundCurrentTaskIndex); + SweeperTaskBean nextStation = stationList.get(backgroundCurrentTaskIndex + 1); + SweeperAnalyticsManager.getInstance().triggerUnableStartAPReasonEvent( + currentStation.getName(), nextStation.getName(), currentLineId, + OCHAdasAbilityManager.getInstance().getAutopilotUnAbilityReason()); + } + + public SweeperRoutesResult getBusRoutesResult() { + return busRoutesResult; + } + + public int getCurrentStationIndex() { + return backgroundCurrentTaskIndex; + } + + /** + * 将业务订单信息保存,鹰眼可取用 + */ + private void updateAutopilotControlParameters() { + + AutopilotControlParameters parameters = initAutopilotControlParameters(-1); + if (null == parameters) { + CallerLogger.INSTANCE.e(M_BUS + TAG, "AutopilotControlParameters is empty."); + return; + } + CallerLogger.INSTANCE.d(M_BUS + TAG, "AutopilotControlParameters is update."); + CallerAutoPilotStatusListenerManager.INSTANCE.updateAutopilotControlParameters(parameters); + } + + private void clearAutopilotControlParameters() { + CallerLogger.INSTANCE.d(M_BUS + TAG, "AutopilotControlParameters is clear."); + CallerAutoPilotStatusListenerManager.INSTANCE.updateAutopilotControlParameters(null); + } + + private AutopilotControlParameters initAutopilotControlParameters(int leaveIndex) { + SweeperTaskBean currentStation = null; + SweeperTaskBean nextStation = null; + + if (leaveIndex < 0) { + if (backgroundCurrentTaskIndex + 1 > stationList.size() - 1 || !isGoingToNextStation) { + CallerLogger.INSTANCE.e(M_BUS + TAG, "行程日志-mismatch condition1."); + return null; + } + currentStation = stationList.get(backgroundCurrentTaskIndex); + nextStation = stationList.get(backgroundCurrentTaskIndex + 1); + } else { + if (leaveIndex + 1 > stationList.size() - 1 || !isGoingToNextStation) { + CallerLogger.INSTANCE.e(M_BUS + TAG, "行程日志-mismatch condition2."); + return null; + } + currentStation = stationList.get(leaveIndex); + nextStation = stationList.get(leaveIndex + 1); + } + + AutopilotControlParameters parameters = new AutopilotControlParameters(); + parameters.routeID = busRoutesResult.getLineId(); + parameters.routeName = busRoutesResult.getName(); + parameters.startName = PinYinUtil.getPinYinHeadChar(currentStation.getName()); + parameters.endName = PinYinUtil.getPinYinHeadChar(nextStation.getName()); + parameters.startLatLon = new AutopilotControlParameters + .AutoPilotLonLat(currentStation.getLat(), currentStation.getLon()); + parameters.endLatLon = new AutopilotControlParameters + .AutoPilotLonLat(nextStation.getLat(), nextStation.getLon()); + parameters.vehicleType = VEHICLE_TYPE; + if (parameters.autoPilotLine == null) { + parameters.autoPilotLine = new AutopilotControlParameters.AutoPilotLine( + busRoutesResult.getLineId(), + busRoutesResult.csvFileUrl, busRoutesResult.csvFileMd5, + busRoutesResult.txtFileUrl, busRoutesResult.txtFileMd5, + busRoutesResult.contrailSaveTime, busRoutesResult.carModel, + busRoutesResult.csvFileUrlDPQP, busRoutesResult.csvFileMd5DPQP, + busRoutesResult.txtFileUrlDPQP, busRoutesResult.txtFileMd5DPQP, + busRoutesResult.contrailSaveTimeDPQP); + } + + return parameters; + } +} diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/net/ISweeperApiService.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/net/ISweeperApiService.java index 697d70f93e..0425ae88e6 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/net/ISweeperApiService.java +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/net/ISweeperApiService.java @@ -1,7 +1,6 @@ package com.mogo.och.sweeper.net; import com.mogo.eagle.core.data.BaseData; -import com.mogo.och.sweeper.bean.CarHeartbeatReqBean; import com.mogo.och.sweeper.bean.SweeperRoutePlanningUpdateReqBean; import io.reactivex.Observable; @@ -11,26 +10,10 @@ import retrofit2.http.Headers; import retrofit2.http.POST; /** - * 小巴车相关接口 - * - * @author tongchenfei - *

- * wiki: http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=48970072 + * 清扫车相关接口 */ public interface ISweeperApiService { - /** - * 车机端上传心跳数据(只在出车状态时上传):包含高德坐标系经纬度 - * - * @param data - * @return - */ - @Headers({"Content-type:application/json;charset=UTF-8"}) - @POST("/autopilot-car-hailing/location/v2/driver/bus/heartbeat") - Observable runCarHeartbeat(@Header("appId") String appId, @Header("ticket") String ticket, @Body CarHeartbeatReqBean data); - @Headers({"Content-type:application/json;charset=UTF-8"}) - @POST("/autopilot-car-hailing/location/v2/driver/bus/saveLineCoordinate") - Observable updateOrderRoute(@Header("appId") String appId, @Header("ticket") String ticket, - @Body SweeperRoutePlanningUpdateReqBean data); + } diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/net/SweeperServiceManager.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/net/SweeperServiceManager.java index d1262e670b..59cf2ece83 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/net/SweeperServiceManager.java +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/net/SweeperServiceManager.java @@ -1,30 +1,15 @@ package com.mogo.och.sweeper.net; -import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS; import android.content.Context; -import com.mogo.cloud.passport.MoGoAiCloudClientConfig; import com.mogo.eagle.core.data.BaseData; import com.mogo.eagle.core.network.MoGoRetrofitFactory; import com.mogo.eagle.core.network.RequestOptions; import com.mogo.eagle.core.network.SubscribeImpl; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; -import com.mogo.och.sweeper.bean.SweeperQueryLinesResponse; -import com.mogo.och.sweeper.bean.SweeperRoutePlanningUpdateReqBean; -import com.mogo.och.sweeper.bean.SweeperRoutesResponse; -import com.mogo.och.sweeper.bean.CarHeartbeatReqBean; -import com.mogo.och.sweeper.bean.SweeperOperationStatusRequest; -import com.mogo.och.sweeper.bean.SweeperOperationStatusResponse; -import com.mogo.och.sweeper.bean.SweeperQueryLineStationsRequest; -import com.mogo.och.sweeper.bean.SweeperResetDrivingLineRequest; -import com.mogo.och.sweeper.bean.SweeperUpdateSiteStatusRequest; import com.mogo.och.sweeper.constant.SweeperConst; -import com.mogo.och.sweeper.model.SweeperOrderModel; -import java.util.List; - -import io.reactivex.android.schedulers.AndroidSchedulers; -import io.reactivex.schedulers.Schedulers; +import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS; /** * @author: wangmingjun @@ -47,36 +32,6 @@ public class SweeperServiceManager { private SweeperServiceManager(){ mService = MoGoRetrofitFactory.getInstance(SweeperConst.getBaseUrl()).create(ISweeperApiService.class); } - - public void updateOrderRoute(Context context,int lineId, int startSiteId, int endSiteId - , List< SweeperRoutePlanningUpdateReqBean.Result > points - , ISweeperServiceCallback callback){ - mService.updateOrderRoute(MoGoAiCloudClientConfig.getInstance().getServiceAppId() - ,MoGoAiCloudClientConfig.getInstance().getToken() - ,new SweeperRoutePlanningUpdateReqBean(MoGoAiCloudClientConfig.getInstance().getSn() - ,lineId,startSiteId,endSiteId, points)) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(getSubscribeImpl(context,callback,"updateOrderRoute")); - } - - /** - * 车机端上传心跳数据(只在出车状态时上传):包含高德坐标系经纬度 - * @param context - * @param lon - * @param lat - * @param callback - */ - public void runCarHeartbeat(Context context, double lon, double lat, - ISweeperServiceCallback callback) { - mService.runCarHeartbeat(MoGoAiCloudClientConfig.getInstance().getServiceAppId() - ,MoGoAiCloudClientConfig.getInstance().getToken(),new CarHeartbeatReqBean( - MoGoAiCloudClientConfig.getInstance().getSn(), lon, lat)) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(getSubscribeImpl(context, callback, "runCarHeartbeat")); - } - private SubscribeImpl getSubscribeImpl(Context context, ISweeperServiceCallback callback, String apiName){ return new SubscribeImpl(RequestOptions.create(context)){ @Override diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/presenter/SweeperModelLoopManager.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/presenter/SweeperModelLoopManager.java deleted file mode 100644 index ac03cc4800..0000000000 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/presenter/SweeperModelLoopManager.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.mogo.och.sweeper.presenter; - -import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS; - -import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; -import com.mogo.och.sweeper.constant.SweeperConst; -import com.mogo.och.sweeper.model.SweeperOrderModel; - -import java.util.concurrent.TimeUnit; - -import io.reactivex.Observable; -import io.reactivex.android.schedulers.AndroidSchedulers; -import io.reactivex.disposables.Disposable; -import io.reactivex.schedulers.Schedulers; - -/** - * Created on 2021/11/22 - * - * 管理轮询逻辑(订单轮询、新单轮询、新单抢单结果轮询等等) - */ -public class SweeperModelLoopManager { - - private static final String TAG = SweeperModelLoopManager.class.getSimpleName(); - - private static final class SingletonHolder { - private static final SweeperModelLoopManager INSTANCE = new SweeperModelLoopManager(); - } - - public static SweeperModelLoopManager getInstance() { - return SingletonHolder.INSTANCE; - } - - private Disposable mHeartbeatDisposable; //心跳轮询 - - public void startHeartbeatLoop() { - if (mHeartbeatDisposable != null && !mHeartbeatDisposable.isDisposed()) { - return; - } - CallerLogger.INSTANCE.i(M_BUS + TAG, "startHeartbeatLoop()"); - mHeartbeatDisposable = Observable.interval(SweeperConst.LOOP_DELAY, - SweeperConst.LOOP_PERIOD_60S, TimeUnit.MILLISECONDS) - .map((aLong -> aLong + 1)) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(aLong -> SweeperOrderModel.getInstance().runCarHeartbeat()); - } - - public void stopHeartbeatLoop() { - if (mHeartbeatDisposable != null) { - CallerLogger.INSTANCE.i(M_BUS + TAG, "stopHeartbeatLoop()"); - mHeartbeatDisposable.dispose(); - mHeartbeatDisposable = null; - } - } -} diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/presenter/SweeperPresenter.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/presenter/SweeperPresenter.java index 39dcb7c761..79c20e5c9e 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/presenter/SweeperPresenter.java +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/presenter/SweeperPresenter.java @@ -2,22 +2,21 @@ package com.mogo.och.sweeper.presenter; import android.os.Looper; +import com.mogo.commons.AbsMogoApplication; import com.mogo.commons.mvp.Presenter; import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo; import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager; import com.mogo.eagle.core.utilcode.util.UiThreadHandler; -import com.mogo.och.sweeper.bean.SweeperStationBean; +import com.mogo.och.common.module.manager.OCHAdasAbilityManager; +import com.mogo.och.sweeper.callback.ISweeperADASStatusCallback; import com.mogo.och.sweeper.callback.ISweeperControllerStatusCallback; import com.mogo.och.sweeper.fragment.SweeperFragment; -import com.mogo.och.sweeper.model.SweeperOrderModel; +import com.mogo.och.sweeper.model.SweeperTaskModel; import com.mogo.och.sweeper.util.SweeperTrajectoryManager; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; -import java.util.List; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.lifecycle.LifecycleOwner; @@ -31,20 +30,19 @@ import system_master.SystemStatusInfo; * @author tongchenfei */ public class SweeperPresenter extends Presenter - implements IMoGoAutopilotStatusListener, ISweeperControllerStatusCallback { + implements IMoGoAutopilotStatusListener, ISweeperControllerStatusCallback, ISweeperADASStatusCallback{ private static final String TAG = "BusPresenter"; private int currentAutopilotStatus = -1; - private List mStationList = new ArrayList<>(); - private int mCurrentStation = 0; private boolean isRestartAutopilot = false; public SweeperPresenter(SweeperFragment view) { super(view); //2021.11.1 鹰眼架构整合,由IMoGoAutopilotStatusListener逐步替代IMogoAdasOCHCallback接口 CallerAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, this); - SweeperOrderModel.getInstance().init(); + SweeperTaskModel.getInstance().init(); + OCHAdasAbilityManager.getInstance().init(AbsMogoApplication.getApp()); } @Override @@ -56,21 +54,23 @@ public class SweeperPresenter extends Presenter @Override public void onDestroy(@NonNull LifecycleOwner owner) { super.onDestroy(owner); - SweeperOrderModel.getInstance().release(); + SweeperTaskModel.getInstance().release(); releaseListener(); } public void initModelListener() { - SweeperOrderModel.getInstance().setControllerStatusCallback(this); + SweeperTaskModel.getInstance().setControllerStatusCallback(this); + SweeperTaskModel.getInstance().setAdasStatusCallback(this); } public void releaseListener() { - SweeperOrderModel.getInstance().setControllerStatusCallback(null); + SweeperTaskModel.getInstance().setControllerStatusCallback(null); + SweeperTaskModel.getInstance().setAdasStatusCallback(null); } public void restartAutopilot() { currentAutopilotStatus = -1; - SweeperOrderModel.getInstance().restartAutopilot(); + SweeperTaskModel.getInstance().restartAutopilot(); isRestartAutopilot = true; } @Override @@ -79,13 +79,34 @@ public class SweeperPresenter extends Presenter int state = autopilotStatusInfo.getState(); switch (state) { case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE: + if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE) { + currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE; + } + // 改变UI自动驾驶状态 + runOnUIThread(() -> mView.onAutopilotStatusChanged(currentAutopilotStatus)); break; case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING: - + if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { + currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING; + SweeperTaskModel.getInstance().triggerStartServiceEvent( + SweeperTaskModel.getInstance().isRestartAutopilot(), true); + } + // 改变UI自动驾驶状态 + runOnUIThread(() -> mView.onAutopilotStatusChanged(currentAutopilotStatus)); break; case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE: + if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) { + currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE; + } + // 改变UI自动驾驶状态 + runOnUIThread(() -> mView.onAutopilotStatusChanged(currentAutopilotStatus)); break; - default: + case IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING: + if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING) { + currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING; + } + // 改变UI自动驾驶状态 + runOnUIThread(() -> mView.onAutopilotStatusChanged(currentAutopilotStatus)); break; } } @@ -152,4 +173,9 @@ public class SweeperPresenter extends Presenter public void onAutopilotSNRequest() { } + + @Override + public void onStartAdasFailure() { + + } } diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/util/BDRouteDataTestUtils.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/util/BDRouteDataTestUtils.java deleted file mode 100644 index 85634178f1..0000000000 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/util/BDRouteDataTestUtils.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.mogo.och.sweeper.util; - -import com.mogo.och.sweeper.model.SweeperOrderModel; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import java.util.ArrayList; -import java.util.List; - -import mogo.telematics.pad.MessagePad; - -/** - * @author: wangmingjun - * @date: 2022/4/13 - */ -public class BDRouteDataTestUtils { - - static String jsonStr ="{\n" + - " \"models\": [\n" + - " {\n" + - " \"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19927760268911,\"lon\":116.73512607061035,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19927736555187,\"lon\":116.73498243020299,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19927135941599,\"lon\":116.73482951462647,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199260672670036,\"lon\":116.73468429259535,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199251260349946,\"lon\":116.73453933465,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19924691997577,\"lon\":116.7343756435551,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199247953493625,\"lon\":116.73421240809087,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19924986849947,\"lon\":116.73400425509712,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199249431152175,\"lon\":116.73378579041055,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199248921305724,\"lon\":116.73357811807278,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19925012387371,\"lon\":116.73337650020184,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199252270195075,\"lon\":116.73318223781153,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.1992521615169,\"lon\":116.73298632625203,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19925202633083,\"lon\":116.73279582043983,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199261230205735,\"lon\":116.73263403473568,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199327991681926,\"lon\":116.73251962434813,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19944850496711,\"lon\":116.73249661840195,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199582026896415,\"lon\":116.73251038561487,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199743326352014,\"lon\":116.73253087453938,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199908347167394,\"lon\":116.73255070500186,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.200065950595445,\"lon\":116.7325720694418,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20022747460407,\"lon\":116.73259461416663,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.200384057310536,\"lon\":116.73261575018056,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20053849777916,\"lon\":116.73263451936387,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.200696919444624,\"lon\":116.7326540541723,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.2008524952796,\"lon\":116.7326743511824,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20101429705625,\"lon\":116.73269393580199,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20118279997041,\"lon\":116.73271564378308,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.201342388452076,\"lon\":116.73273653366076,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.201476063822355,\"lon\":116.73275292393079,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20163479199852,\"lon\":116.73277440686762,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20181243476041,\"lon\":116.7328052766508,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.201991767093304,\"lon\":116.7328453845644,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20215573733484,\"lon\":116.73287624009339,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202313648759784,\"lon\":116.73289887933315,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202434745374454,\"lon\":116.7329182210956,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20253164952098,\"lon\":116.73297539811277,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20258043275509,\"lon\":116.73312335324984,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20258233576585,\"lon\":116.73331077089557,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20257107560234,\"lon\":116.73351244039137,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202561578580514,\"lon\":116.73370176209845,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20256256788661,\"lon\":116.73391325024126,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20255633158834,\"lon\":116.73413195000244,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202543311179575,\"lon\":116.73436614303907,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20253067346457,\"lon\":116.73458032609663,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20251776111356,\"lon\":116.73477082198242,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202503997557805,\"lon\":116.73498624001282,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20249129260376,\"lon\":116.73518976336872,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20247877796589,\"lon\":116.73537786253135,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20246651610268,\"lon\":116.73559239130266,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20245754388014,\"lon\":116.73574239922202,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20244749208,\"lon\":116.73589674090469,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20243806550113,\"lon\":116.73607057284322,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20243550556816,\"lon\":116.73628106525871,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20243654127756,\"lon\":116.7364949950665,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20243738221016,\"lon\":116.7367061649993,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20243672476754,\"lon\":116.73691115930336,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20243590788176,\"lon\":116.73710722104272,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202436434375336,\"lon\":116.73730688607075,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20243749821501,\"lon\":116.73750140347998,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20243625962803,\"lon\":116.73771330926793,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202434515480725,\"lon\":116.73791895606205,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.2024326561388,\"lon\":116.73815206945737,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20243092086137,\"lon\":116.73838655528765,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202430876006126,\"lon\":116.73861890759498,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20242914053177,\"lon\":116.73882029918758,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20242843336561,\"lon\":116.73904465495175,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20242661219026,\"lon\":116.73922453252953,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202426462811076,\"lon\":116.7393708046956,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20242687134937,\"lon\":116.73954685547025,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20242694967377,\"lon\":116.73975021183773,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202424630601236,\"lon\":116.73999740812975,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202422502184625,\"lon\":116.74028266774337,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202419634158936,\"lon\":116.7405942561498,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20241975959762,\"lon\":116.7409069557092,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20241920524113,\"lon\":116.74120156191647,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20241765540262,\"lon\":116.74149288504978,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20241569149764,\"lon\":116.7418080096762,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202414529497084,\"lon\":116.74210262897205,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20241419532155,\"lon\":116.74241767661879,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202413879360954,\"lon\":116.7427571218185,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20241287045245,\"lon\":116.7431284691325,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20241214965105,\"lon\":116.74343354359334,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20241141271715,\"lon\":116.7437220210538,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.2024080520075,\"lon\":116.74399113498052,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202391714280026,\"lon\":116.74427625698272,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20238163805639,\"lon\":116.74452083315958,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202379293010274,\"lon\":116.74475703837204,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202379007817086,\"lon\":116.7449961645494,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20237814181231,\"lon\":116.7452036063558,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202375477619896,\"lon\":116.74539567654291,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.2023632396621,\"lon\":116.74555457589031,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20229396554444,\"lon\":116.7456716047369,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20217800547467,\"lon\":116.74574081942625,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202047498095304,\"lon\":116.74573659255675,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20188573786706,\"lon\":116.74571018281719,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.201738240263026,\"lon\":116.74568463148606,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20157507049073,\"lon\":116.74565525041498,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20137985142042,\"lon\":116.745619970576,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.201187335613575,\"lon\":116.74558631350607,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20098251429043,\"lon\":116.74555055587679,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.2007748533628,\"lon\":116.74551426934663,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20057082986032,\"lon\":116.74547749663195,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20036944224329,\"lon\":116.74544156175533,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20016365229035,\"lon\":116.74540577510051,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.1999958572445,\"lon\":116.74537505807076,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19984100521566,\"lon\":116.7453433678602,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.1996863960282,\"lon\":116.74529675648621,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19953919567943,\"lon\":116.74525916493474,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19940587189373,\"lon\":116.74523402869453,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19929047792381,\"lon\":116.74518617038383,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19922141745155,\"lon\":116.74506912884067,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19920798885308,\"lon\":116.744896716334,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19920912644279,\"lon\":116.74467216715483,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199209186509314,\"lon\":116.74448257515108,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19920910709997,\"lon\":116.74430613406223,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.1992100786082,\"lon\":116.74410888316238,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19921081961254,\"lon\":116.74391968819582,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19921040855518,\"lon\":116.7437082083402,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19921085053439,\"lon\":116.74346931155634,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19921197237373,\"lon\":116.74325149697013,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19921248248983,\"lon\":116.74301103786591,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.1992139724646,\"lon\":116.74277237066539,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199215818352386,\"lon\":116.74253219408898,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199216175018876,\"lon\":116.74228853120842,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199215970354246,\"lon\":116.74204663206451,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199216627492966,\"lon\":116.74183871233049,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19921789170398,\"lon\":116.74165788334192,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19922000138535,\"lon\":116.74144512197054,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199221559127494,\"lon\":116.741249370491,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19922287231889,\"lon\":116.7410525810756,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19922229019589,\"lon\":116.74085266662037,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.1992216995901,\"lon\":116.74061957723823,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19922263073874,\"lon\":116.74041638149129,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19922478093337,\"lon\":116.7402123910757,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199227066091595,\"lon\":116.74003419421553,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199228634241756,\"lon\":116.73985841944678,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19922951636012,\"lon\":116.7397079274105,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199252095329484,\"lon\":116.73956265582487,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199346162997905,\"lon\":116.73944690416265,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199470799628024,\"lon\":116.73941941053417,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19962513314346,\"lon\":116.7394280706812,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199780626058924,\"lon\":116.73944255215424,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199961525343376,\"lon\":116.73945856750177,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20016196947193,\"lon\":116.73947572081121,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.200384479551936,\"lon\":116.7394949225795,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.200595083817475,\"lon\":116.73951027963179,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.200792203321086,\"lon\":116.73952526850614,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.200985930701684,\"lon\":116.73954125209579,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20115978977055,\"lon\":116.73955610094161,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.201321019536124,\"lon\":116.7395695239138,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20147117943043,\"lon\":116.7395823299481,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20163699848565,\"lon\":116.73959633422596,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20178484338371,\"lon\":116.7396085776486,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.201962185646316,\"lon\":116.73962351991214,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.2021018923927,\"lon\":116.7396354059821,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.2022137620686,\"lon\":116.73964348380458,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20232600820075,\"lon\":116.73961190446633,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20241090270993,\"lon\":116.73951649703137,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20245777783807,\"lon\":116.73937664238166,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20246906634823,\"lon\":116.73920146119093,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202470916682884,\"lon\":116.73898763065634,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20247034830421,\"lon\":116.73878158418357,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20246978204673,\"lon\":116.73857680142473,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20247082638905,\"lon\":116.73834517890637,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202471943178196,\"lon\":116.7381047689514,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20247131648035,\"lon\":116.73787761484981,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202470799473765,\"lon\":116.73766230702478,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20247013054322,\"lon\":116.73743619407796,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20246999515433,\"lon\":116.73724916823292,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20247199652478,\"lon\":116.73704888970806,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202473960263525,\"lon\":116.73684083235807,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202474504753205,\"lon\":116.73665462440796,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20247501354581,\"lon\":116.73650710371837,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20246541231906,\"lon\":116.73635807696789,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202426768984274,\"lon\":116.73622283382787,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20236638788854,\"lon\":116.73610589402243,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20227106919894,\"lon\":116.73600895001849,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.2021428343084,\"lon\":116.73596816020945,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20197815580698,\"lon\":116.73594623645097,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20181789535303,\"lon\":116.73593148707488,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.201667906886954,\"lon\":116.73591743008926,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.201505897730755,\"lon\":116.7359002912543,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20135083580946,\"lon\":116.73588579696379,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20118617904595,\"lon\":116.73586970398149,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20102374028594,\"lon\":116.73585314703226,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20085554043743,\"lon\":116.73583763953049,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20069451888229,\"lon\":116.73582073901778,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.200530837344964,\"lon\":116.73580314359012,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.2003608457064,\"lon\":116.73578183888779,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20021770046798,\"lon\":116.73575292592922,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20003454701824,\"lon\":116.7357174959358,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19986125116602,\"lon\":116.73569499961796,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19969408518737,\"lon\":116.73567725223492,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19955533048882,\"lon\":116.73566375985422,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19943174810538,\"lon\":116.73564927714162,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19933167546824,\"lon\":116.735595995086,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199280357603875,\"lon\":116.73546293260645,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19927848361656,\"lon\":116.73531579486274,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19928127892504,\"lon\":116.73505848474375,\"speed\": 0.0\n" + - " }\n" + - " ]\n" + - "}"; - public static void converToRouteData(){ - List list = new ArrayList<>(); - - try { - JSONObject jsonObject = new JSONObject(jsonStr); - JSONArray jsonElements = jsonObject.getJSONArray("models"); - for (int i = 0; i < jsonElements.length(); i++) { - JSONObject s = jsonElements.getJSONObject(i); - MessagePad.Location.Builder builder = MessagePad.Location.newBuilder(); - builder.setLatitude(s.getDouble("lat")); - builder.setLongitude(s.getDouble("lon")); - list.add(builder.build()); - } - SweeperOrderModel.getInstance().debugUpdateOrderRoute(list); - } catch (JSONException e) { - e.printStackTrace(); - } - } -} diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/util/SweeperAnalyticsManager.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/util/SweeperAnalyticsManager.java index 76f43e4388..4176bfcf15 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/util/SweeperAnalyticsManager.java +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/util/SweeperAnalyticsManager.java @@ -1,5 +1,6 @@ package com.mogo.och.sweeper.util; +import android.os.Build; import android.text.TextUtils; import com.mogo.cloud.passport.MoGoAiCloudClientConfig; @@ -8,12 +9,15 @@ import com.mogo.eagle.core.data.app.AppConfigInfo; import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; import com.mogo.eagle.core.function.call.analytics.AnalyticsManager; import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager; +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.eagle.core.utilcode.util.DateTimeUtils; import com.mogo.eagle.core.utilcode.util.UiThreadHandler; import com.mogo.och.sweeper.constant.SweeperConst; import java.util.HashMap; +import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_SWEEPER; + /** * OCH sweeper埋点工具 * @@ -29,18 +33,55 @@ public class SweeperAnalyticsManager { return SweeperAnalyticsManager.SingletonHolder.INSTANCE; } - - private String mStartAutopilotKey; private HashMap mStartAutopilotParams = new HashMap<>(); private Runnable startAutopilotRunnable = () -> { // 15s内未开启,上报失败埋点 + triggerStartAutopilotFailureEvent("", "15s后app等待超时"); + }; + + public void triggerStartAutopilotFailureEventByAdas(String failCode, String failMsg){ + removeWaitingCallback(); + triggerStartAutopilotFailureEvent(failCode, failMsg); + } + + private void triggerStartAutopilotFailureEvent(String failCode, String failMsg){ + if (mStartAutopilotParams.isEmpty()) return; + + CallerLogger.INSTANCE.e( M_SWEEPER + "triggerStartAutopilotFailureEvent", failMsg ); + + if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() != + IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING){ + mStartAutopilotParams.put(SweeperConst.EVENT_PARAM_START_FAILURE_CODE, failCode); + mStartAutopilotParams.put(SweeperConst.EVENT_PARAM_START_FAILURE_MSG, failMsg); + } mStartAutopilotParams.put(SweeperConst.EVENT_PARAM_START_RESULT , CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING); + AnalyticsManager.INSTANCE.track(mStartAutopilotKey, mStartAutopilotParams); - }; + + clearStartAutopilotParams();//清空参数数据,防止误传 + } + + private void removeWaitingCallback() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + if (startAutopilotRunnable != null && + UiThreadHandler.getsUiHandler().hasCallbacks(startAutopilotRunnable)) { + UiThreadHandler.removeCallbacks(startAutopilotRunnable); + } + } + } + + public void clearStartAutopilotFailureMSG(){ + mStartAutopilotParams.put(SweeperConst.EVENT_PARAM_START_FAILURE_CODE, ""); + mStartAutopilotParams.put(SweeperConst.EVENT_PARAM_START_FAILURE_MSG, ""); + } + + private void clearStartAutopilotParams(){ + mStartAutopilotParams.clear(); + } /** * 触发'开启自动驾驶'埋点流程 @@ -67,15 +108,43 @@ public class SweeperAnalyticsManager { mStartAutopilotParams.put(SweeperConst.EVENT_PARAM_LINE_ID, lineId); if (send) { + if (mStartAutopilotParams.isEmpty()) return; // 开启成功,上报埋点 - if (startAutopilotRunnable != null && - UiThreadHandler.getsUiHandler().hasCallbacks(startAutopilotRunnable)) { - UiThreadHandler.removeCallbacks(startAutopilotRunnable); - } + clearStartAutopilotFailureMSG(); + removeWaitingCallback(); mStartAutopilotParams.put(SweeperConst.EVENT_PARAM_START_RESULT, true); AnalyticsManager.INSTANCE.track(mStartAutopilotKey, mStartAutopilotParams); + + clearStartAutopilotParams();//清空参数数据,防止误传 } else { UiThreadHandler.postDelayed(startAutopilotRunnable, SweeperConst.LOOP_PERIOD_15S); } } + + /** + * 触发"无法开启自驾已知异常"埋点 + * @param startName + * @param endName + * @param lineId + */ + public void triggerUnableStartAPReasonEvent(String startName, String endName, int lineId, + String reason) { + String sn = MoGoAiCloudClientConfig.getInstance().getSn(); + String plateNum = AppConfigInfo.INSTANCE.getPlateNumber(); + String dateTime = DateTimeUtils.getTimeText( + System.currentTimeMillis(), DateTimeUtils.yyyy_MM_dd_HH_mm_ss); + + HashMap params = new HashMap<>(); + + params.put(SweeperConst.EVENT_PARAM_SN, sn); + params.put(SweeperConst.EVENT_PARAM_PLATE_NUM, TextUtils.isEmpty(plateNum) ? "" : plateNum); + params.put(SweeperConst.EVENT_PARAM_ENV_ONLINE, + DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE ? true : false); + params.put(SweeperConst.EVENT_PARAM_TIME, dateTime); + params.put(SweeperConst.EVENT_PARAM_START_NAME, startName); + params.put(SweeperConst.EVENT_PARAM_END_NAME, endName); + params.put(SweeperConst.EVENT_PARAM_LINE_ID, lineId); + params.put(SweeperConst.EVENT_PARAM_UNABLE_START_REASON, reason); + AnalyticsManager.INSTANCE.track(SweeperConst.EVENT_KEY_AP_UNABLE_START_REASON, params); + } } diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/util/SweeperTrajectoryManager.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/util/SweeperTrajectoryManager.java index 8f054bf16a..4433144dcb 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/util/SweeperTrajectoryManager.java +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/util/SweeperTrajectoryManager.java @@ -8,7 +8,7 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.eagle.core.utilcode.util.GsonUtils; import com.mogo.och.sweeper.bean.SweeperRoutesResult; import com.mogo.och.sweeper.constant.SweeperConst; -import com.mogo.och.sweeper.model.SweeperOrderModel; +import com.mogo.och.sweeper.model.SweeperTaskModel; import java.util.concurrent.TimeUnit; @@ -48,10 +48,10 @@ public class SweeperTrajectoryManager { * 同步Bus路线信息 */ public void syncTrajectoryInfo() { - SweeperRoutesResult routesResult = SweeperOrderModel.getInstance().getBusRoutesResult(); - if (SweeperOrderModel.getInstance().isWorking() && routesResult != null - && SweeperOrderModel.getInstance().getCurrentStationIndex() == 0 - && !SweeperOrderModel.getInstance().isGoingToNextStation()) { + SweeperRoutesResult routesResult = SweeperTaskModel.getInstance().getBusRoutesResult(); + if (routesResult != null + && SweeperTaskModel.getInstance().getCurrentStationIndex() == 0 + && !SweeperTaskModel.getInstance().isGoingToNextStation()) { CallerLogger.INSTANCE.d(M_BUS + TAG, "syncTrajectoryInfo() start."); startTrajReqLoop(); } else { @@ -95,7 +95,7 @@ public class SweeperTrajectoryManager { } private void setupAutoPilotLine() { - SweeperRoutesResult routesResult = SweeperOrderModel.getInstance().getBusRoutesResult(); + SweeperRoutesResult routesResult = SweeperTaskModel.getInstance().getBusRoutesResult(); if (routesResult == null) { CallerLogger.INSTANCE.e(M_BUS + TAG, "setupAutoPilotLine(): routesResult is null."); diff --git a/OCH/mogo-och-sweeper/src/main/res/layout/sweeper_base_fragment.xml b/OCH/mogo-och-sweeper/src/main/res/layout/sweeper_base_fragment.xml index 9bc969996f..68c9768f55 100644 --- a/OCH/mogo-och-sweeper/src/main/res/layout/sweeper_base_fragment.xml +++ b/OCH/mogo-och-sweeper/src/main/res/layout/sweeper_base_fragment.xml @@ -4,7 +4,8 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_marginTop="@dimen/dp_72"> + android:layout_marginTop="@dimen/dp_72" + android:id="@+id/sweeper_root_View">