yy1717
2020-01-14 054cc31516fe51b31b606485223228cba15da4d2
app/src/main/java/safeluck/drive/evaluation/fragment/MapFragment.java
@@ -24,17 +24,21 @@
import com.anyun.exam.lib.MyLog;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.List;
import me.yokeyword.fragmentation.SupportFragment;
import safeluck.drive.evaluation.Constant;
import safeluck.drive.evaluation.R;
import safeluck.drive.evaluation.bean.ExamMap;
import safeluck.drive.evaluation.bean.RealTimeCarPos;
import safeluck.drive.evaluation.cEventCenter.CEventCenter;
import safeluck.drive.evaluation.cEventCenter.ICEventListener;
import safeluck.drive.evaluation.util.CThreadPoolExecutor;
import safeluck.drive.evaluation.util.FileUtil;
/**
@@ -66,6 +70,7 @@
    private String osd = null;
    private String osd2 = null;
    private String osd3 = null;
    private int map_id;
    double map[][] = {{1, 1}, {10, 1}, {10, 10}, {1, 10}};
    double car[][] = {{8.278, 1.467}, {7.2780000000000009, 1.467}, {7.2780000000000009, -1.533}, {8.278, -1.533}
            , {9.278, -1.5330000000000004}, {9.277999999999999, 1.467000000000001}};
@@ -312,6 +317,7 @@
    }
    int line = 0;
    int map_line = 0;
    private ICEventListener icEventListener = new ICEventListener() {
        @Override
        public void onCEvent(String topic, int msgCode, int resultCode, Object obj) {
@@ -319,6 +325,7 @@
            RealTimeCarPos timeCarPos = gson.fromJson((String) obj, RealTimeCarPos.class);
            List<Double> points = timeCarPos.getPoint();
            line = 0;
            map_line = 0;
            for (int i = 0; i < points.size(); i++) {
                if ((i % 2) == 0) {
@@ -331,7 +338,38 @@
                }
            }
            CThreadPoolExecutor.runInBackground(new NeedForSpeed(car,map));
            map_id = timeCarPos.getMap_id();
//            1 - 倒库
//            2 - 坡起
//            3 - 侧方停车
//            4 - 曲线行驶
//            5 - 直角转弯
            StringBuffer buffer = FileUtil.readTxtFileFromSD(_mActivity,Constant.MAP);
            Type type = new TypeToken<List<ExamMap>>(){}.getType();
            if (buffer != null){
                List<ExamMap> examMaps = gson.fromJson(buffer.toString().trim(), type);
                for (int i = 0; i < examMaps.size(); i++) {
                    ExamMap examMap = examMaps.get(i);
                    if (map_id == examMap.getId()){
                        List<ExamMap.PointBean> pointBeanList = examMap.getPoint();
                        for(int j=0; j<pointBeanList.size();j++){
                            if ((j % 2) == 0) {
                                map[map_line][0] = points.get(i);
                            } else {
                                double value = 0 - points.get(i);
                                Log.i(TAG, "onCEvent: map新值=" + value + " 位置:" + i);
                                map[map_line][1] = value;
                                map_line++;
                            }
                        }
                        break;
                    }
                }
            }
            CThreadPoolExecutor.runInBackground(new NeedForSpeed(car, map));
        }
    };