From 8ee5db35d4b70cd13ca31d3783f427208aa8c0a4 Mon Sep 17 00:00:00 2001
From: endian11 <Dana_Lee1016@126.com>
Date: 星期五, 04 十二月 2020 11:36:56 +0800
Subject: [PATCH] 重构发送初始数据 ,改在蓝牙连接状态之后发送初始数据和考试状态
---
app/src/main/java/safeluck/drive/evaluation/util/DataInit.kt | 42 ++++-
app/src/main/java/safeluck/drive/evaluation/app.java | 165 ++-----------------
app/src/main/java/safeluck/drive/evaluation/DB/rtktb/RTKConfigUpdateWorker.kt | 6
app/src/main/java/safeluck/drive/evaluation/MainActivity.java | 53 +----
app/src/main/java/safeluck/drive/evaluation/bean/AbsInitialData.java | 142 +++++++++++++++++
app/src/main/java/safeluck/drive/evaluation/bean/UserOpStatus.java | 57 +++++++
app/src/main/java/safeluck/drive/evaluation/fragment/SetArgumentsFragment.java | 7
7 files changed, 278 insertions(+), 194 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 d911339..979950a 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
@@ -64,9 +64,9 @@
phone = sn
Log.i(TAG,"phone="+phone)
- getMap(sn, "road")
- getMap(sn, "yard")
- getMap(sn, "car")
+// getMap(sn, "road")
+// getMap(sn, "yard")
+// getMap(sn, "car")
MyLog.i(PlatFormConstant.TAG,"閲嶇疆TCP杩炴帴")
IMSClientBootstrap.getInstance().resetConnect();
diff --git a/app/src/main/java/safeluck/drive/evaluation/MainActivity.java b/app/src/main/java/safeluck/drive/evaluation/MainActivity.java
index 3303434..9815907 100644
--- a/app/src/main/java/safeluck/drive/evaluation/MainActivity.java
+++ b/app/src/main/java/safeluck/drive/evaluation/MainActivity.java
@@ -37,6 +37,7 @@
import safeluck.drive.evaluation.DB.rtktb.RTKConfigUpdateWorker;
import safeluck.drive.evaluation.DB.rtktb.RTKConfigViewModel;
import safeluck.drive.evaluation.DB.signalConfigdb.SignalConfigViewModel;
+import safeluck.drive.evaluation.bean.AbsInitialData;
import safeluck.drive.evaluation.bean.ExamPlatformData;
import safeluck.drive.evaluation.bean.SignalConfigRemote;
import safeluck.drive.evaluation.cEventCenter.CEventCenter;
@@ -64,6 +65,7 @@
import safeluck.drive.evaluation.platformMessage.JKMessage0101;
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.PermissionManager;
import safeluck.drive.evaluation.util.SPUtils;
@@ -130,12 +132,14 @@
break;
case 1:
des ="钃濈墮鎵撳紑";
+
break;
case 2:
des ="钃濈墮鏈繛鎺�";
break;
case 3:
- authMapViewmodel.setAuthValue(3);
+ //闇�瑕佸欢杩熷啀鍙戦�侊紝鍥犱负鍙戦�佽摑鐗欏凡杩炴帴鍦ㄥ墠锛屾敹鍒皊n鍦ㄥ悗锛屾墍浠ュ欢杩熷彂閫�3 锛屽彲浠ュ彇寰梥n
+ scheduledExecutorService.schedule(()->{ authMapViewmodel.setAuthValue(3);},1,TimeUnit.SECONDS);
des ="钃濈墮杩炴帴";
String mac = jsonObject.getString("bluetooth_addr");
SPUtils.put(getApplicationContext(),SPUtils.BLUETOOTH_MAC,mac);
@@ -222,10 +226,14 @@
if (integer.intValue() == Constant.BLUETOOTH_CONNECT){
MyLog.i(TAG,"Bluetooth connected锛宎uth permission and sn != null");
String sn = ExamPlatformData.getInstance().getMcuSN();
- MyLog.i(TAG,"鏉冮檺鍏佽锛岃幏寰楀埌鐨剆n="+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).setInputData(data).build();
- WorkManager.getInstance(getApplicationContext()).enqueue(rtkConfigUpdateWorker);
+ if (!TextUtils.isEmpty(sn)){
+
+ MyLog.i(TAG,"鏉冮檺鍏佽,钃濈墮宸茶繛鎺ワ紝鑾峰緱鍒扮殑sn="+sn);
+ AbsInitialData.getInstance().sendInitialData();
+ }else{
+ MyLog.i(TAG,"鏉冮檺鍏佽,钃濈墮宸茶繛鎺ワ紝鑾峰緱鍒扮殑sn=null,涓嶈兘鍙戦�佸垵濮嬫暟鎹�");
+ }
+
}
}
});
@@ -336,42 +344,9 @@
private void setSDAuthAndSendJudgeArg() {
ExamPlatformData.getInstance().setCanWriteSD(true);
//鍙app涓嶉攢姣侊紙閲嶅惎锛夊彧浼氳姹備竴娆★紝浣嗘槸纭繚PERMISSIONS鏈�鍚庝竴涓厓绱犳槸writeSD
- CThreadPoolExecutor.runInBackground(()->{
- MyLog.i(TAG,"鏉冮檺鍏佽锛屽紑濮嬪彂閫侀厤缃弬鏁�");
- sendJudgeArgs();
- });
+
}
- private void sendJudgeArgs() {
- FileUtil.createdirs(getApplicationContext());
- File dir = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+File.separator+getPackageName());
-
- List<String> names = ExamPlatformData.getRulesettingFilesName();
- for (int i = 0; i < names.size(); i++) {
- File settFile = new File(dir,names.get(i));
- if (settFile.exists() ){
- Log.i(TAG,settFile.getName()+"瀛樺湪涓嶅鍒�");
- }else{
- Log.i(TAG,settFile.getName()+"涓嶅瓨鍦紝澶嶅埗...");
- FileUtil.copyAssertFileToSD(getApplicationContext(),names.get(i));
- }
- }
-
- if (dir.exists()){
- File[] files = dir.listFiles();
- for (int i = 0; i < files.length; i++) {
- Log.i(TAG,files[i].getName());
- if (names.contains(files[i].getName())){
-
-
- byte[] buffer = FileUtil.readFile(files[i].getAbsolutePath());
- AYSdk.getInstance().sendCmd(Constant.ID_judge_args,new String(buffer).trim());
- }else{
-
- }
- }
- }
- }
@Override
protected void onDestroy() {
super.onDestroy();
diff --git a/app/src/main/java/safeluck/drive/evaluation/app.java b/app/src/main/java/safeluck/drive/evaluation/app.java
index 0bd8129..fe1b37f 100644
--- a/app/src/main/java/safeluck/drive/evaluation/app.java
+++ b/app/src/main/java/safeluck/drive/evaluation/app.java
@@ -3,7 +3,6 @@
import android.app.Application;
import android.content.Context;
import android.os.Environment;
-import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
@@ -32,13 +31,10 @@
import org.json.JSONException;
import org.json.JSONObject;
-import java.io.BufferedReader;
import java.io.File;
-import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
-import java.util.concurrent.Executors;
import safeluck.drive.evaluation.DB.WorkRoomDataBase;
import safeluck.drive.evaluation.DB.appstatusdb.AppStatusWorker;
@@ -46,17 +42,15 @@
import safeluck.drive.evaluation.DB.criterias.CriteriaForIII;
import safeluck.drive.evaluation.DB.exam_status.ExamStatus;
import safeluck.drive.evaluation.DB.exam_status.ExamStatusOutWorker;
-import safeluck.drive.evaluation.DB.exam_status.ExamStatusWoker;
import safeluck.drive.evaluation.DB.failitems.FailedProj;
import safeluck.drive.evaluation.DB.failitems.LuKaoFailedProj;
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.CEvent;
import safeluck.drive.evaluation.cEventCenter.CEventCenter;
import safeluck.drive.evaluation.im.MessageProcessor;
import safeluck.drive.evaluation.platformMessage.AttachInfo;
@@ -64,7 +58,6 @@
import safeluck.drive.evaluation.platformMessage.JKMessage0203;
import safeluck.drive.evaluation.platformMessage.JKMessage0206;
import safeluck.drive.evaluation.platformMessage.PlatFormConstant;
-import safeluck.drive.evaluation.routecollect.RouteCollectController;
import safeluck.drive.evaluation.util.CThreadPoolExecutor;
import safeluck.drive.evaluation.util.DataInitKt;
import safeluck.drive.evaluation.util.FileUtil;
@@ -72,7 +65,7 @@
import safeluck.drive.evaluation.util.SystemUtil;
import safeluck.drive.evaluation.util.Utils;
-import static safeluck.drive.evaluation.bean.ExamPlatformData.getRulesettingFilesName;
+import static safeluck.drive.evaluation.util.DataInitKt.sendJudgeArgs;
/**
* MyApplication2
@@ -115,7 +108,8 @@
//鑰冭瘯鐘舵�� 锛屼竴浜涘垵濮嬬姸鎬侊紝app涓�浜涚姸鎬佸簲璇ュ厛鍒濆鍖栦竴涓�
-
+// ExamPlatformData.getInstance().setMcuSN("0314200100000004");
+// ExamPlatformData.getInstance().setCanWriteSD(true);
}
}
@@ -123,21 +117,9 @@
private void initData() {
CThreadPoolExecutor.runInBackground(()->{
-
int type = WorkRoomDataBase.getWorkRoomDataBase(getApplicationContext()).getExamStatusDao().getStartExamInt();
- MyLog.i("寮�濮嬪垵濮嬪寲鏁版嵁鍙戦�佸湴鍥�/杞﹁締/mcu鍗囩骇鏂囦欢/鑰冭瘯鐘舵��="+type);
- ExamPlatformData.getInstance().setExamType(type);
-// OneTimeWorkRequest examStatausOutWorker = OneTimeWorkRequest.from(ExamStatusOutWorker.class);
-// sendMapInfo();
-// sendVechileInfo();
- sendRouteExam();
-// DataInitKt.MCUUpgrade(getApplicationContext());
- DataInitKt.sendExamLights(getApplicationContext());
- DataInitKt.sendRtkConfig(getApplicationContext());
-// DataInitKt.sendSignalConfigToRemote(getApplicationContext());
-// OneTimeWorkRequest mcuUpgradeWorker = OneTimeWorkRequest.from(MCUUpgradeWorker.class);
-// WorkManager.getInstance(getApplicationContext()).beginWith(examStatausOutWorker).then(mcuUpgradeWorker).enqueue();
-
+ MyLog.i("鑰冭瘯鐘舵��="+type);
+ ExamPlatformData.getInstance().setExamType(type);
//鍙戦�佽摑鐗欓厤缃秷鎭�
String mac= (String) SPUtils.get(getAppContext(),SPUtils.BLUETOOTH_MAC,"");
if (!TextUtils.isEmpty(mac)){
@@ -153,6 +135,17 @@
Log.i(TAG,json);
AYSdk.getInstance().sendCmd(Constant.ID_MS_BLUETOOTH_NAME,json);
}
+
+
+ sendRouteExam();
+ DataInitKt.sendRtkConfig(getApplicationContext());
+// DataInitKt.MCUUpgrade(getApplicationContext());
+
+ //鏀瑰湪钃濈墮宸茬粡杩炴帴锛屽彂閫乮nitialdata
+
+
+
+
@@ -221,35 +214,7 @@
AYSdk.getInstance().sendCmd(0x8017,str);
}
- private void sendJudgeArgs() {
- File dir = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+File.separator+getPackageName());
- List<String> names = ExamPlatformData.getRulesettingFilesName();
- for (int i = 0; i < names.size(); i++) {
- File settFile = new File(dir,names.get(i));
- if (settFile.exists() ){
- Log.i(TAG,settFile.getName()+"瀛樺湪涓嶅鍒�");
- }else{
- Log.i(TAG,settFile.getName()+"涓嶅瓨鍦紝澶嶅埗...");
- FileUtil.copyAssertFileToSD(getApplicationContext(),names.get(i));
- }
- }
-
- if (dir.exists()){
- File[] files = dir.listFiles();
- for (int i = 0; i < files.length; i++) {
- Log.i(TAG,files[i].getName());
- if (names.contains(files[i].getName())){
-
-
- byte[] buffer = FileUtil.readFile(files[i].getAbsolutePath());
- AYSdk.getInstance().sendCmd(Constant.ID_judge_args,new String(buffer).trim());
- }else{
-
- }
- }
- }
- }
public static Context getAppContext(){
return appContext;
@@ -424,11 +389,12 @@
}
}
- sendMapInfo();
+ DataInitKt.sendMapInfo();
+ DataInitKt.sendRoadMapInfo();
break;
case -2:
- sendVechileInfo();
+ DataInitKt.sendVehicleInfo();
break;
case -3:
Data data = new Data.Builder().putInt(Constant.NEED_MAPS_CAR,1).build();
@@ -457,7 +423,7 @@
break;
case Constant.REQ_VECHILE_PROFILE:
- sendVechileInfo();
+ DataInitKt.sendVehicleInfo();
break;
case Constant.GPS_INFO:
Data gpsData = new Data.Builder().putString(Constant.GPS_INFO_DATA,json).build();
@@ -679,6 +645,7 @@
initData();
}else{
ExamPlatformData.getInstance().getTTS().speak("鏈嶅姟寮傚父姝讳骸");
+ AbsInitialData.getInstance().resethasSendInitData();
}
@@ -705,94 +672,6 @@
return false;
}
- private void sendVechileInfo() {
-
- String carPath = ExamPlatformData.getInstance().getCarModelPath();
- if (!TextUtils.isEmpty(carPath)){
- MyLog.i("浣跨敤鏇存柊鍚庣殑Car妯″瀷鍦板浘"+carPath);
- byte[] bytes = FileUtil.readFile(carPath);
- if (bytes != null){
- String str = new String(bytes);
- 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{
- CThreadPoolExecutor.runOnMainThread(()->{
- MyLog.i("杞﹁締妯″瀷鍙戦�佸け璐ワ紝璇锋墜鍔ㄨ缃�");
- Toast.makeText(getAppContext(), "杞﹁締妯″瀷鍙戦�佸け璐ワ紝璇锋墜鍔ㄨ缃�", Toast.LENGTH_SHORT).show();
- });
- }
-
-
- }
-
- private void sendMapInfo(){
-
- final String mapPath = ExamPlatformData.getInstance().getMapPath();
- final String roadmapPath = ExamPlatformData.getInstance().getRoadMapPath();
-
- if (!TextUtils.isEmpty(roadmapPath)){
- MyLog.i("璋冪敤鏇存柊RoadMap璺緞鍚庣殑鍦板浘"+roadmapPath);
- byte[] fileContent = FileUtil.readFile(roadmapPath);
- if (fileContent != null){
- String str = new String(fileContent);
- MyLog.i("鏂囦欢鍐呭锛�"+str);
- AYSdk.getInstance().sendCmd(Constant.PUSH_ROAD_MAP_INFO,str);
- }else{
- MyLog.i(String.format("鏂囦欢:%s涓嶅瓨鍦�",roadmapPath));
- CThreadPoolExecutor.runOnMainThread(new Runnable() {
- @Override
- public void run() {
- Toast.makeText(getAppContext(), "鏂囦欢锛�"+roadmapPath+"涓嶅瓨鍦�", Toast.LENGTH_SHORT).show();
- }
- });
- }
- }else{
- 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);
- byte[] fileContent = FileUtil.readFile(mapPath);
- if (fileContent != null){
- String str = new String(fileContent);
- Log.i(TAG, "鏂囦欢鍐呭锛�"+str);
- AYSdk.getInstance().sendCmd(Constant.PUSH_MAP_INFO,str);
- }else{
- MyLog.i(String.format("鏂囦欢:%s涓嶅瓨鍦�",mapPath));
-
- CThreadPoolExecutor.runOnMainThread(new Runnable() {
- @Override
- public void run() {
- Toast.makeText(getAppContext(), "鏂囦欢锛�"+mapPath+"涓嶅瓨鍦�", Toast.LENGTH_SHORT).show();
- }
- });
- }
- }else{
- CThreadPoolExecutor.runOnMainThread(new Runnable() {
- @Override
- public void run() {
- MyLog.i("鍦哄湴鍦板浘鍙戦�佸け璐ワ紝璇锋墜鍔ㄨ缃�");
- Toast.makeText(getAppContext(), "鍦哄湴鍦板浘鍙戦�佸け璐ワ紝璇锋墜鍔ㄨ缃�", Toast.LENGTH_SHORT).show();
- }
- });
- }
-
-
-
- }
}
diff --git a/app/src/main/java/safeluck/drive/evaluation/bean/AbsInitialData.java b/app/src/main/java/safeluck/drive/evaluation/bean/AbsInitialData.java
new file mode 100644
index 0000000..37bcad6
--- /dev/null
+++ b/app/src/main/java/safeluck/drive/evaluation/bean/AbsInitialData.java
@@ -0,0 +1,142 @@
+package safeluck.drive.evaluation.bean;
+
+import android.os.Environment;
+import android.renderscript.Element;
+import android.text.TextUtils;
+import android.util.Log;
+import android.widget.Toast;
+
+import com.anyun.basecommonlib.MyLog;
+import com.anyun.exam.lib.AYSdk;
+import com.google.gson.Gson;
+
+import org.json.JSONObject;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import okhttp3.ResponseBody;
+import retrofit2.Call;
+import retrofit2.Callback;
+import retrofit2.Response;
+import safeluck.drive.evaluation.Constant;
+import safeluck.drive.evaluation.app;
+import safeluck.drive.evaluation.httpmodule.HttpCarRespBean;
+import safeluck.drive.evaluation.httpmodule.HttpRequetBean;
+import safeluck.drive.evaluation.httpmodule.HttpRoadMapRsp;
+import safeluck.drive.evaluation.httpmodule.HttpYardRsp;
+import safeluck.drive.evaluation.httpmodule.RetrofitCreator;
+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 static safeluck.drive.evaluation.util.DataInitKt.sendJudgeArgs;
+
+/**
+ * DriveJudge
+ * Created by lzw on 2020/12/3. 15:45:26
+ * 閭锛�632393724@qq.com
+ * All Rights Saved! Chongqing AnYun Tech co. LTD
+ */
+public class AbsInitialData {
+ private UserOpStatus userOpStatus = UserOpStatus.getInstance();
+ private static boolean hasSend = false;
+
+ public static AbsInitialData getInstance(){
+ return new AbsInitialData();
+ }
+
+ private boolean checkPermission(){
+ return ExamPlatformData.getInstance().isCanWriteSD();
+ }
+
+ /***
+ * 濡傛灉鏈嶅姟寮傚父姝讳骸锛屽彲浠ョ疆hasSend涓篺alse锛岀劧鍚巗endINintdata
+ */
+ public void resethasSendInitData(){
+ hasSend = false;
+ }
+
+ /**********f鍙戦�佺伅鍏夎�冭瘯椤瑰拰鑰冭瘯鐘舵��**********/
+ private void sendLightsAndExamStatus(){
+ DataInitKt.sendExamLightsAndExamStatus(app.getAppContext());
+ }
+
+ private void sendCarModelFile(){
+ if (userOpStatus.getCarFileSelectState()== UserOpStatus.State.SELECT_CAR_FILE_STATE){
+ MyLog.i("鐢ㄦ埛鍦ㄨ缃噷闈㈤�夋嫨杞︽ā鍨嬫枃浠�");
+ DataInitKt.sendVehicleInfo();
+ }else{
+ MyLog.i("鐢ㄦ埛娌℃湁鍦ㄨ缃噷闈㈤�夋嫨杞︽ā鍨嬫枃浠讹紝鍒欒繘琛宧tp璇锋眰(鍏堟鏌n鏄惁涓虹┖)");
+ if (ExamPlatformData.getInstance().getMcuSN() != null){
+ DataInitKt.getMap(ExamPlatformData.getInstance().getMcuSN(),"car");
+ }else{
+ MyLog.i("sn涓虹┖锛屼笉鑳借姹俬ttp涓嬭浇杞︽ā鍨�");
+ }
+ }
+
+ }
+ private void sendRoadMapFile(){
+ if (userOpStatus.getRoadFileSelectState()== UserOpStatus.State.SELECT_ROAD_MAP_STATE){
+ MyLog.i("鐢ㄦ埛鍦ㄨ缃噷闈㈤�夋嫨杞︽ā鍨嬫枃浠�");
+ DataInitKt.sendRoadMapInfo();
+ }else{
+ MyLog.i("鐢ㄦ埛娌℃湁鍦ㄨ缃噷闈㈤�夋嫨杞︽ā鍨嬫枃浠讹紝鍒欒繘琛宧tp璇锋眰(鍏堟鏌n鏄惁涓虹┖)");
+ if (ExamPlatformData.getInstance().getMcuSN() != null){
+ DataInitKt.getMap(ExamPlatformData.getInstance().getMcuSN(),"road");
+ }else{
+ MyLog.i("sn涓虹┖锛屼笉鑳借姹俬ttp涓嬭浇閬撹矾");
+ }
+ }
+ }
+
+
+ private void sendItemsMapFile(){
+
+ if (userOpStatus.getItemsFileSelectState()== UserOpStatus.State.SELECT_ITEMS_MAP_STATE){
+ MyLog.i("鐢ㄦ埛鍦ㄨ缃噷闈㈤�夋嫨鍦哄湴鏂囦欢");
+ DataInitKt.sendMapInfo();
+ }else{
+ MyLog.i("鐢ㄦ埛娌℃湁鍦ㄨ缃噷闈㈤�夋嫨鍦哄湴鏂囦欢锛屽垯杩涜htp璇锋眰(鍏堟鏌n鏄惁涓虹┖)");
+ if (ExamPlatformData.getInstance().getMcuSN() != null){
+ DataInitKt.getMap(ExamPlatformData.getInstance().getPhone(),"yard");
+ }else{
+ MyLog.i("sn涓虹┖锛屼笉鑳借姹俬ttp涓嬭浇鍦哄湴");
+ }
+ }
+ }
+ ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
+ public synchronized void sendInitialData(){
+ if (checkPermission() && !hasSend){
+ /**********鍙湁鏉冮檺婊¤冻锛堣鍐橲D鍗℃潈闄愶級鍜屾病鏈夊彂閫佽繃鐨勬儏鍐典笅鎵嶈繘琛屼互涓嬫搷浣�*********/
+ hasSend = true;
+ sendCarModelFile();
+ sendRoadMapFile();
+ sendItemsMapFile();
+ sendJudgeArgs();
+//闇�瑕佸欢杩熷彂閫侊紝鍥犱负鍓嶉潰鏈塰ttp璇锋眰
+ executorService.schedule(()->{
+ Log.i("AYJiaKao","寤惰繜鍙戦��");
+ sendLightsAndExamStatus();},1, TimeUnit.SECONDS);
+
+
+ }else{
+ MyLog.i(hasSend?"宸茬粡鍙戦�佽繃浜嗗垵濮嬫暟鎹�":"鏉冮檺涓嶅厑璁革紝涓嶈兘鍙戦�佸垵濮嬫暟鎹�");
+ }
+
+ }
+
+
+
+
+
+
+
+
+
+}
diff --git a/app/src/main/java/safeluck/drive/evaluation/bean/UserOpStatus.java b/app/src/main/java/safeluck/drive/evaluation/bean/UserOpStatus.java
new file mode 100644
index 0000000..2568f86
--- /dev/null
+++ b/app/src/main/java/safeluck/drive/evaluation/bean/UserOpStatus.java
@@ -0,0 +1,57 @@
+package safeluck.drive.evaluation.bean;
+
+/**
+ * DriveJudge
+ *
+ * 鐢ㄦ埛鎵嬪姩鍦ㄨ缃噷闈㈤�夋嫨 杞﹁締妯″瀷鏂囦欢锛岀浜� 銆佺涓夊湴鍥炬枃浠�
+ * Created by lzw on 2020/12/3. 15:37:53
+ * 閭锛�632393724@qq.com
+ * All Rights Saved! Chongqing AnYun Tech co. LTD
+ */
+public class UserOpStatus {
+ public static UserOpStatus getInstance() {
+ return new UserOpStatus();
+ }
+private UserOpStatus(){}
+ public enum State{
+ SELECT_NOEN_STATE,SELECT_CAR_FILE_STATE,SELECT_ROAD_MAP_STATE,SELECT_ITEMS_MAP_STATE
+ }
+ /*******榛樿鏄病鏈夋墜鍔ㄩ�夋嫨鏂囦欢锛屾槸閫氳繃http杩涜涓嬭浇鐒跺悗淇濆瓨鍙戦�佸湴鍥炬枃浠躲�佽溅杈嗘枃浠�********/
+ private State carFileSelectState = State.SELECT_NOEN_STATE;
+ private State roadFileSelectState = State.SELECT_NOEN_STATE;
+ private State itemsFileSelectState = State.SELECT_NOEN_STATE;
+
+ public State getCarFileSelectState() {
+ return carFileSelectState;
+ }
+
+ public void setCarFileSelectState(State carFileSelectState) {
+ this.carFileSelectState = carFileSelectState;
+ }
+
+ public State getRoadFileSelectState() {
+ return roadFileSelectState;
+ }
+
+ public void setRoadFileSelectState(State roadFileSelectState) {
+ this.roadFileSelectState = roadFileSelectState;
+ }
+
+ public State getItemsFileSelectState() {
+ return itemsFileSelectState;
+ }
+
+ public void setItemsFileSelectState(State itemsFileSelectState) {
+ this.itemsFileSelectState = itemsFileSelectState;
+ }
+
+ public void resetItemsFileSelectState(){
+ itemsFileSelectState = State.SELECT_NOEN_STATE;
+ }
+ public void resetRoadFileSelectState(){
+ roadFileSelectState = State.SELECT_NOEN_STATE;
+ }
+ public void resetCarFileSelectState(){
+ carFileSelectState = State.SELECT_NOEN_STATE;
+ }
+}
diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/SetArgumentsFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/SetArgumentsFragment.java
index 388600a..2229bc5 100644
--- a/app/src/main/java/safeluck/drive/evaluation/fragment/SetArgumentsFragment.java
+++ b/app/src/main/java/safeluck/drive/evaluation/fragment/SetArgumentsFragment.java
@@ -54,6 +54,7 @@
import safeluck.drive.evaluation.adapter.WrapContentLinearLayoutManager;
import safeluck.drive.evaluation.bean.ExamPlatformData;
import safeluck.drive.evaluation.bean.MCUInfo;
+import safeluck.drive.evaluation.bean.UserOpStatus;
import safeluck.drive.evaluation.cEventCenter.CEventCenter;
import safeluck.drive.evaluation.cEventCenter.ICEventListener;
import safeluck.drive.evaluation.customview.MyArgEditText;
@@ -269,14 +270,17 @@
case R.id.btn_car_upgrade:
Toast.makeText(_mActivity, "鏇存柊杞︽ā鍨�", Toast.LENGTH_SHORT).show();
DataInitKt.getMap(ExamPlatformData.getInstance().getPhone(),"car");
+ UserOpStatus.getInstance().resetCarFileSelectState();
break;
case R.id.btn_yard_update:
Toast.makeText(_mActivity, "鏇存柊鍦哄湴鍦板浘", Toast.LENGTH_SHORT).show();
DataInitKt.getMap(ExamPlatformData.getInstance().getPhone(),"yard");
+ UserOpStatus.getInstance().resetItemsFileSelectState();
break;
case R.id.btn_road_update:
Toast.makeText(_mActivity, "鏇存柊閬撹矾鍦板浘", Toast.LENGTH_SHORT).show();
DataInitKt.getMap(ExamPlatformData.getInstance().getPhone(),"road");
+ UserOpStatus.getInstance().resetRoadFileSelectState();
break;
default:
break;
@@ -302,6 +306,7 @@
if (data != null){
final Uri uri= data.getData();
Log.i(TAG, "onActivityResult: "+uri.getPath());
+ UserOpStatus.getInstance().setItemsFileSelectState(UserOpStatus.State.SELECT_ITEMS_MAP_STATE);
ExamPlatformData.getInstance().setNewMapPath(uri.getPath());
CThreadPoolExecutor.runInBackground(()-> {
@@ -321,6 +326,7 @@
final Uri uri= data.getData();
Log.i(TAG, "onActivityResult: "+uri.getPath());
ExamPlatformData.getInstance().setCarModelPath(uri.getPath());
+ UserOpStatus.getInstance().setCarFileSelectState(UserOpStatus.State.SELECT_CAR_FILE_STATE);
CThreadPoolExecutor.runInBackground(()-> {
byte[] fileContent = FileUtil.readFile(uri.getPath());
@@ -339,6 +345,7 @@
final Uri uri= data.getData();
Log.i(TAG, "onActivityResult: "+uri.getPath());
ExamPlatformData.getInstance().setNewRoadMapPath(uri.getPath());
+ UserOpStatus.getInstance().setRoadFileSelectState(UserOpStatus.State.SELECT_ROAD_MAP_STATE);
CThreadPoolExecutor.runInBackground(() -> {
byte[] fileContent = FileUtil.readFile(uri.getPath());
if (fileContent != null){
diff --git a/app/src/main/java/safeluck/drive/evaluation/util/DataInit.kt b/app/src/main/java/safeluck/drive/evaluation/util/DataInit.kt
index c722b2d..3dd8ff5 100644
--- a/app/src/main/java/safeluck/drive/evaluation/util/DataInit.kt
+++ b/app/src/main/java/safeluck/drive/evaluation/util/DataInit.kt
@@ -6,9 +6,8 @@
import android.util.Log
import android.widget.Toast
import androidx.work.Data
-import androidx.work.ListenableWorker
-import com.anyun.exam.lib.AYSdk
import com.anyun.basecommonlib.MyLog
+import com.anyun.exam.lib.AYSdk
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.google.gson.stream.JsonReader
@@ -18,7 +17,6 @@
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
-import retrofit2.http.Url
import safeluck.drive.evaluation.Constant
import safeluck.drive.evaluation.DB.WorkRoomDataBase
import safeluck.drive.evaluation.DB.rtktb.RTKConfig
@@ -31,10 +29,9 @@
import safeluck.drive.evaluation.httpmodule.HttpYardRsp
import safeluck.drive.evaluation.httpmodule.RetrofitCreator.Companion.getRestService
import safeluck.drive.evaluation.platformMessage.PlatFormConstant
-import safeluck.drive.evaluation.worker.MCUUpgradeWorker
+import java.io.File
import java.io.IOException
import java.io.InputStreamReader
-import java.net.URL
import java.net.URLDecoder
import java.nio.charset.Charset
@@ -75,7 +72,7 @@
private val gson = Gson()
private val tempQs: MutableList<SimulateNightBean.QuestionBean> = java.util.ArrayList()
var simulateNightBean:SimulateNightBean=SimulateNightBean()
-fun sendExamLights(applicationContext: Context){
+fun sendExamLightsAndExamStatus(applicationContext: Context){
MyLog.i("鍙戦�佺伅鍏�")
val examType = ExamPlatformData.getInstance().examType
@@ -327,7 +324,7 @@
}
-private fun sendMapInfo(){
+ fun sendMapInfo(){
val mapPath = ExamPlatformData.getInstance().mapPath
@@ -344,7 +341,7 @@
}
}
-private fun sendVehicleInfo(){
+ fun sendVehicleInfo(){
val carPath = ExamPlatformData.getInstance().carModelPath
if (!TextUtils.isEmpty(carPath)) {
MyLog.i("鏇存柊鍚庣殑Car妯″瀷$carPath")
@@ -357,7 +354,7 @@
}
}
}
-private fun sendRoadMapInfo(){
+ fun sendRoadMapInfo(){
val roadmapPath = ExamPlatformData.getInstance().roadMapPath
if (!TextUtils.isEmpty(roadmapPath)) {
@@ -374,3 +371,30 @@
}
}
+
+
+ fun sendJudgeArgs() {
+ val dir = File(Environment.getExternalStorageDirectory().absolutePath + File.separator + app.getAppContext().getPackageName())
+ val names = ExamPlatformData.getRulesettingFilesName()
+ for (i in names.indices) {
+ val settFile = File(dir, names[i])
+ if (settFile.exists()) {
+ Log.i("app.TAG", settFile.name + "瀛樺湪涓嶅鍒�")
+ } else {
+ Log.i("app.TAG", settFile.name + "涓嶅瓨鍦紝澶嶅埗...")
+ FileUtil.copyAssertFileToSD(app.getAppContext().applicationContext, names[i])
+ }
+ }
+ if (dir.exists()) {
+ val files = dir.listFiles()
+ for (i in files.indices) {
+ Log.i("app.TAG", files[i].name+" names.size="+names.size)
+ if (names.contains(files[i].name)) {
+ val buffer = FileUtil.readFile(files[i].absolutePath)
+ var str =String(buffer)
+ AYSdk.getInstance().sendCmd(Constant.ID_judge_args, str)
+ } else {
+ }
+ }
+ }
+}
--
Gitblit v1.8.0