From 202bc6b58cc9b5157761163e645c8e0170ab97ac Mon Sep 17 00:00:00 2001 From: lizhanwei <Dana_Lee1016@126.com> Date: 星期一, 27 七月 2020 17:29:41 +0800 Subject: [PATCH] 修改地图和信号配置加锁 --- app/src/main/java/safeluck/drive/evaluation/app.java | 55 ++++++------------ app/src/main/java/safeluck/drive/evaluation/DB/rtktb/RTKConfigUpdateWorker.kt | 23 ++++--- app/src/main/java/safeluck/drive/evaluation/fragment/InspectSignalFragment.java | 75 +++++++++++++----------- 3 files changed, 72 insertions(+), 81 deletions(-) diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/rtktb/RTKConfigUpdateWorker.kt b/app/src/main/java/safeluck/drive/evaluation/DB/rtktb/RTKConfigUpdateWorker.kt index b87b8ce..54e7565 100644 --- a/app/src/main/java/safeluck/drive/evaluation/DB/rtktb/RTKConfigUpdateWorker.kt +++ b/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, "瑙f瀽涔嬪悗鐨勮溅妯″瀷=$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() +// } } } diff --git a/app/src/main/java/safeluck/drive/evaluation/app.java b/app/src/main/java/safeluck/drive/evaluation/app.java index 2401054..23357ad 100644 --- a/app/src/main/java/safeluck/drive/evaluation/app.java +++ b/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()); - - } - } } diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/InspectSignalFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/InspectSignalFragment.java index dc0c870..6b3b62f 100644 --- a/app/src/main/java/safeluck/drive/evaluation/fragment/InspectSignalFragment.java +++ b/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); + } + }); + } } + } + } }; -- Gitblit v1.8.0