lizhanwei
2020-07-27 202bc6b58cc9b5157761163e645c8e0170ab97ac
修改地图和信号配置加锁
3个文件已修改
153 ■■■■ 已修改文件
app/src/main/java/safeluck/drive/evaluation/DB/rtktb/RTKConfigUpdateWorker.kt 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/app.java 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/fragment/InspectSignalFragment.java 75 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/DB/rtktb/RTKConfigUpdateWorker.kt
@@ -106,8 +106,9 @@
                                                + applicationContext.getPackageName() + "/" + fileName)
                                        CThreadPoolExecutor.runInBackground(Runnable {
                                            str = gson.toJson(map.data.map_json)
                                            MyLog.i(PlatFormConstant.HTTPTAG,"科三道路地图保存成功")
                                            FileUtil.writeTxtFileToSD(applicationContext, fileName, str, "")
                                            sendRoadMapInfo()
//                                            sendRoadMapInfo()
                                        })
                                    }
@@ -124,9 +125,10 @@
                                            ExamPlatformData.getInstance().setNewMapPath(Environment.getExternalStorageDirectory().absolutePath + "/"
                                                    + applicationContext.getPackageName() + "/"+fileName)
                                            CThreadPoolExecutor.runInBackground(Runnable{
                                                MyLog.i(PlatFormConstant.HTTPTAG,"科三场地地图保存成功")
                                                str = gson.toJson(yard.data.map_json)
                                                FileUtil.writeTxtFileToSD(applicationContext,fileName,str,"")
                                                sendMapInfo()
//                                                sendMapInfo()
                                            })
                                        }
                                    }
@@ -142,8 +144,9 @@
                                        Log.i(TAG, "解析之后的车模型=$str")
                                        CThreadPoolExecutor.runInBackground(Runnable{
                                            str = gson.toJson(car.data.map_json)
                                            MyLog.i(PlatFormConstant.HTTPTAG,"车辆模型保存成功")
                                            FileUtil.writeTxtFileToSD(applicationContext,fileName,str,"")
                                            sendVehicleInfo()
//                                            sendVehicleInfo()
                                        })
                                    }
@@ -152,18 +155,18 @@
                        }
                    } else {
                        Toast.makeText(applicationContext, jsonObject1!!.getString("data"), Toast.LENGTH_SHORT).show()
//                        Toast.makeText(applicationContext, jsonObject1!!.getString("data"), Toast.LENGTH_SHORT).show()
                    }
                }
            })
        }else{
            MyLog.i(PlatFormConstant.HTTPTAG,"已存在直接发送车辆和地图")
            when(type){
                "road" -> sendRoadMapInfo()
                "yard" -> sendMapInfo()
                else -> sendVehicleInfo()
            }
//            MyLog.i(PlatFormConstant.HTTPTAG,"已存在直接发送车辆和地图"+fileName)
//            when(type){
//                "road" -> sendRoadMapInfo()
//                "yard" -> sendMapInfo()
//                else -> sendVehicleInfo()
//            }
        }
    }
app/src/main/java/safeluck/drive/evaluation/app.java
@@ -549,15 +549,18 @@
                        AYSdk.getInstance().sendCmd(Constant.PUSH_VECHILE_PROFILE,str);
                    }else{
                        MyLog.i(String.format("文件:%s不存在",carPath));
                        CThreadPoolExecutor.runOnMainThread(new Runnable() {
                            @Override
                            public void run() {
                                Toast.makeText(getAppContext(), "文件:"+carPath+"不存在", Toast.LENGTH_SHORT).show();
                            }
                        });
                    }
                }else{
                    StringBuffer vebuffer =FileUtil.readAssetTxtFile(getApplicationContext(),Constant.VEHICLE);
                    if (vebuffer != null){
                        AYSdk.getInstance().sendCmd(Constant.PUSH_VECHILE_PROFILE,vebuffer.toString());
                    }else{
                        MyLog.d(TAG,String.format("车辆模型模型未拷入[%s]目录下", Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+getApplicationContext().getPackageName()));
                    }
                    CThreadPoolExecutor.runOnMainThread(()->{
                        MyLog.i("车辆模型发送失败,请手动设置");
                        Toast.makeText(getAppContext(), "车辆模型发送失败,请手动设置", Toast.LENGTH_SHORT).show();
                    });
                }
            }
@@ -588,21 +591,13 @@
                        });
                    }
                }else{
                    StringBuffer buffer;
                    buffer =FileUtil.readAssetTxtFile(getApplicationContext(),Constant.ROAD_MAP);
                    if (buffer != null){
                        AYSdk.getInstance().sendCmd(Constant.PUSH_ROAD_MAP_INFO,buffer.toString());
                    }else{
                        MyLog.d(TAG,String.format("地图模型未拷入[%s]目录下", Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+getApplicationContext().getPackageName()));
                        CThreadPoolExecutor.runOnMainThread(new Runnable() {
                            @Override
                            public void run() {
                                Toast.makeText(getAppContext(), String.format("地图模型未拷入[%s]目录下", Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+getApplicationContext().getPackageName()), Toast.LENGTH_SHORT).show();
                            }
                        });
                    }
                    CThreadPoolExecutor.runOnMainThread(new Runnable() {
                        @Override
                        public void run() {
                            MyLog.i("道路地图发送失败,请手动设置");
                            Toast.makeText(getAppContext(), "道路地图发送失败,请手动设置", Toast.LENGTH_SHORT).show();
                        }
                    });
                }
                if (!TextUtils.isEmpty(mapPath)){
                    MyLog.i("调用更新Map路径后的地图"+mapPath);
@@ -622,25 +617,13 @@
                        });
                    }
                }else{
                    MyLog.i("读取Assert目录下初始化的地图");
                    CThreadPoolExecutor.runOnMainThread(new Runnable() {
                        @Override
                        public void run() {
                            Toast.makeText(getAppContext(), "读取Assert目录下初始化的地图", Toast.LENGTH_SHORT).show();
                            MyLog.i("场地地图发送失败,请手动设置");
                            Toast.makeText(getAppContext(), "场地地图发送失败,请手动设置", Toast.LENGTH_SHORT).show();
                        }
                    });
                    StringBuffer buffer;
                        buffer =FileUtil.readAssetTxtFile(getApplicationContext(),Constant.MAP);
                        if (buffer != null){
                            AYSdk.getInstance().sendCmd(Constant.PUSH_MAP_INFO,buffer.toString());
                        }else{
                            MyLog.d(TAG,String.format("地图模型未拷入[%s]目录下", Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+getApplicationContext().getPackageName()));
                            CThreadPoolExecutor.runOnMainThread(() -> Toast.makeText(getAppContext(), String.format("地图模型未拷入[%s]目录下", Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+getApplicationContext().getPackageName()), Toast.LENGTH_SHORT).show());
                        }
                }
            }
app/src/main/java/safeluck/drive/evaluation/fragment/InspectSignalFragment.java
@@ -51,48 +51,53 @@
    Drawable leftGreen ;
    Drawable leftGray ;
    private int  index =0 ;
    private Object object = new Object();
    private ICEventListener icEventListener = new ICEventListener() {
        @Override
        public void onCEvent(String topic, int msgCode, int resultCode, Object obj) {
            if (msgCode==Constant.MCU_SN){
                final MCUInfo mcuInfo = gson.fromJson((String)obj, MCUInfo.class);
                if (mcuInfo != null){
            synchronized (object){
                if (msgCode==Constant.MCU_SN){
                    final MCUInfo mcuInfo = gson.fromJson((String)obj, MCUInfo.class);
                    if (mcuInfo != null){
                        gpios.clear();
                            for (int i = 0; i < 16; i++) {
                        for (int i = 0; i < 16; i++) {
                                gpios.add(      ByteUtil.getBitStatus(mcuInfo.getGpio(),i));
                            }
                            MyLog.i("mcu info gpio"+mcuInfo.getGpio());
                    handler.post(new Runnable() {
                                @Override
                                public void run() {
                                    bingding.roatespeed.updateStr(String.valueOf(mcuInfo.getEngine()));
                                    bingding.myspeed.updateStr(String.valueOf(mcuInfo.getSpeed()/10.0));
                                    for (int i = 0; i < gpios.size(); i++) {
                                        Log.i(TAG, "run: gpio["+i+"]="+gpios.get(i));
                                    }
                                    bingding.inpsetSignalSlice.tvSeatBelt.setCompoundDrawablesWithIntrinsicBounds(gpios.get(5)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvTrunLeft.setCompoundDrawablesWithIntrinsicBounds(gpios.get(14)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvTurnRight.setCompoundDrawablesWithIntrinsicBounds(gpios.get(15)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvParkingBrake.setCompoundDrawablesWithIntrinsicBounds(gpios.get(2)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvFootBrake.setCompoundDrawablesWithIntrinsicBounds(gpios.get(7)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvLowLamp.setCompoundDrawablesWithIntrinsicBounds(gpios.get(13)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvHighBeam.setCompoundDrawablesWithIntrinsicBounds(gpios.get(11)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvGateLock.setCompoundDrawablesWithIntrinsicBounds(gpios.get(9)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvNullEngine.setCompoundDrawablesWithIntrinsicBounds(gpios.get(8)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvGearOne.setCompoundDrawablesWithIntrinsicBounds(gpios.get(3)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvGearTwo.setCompoundDrawablesWithIntrinsicBounds(gpios.get(6)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvGearThree.setCompoundDrawablesWithIntrinsicBounds(gpios.get(1)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvGearFour.setCompoundDrawablesWithIntrinsicBounds(gpios.get(4)==VALIAD_NUM?leftGreen:leftGray,null,null,null);//副刹
                                    bingding.inpsetSignalSlice.tvWindingOne.setCompoundDrawablesWithIntrinsicBounds(gpios.get(12)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                    bingding.inpsetSignalSlice.tvWindingTwo.setCompoundDrawablesWithIntrinsicBounds(gpios.get(10)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                }
                            });
                            gpios.add(      ByteUtil.getBitStatus(mcuInfo.getGpio(),i));
                        }
                        MyLog.i("mcu info gpio"+mcuInfo.getGpio());
                        handler.post(new Runnable() {
                            @Override
                            public void run() {
                                bingding.roatespeed.updateStr(String.valueOf(mcuInfo.getEngine()));
                                bingding.myspeed.updateStr(String.valueOf(mcuInfo.getSpeed()/10.0));
                                for (int i = 0; i < gpios.size(); i++) {
                                    MyLog.i(TAG, "run: gpio["+i+"]="+gpios.get(i));
                                }
                                MyLog.i("gpios.size="+gpios.size());
                                bingding.inpsetSignalSlice.tvSeatBelt.setCompoundDrawablesWithIntrinsicBounds(gpios.get(5)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                bingding.inpsetSignalSlice.tvTrunLeft.setCompoundDrawablesWithIntrinsicBounds(gpios.get(14)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                bingding.inpsetSignalSlice.tvTurnRight.setCompoundDrawablesWithIntrinsicBounds(gpios.get(15)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                bingding.inpsetSignalSlice.tvParkingBrake.setCompoundDrawablesWithIntrinsicBounds(gpios.get(2)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                bingding.inpsetSignalSlice.tvFootBrake.setCompoundDrawablesWithIntrinsicBounds(gpios.get(7)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                bingding.inpsetSignalSlice.tvLowLamp.setCompoundDrawablesWithIntrinsicBounds(gpios.get(13)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                bingding.inpsetSignalSlice.tvHighBeam.setCompoundDrawablesWithIntrinsicBounds(gpios.get(11)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                bingding.inpsetSignalSlice.tvGateLock.setCompoundDrawablesWithIntrinsicBounds(gpios.get(9)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                bingding.inpsetSignalSlice.tvNullEngine.setCompoundDrawablesWithIntrinsicBounds(gpios.get(8)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                bingding.inpsetSignalSlice.tvGearOne.setCompoundDrawablesWithIntrinsicBounds(gpios.get(3)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                bingding.inpsetSignalSlice.tvGearTwo.setCompoundDrawablesWithIntrinsicBounds(gpios.get(6)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                bingding.inpsetSignalSlice.tvGearThree.setCompoundDrawablesWithIntrinsicBounds(gpios.get(1)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                bingding.inpsetSignalSlice.tvGearFour.setCompoundDrawablesWithIntrinsicBounds(gpios.get(4)==VALIAD_NUM?leftGreen:leftGray,null,null,null);//副刹
                                bingding.inpsetSignalSlice.tvWindingOne.setCompoundDrawablesWithIntrinsicBounds(gpios.get(12)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                                bingding.inpsetSignalSlice.tvWindingTwo.setCompoundDrawablesWithIntrinsicBounds(gpios.get(10)==VALIAD_NUM?leftGreen:leftGray,null,null,null);
                            }
                        });
                    }
                }
            }
        }
    };