app/src/main/java/safeluck/drive/evaluation/app.java
@@ -53,6 +53,7 @@ import safeluck.drive.evaluation.platformMessage.JKMessage0203; import safeluck.drive.evaluation.platformMessage.JKMessage0206; import safeluck.drive.evaluation.platformMessage.PlatFormConstant; import safeluck.drive.evaluation.routecollect.RouteCollectController; import safeluck.drive.evaluation.util.CThreadPoolExecutor; import safeluck.drive.evaluation.util.DataInitKt; import safeluck.drive.evaluation.util.FileUtil; @@ -107,6 +108,7 @@ CThreadPoolExecutor.runInBackground(()->{ int type = WorkRoomDataBase.getWorkRoomDataBase(getApplicationContext()).getExamStatusDao().getStartExamInt(); RouteCollectController.getInstance().startRoadListener(); MyLog.i("开始初始化数据发送地图/车辆/mcu升级文件/考试状态="+type); ExamPlatformData.getInstance().setExamType(type); // OneTimeWorkRequest examStatausOutWorker = OneTimeWorkRequest.from(ExamStatusOutWorker.class); @@ -524,7 +526,7 @@ // CEventCenter.dispatchEvent(Constant.BIND_RTK_INFO_MAP,cmd,0,json); // break; case Constant.ENTER_OR_EXIT_ROADCROSS_ID: CEventCenter.dispatchEvent(Constant.BIND_RTK_INFO_MAP,cmd,0,json); CEventCenter.dispatchEvent(Constant.BIND_ROUTE_COLLECT_TOPIC,cmd,0,json); break; } app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java
@@ -150,7 +150,7 @@ private RouteCross routeCross; //要插入数据库的触发线信息 private RouteTriggerLine routeTriggerLine; private RouteTriggerLine routeTriggerLine = new RouteTriggerLine(); private List<Integer> btn_ids = new ArrayList<Integer>(); private HashMap<String,Integer> routeCollect_btn_ids = new HashMap<>(); @@ -528,6 +528,7 @@ if (exam_type != Constant.NONE_BEEN_START_EXAM){ if (ROUTE_COLLECT == exam_type){ btn_start_exam.setText("结束采集"); routeCollectController.startRoadListener(); }else{ btn_start_exam.setText("结束训练"); @@ -575,7 +576,9 @@ private void initView(View view) { tv_route_collect_info = view.findViewById(R.id.tv_route_info); routeCollectController = new RouteCollectController(this); // routeCollectController = new RouteCollectController(this); routeCollectController = RouteCollectController.getInstance(); routeCollectController.setRouteCollectController(this); items = view.findViewById(R.id.items); items_score=view.findViewById(R.id.items_score); route_collect=view.findViewById(R.id.route_collect); @@ -713,6 +716,7 @@ ExamPlatformData.getInstance().setTrainingMode(ExamPlatformData.ROUTE_MODE); exam_type = 5; sendExamJson(1,exam_type); examStatusViewModel.updateStartExam(exam_type); items.setVisibility(View.GONE); items_score.setVisibility(View.GONE); @@ -744,6 +748,7 @@ Toast.makeText(_mActivity, "结束采集", Toast.LENGTH_SHORT).show(); routeLineViewModel.updateCurrCollectFlag(""); routeCollectController.endRoadListener(); ExamPlatformData.getInstance().setTrainingMode(ExamPlatformData.MODE_NONE); exam_type = 0; examStatusViewModel.updateStartExam(exam_type); @@ -996,7 +1001,7 @@ remoteRouteCollect.setScheme(routeCollects); String str = new Gson().toJson(remoteRouteCollect); Log.i(TAG,"json====="+str); //todo 发送线路 AYSdk.getInstance().sendCmd(0x8017,str); sendMessage(); break; } @@ -1106,9 +1111,9 @@ @Override public void beginCollectView() { Log.i(TAG,"BIND_RTK_INFO_MAP"); CThreadPoolExecutor.runOnMainThread(()->{ StatusDialog.with(_mActivity).setType(StatusDialog.Type.PROGRESS).setCancelable(true).show(); }); // CThreadPoolExecutor.runOnMainThread(()->{ // StatusDialog.with(_mActivity).setType(StatusDialog.Type.PROGRESS).setCancelable(true).show(); // }); } @@ -1129,6 +1134,8 @@ if (roadInfo != null && roadInfo.getStatus()==1){ Log.i(TAG,"在某个路里面"+roadInfo.getRoad_id()); stringBuilder.append(String.format("在%d号路里面",roadInfo.getRoad_id())); stringBuilder.append("\n"); routeTriggerLine.setX(collectPointResult.getX()); routeTriggerLine.setY(collectPointResult.getY()); routeTriggerLine.setType(ExamPlatformData.getInstance().getCurrRouteItem()); @@ -1154,7 +1161,6 @@ public void roadinfo(RoadInfo roadInfo) { Log.i(TAG,String.format("道路信息%s",roadInfo.toString())); //道路信息是没有进行本地保存的,如果崩溃的话,就有问题 ExamPlatformData.getInstance().setRouteCollectRoadInfo(roadInfo); stringBuilder.append(String.format("道路信息%s",roadInfo.toString())); stringBuilder.append("\n"); showRouteCollectInfoText(); app/src/main/java/safeluck/drive/evaluation/routecollect/IRouteCollectInterface.java
@@ -10,10 +10,21 @@ /** * 开始踩点 不断的返回点坐标 */ void startCollect(ILoadListener listener); void startCollect(); /** * 告诉远程服务 停止采点,不要一直返点的坐标了 */ void endCollect(); /** *监听进入某一道路 */ void startRoadListener(); void endRoadListener(); void setLoadListener(ILoadListener routeCollectController); } app/src/main/java/safeluck/drive/evaluation/routecollect/RouteCollectController.java
@@ -1,5 +1,7 @@ package safeluck.drive.evaluation.routecollect; import android.util.Log; import com.anyun.exam.lib.AYSdk; import safeluck.drive.evaluation.fragment.TrainFragment; @@ -18,13 +20,23 @@ ICollectView iCollectView; RouteModel routeModel; private static final String TAG = "RouteModel"; private boolean isStartRoadListener = false; private RouteCollectController() { routeModel = new RouteModel(); } public static RouteCollectController getInstance(){ return new RouteCollectController(); } /** * Topic=[bind_rtk_info_map],message={"utc":"20200917081227.40","qf":3,"coord_x":0.974,"coord_x_dir":"N","coord_y":-0.191,"coord_y_dir":"E","heading":315.0,"pitch":0.0,"roll":0.0,"sat_num":14,"latitude":31.174458016666667,"longitude":121.38786518333333,"altitude":58.9666,"speed":1.72591488,"track_ture":315.0} * @param collectView */ public RouteCollectController(ICollectView collectView){ public void setRouteCollectController(ICollectView collectView){ this.iCollectView = collectView; routeModel = new RouteModel(); routeModel.setLoadListener(this); } @@ -33,7 +45,7 @@ iCollectView.beginCollectView(); } if (routeModel != null){ routeModel.startCollect(this); routeModel.startCollect(); } } @@ -53,14 +65,35 @@ @Override public void roadInfo(RoadInfo roadInfo) { if (iCollectView != null){ iCollectView.roadinfo(roadInfo); } } @Override public void roadCrossInfo(RoadCrossInfo roadCrossInfo) { if (iCollectView != null){ iCollectView.roadcrossInfo(roadCrossInfo); } } public void startRoadListener() { if (!isStartRoadListener){ isStartRoadListener = true; if (routeModel != null){ routeModel.startRoadListener(); } }else{ Log.i(TAG,"已经监听过了,不再监听"); } } public void endRoadListener(){ if (routeModel != null){ routeModel.endRoadListener(); } } } app/src/main/java/safeluck/drive/evaluation/routecollect/impl/RouteModel.java
@@ -3,16 +3,20 @@ import android.util.Log; import com.anyun.exam.lib.IRemoteInterface; import com.google.gson.Gson; import org.json.JSONException; import org.json.JSONObject; import safeluck.drive.evaluation.Constant; import safeluck.drive.evaluation.bean.ExamPlatformData; import safeluck.drive.evaluation.cEventCenter.CEventCenter; import safeluck.drive.evaluation.cEventCenter.ICEventListener; import safeluck.drive.evaluation.routecollect.CollectPointResult; import safeluck.drive.evaluation.routecollect.ILoadListener; import safeluck.drive.evaluation.routecollect.IRouteCollectInterface; import safeluck.drive.evaluation.routecollect.bean.RoadCrossInfo; import safeluck.drive.evaluation.routecollect.bean.RoadInfo; import safeluck.drive.evaluation.util.Utils; /** @@ -24,7 +28,32 @@ public class RouteModel implements IRouteCollectInterface{ ILoadListener iLoadListener; private Gson gson = new Gson(); private static final String TAG = "RouteModel"; private ICEventListener icEventListener1= new ICEventListener() { @Override public void onCEvent(String topic, int msgCode, int resultCode, Object obj) { if (msgCode == Constant.ENTER_OR_EXIT_ROAD_ID){ if (iLoadListener != null){ Log.i(TAG,"道路消息"+(String)obj); RoadInfo roadInfo = gson.fromJson((String)obj,RoadInfo.class); ExamPlatformData.getInstance().setRouteCollectRoadInfo(roadInfo); iLoadListener.roadInfo(roadInfo); } } if (msgCode == Constant.ENTER_OR_EXIT_ROADCROSS_ID){ Log.i(TAG,"路口消息"+(String)obj); if (iLoadListener != null){ RoadCrossInfo roadCrossInfo = gson.fromJson((String) obj,RoadCrossInfo.class); iLoadListener.roadCrossInfo(roadCrossInfo); } } } }; private ICEventListener icEventListener= new ICEventListener() { @Override public void onCEvent(String topic, int msgCode, int resultCode, Object obj) { @@ -48,20 +77,13 @@ } } if (msgCode == Constant.ENTER_OR_EXIT_ROAD_ID){ Log.i(TAG,"道路消息"+(String)obj); } if (msgCode == Constant.ENTER_OR_EXIT_ROADCROSS_ID){ Log.i(TAG,"路口消息"+(String)obj); } } }; @Override public void startCollect(ILoadListener listener) { iLoadListener = listener; public void startCollect() { //调用AYSdk 方法启动采点 //set IRouteRemotePointCallback @@ -76,7 +98,25 @@ public void endCollect() { //如果采用application的callback ,可能需要反注册一个CEventLisntener 解绑 CEventCenter.onBindEvent(false,icEventListener,Constant.BIND_RTK_INFO_MAP); iLoadListener = null; } @Override public void startRoadListener() { Log.i(TAG,"线路采集,开始路监听"); CEventCenter.onBindEvent(true,icEventListener1, Constant.BIND_ROUTE_COLLECT_TOPIC); } @Override public void endRoadListener() { CEventCenter.onBindEvent(false,icEventListener1, Constant.BIND_ROUTE_COLLECT_TOPIC); } @Override public void setLoadListener(ILoadListener routeCollectController) { iLoadListener = routeCollectController; }