移动站服务报错误信息的时候,给ExamOUtWorker设置输入参数,重新发送map和car。 download的时候down那个就发送那个
| | |
| | | "x-y": [16579.3086, -7626.9764, 16579.8354, -7627.7888, 16580.3393, -7628.4316, 16581.181, -7629.2701, 16582.0667, -7629.9052, 16583.1605, -7630.4413, 16584.3072, -7630.818, 16585.5416, -7630.993, 16586.918, -7630.9599, 16588.0948, -7630.7205, 16589.1489, -7630.3119, 16590.3826, -7629.6211, 16591.2856, -7628.8977, 16592.0383, -7628.0128, 16592.8408, -7626.7007, 16593.3354, -7625.4394, 16593.886, -7624.4265, 16594.9656, -7623.4808, 16596.0498, -7623.0286, 16597.3348, -7622.955, 16598.4564, -7623.2286, 16599.4254, -7623.7931, 16600.1166, -7624.5026] |
| | | }] |
| | | }], |
| | | "name": "科二场考地图", |
| | | "name": "app自带场考地图", |
| | | "type": "yard" |
| | | } |
| | |
| | | { |
| | | "points": [0, 1, 1.6, 1, 2.55, 1, 3.05, 1, 4.55, 1, 5.003, 1, 6.003, 1, 9.003, 1, 9.003, 4, 0, 0.5, 9.003, 0.5, 0, 0, 1.6, 0, 2.55, 0, 3.05, 0, 4.55, 0, 5.003, 0, 5.003, -2, 5.003, -3, 5.003, -4, 6.003, -4, 7.003, -4, 9.003, -4, 10.003, -4, 10.003, -3, 10.003, 4, 6.003, 0, 9.003, 0, 6.003, 0, 6.003, -3, 9.003, -3, 9.003, 0, 5.503, 0, 5.503, -2, 5.503, -3.5, 7.003, -3.5, 9.503, -3.5, 9.503, 4, 1.6, 1, 1.6, 0, 2.55, 1, 2.55, 0, 3.05, 0, 3.05, 1, 4.55, 1, 4.55, 0, 5.003, 1, 5.003, 0, 6.003, 0, 6.003, 1, 6.003, -2, 5.003, -2, 6.003, -3, 5.003, -3, 5.003, -4, 6.003, -4, 9.003, -1, 10.003, -1, 9.003, 0, 10.003, 0, 10.003, 1, 9.003, 1,11.003,4,11.003,-4,10.5003,4,10.5003,-4, |
| | | 10.003,3,9.003,3,10.003,4,9.003,4,11.003,4,10.003,4,11.003,3,10.003,3,11.003,1,10.003,1,11.003,0,10.003,0,11.003,-1,10.003,-1,11.003,-2,10.003,-2,10.5003,-3,10.5003,-3,11.003,-3,10.003,-3], |
| | | "name": "科三路考地图", |
| | | "name": "app自带路考地图", |
| | | "type": "road", |
| | | "maps": [{ |
| | | "id": 1000, |
| | |
| | | public static final String RTK_INFO_SAT_QF = "RTK_INFO_SAT_QF";//从RTK info中获取的卫星颗数和qf 组成的json |
| | | public static final int SUBJECT_III = 3;//路考 |
| | | public static final int LEFT_RIGHT_DISTANCE = 0x0020; |
| | | public static final String NEED_MAPS_CAR = "need_maps_car"; |
| | | public static String exam_enter_exitdata="exam_enter_exitdata"; |
| | | public static int Chang_di = 2; |
| | | public static int DaoLu_night = 3; |
| | |
| | | tempQs.add(list[list.size-1])//提示灯光考试结束 |
| | | simulateNightBean.setQuestion(tempQs) |
| | | AYSdk.getInstance().sendCmd(0x8012, gson.toJson(simulateNightBean)) |
| | | sendMapInfo() |
| | | sendVehicleInfo() |
| | | if (inputData.getInt(safeluck.drive.evaluation.Constant.NEED_MAPS_CAR,0)==1){ |
| | | sendMapInfo() |
| | | sendVehicleInfo() |
| | | } |
| | | |
| | | |
| | | MyLog.i(TAG,"查到的考试type="+examType) |
| | | ExamPlatformData.getInstance().examType = examType |
| | |
| | | import retrofit2.Response |
| | | import safeluck.drive.evaluation.DB.Constant |
| | | import safeluck.drive.evaluation.DB.WorkRoomDataBase |
| | | import safeluck.drive.evaluation.app |
| | | import safeluck.drive.evaluation.bean.ExamPlatformData |
| | | import safeluck.drive.evaluation.httpmodule.HttpCarRespBean |
| | | import safeluck.drive.evaluation.httpmodule.HttpRequetBean |
| | |
| | | phone = sn |
| | | Log.i(TAG,"phone="+phone) |
| | | |
| | | if (!FileUtil.isMapExist(applicationContext,"map.json")){ |
| | | MyLog.i("地图文件不存在,去平台取") |
| | | getRestService().getMapsAndVehicleModel(HttpRequetBean(sn, "place")).enqueue(object : Callback<ResponseBody> { |
| | | override fun onResponse(call: Call<ResponseBody>, response: Response<ResponseBody>) { |
| | | var str: String? = null |
| | | try { |
| | | str = response.body()!!.string() |
| | | } catch (e: IOException) { |
| | | e.printStackTrace() |
| | | } |
| | | Log.i(TAG, "服务器返回的body=$str") |
| | | getMap(sn, "road") |
| | | getMap(sn, "yard") |
| | | getMap(sn, "car") |
| | | |
| | | jsonObject = JSONObject(str) |
| | | val result = jsonObject!!.getBoolean("result") |
| | | if (result){ |
| | | if (str!!.contains("road")){ |
| | | val map = gson.fromJson<HttpRoadMapRsp>(str,HttpRoadMapRsp::class.java) |
| | | if (map.isResult){ |
| | | if (map.data != null){ |
| | | if (map.data.map_json.type.equals("road")){ |
| | | ExamPlatformData.getInstance().setNewRoadMapPath(Environment.getExternalStorageDirectory().absolutePath + "/" |
| | | + applicationContext.getPackageName() + "/roadmap.json") |
| | | CThreadPoolExecutor.runInBackground(Runnable{ |
| | | str = gson.toJson(map.data.map_json) |
| | | FileUtil.writeTxtFileToSD(applicationContext,"roadmap.json",str,"") |
| | | }) |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | }else{ |
| | | val yard = gson.fromJson<HttpYardRsp>(str,HttpYardRsp::class.java) |
| | | if (yard.isResult){ |
| | | if (yard.data !=null){ |
| | | Log.i(TAG,"yard====") |
| | | ExamPlatformData.getInstance().setNewMapPath(Environment.getExternalStorageDirectory().absolutePath + "/" |
| | | + applicationContext.getPackageName() + "/yard.json") |
| | | CThreadPoolExecutor.runInBackground(Runnable{ |
| | | str = gson.toJson(yard.data.map_json) |
| | | FileUtil.writeTxtFileToSD(applicationContext,"yard.json",str,"") |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | Toast.makeText(applicationContext,jsonObject!!.getString("data"),Toast.LENGTH_SHORT).show() |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | override fun onFailure(call: Call<ResponseBody>, t: Throwable) { |
| | | Log.i(TAG, t.localizedMessage) |
| | | } |
| | | }) |
| | | } |
| | | if (!FileUtil.isMapExist(applicationContext,"car.json")){ |
| | | MyLog.i("车辆模型文件不存在,去平台取") |
| | | getRestService().getMapsAndVehicleModel(HttpRequetBean(sn, "car")).enqueue(object : Callback<ResponseBody> { |
| | | override fun onResponse(call: Call<ResponseBody>, response: Response<ResponseBody>) { |
| | | var str: String? = null |
| | | try { |
| | | str = response.body()!!.string() |
| | | Log.i(TAG, "服务器返回的body=$str") |
| | | jsonObject = JSONObject(str) |
| | | val result = jsonObject!!.getBoolean("result") |
| | | if (result){ |
| | | val car = gson.fromJson<HttpCarRespBean>(str,HttpCarRespBean::class.java) |
| | | |
| | | if (car.isResult){ |
| | | if (car.data !=null){ |
| | | ExamPlatformData.getInstance().carModelPath = Environment.getExternalStorageDirectory().absolutePath + "/" + |
| | | applicationContext.getPackageName() + "/car.json" |
| | | |
| | | Log.i(TAG, "解析之后的车模型=$str") |
| | | CThreadPoolExecutor.runInBackground(Runnable{ |
| | | str = gson.toJson(car.data.map_json) |
| | | FileUtil.writeTxtFileToSD(applicationContext,"car.json",str,"") |
| | | }) |
| | | |
| | | } |
| | | } |
| | | }else{ |
| | | Toast.makeText(applicationContext,jsonObject!!.getString("data"),Toast.LENGTH_SHORT).show() |
| | | } |
| | | |
| | | } catch (e: IOException) { |
| | | e.printStackTrace() |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | override fun onFailure(call: Call<ResponseBody>, t: Throwable) { |
| | | Log.i(TAG, t.localizedMessage) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | MyLog.i(PlatFormConstant.TAG,"重置TCP连接") |
| | | IMSClientBootstrap.getInstance().resetConnect(); |
| | |
| | | |
| | | sendRtkConfigInfo(WorkRoomDataBase.getWorkRoomDataBase(applicationContext).rtkConfigDao._getRtkConfig()) |
| | | return Result.success() |
| | | } |
| | | |
| | | private fun getMap(sn: String, type: String){ |
| | | lateinit var jsonObject1 :JSONObject |
| | | lateinit var fileName :String |
| | | when(type){ |
| | | "road" -> fileName = safeluck.drive.evaluation.Constant.ROAD_MAP |
| | | "yard" -> fileName = safeluck.drive.evaluation.Constant.MAP |
| | | else -> fileName = safeluck.drive.evaluation.Constant.VEHICLE |
| | | } |
| | | if (!FileUtil.isMapExist(applicationContext,fileName)) { |
| | | getRestService().getMapsAndVehicleModel(HttpRequetBean(sn, type)).enqueue(object : Callback<ResponseBody> { |
| | | override fun onFailure(call: Call<ResponseBody>, t: Throwable) { |
| | | MyLog.i(PlatFormConstant.HTTPTAG,t.localizedMessage) |
| | | } |
| | | |
| | | override fun onResponse(call: Call<ResponseBody>, response: Response<ResponseBody>) { |
| | | var str: String = response.body()!!.string() |
| | | MyLog.i(PlatFormConstant.HTTPTAG,str) |
| | | jsonObject1 = JSONObject(str) |
| | | val result = jsonObject1!!.getBoolean("result") |
| | | if (result) { |
| | | when(type){ |
| | | "road" ->{ |
| | | val map = gson.fromJson<HttpRoadMapRsp>(str, HttpRoadMapRsp::class.java) |
| | | if (map.isResult) { |
| | | if (map.data != null) { |
| | | if (map.data.map_json.type.equals("road")) { |
| | | ExamPlatformData.getInstance().setNewRoadMapPath(Environment.getExternalStorageDirectory().absolutePath + "/" |
| | | + applicationContext.getPackageName() + "/" + fileName) |
| | | CThreadPoolExecutor.runInBackground(Runnable { |
| | | str = gson.toJson(map.data.map_json) |
| | | FileUtil.writeTxtFileToSD(applicationContext, fileName, str, "") |
| | | sendRoadMapInfo() |
| | | }) |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | }} |
| | | "yard" ->{ |
| | | val yard = gson.fromJson<HttpYardRsp>(str,HttpYardRsp::class.java) |
| | | if (yard.isResult){ |
| | | if (yard.data !=null){ |
| | | Log.i(TAG,"yard====") |
| | | ExamPlatformData.getInstance().setNewMapPath(Environment.getExternalStorageDirectory().absolutePath + "/" |
| | | + applicationContext.getPackageName() + "/"+fileName) |
| | | CThreadPoolExecutor.runInBackground(Runnable{ |
| | | str = gson.toJson(yard.data.map_json) |
| | | FileUtil.writeTxtFileToSD(applicationContext,fileName,str,"") |
| | | sendMapInfo() |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | else ->{ |
| | | val car = gson.fromJson<HttpCarRespBean>(str,HttpCarRespBean::class.java) |
| | | |
| | | if (car.isResult){ |
| | | if (car.data !=null){ |
| | | ExamPlatformData.getInstance().carModelPath = Environment.getExternalStorageDirectory().absolutePath + "/" + |
| | | applicationContext.getPackageName() + "/"+fileName |
| | | |
| | | Log.i(TAG, "解析之后的车模型=$str") |
| | | CThreadPoolExecutor.runInBackground(Runnable{ |
| | | str = gson.toJson(car.data.map_json) |
| | | FileUtil.writeTxtFileToSD(applicationContext,fileName,str,"") |
| | | sendVehicleInfo() |
| | | }) |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } else { |
| | | Toast.makeText(applicationContext, jsonObject1!!.getString("data"), Toast.LENGTH_SHORT).show() |
| | | } |
| | | } |
| | | }) |
| | | |
| | | }else{ |
| | | MyLog.i(PlatFormConstant.HTTPTAG,"已存在直接发送车辆和地图") |
| | | when(type){ |
| | | "road" -> sendRoadMapInfo() |
| | | "yard" -> sendMapInfo() |
| | | else -> sendVehicleInfo() |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | private fun sendRoadMapInfo(){ |
| | | val roadmapPath = ExamPlatformData.getInstance().roadMapPath |
| | | |
| | | if (!TextUtils.isEmpty(roadmapPath)) { |
| | | MyLog.i("调用更新RoadMap路径后的地图$roadmapPath") |
| | | val fileContent = FileUtil.readFile(roadmapPath) |
| | | if (fileContent != null) { |
| | | val str = String(fileContent) |
| | | Log.i(TAG,"文件内容:$str") |
| | | AYSdk.getInstance().sendCmd(safeluck.drive.evaluation.Constant.PUSH_ROAD_MAP_INFO, str) |
| | | } else { |
| | | MyLog.i(String.format("文件:%s不存在", roadmapPath)) |
| | | CThreadPoolExecutor.runOnMainThread { Toast.makeText(app.getAppContext(), "文件:" + roadmapPath + "不存在", Toast.LENGTH_SHORT).show() } |
| | | } |
| | | } else { |
| | | val buffer: StringBuffer? |
| | | buffer = FileUtil.readAssetTxtFile(applicationContext, safeluck.drive.evaluation.Constant.ROAD_MAP) |
| | | if (buffer != null) { |
| | | AYSdk.getInstance().sendCmd(safeluck.drive.evaluation.Constant.PUSH_ROAD_MAP_INFO, buffer.toString()) |
| | | } else { |
| | | MyLog.i(String.format("地图模型未拷入[%s]目录下", Environment.getExternalStorageDirectory().absolutePath + "/" + applicationContext.packageName)) |
| | | CThreadPoolExecutor.runOnMainThread { Toast.makeText(app.getAppContext(), String.format("地图模型未拷入[%s]目录下", Environment.getExternalStorageDirectory().absolutePath + "/" + applicationContext.packageName), Toast.LENGTH_SHORT).show() } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private fun sendRtkConfigInfo(mRTKConfig: RTKConfig) { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | private fun sendMapInfo(){ |
| | | val mapPath = ExamPlatformData.getInstance().mapPath |
| | | |
| | | |
| | | if (!TextUtils.isEmpty(mapPath)) { |
| | | MyLog.i("调用更新Map路径后的地图$mapPath") |
| | | val fileContent = FileUtil.readFile(mapPath) |
| | | if (fileContent != null) { |
| | | val str = String(fileContent) |
| | | Log.i(TAG,"文件内容:$str") |
| | | AYSdk.getInstance().sendCmd(safeluck.drive.evaluation.Constant.PUSH_MAP_INFO, str) |
| | | } else { |
| | | MyLog.i(String.format("文件:%s不存在", mapPath)) |
| | | CThreadPoolExecutor.runOnMainThread { Toast.makeText(app.getAppContext(), "文件:" + mapPath + "不存在", Toast.LENGTH_SHORT).show() } |
| | | } |
| | | } else { |
| | | MyLog.i("读取Assert目录下初始化的地图") |
| | | var buffer: StringBuffer? |
| | | buffer = FileUtil.readAssetTxtFile(applicationContext, safeluck.drive.evaluation.Constant.MAP) |
| | | if (buffer != null) { |
| | | AYSdk.getInstance().sendCmd(safeluck.drive.evaluation.Constant.PUSH_MAP_INFO, buffer.toString()) |
| | | } else { |
| | | MyLog.i( String.format("地图模型未拷入[%s]目录下", Environment.getExternalStorageDirectory().absolutePath + "/" + applicationContext.packageName)) |
| | | CThreadPoolExecutor.runOnMainThread { Toast.makeText(app.getAppContext(), String.format("地图模型未拷入[%s]目录下", Environment.getExternalStorageDirectory().absolutePath + "/" + applicationContext.packageName), Toast.LENGTH_SHORT).show() } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private fun sendVehicleInfo(){ |
| | | val carPath = ExamPlatformData.getInstance().carModelPath |
| | | if (!TextUtils.isEmpty(carPath)) { |
| | | MyLog.i("使用更新后的Car模型地图$carPath") |
| | | val bytes = FileUtil.readFile(carPath) |
| | | if (bytes != null) { |
| | | val str = String(bytes) |
| | | AYSdk.getInstance().sendCmd(safeluck.drive.evaluation.Constant.PUSH_VECHILE_PROFILE, str) |
| | | } else { |
| | | MyLog.i(String.format("文件:%s不存在", carPath)) |
| | | } |
| | | } else { |
| | | val vebuffer = FileUtil.readAssetTxtFile(applicationContext, safeluck.drive.evaluation.Constant.VEHICLE) |
| | | if (vebuffer != null) { |
| | | AYSdk.getInstance().sendCmd(safeluck.drive.evaluation.Constant.PUSH_VECHILE_PROFILE, vebuffer.toString()) |
| | | } else { |
| | | MyLog.i(String.format("车辆模型模型未拷入[%s]目录下", Environment.getExternalStorageDirectory().absolutePath + "/" + applicationContext.packageName)) |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | // sendVechileInfo(); |
| | | // break; |
| | | case -3: |
| | | OneTimeWorkRequest examStatausOutWorker1 = OneTimeWorkRequest.from(ExamStatusOutWorker.class); |
| | | 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; |
| | | } |
| | |
| | | WorkManager.getInstance(getApplicationContext()).enqueue(oneTimeWorkRequest); |
| | | break; |
| | | case Constant.FETCH_MAP_INFO: |
| | | sendMapInfo(); |
| | | // sendMapInfo(); |
| | | |
| | | break; |
| | | case Constant.REQ_VECHILE_PROFILE: |
| | |
| | | |
| | | jkMessage0206.attachInfo = attachInfo; |
| | | if (ExamPlatformData.getInstance().getTrainingMode()==ExamPlatformData.MODE_NONE){ |
| | | Log.i(TAG,"非训练和考试"); |
| | | //判断10s时间是否到 |
| | | if (ExamPlatformData.getInstance().isTimeArrive_10s()){ |
| | | Log.i(TAG,"非训练和考试10s到"); |
| | | |
| | | //到了 就走下面发送0206消息 |
| | | MessageProcessor.getInstance().sendMessage(jkMessage0206); |
| | | //重置标记 |
| | |
| | | public class PlatFormConstant { |
| | | |
| | | public static final String TAG = "PlatFormMessage"; |
| | | public static final String HTTPTAG = "HTTPMessage"; |
| | | |
| | | public static final int SUCCESS = 0; |
| | | public static final short STU_INFO_SUCC = 1; |