endian11
2020-09-17 399bf6ae73d636d56ecd590036964e52433b4743
设置一个ROUTE_MODE 为 采集模式, app  HomeFragment增加这个模式的判断
1个文件已删除
6个文件已修改
122 ■■■■■ 已修改文件
app/src/main/java/safeluck/drive/evaluation/app.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/bean/ExamPlatformData.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/fragment/HomeFragment.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java 41 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/routecollect/IRouteRemotePointCallback.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/routecollect/RouteCollectController.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/routecollect/impl/RouteModel.java 50 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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()){
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一次发送
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, "当前正处于训练模式,无法进入联网考试,请先结束训练", Toast.LENGTH_SHORT).show();
                }else{
                    NetWorkTrainFragment netWorkTrainFragment = findFragment(NetWorkTrainFragment.class);
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;//返回的ic卡信息 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()));
    }
}
app/src/main/java/safeluck/drive/evaluation/routecollect/IRouteRemotePointCallback.java
File was deleted
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();
        }
    }
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("采集到的点【x=%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的callback ,可能需要注册一个CEventLisntener
        CEventCenter.onBindEvent(true,icEventListener, Constant.BIND_RTK_INFO_MAP);
    }
    /**
@@ -32,17 +64,9 @@
    @Override
    public void endCollect() {
        //如果采用application的callback ,可能需要反注册一个CEventLisntener 解绑
        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);
        }
    }
}