fctom1215
2021-04-28 148254bb1dc170db320bcb208ca79b0e252751d8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
package safeluck.drive.evaluation;
 
import android.app.Application;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
 
 
import androidx.annotation.NonNull;
import androidx.work.Data;
import androidx.work.OneTimeWorkRequest;
import androidx.work.WorkManager;
 
import com.anyun.exam.lib.AYSdk;
import com.anyun.exam.lib.IAYExamListener;
 
import me.yokeyword.fragmentation.Fragmentation;
import me.yokeyword.fragmentation.helper.ExceptionHandler;
 
import com.anyun.basecommonlib.MyLog;
import com.anyun.exam.lib.crash.CrashHandler;
import com.facebook.stetho.Stetho;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
 
 
import org.json.JSONException;
import org.json.JSONObject;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
import safeluck.drive.evaluation.DB.WorkRoomDataBase;
import safeluck.drive.evaluation.DB.appstatusdb.AppStatusWorker;
import safeluck.drive.evaluation.DB.criterias.Criteria;
import safeluck.drive.evaluation.DB.exam_status.ExamStatus;
import safeluck.drive.evaluation.DB.exam_status.ExamStatusOutWorker;
import safeluck.drive.evaluation.DB.failitems.FailedProj;
import safeluck.drive.evaluation.DB.gps.GpsInfoWorker;
import safeluck.drive.evaluation.DB.route.RouteCross;
import safeluck.drive.evaluation.DB.route.RouteTriggerLine;
import safeluck.drive.evaluation.DB.rtktb.RTKConfigUpdateWorker;
import safeluck.drive.evaluation.bean.AbsInitialData;
import safeluck.drive.evaluation.bean.ExamPlatformData;
import safeluck.drive.evaluation.bean.RemoteRouteCollect;
import safeluck.drive.evaluation.bean.RouteCollect;
import safeluck.drive.evaluation.cEventCenter.CEventCenter;
import safeluck.drive.evaluation.im.MessageProcessor;
import safeluck.drive.evaluation.platformMessage.AttachInfo;
import safeluck.drive.evaluation.platformMessage.AttachInfo2;
import safeluck.drive.evaluation.platformMessage.JKMessage0202;
import safeluck.drive.evaluation.platformMessage.JKMessage0203;
import safeluck.drive.evaluation.platformMessage.JKMessage0204;
import safeluck.drive.evaluation.platformMessage.JKMessage0206;
import safeluck.drive.evaluation.platformMessage.PlatFormConstant;
import safeluck.drive.evaluation.util.CThreadPoolExecutor;
import safeluck.drive.evaluation.util.DataInitKt;
import safeluck.drive.evaluation.util.FileUtil;
import safeluck.drive.evaluation.util.SPUtils;
import safeluck.drive.evaluation.util.SystemUtil;
import safeluck.drive.evaluation.util.Utils;
 
import static safeluck.drive.evaluation.util.DataInitKt.sendJudgeArgs;
 
/**
 * MyApplication2
 * Created by lzw on 2019/3/15. 10:53:52
 * 邮箱:632393724@qq.com
 * All Rights Saved! Chongqing AnYun Tech co. LTD
 */
public class app extends Application implements IAYExamListener  {
 
    private static final String TAG = "JiaKaoApplication";
    private static  int EXIT_EXAM_COUNT = 0;
    private static Context appContext=null;
    @Override
    public void onCreate() {
        super.onCreate();
        //初始化Fragment 建议在Application onCreate里面初始化
        if (SystemUtil.compareProcessName(this)) {
            Fragmentation.builder().stackViewMode(Fragmentation.BUBBLE).debug(false)
                    .handleException(new ExceptionHandler() {
                        @Override
                        public void onException(@NonNull Exception e) {
                            MyLog.i(TAG, "onException: " + e.getMessage());
                        }
                    })
                    .install();
 
 
 
 
            CrashHandler crashHandler = CrashHandler.getInstance();
            crashHandler.init(getApplicationContext());
            AYSdk.getInstance().init(getApplicationContext());
            AYSdk.getInstance().registListener(this);
            Stetho.initializeWithDefaults(this);
 
            appContext = this;
 
            //数据库操作
            MyLog.i(TAG, "onCreate111");
            FileUtil.createdirs(getApplicationContext());
 
            //考试状态 ,一些初始状态,app一些状态应该先初始化一下
 
//            ExamPlatformData.getInstance().setMcuSN("0314200100000004");
//            ExamPlatformData.getInstance().setCanWriteSD(true);
        }
 
    }
 
    private void sendExamJson(int type) {
        try {
            MyLog.i("收到错误码之后,发送考试状态,examType="+type);
            JSONObject jsonObject = new JSONObject();
            if (type != Constant.NONE_BEEN_START_EXAM){
 
            jsonObject.put("exam", 1);
            }else{
 
            jsonObject.put("exam", 0);
            }
            jsonObject.put("type", type);
            String examJson = jsonObject.toString();
            Log.i(TAG, "onClick: " + examJson);
            AYSdk.getInstance().sendCmd(Constant.EXAM_STATUS, examJson);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
 
    private void initData() {
        CThreadPoolExecutor.runInBackground(()->{
                int type = WorkRoomDataBase.getWorkRoomDataBase(getApplicationContext()).getExamStatusDao().getStartExamInt();
            MyLog.i("考试状态="+type);
            ExamPlatformData.getInstance().setExamType(type);
            //发送蓝牙配置消息
            String mac= (String) SPUtils.get(getAppContext(),SPUtils.BLUETOOTH_MAC,"");
            if (!TextUtils.isEmpty(mac)){
                JSONObject jsonObject = new JSONObject();
                try {
 
                    jsonObject.put("bluetooth_addr",mac);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
 
                String json = jsonObject.toString();
                Log.i(TAG,json);
                AYSdk.getInstance().sendCmd(Constant.ID_MS_BLUETOOTH_NAME,json);
            }
 
 
            sendRouteExam();
            //2021 1. 12
//            DataInitKt.sendRtkConfig(getApplicationContext());
//            DataInitKt.MCUUpgrade(getApplicationContext());
 
          //改在蓝牙已经连接,发送initialdata
 
 
 
 
 
 
 
        });
    }
 
    private void sendRouteExam() {
        if (CThreadPoolExecutor.isOnMainThread()){
            Log.i(TAG,"sendRouteExam 运行在主线,需要在子线程发送线路");
                CThreadPoolExecutor.runInBackground(()->{
                    opDBAndSendRoute();
                });
        }else{
            Log.i(TAG,"sendRouteExam 运行子线程");
            opDBAndSendRoute();
        }
    }
 
    private void opDBAndSendRoute() {
        List<RouteCollect.CrossingActiveBean> crossingActiveBeans = new ArrayList<>();
        List<RouteCollect.TriggerLineBean> triggerLineBeans = new ArrayList<>();
 
        RemoteRouteCollect remoteRouteCollect = new RemoteRouteCollect();
        RouteCollect routeCollect = new RouteCollect();
        List<RouteCollect> routeCollects = new ArrayList<>();
        String routeName = WorkRoomDataBase.getWorkRoomDataBase(getApplicationContext()).getRouteBeanDao().getCurrRouteName(ExamPlatformData.getInstance().getExamRoute());
        routeCollect.setName(routeName);
        List<RouteTriggerLine> routeTriggerLines = WorkRoomDataBase.getWorkRoomDataBase(getApplicationContext()).getRouteTriggerLineDao().getAllRouteTriggerLine(ExamPlatformData.getInstance().getExamRoute());
        List<RouteCross> routeCrosses = WorkRoomDataBase.getWorkRoomDataBase(getApplicationContext().getApplicationContext()).getRouteCrooDao().getAllRouteCross(ExamPlatformData.getInstance().getExamRoute());
        for (RouteTriggerLine line:routeTriggerLines){
            List<Double> xy = new ArrayList<>();
            RouteCollect.TriggerLineBean triggerLineBean = new RouteCollect.TriggerLineBean();
            int road = line.getRoad();
            int type = line.getType();
 
            double x = line.getX();
            double y = line.getY();
            xy.clear();
            xy.add(x);
            xy.add(y);
            triggerLineBean.setRoad(road);
            triggerLineBean.setType(type);
            triggerLineBean.setX_y(xy);
            triggerLineBeans.add(triggerLineBean);
 
 
        }
        routeCollect.setTrigger_line(triggerLineBeans);
 
        for (RouteCross routeCross:routeCrosses){
            int idx = routeCross.getIdx();
            int road = routeCross.getRoad();
            int active = routeCross.getActive();
            RouteCollect.CrossingActiveBean crossingActiveBean = new RouteCollect.CrossingActiveBean();
            crossingActiveBean.setActive(active);
            crossingActiveBean.setIdx(idx);
            crossingActiveBean.setRoad(road);
            crossingActiveBeans.add(crossingActiveBean);
        }
        routeCollect.setCrossing_active(crossingActiveBeans);
        routeCollects.add(routeCollect);
 
        remoteRouteCollect.setScheme(routeCollects);
        String str = new Gson().toJson(remoteRouteCollect);
        Log.i(TAG,"json====="+str);
        AYSdk.getInstance().sendCmd(0x8017,str);
    }
 
 
 
    public static Context getAppContext(){
        return appContext;
    }
 
    @Override
    public void onTerminate() {
        super.onTerminate();
        MyLog.e(TAG, "OnTerminate()");
        AYSdk.getInstance().uninit();
    }
 
    @Override
    public void onLowMemory() {
        super.onLowMemory();
        MyLog.e(TAG, "OnTerminate()");
    }
 
    private String lastStr;
    private String lastSn;
    private int mapId = 0;
    int type = 0;
    int enter_status = -1;
    @Override
    public void callBackMsg(final int cmd, String json) {
        if (cmd!=11 && cmd!=14){
            String strConent = String.format("收到命令[%d],Json内容为%s", cmd, json);
            if (strConent.equalsIgnoreCase(lastStr)){
 
            }else{
 
                MyLog.d(TAG,strConent );
                lastStr = strConent;
            }
        }
 
        switch (cmd) {
            case Constant.ID_SM_BLUETOOTH_BRIEF:
                CEventCenter.dispatchEvent(Constant.BIND_CONNECT_RTK_TOPIC,cmd,0,json);
                break;
            case Constant.NDK_START:
 
 
 
 
                break;
            case Constant.RTK_PLATFORM_REGISTER_STATUS:
                CEventCenter.dispatchEvent(Constant.BIND_CONNECT_RTK_TOPIC,cmd,0,json);
 
                //RTK平台注册状态,需要保存数据库
 
                break;
            case Constant.RTK_PLATFORM_REGISTER_RESULT:
                String[] strs = new String[2];
                strs[0] = Constant.RTK_LOGIN_CODE_COLUMN;
                strs[1] = json;
                //RTK平台登录结果
                Data rtkLoginData = new Data.Builder().putStringArray(Constant.APP_STATUS,strs).build();
                OneTimeWorkRequest loginWorkRequest = new OneTimeWorkRequest.Builder(AppStatusWorker.class).setInputData(rtkLoginData).build();
                WorkManager.getInstance(getApplicationContext()).enqueue(loginWorkRequest);
 
                break;
            case Constant.FETCH_RTK_PLATFORM_INFO:
//                CEventCenter.dispatchEvent(Constant.BIND_RTKCONFIG_TOPIC,cmd,0,"");
                break;
            case Constant.JUDGE_INFO:
                if (ExamPlatformData.getInstance().getTrainingMode()==ExamPlatformData.ROUTE_MODE){
                    MyLog.i(TAG,"采集模式不接受评判消息");
                    return;
                }
                if(!TextUtils.isEmpty(json)){
                    final JKMessage0203 jkMessage0203 = new JKMessage0203();
 
                    final JsonArray jsonArray = (JsonArray) JsonParser.parseString(json);
//
 
                    CThreadPoolExecutor.runInBackground(new Runnable() {
                        @Override
                        public void run() {
                            for (int i = 0; i < jsonArray.size(); i++) {
                                JsonObject jsonObject = jsonArray.get(i).getAsJsonObject();
                                int emp_id = jsonObject.get("wrong_id").getAsInt();
                                String utc = jsonObject.get("utc").getAsString();
                                Log.i(TAG,"jdge utc="+utc);
                                int sn = jsonObject.get("sn").getAsInt();
 
 
                                    Criteria  ttsStr=WorkRoomDataBase.getWorkRoomDataBase(getAppContext()).getCriteriaDao().queryItemForCriteriaNoLive(emp_id);
                                    ExamPlatformData.getInstance().getTTS().speak(ttsStr.getDeducting_reason().replace("s","秒") + (ttsStr.getScore_deducting() == 100? "不合格  " : "扣" +
                                            ttsStr.getScore_deducting() + "分  "));
                                    jkMessage0203.fail_item_id =ttsStr.getItem_id();
                                    jkMessage0203.fail_score = ttsStr.getScore_deducting();
                                    jkMessage0203.fail_reason = ttsStr.getDeducting_reason();
 
 
                                if (!TextUtils.isEmpty(utc) && utc.length() > 14) {
                                    utc = utc.substring(0, 14);
                                }
                                Date date = new Date(Utils.utc2NetWorkTime(utc));
                                jkMessage0203.timeBCD = date;
                                jkMessage0203.exam_id = ExamPlatformData.getInstance().getExam_id();
                                MyLog.i(String.format("收到远程服务给的评判消息 timeBCD=%s",Utils.formatTimeYYMMDDHHmmSS(jkMessage0203.timeBCD.getTime())));
 
                                MessageProcessor.getInstance().sendMessage(jkMessage0203);
 
 
 
 
 
 
                                FailedProj failedProj = new FailedProj(Constant.SUBJECT_ALL, emp_id, Constant.TEST_STU_ID, utc, sn);
                                        MyLog.i("插入fail_projects表="+failedProj.toString());
                                WorkRoomDataBase.getWorkRoomDataBase(getApplicationContext()).getFailProjDao().insert(failedProj);
 
 
 
 
 
 
 
 
                            }
                        }
                    });
 
 
 
                }
 
                break;
            case Constant.EXAM_STATUS_REPLY:
                MyLog.d(TAG, "考试开始,复位数据库失败项目表");
 
                try {
                    JSONObject jsonObject =new JSONObject((String)json);
                    int errCode = jsonObject.getInt("error");
                    MyLog.i("收到考试应答错误码="+errCode);
                    switch (errCode){
                        case -1:
                            if (ExamPlatformData.getInstance().getExamType()>ExamPlatformData.EXAM_TYPE_ChangKAO){
                                if (TextUtils.isEmpty(ExamPlatformData.getInstance().getRoadMapPath())){
                                    MyLog.i("开始考试后,远程服务缺少路考地图,但地图确实不存在无法发送给远程服务");
                                    CThreadPoolExecutor.runOnMainThread(() -> Toast.makeText(appContext, "缺少路考地图,请前往\"设置\"选择地图", Toast.LENGTH_SHORT).show());
 
                                    return;
                                }
                            }
                            if (ExamPlatformData.getInstance().getExamType()==ExamPlatformData.EXAM_TYPE_ChangKAO){
                                if (TextUtils.isEmpty(ExamPlatformData.getInstance().getMapPath())){
                                    MyLog.i("开始考试后,远程服务缺少chang考地图,但地图确实不存在无法发送给远程服务");
                                    CThreadPoolExecutor.runOnMainThread(new Runnable() {
                                        @Override
                                        public void run() {
                                            Toast.makeText(appContext, "缺少场考地图,请前往\"设置\"选择地图", Toast.LENGTH_SHORT).show();
 
                                        }
                                    });
 
                                    return;
                                }
                            }
 
                            DataInitKt.sendMapInfo();
                            DataInitKt.sendRoadMapInfo();
                            sendExamJson(ExamPlatformData.getInstance().getExamType());
                            break;
                        case -2:
 
                            DataInitKt.sendVehicleInfo();
                            sendExamJson(ExamPlatformData.getInstance().getExamType());
                            break;
                        case -3:
                            sendRouteExam();
                            sendJudgeArgs();
                            Data data = new Data.Builder().putInt(Constant.NEED_MAPS_CAR,1).build();
                            OneTimeWorkRequest examStatausOutWorker1 = new OneTimeWorkRequest.Builder(ExamStatusOutWorker.class)
                                    .setInputData(data).build();
                            WorkManager.getInstance(getApplicationContext()).enqueue(examStatausOutWorker1);
 
                            break;
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                break;
            case Constant.RTK_PLATFORM_CONNECT_STATUS:
                String[] conn_strs = new String[2];
                conn_strs[0] = Constant.RTK_CONN_STATUS_COLUMN;
                conn_strs[1] = json;
                //RTK平台连接状态
                Data connStatusData = new Data.Builder().putStringArray(Constant.APP_STATUS,conn_strs).build();
                OneTimeWorkRequest oneTimeWorkRequest = new OneTimeWorkRequest.Builder(AppStatusWorker.class).setInputData(connStatusData).build();
                WorkManager.getInstance(getApplicationContext()).enqueue(oneTimeWorkRequest);
                break;
            case Constant.FETCH_MAP_INFO:
//                sendMapInfo();
 
                break;
            case Constant.REQ_VECHILE_PROFILE:
                DataInitKt.sendVehicleInfo();
                break;
            case Constant.GPS_INFO:
                Data gpsData = new Data.Builder().putString(Constant.GPS_INFO_DATA,json).build();
                OneTimeWorkRequest gpsinfoWorkRequest = new OneTimeWorkRequest.Builder(GpsInfoWorker.class).setInputData(gpsData).build();
                WorkManager.getInstance(getApplicationContext()).enqueue(gpsinfoWorkRequest);
                break;
            case Constant.ENTER_OR_EXIT_ITEM:
 
                try {
                    JSONObject rtkConfigUpdtea = new JSONObject(json);
                    type = rtkConfigUpdtea.getInt("type");
                    enter_status = rtkConfigUpdtea.getInt("enter");
                    mapId = rtkConfigUpdtea.getInt("map_id");
                    if (enter_status==0){
                        Log.i(TAG,"全局设置退出");
                        EXIT_EXAM_COUNT++;
                        if (EXIT_EXAM_COUNT==5){
                            Log.i(TAG,"全局设置退出---");
                            ExamPlatformData.getInstance().setExitExam(Constant.EXIT_EXAM);
 
                            EXIT_EXAM_COUNT = 0;
 
                            if (ExamPlatformData.getInstance().getTrainingMode()==ExamPlatformData.TRAINING_MODE){
                                sendStopExam();
                                sendstartExam();
                            }
                        }
                    }
                    String itemstr=ExamPlatformData.getInstance().getItemStatusStr(type);
                    MyLog.i(PlatFormConstant.LUKAO,String.format("%s",itemstr+(enter_status==Constant.EXIT_CURRENT_ITEM?"结束":"开始")));
                    if (ExamPlatformData.getInstance().getTrainingMode()== ExamPlatformData.TRAINING_MODE){
                        if (ExamPlatformData.getInstance().getExamType()>ExamPlatformData.EXAM_TYPE_ChangKAO){
                            MyLog.i("路考不报项目开始结束语音");
                        }else{
 
                            ExamPlatformData.getInstance().getTTS().speak(itemstr+(enter_status==Constant.EXIT_CURRENT_ITEM?"结束":"开始"));
                        }
 
                    }else{
                        if (enter_status!=Constant.EXIT_CURRENT_ITEM){
                            if (ExamPlatformData.getInstance().getExamType()>ExamPlatformData.EXAM_TYPE_ChangKAO){
                                MyLog.i("路考不报项目开始结束语音");
                            }else{
 
                                ExamPlatformData.getInstance().getTTS().speak(itemstr+"开始");
                            }
 
                        }
 
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
 
 
                CThreadPoolExecutor.runInBackground(new Runnable() {
                    @Override
                    public void run() {
                        ExamStatus examStatus = new ExamStatus();
                        examStatus.setEnter(enter_status);
                        examStatus.setMap_id(mapId);
                        examStatus.setMap_item(type);
                        WorkRoomDataBase.getWorkRoomDataBase(getApplicationContext()).getExamStatusDao().insert(examStatus);
                        CEventCenter.dispatchEvent(Constant.BIND_EXAM_STATUS_TOPIC,cmd,0,examStatus);
                    }
                });
//                Data exam_enter_exitdata = new Data.Builder().putString(Constant.exam_enter_exitdata,json).build();
//                OneTimeWorkRequest examStatusWorker = new OneTimeWorkRequest.Builder(ExamStatusWoker.class).setInputData(exam_enter_exitdata).build();
//                WorkManager.getInstance(getApplicationContext()).enqueue(examStatusWorker);
                break;
            case Constant.REAL_TIME_CAR_POS:
                try {
                    JSONObject jsSpeed = new JSONObject(json);
                    double speed = jsSpeed.getDouble("speed");
                    CEventCenter.dispatchEvent(Constant.BIND_SPEED_TOPIC,cmd,0,speed);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                CEventCenter.dispatchEvent(Constant.REAL_TIME_POS_CAR_TOPIC,cmd,0,json);
                break;
            case Constant.DEBUG_RTCM:
                CEventCenter.dispatchEvent(Constant.BIND_RTCM_TOPIC,cmd,0,json);
                break;
            case Constant.DEBUG_TXT:
                CEventCenter.dispatchEvent(Constant.BIND_DEBUG_TXT,cmd,0,json);
                break;
            case Constant.MCU_SN:
                String sn = null;
                try {
                    JSONObject rtkConfigUpdtea = new JSONObject(json);
                    sn = rtkConfigUpdtea.getString("sn");
//                    sn = rtkConfigUpdtea.put(safeluck.drive.evaluation.DB.Constant.RTK_CONFIG_SN,sn).toString();
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                if (sn.equalsIgnoreCase(lastSn)){
 
                }else{
                    if (TextUtils.isEmpty(lastSn)){
                        lastSn ="123";
                        return;
                    }
                    lastSn = sn;
                    ExamPlatformData.getInstance().setMcuSN(sn);
                    Data data = new Data.Builder().putString(safeluck.drive.evaluation.DB.Constant.RTK_CONFIG_UPDATE_JSON,sn).build();
                    OneTimeWorkRequest rtkConfigUpdateWorker= new OneTimeWorkRequest.Builder(RTKConfigUpdateWorker.class).build();
                    WorkManager.getInstance(getAppContext()).enqueue(rtkConfigUpdateWorker);
                }
                CEventCenter.dispatchEvent(Constant.BIND_MCUINFO_TOPIC,cmd,0,json);
                break;
            case Constant.RTK_MODLUE_STATUS:
                ExamPlatformData.getInstance().setRTKModuleInfo(json);
                break;
            case Constant.IC_ID:
 
                CEventCenter.dispatchEvent(Constant.BIND_SPEED_TOPIC,cmd,0,json);
                break;
            case Constant.RTK_INFO:
                JSONObject jsonObject = null;
                String utc=null;
                try {
                    jsonObject = new JSONObject(json);
                    int qf = jsonObject.getInt("qf");
                    int satNum = jsonObject.getInt("sat_num");
 
                    //需要将utc时间取出来,然后+8个小时为北京时间,再修改json字符串,然后发给服务器
                     utc = jsonObject.getString("utc");
                    //移动站服务给的是.40 的话 代表是400毫秒
                    utc=Utils.utc2NetWorkTimeMillSeconds(utc+"0");
 
                    if (lastSatEqualNow(satNum)&&lastQfEqualNow(qf)){
                    }else{
                        ExamPlatformData.getInstance().setQfAndSatNum(qf,satNum);
                    }
 
                } catch (JSONException e) {
                    e.printStackTrace();
                }
 
                CEventCenter.dispatchEvent(Constant.BIND_RTK_INFO_MAP,cmd,0,json);
 
 
                if (ExamPlatformData.getInstance().getExamplatformStatus()==ExamPlatformData.DEV_LOGIN){
                    try {
                        JSONObject jsSpeed = new JSONObject(json);
                        double speed = jsSpeed.getDouble("speed");
                        CEventCenter.dispatchEvent(Constant.BIND_RTK_SPEED_TOPIC,cmd,0,speed);
                        JKMessage0206 jkMessage0206 = new JKMessage0206();
                        jkMessage0206.alert = 0;
                        jkMessage0206.status = 0;
 
 
 
                        utc = utc.substring(0,utc.length()-1);
                        json=json.replaceFirst("[1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*",utc);
                        jkMessage0206.json =json;
                        jkMessage0206.length = jkMessage0206.json.length();
                        AttachInfo attachInfo = new AttachInfo();
                        AttachInfo2 attachInfo2 = new AttachInfo2();
                        attachInfo.attach_message_id = 0x41;
 
                        attachInfo.attach_data = ExamPlatformData.getInstance().getExam_id();
                        jkMessage0206.attachInfo = attachInfo;
 
 
                        attachInfo2.attach_message_id = 0x42;
                        if (ExamPlatformData.getInstance().getExamType()>ExamPlatformData.EXAM_TYPE_ChangKAO){
 
                            attachInfo2.attach_data =1;
                        }else{
 
                            attachInfo2.attach_data = 0;
                        }
 
                        jkMessage0206.attachInfo2 = attachInfo2;
                    if (ExamPlatformData.getInstance().getTrainingMode()==ExamPlatformData.MODE_NONE||ExamPlatformData.getInstance().getTrainingMode()==ExamPlatformData.ROUTE_MODE){
                        //判断10s时间是否到
                        if (ExamPlatformData.getInstance().isTimeArrive_10s()){
 
                            //到了 就走下面发送0206消息
                            MessageProcessor.getInstance().sendMessage(jkMessage0206);
                            //重置标记
                            ExamPlatformData.getInstance().setTimeArrive_10s(false);
                        }else{
                            //没到,就不走下面 不发送0206,直接return
                            return;
                        }
 
 
                    }else{
                        MessageProcessor.getInstance().sendMessage(jkMessage0206);
                    }
 
 
 
 
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
 
                }else{
 
                    String str = "登录未成功,不能发送消息=0206";
                    if (str.equalsIgnoreCase(last0206Str)){
 
                    }else{
                        last0206Str = str;
                        MyLog.i(PlatFormConstant.TAG,str);
                    }
                }
 
                break;
            case Constant.LEFT_RIGHT_DISTANCE:
                CEventCenter.dispatchEvent(Constant.BIND_RTK_SPEED_TOPIC,cmd,0,json);
                break;
            case Constant.ID_SM_CARSENSOR:
                Log.i("InspectSignal",json);
                CEventCenter.dispatchEvent(Constant.BIND_MCUINFO_TOPIC,cmd,0,json);
                break;
            case Constant.ENTER_OR_EXIT_ROAD_ID:
                case Constant.ENTER_OR_EXIT_ROADCROSS_ID:
                    CEventCenter.dispatchEvent(Constant.BIND_ROUTE_COLLECT_TOPIC,cmd,0,json);
                break;
            case Constant. ID_SM_CAN_BRIEF:
                ExamPlatformData.getInstance().setSM_CAN_BRIEF(json);
                break;
        }
 
    }
 
    @Override
    public void bindStatus(int code) {
        MyLog.i(String.format("bindStatus = %d",code));
        if (code == 0){
            ExamPlatformData.getInstance().getTTS().speak("服务绑定成功");
            ExamPlatformData.getInstance().setServiceBindStatus(0);
            initData();
        }else{
            ExamPlatformData.getInstance().getTTS().speak("服务异常死亡");
            MyLog.i("服务异常死亡监听到之后,重置发送标志,然后发送数据");
            ExamPlatformData.getInstance().setServiceBindStatus(-1);
            AbsInitialData.getInstance().resethasSendInitData();
            AbsInitialData.getInstance().sendInitialData();
        }
 
 
    }
 
    private String last0206Str="";
    private int lastSatNum= -1;
    private int lastQf = -1;
 
    private boolean lastSatEqualNow(int satNum) {
        if (lastSatNum == satNum){
            return true;
        }else{
            lastSatNum = satNum;
        }
        return false;
    }
    private boolean lastQfEqualNow(int qf) {
        if (lastQf == qf){
            return true;
        }else{
            lastQf = qf;
        }
        return false;
    }
 
private void sendStopExam(){
    JKMessage0204 jkMessage0204 = new JKMessage0204();
    jkMessage0204.timeBCD = new Date();
    jkMessage0204.score = ExamPlatformData.getInstance().getCurTotalScore();
    jkMessage0204.stop = JKMessage0204.SUCC_STOP;
    jkMessage0204.exam_id = ExamPlatformData.getInstance().getExam_id();
    MessageProcessor.getInstance().sendMessage(jkMessage0204);
}
 
private void sendstartExam(){
    final JKMessage0202 jkMessage0202 = new JKMessage0202();
    Date date = new Date();
    jkMessage0202.timeBCD = date;
    ExamPlatformData.getInstance().setExam_id(Utils.parseUnsignedInt(String.valueOf(date.getTime()/1000),10));
    jkMessage0202.stu_id = ExamPlatformData.getInstance().getID();
    jkMessage0202.coach_id = ExamPlatformData.getInstance().getCoachID();
    jkMessage0202.exam_id = ExamPlatformData.getInstance().getExam_id();
 
 
        jkMessage0202.curr_exam = 1;//  跟移动站服务定义的场考是2  ,平台是0 ;  移动站路考是3 ,平台是1
 
        jkMessage0202.curr_exam = 0;//  跟移动站服务定义的场考是2  ,平台是0 ;  移动站路考是3 ,平台是1
 
    jkMessage0202.mode = ExamPlatformData.getInstance().getTrainingMode()==ExamPlatformData.TRAINING_MODE?1:0;
    MessageProcessor.getInstance().sendMessage(jkMessage0202);
}
 
}