| | |
| | | package safeluck.drive.evaluation; |
| | | |
| | | import android.app.Application; |
| | | import android.os.Handler; |
| | | import android.util.Log; |
| | | import android.widget.Toast; |
| | | |
| | | |
| | |
| | | |
| | | import safeluck.drive.evaluation.DB.failitems.FailedProj; |
| | | import safeluck.drive.evaluation.DB.failitems.FailedProjRepository; |
| | | import safeluck.drive.evaluation.bean.RTKConfig; |
| | | import safeluck.drive.evaluation.cEventCenter.CEventCenter; |
| | | import safeluck.drive.evaluation.DB.rtktb.RTKConfig; |
| | | import safeluck.drive.evaluation.DB.rtktb.RTKWorkRepository; |
| | | import safeluck.drive.evaluation.util.SystemUtil; |
| | | |
| | | /** |
| | |
| | | private static final String TAG = "app"; |
| | | private Gson gson; |
| | | RTKConfig rtkConfig; |
| | | FailedProjRepository failedProjRepository; |
| | | FailedProjRepository failedProjRepository;//失败项目表数据库 |
| | | RTKWorkRepository rtkWorkRepository;//保存RTK配置表 |
| | | Random random = new Random(); |
| | | |
| | | @Override |
| | |
| | | |
| | | |
| | | //RTK配置信息 |
| | | rtkConfig = new RTKConfig(); |
| | | rtkConfig.setCity(12); |
| | | rtkConfig.setImei("460123874561"); |
| | | rtkConfig.setInterval(1); |
| | | rtkConfig.setIp("47.93.80.84"); |
| | | rtkConfig.setModel("123"); |
| | | rtkConfig.setPhone("2019101500000001"); |
| | | rtkConfig.setPort(12125); |
| | | rtkConfig.setProvince(23); |
| | | rtkConfig.setSn("2019101500000001"); |
| | | // rtkConfig = new RTKConfig(); |
| | | // rtkConfig.setCity(12); |
| | | // rtkConfig.setImei("460123874561"); |
| | | // rtkConfig.setInterval(1); |
| | | // rtkConfig.setIp("47.93.80.84"); |
| | | // rtkConfig.setModel("123"); |
| | | // rtkConfig.setPhone("2019101500000001"); |
| | | // rtkConfig.setPort(12125); |
| | | // rtkConfig.setProvince(23); |
| | | // rtkConfig.setSn("2019101500000001"); |
| | | //数据库操作 |
| | | MyLog.i(TAG, "onCreate111"); |
| | | failedProjRepository = new FailedProjRepository(this); |
| | | rtkWorkRepository = new RTKWorkRepository(this); |
| | | } |
| | | |
| | | } |
| | |
| | | Toast.makeText(this, "NDK start", Toast.LENGTH_SHORT).show(); |
| | | break; |
| | | case Constant.RTK_PLATFORM_REGISTER_STATUS: |
| | | failedProjRepository.insert(new FailedProj(Constant.SUBJECT_I, cmd + random.nextInt(30), Constant.TEST_STU_ID)); |
| | | |
| | | failedProjRepository.insert(new FailedProj(Constant.SUBJECT_I, cmd + random.nextInt(26), Constant.TEST_STU_ID)); |
| | | rtkConfig = rtkWorkRepository.getRTKConfigNoLive(); |
| | | |
| | | try { |
| | | JSONObject jsonObject = new JSONObject(json); |
| | | String rtkLoginPwd = jsonObject.getString("password"); |
| | |
| | | } catch (JSONException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | rtkWorkRepository.insertRTKConfig(rtkConfig); |
| | | break; |
| | | case Constant.RTK_PLATFORM_REGISTER_RESULT: |
| | | |
| | | failedProjRepository.insert(new FailedProj(Constant.SUBJECT_I, cmd + random.nextInt(30), Constant.TEST_STU_ID)); |
| | | failedProjRepository.insert(new FailedProj(Constant.SUBJECT_I, cmd + random.nextInt(26), Constant.TEST_STU_ID)); |
| | | |
| | | try { |
| | | JSONObject jsonObject = new JSONObject(json); |
| | | int rtklogincode = jsonObject.getInt("login_code"); |
| | | rtkConfig.setRegistered(rtklogincode); |
| | | } catch (JSONException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | |
| | | break; |
| | | case Constant.FETCH_RTK_PLATFORM_INFO: |
| | | rtkConfig = rtkWorkRepository.getRTKConfigNoLive(); |
| | | if (gson == null) { |
| | | gson = new Gson(); |
| | | } |
| | | MyLog.i(TAG, "RTK配置信息:" + gson.toJson(rtkConfig)); |
| | | AYSdk.getInstance().sendCmd(Constant.PUSH_RTK_PLATFORM_INFO, gson.toJson(rtkConfig)); |
| | | if (rtkConfig==null){ |
| | | |
| | | rtkConfig = rtkWorkRepository.getRTKConfigNoLive(); |
| | | } |
| | | if (rtkConfig != null){ |
| | | String rtkjson = gson.toJson(rtkConfig); |
| | | MyLog.i(TAG, "RTK配置信息:" + rtkjson); |
| | | |
| | | //去除id字段 |
| | | JSONObject jsonObject = null; |
| | | try { |
| | | jsonObject = new JSONObject(rtkjson); |
| | | } catch (JSONException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | jsonObject.remove("_id"); |
| | | rtkjson = null; |
| | | rtkjson = jsonObject.toString(); |
| | | MyLog.i(TAG, "RTK配置信息:" + rtkjson); |
| | | AYSdk.getInstance().sendCmd(Constant.PUSH_RTK_PLATFORM_INFO, rtkjson); |
| | | } |
| | | |
| | | break; |
| | | case Constant.JUDGE_INFO: |
| | | |
| | |
| | | MyLog.d(TAG, "考试开始,需要删除上一个考试学员的数据库失败项目表"); |
| | | failedProjRepository.deleteAll(); |
| | | break; |
| | | case Constant.RTK_PLATFORM_CONNECT_STATUS: |
| | | rtkConfig = rtkWorkRepository.getRTKConfigNoLive(); |
| | | |
| | | try { |
| | | JSONObject jsonObject3 = new JSONObject(json); |
| | | String ip = jsonObject3.getString("ip"); |
| | | int port = jsonObject3.getInt("port"); |
| | | int reg_code = jsonObject3.getInt("connected"); |
| | | rtkConfig.setRegistered(reg_code); |
| | | rtkConfig.setIp(ip); |
| | | rtkConfig.setPort(port); |
| | | } catch (JSONException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | rtkWorkRepository.insertRTKConfig(rtkConfig); |
| | | break; |
| | | } |
| | | |
| | | } |