From ee9d75f83fb85f8206c8ea8d08750611bee35856 Mon Sep 17 00:00:00 2001
From: endian11 <Dana_Lee1016@126.com>
Date: 星期五, 18 九月 2020 17:22:32 +0800
Subject: [PATCH] 测试项目采集、路口采集,完成发送0x8017;目前需要加一个发送查询是否在某段路
---
app/src/main/java/safeluck/drive/evaluation/app.java | 4 +
app/src/main/java/safeluck/drive/evaluation/routecollect/impl/RouteModel.java | 60 ++++++++++++++++---
app/src/main/java/safeluck/drive/evaluation/routecollect/RouteCollectController.java | 41 ++++++++++++-
app/src/main/java/safeluck/drive/evaluation/routecollect/IRouteCollectInterface.java | 13 ++++
app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java | 20 ++++--
5 files changed, 115 insertions(+), 23 deletions(-)
diff --git a/app/src/main/java/safeluck/drive/evaluation/app.java b/app/src/main/java/safeluck/drive/evaluation/app.java
index f745d5a..d964f41 100644
--- a/app/src/main/java/safeluck/drive/evaluation/app.java
+++ b/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;
}
diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java
index 2698ff7..a66a6a2 100644
--- a/app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java
+++ b/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();
diff --git a/app/src/main/java/safeluck/drive/evaluation/routecollect/IRouteCollectInterface.java b/app/src/main/java/safeluck/drive/evaluation/routecollect/IRouteCollectInterface.java
index ccfca56..b659f5d 100644
--- a/app/src/main/java/safeluck/drive/evaluation/routecollect/IRouteCollectInterface.java
+++ b/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);
}
diff --git a/app/src/main/java/safeluck/drive/evaluation/routecollect/RouteCollectController.java b/app/src/main/java/safeluck/drive/evaluation/routecollect/RouteCollectController.java
index 9c5bdcf..9915074 100644
--- a/app/src/main/java/safeluck/drive/evaluation/routecollect/RouteCollectController.java
+++ b/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();
+ }
+ }
}
diff --git a/app/src/main/java/safeluck/drive/evaluation/routecollect/impl/RouteModel.java b/app/src/main/java/safeluck/drive/evaluation/routecollect/impl/RouteModel.java
index cdc1386..1461829 100644
--- a/app/src/main/java/safeluck/drive/evaluation/routecollect/impl/RouteModel.java
+++ b/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鐨刢allback 锛屽彲鑳介渶瑕佸弽娉ㄥ唽涓�涓狢EventLisntener 瑙g粦
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;
}
--
Gitblit v1.8.0