From 399bf6ae73d636d56ecd590036964e52433b4743 Mon Sep 17 00:00:00 2001 From: endian11 <Dana_Lee1016@126.com> Date: 星期四, 17 九月 2020 17:30:27 +0800 Subject: [PATCH] 设置一个ROUTE_MODE 为 采集模式, app HomeFragment增加这个模式的判断 --- app/src/main/java/safeluck/drive/evaluation/app.java | 2 /dev/null | 13 ---- app/src/main/java/safeluck/drive/evaluation/bean/ExamPlatformData.java | 2 app/src/main/java/safeluck/drive/evaluation/fragment/HomeFragment.java | 2 app/src/main/java/safeluck/drive/evaluation/routecollect/impl/RouteModel.java | 50 ++++++++++++---- app/src/main/java/safeluck/drive/evaluation/routecollect/RouteCollectController.java | 12 ++- app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java | 41 ++++++++++--- 7 files changed, 80 insertions(+), 42 deletions(-) diff --git a/app/src/main/java/safeluck/drive/evaluation/app.java b/app/src/main/java/safeluck/drive/evaluation/app.java index a17b22f..db45ca9 100644 --- a/app/src/main/java/safeluck/drive/evaluation/app.java +++ b/app/src/main/java/safeluck/drive/evaluation/app.java @@ -473,7 +473,7 @@ } jkMessage0206.attachInfo2 = attachInfo2; - if (ExamPlatformData.getInstance().getTrainingMode()==ExamPlatformData.MODE_NONE){ + if (ExamPlatformData.getInstance().getTrainingMode()==ExamPlatformData.MODE_NONE||ExamPlatformData.getInstance().getTrainingMode()==ExamPlatformData.ROUTE_MODE){ //鍒ゆ柇10s鏃堕棿鏄惁鍒� if (ExamPlatformData.getInstance().isTimeArrive_10s()){ diff --git a/app/src/main/java/safeluck/drive/evaluation/bean/ExamPlatformData.java b/app/src/main/java/safeluck/drive/evaluation/bean/ExamPlatformData.java index 2ce8108..754d143 100644 --- a/app/src/main/java/safeluck/drive/evaluation/bean/ExamPlatformData.java +++ b/app/src/main/java/safeluck/drive/evaluation/bean/ExamPlatformData.java @@ -60,6 +60,8 @@ private int trainingMode = 0;//鍗充笉鏄缁冩ā寮忎篃涓嶆槸鑰冭瘯妯″紡 public static final int EXAMING_MODE =1; public static final int TRAINING_MODE =2; + //閲囬泦妯″紡 + public static final int ROUTE_MODE =3; //涓昏鏄负浜嗘帶鍒舵棦涓嶆槸鑰冭瘯妯″紡涔熶笉鏄缁冩ā寮忎笅 0206娑堟伅鐨勫彂閫侊紝10s涓�娆″彂閫� diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/HomeFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/HomeFragment.java index c5dd073..61e948d 100644 --- a/app/src/main/java/safeluck/drive/evaluation/fragment/HomeFragment.java +++ b/app/src/main/java/safeluck/drive/evaluation/fragment/HomeFragment.java @@ -95,7 +95,7 @@ break; case R.id.network_train: - if (ExamPlatformData.getInstance().getTrainingMode()==ExamPlatformData.TRAINING_MODE){ + if (ExamPlatformData.getInstance().getTrainingMode()==ExamPlatformData.TRAINING_MODE || ExamPlatformData.getInstance().getTrainingMode()==ExamPlatformData.ROUTE_MODE){ Toast.makeText(_mActivity, "褰撳墠姝e浜庤缁冩ā寮忥紝鏃犳硶杩涘叆鑱旂綉鑰冭瘯锛岃鍏堢粨鏉熻缁�", Toast.LENGTH_SHORT).show(); }else{ NetWorkTrainFragment netWorkTrainFragment = findFragment(NetWorkTrainFragment.class); 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 14b7277..e480e6b 100644 --- a/app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java +++ b/app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java @@ -88,6 +88,9 @@ import safeluck.drive.evaluation.platformMessage.JKMessage0202; import safeluck.drive.evaluation.platformMessage.JKMessage0204; import safeluck.drive.evaluation.platformMessage.PlatFormConstant; +import safeluck.drive.evaluation.routecollect.CollectPointResult; +import safeluck.drive.evaluation.routecollect.ICollectView; +import safeluck.drive.evaluation.routecollect.RouteCollectController; import safeluck.drive.evaluation.util.CThreadPoolExecutor; import safeluck.drive.evaluation.util.Utils; import safeluck.drive.evaluation.widget.StatusDialog; @@ -98,7 +101,7 @@ * 閭锛�632393724@qq.com * All Rights Saved! Chongqing AnYun Tech co. LTD */ -public class TrainFragment extends SupportFragment implements View.OnClickListener { +public class TrainFragment extends SupportFragment implements View.OnClickListener, ICollectView { private static final String TAG = TrainFragment.class.getSimpleName(); private static final int ROUTE_COLLECT = 5;//绾胯矾閲囬泦鏍囧織 @@ -137,6 +140,7 @@ String icson;//杩斿洖鐨刬c鍗′俊鎭� json private String content;//鐢ㄤ互鐢熸垚浜岀淮鐮佺殑鍐呭 + RouteCollectController routeCollectController; private List<Integer> btn_ids = new ArrayList<Integer>(); private HashMap<String,Integer> routeCollect_btn_ids = new HashMap<>(); @@ -547,6 +551,7 @@ private void initView(View view) { + routeCollectController = new RouteCollectController(this); items = view.findViewById(R.id.items); items_score=view.findViewById(R.id.items_score); route_collect=view.findViewById(R.id.route_collect); @@ -673,22 +678,23 @@ for (RouteBean bean:mRouteBeans){ if (string.equalsIgnoreCase(bean.getRouteName())){ //鏈夐噸鍚嶇殑绾胯矾锛屾彁绀虹敤鎴峰苟涓嶅紑鍚嚎璺噰闆� - Toast.makeText(_mActivity, "璇ョ嚎璺悕绉板凡琚娇鐢紝璇锋洿鎹�", Toast.LENGTH_SHORT).show(); + Toast.makeText(_mActivity, "缁х画閲囬泦"+bean.getRouteName(), Toast.LENGTH_SHORT).show(); flag = true; break; } } + Toast.makeText(_mActivity, "绾胯矾閲囬泦", Toast.LENGTH_SHORT).show(); + ExamPlatformData.getInstance().setTrainingMode(ExamPlatformData.ROUTE_MODE); + exam_type = 5; + examStatusViewModel.updateStartExam(exam_type); + items.setVisibility(View.GONE); + items_score.setVisibility(View.GONE); + route_collect.setVisibility(View.VISIBLE); if (!flag){ RouteBean routeBean = new RouteBean(); routeBean.setRouteName(string); routeLineViewModel.insertRouteBean(routeBean); - Toast.makeText(_mActivity, "绾胯矾閲囬泦", Toast.LENGTH_SHORT).show(); - ExamPlatformData.getInstance().setTrainingMode(ExamPlatformData.TRAINING_MODE); - exam_type = 5; - examStatusViewModel.updateStartExam(exam_type); - items.setVisibility(View.GONE); - items_score.setVisibility(View.GONE); - route_collect.setVisibility(View.VISIBLE); + } } @@ -782,7 +788,7 @@ while (iterator.hasNext()){ Map.Entry<String, Integer> next = iterator.next(); if (next.getValue()== v.getId()){ - + routeCollectController.startCollect(); Toast.makeText(_mActivity, String.format("鐐瑰嚮浜�%s",next.getKey()), Toast.LENGTH_SHORT).show(); break; } @@ -1039,4 +1045,19 @@ return spannableString; } + @Override + public void beginCollectView() { + Log.i(TAG,"BIND_RTK_INFO_MAP"); + } + + @Override + public void endCollectView() { + Log.i(TAG,"endCollectView"); + routeCollectController.endCollect(); + } + + @Override + public void routeItem(CollectPointResult collectPointResult) { + Log.i(TAG,String.format("x=%f,y=%f",collectPointResult.getX(),collectPointResult.getY())); + } } diff --git a/app/src/main/java/safeluck/drive/evaluation/routecollect/IRouteRemotePointCallback.java b/app/src/main/java/safeluck/drive/evaluation/routecollect/IRouteRemotePointCallback.java deleted file mode 100644 index 0da552c..0000000 --- a/app/src/main/java/safeluck/drive/evaluation/routecollect/IRouteRemotePointCallback.java +++ /dev/null @@ -1,13 +0,0 @@ -package safeluck.drive.evaluation.routecollect; - -/** - * 瀛樻斁c缁欑殑鍥炶皟锛� - * dge - * Created by lzw on 2020/9/16. 10:46:00 - * 閭锛�632393724@qq.com - * All Rights Saved! Chongqing AnYun Tech co. LTD - */ -public interface IRouteRemotePointCallback { - void javaPoint(final int qf, final double x, final double y, final double z,final double heading, - final double pitch,final double roll); -} 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 a72b4ce..bb439c3 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,6 @@ package safeluck.drive.evaluation.routecollect; +import safeluck.drive.evaluation.fragment.TrainFragment; import safeluck.drive.evaluation.routecollect.impl.RouteModel; /** @@ -13,8 +14,11 @@ ICollectView iCollectView; RouteModel routeModel; - - public void RouteCollectController(ICollectView collectView){ + /** + * 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){ this.iCollectView = collectView; routeModel = new RouteModel(); } @@ -29,8 +33,8 @@ } public void endCollect(){ - if (iCollectView != null){ - iCollectView.endCollectView(); + if (routeModel != null){ + routeModel.endCollect(); } } 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 fe352fa..399ca2b 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 @@ -1,11 +1,19 @@ package safeluck.drive.evaluation.routecollect.impl; +import android.util.Log; + import com.anyun.exam.lib.IRemoteInterface; +import org.json.JSONException; +import org.json.JSONObject; + +import safeluck.drive.evaluation.Constant; +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.IRouteRemotePointCallback; +import safeluck.drive.evaluation.util.Utils; /** * DriveJudge @@ -13,10 +21,33 @@ * 閭锛�632393724@qq.com * All Rights Saved! Chongqing AnYun Tech co. LTD */ -public class RouteModel implements IRouteCollectInterface,IRouteRemotePointCallback { +public class RouteModel implements IRouteCollectInterface{ ILoadListener iLoadListener; - private double sx=120.0,sy=10.03; + private static final String TAG = "RouteModel"; + private ICEventListener icEventListener= new ICEventListener() { + @Override + public void onCEvent(String topic, int msgCode, int resultCode, Object obj) { + //,"coord_x":0.974,"coord_x_dir":"N","coord_y":-0.191,"c + if (iLoadListener != null){ + CollectPointResult collectPointResult = new CollectPointResult(); + try { + JSONObject jsonObject = new JSONObject((String)obj); + double x = jsonObject.getDouble("coord_x"); + double y = jsonObject.getDouble("coord_y"); + + Log.i(TAG,String.format("閲囬泦鍒扮殑鐐广�恱=%f,y=%f]",x,y)); + collectPointResult.setX(Utils.getdouble(x,4)); + collectPointResult.setY(Utils.getdouble(y,4)); + iLoadListener.finishCollectItem(collectPointResult); + } catch (JSONException e) { + e.printStackTrace(); + } + + } + } + }; + @Override public void startCollect(ILoadListener listener) { iLoadListener = listener; @@ -24,6 +55,7 @@ //set IRouteRemotePointCallback //濡傛灉閲囩敤application鐨刢allback 锛屽彲鑳介渶瑕佹敞鍐屼竴涓狢EventLisntener + CEventCenter.onBindEvent(true,icEventListener, Constant.BIND_RTK_INFO_MAP); } /** @@ -32,17 +64,9 @@ @Override public void endCollect() { //濡傛灉閲囩敤application鐨刢allback 锛屽彲鑳介渶瑕佸弽娉ㄥ唽涓�涓狢EventLisntener 瑙g粦 + CEventCenter.onBindEvent(false,icEventListener,Constant.BIND_RTK_INFO_MAP); + iLoadListener = null; } - @Override - public void javaPoint(int qf, double x, double y, double z, double heading, double pitch, double roll) { - - if (iLoadListener != null){ - CollectPointResult collectPointResult = new CollectPointResult(); - collectPointResult.setX(sx); - collectPointResult.setY(sy); - iLoadListener.finishCollectItem(collectPointResult); - } - } } -- Gitblit v1.8.0