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;
    }