| | |
| | | private ImageView iv_his, iv_status, iv_search, iv_bottom_status, iv_dianliang; |
| | | private BluetoothService mBluetoothService; |
| | | private ArrayList<String> realResult = new ArrayList<>(); |
| | | private ArrayList<String> realHourResult = new ArrayList<>(); |
| | | private ArrayList<String> realHisResult = new ArrayList<>(); |
| | | //上传数据 |
| | | private ArrayList<RecData> submitResult = new ArrayList<>(); |
| | | private ArrayList<RecData> submitHisResult = new ArrayList<>(); |
| | |
| | | getActivity().runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | Log.d("haijiang", "收到消息====" + StringUtils.byteArrayToHexStr(characteristic.getValue())); |
| | | // Log.d("haijiang", "收到消息====" + StringUtils.byteArrayToHexStr(characteristic.getValue())); |
| | | String result = StringUtils.byteArrayToHexStr(characteristic.getValue()); |
| | | //实时数据 |
| | | parseCurrentData(result); |
| | |
| | | tv_tishi.setText("当前辐射轻微"); |
| | | tv_tishi.setBackgroundResource(R.mipmap.bt_blue); |
| | | iv_bottom_status.setImageResource(R.mipmap.icon_qingwei); |
| | | tv_desc.setText("您所处位置辐射轻微\n不利于您的健康,请远离到安全区域!"); |
| | | tv_desc.setText("您所处位置辐射轻微\n不利于您的健康,建议回避!"); |
| | | iv_status.setImageResource(R.mipmap.icon_head_qingwei); |
| | | tv_status.setText("轻微"); |
| | | tv_status.setText("回避"); |
| | | tv_status.setTextColor(getResources().getColor(R.color.blue_txt)); |
| | | ll_status.setBackgroundResource(R.mipmap.bg_corner_blue); |
| | | } else if (level == 2) { |
| | | tv_tishi.setText("当前辐射偏高"); |
| | | tv_tishi.setBackgroundResource(R.mipmap.bt_zise); |
| | | iv_bottom_status.setImageResource(R.mipmap.icon_zhongdu); |
| | | tv_desc.setText("您所处位置辐射偏高\n不利于您的健康,请远离到安全区域!"); |
| | | tv_desc.setText("您所处位置辐射偏高\n不利于您的健康,请紧急撤离!"); |
| | | iv_status.setImageResource(R.mipmap.icon_head_zhongfu); |
| | | tv_status.setText("中度"); |
| | | tv_status.setText("撤离"); |
| | | tv_status.setTextColor(getResources().getColor(R.color.zi_txt)); |
| | | ll_status.setBackgroundResource(R.mipmap.bg_corner_zise); |
| | | } else if (level == 3) { |
| | | tv_tishi.setText("当前辐射超标"); |
| | | tv_tishi.setBackgroundResource(R.mipmap.bt_red); |
| | | iv_bottom_status.setImageResource(R.mipmap.icon_yanzhong); |
| | | tv_desc.setText("您所处位置辐射超标\n不利于您的健康,请远离到安全区域!"); |
| | | tv_desc.setText("您所处位置辐射超标\n不利于您的健康,请及时逃遁!"); |
| | | iv_status.setImageResource(R.mipmap.icon_danger); |
| | | tv_status.setText("危险"); |
| | | tv_status.setText("逃遁"); |
| | | tv_status.setTextColor(getResources().getColor(R.color.red_txt)); |
| | | ll_status.setBackgroundResource(R.mipmap.bg_conner_red); |
| | | } else if (level == -1) { |
| | |
| | | for (String s : realResult) { |
| | | nowResult += s; |
| | | } |
| | | Log.d("haijiang", "收到消息===nowResult=" + nowResult); |
| | | // Log.d("haijiang", "收到消息===nowResult=" + nowResult); |
| | | /** |
| | | * 20个字节,5A开头 5B结尾 |
| | | */ |
| | | if (!TextUtils.isEmpty(nowResult) && nowResult.length() == 40 && nowResult.startsWith("5A") && nowResult.endsWith("5B")) { |
| | | |
| | | int shunshiValue = Integer.parseInt(nowResult.substring(24, 26), 16) * 256 + Integer.parseInt(nowResult.substring(26, 28), 16); |
| | | int leijiValue = Integer.parseInt(nowResult.substring(28, 30), 16) * 1024 + Integer.parseInt(nowResult.substring(30, 32), 16) * 512 + Integer.parseInt(nowResult.substring(32, 34), 16) * 256 + Integer.parseInt(nowResult.substring(34, 36), 16); |
| | | // float level = (float) (shunshiValue / 10 * 0.01); |
| | | int b1 = Integer.parseInt(nowResult.substring(6, 8), 16); |
| | | int b2 = Integer.parseInt(nowResult.substring(12, 14), 16); |
| | | XLog.d("辐射:" + shunshiValue + "|累计:" + leijiValue + "-----电量:" + b1 + "|" + b2); |
| | | tv_ljjl.setText(NumberUtils.getBigDecimalValue(leijiValue * 0.01, 3) + ""); |
| | | // XLog.d("辐射:" + shunshiValue + "|累计:" + leijiValue + "-----电量:" + b1 + "|" + b2); |
| | | tv_ljjl.setText(NumberUtils.getBigDecimalValue(leijiValue * 0.001, 3) + ""); |
| | | double shishiValue = NumberUtils.getBigDecimalValue((shunshiValue) / 100.0, 3); |
| | | tv_shishi.setText(shishiValue + ""); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | if (shishiValue < 0.25) { |
| | | if (shishiValue < 0.16) { |
| | | data.setIs_warn(0); |
| | | pv.setPercent((float) (shishiValue)); |
| | | pv.setPercent((float) (shishiValue * (0.25 / 0.16))); |
| | | showStatus(0); |
| | | stop(); |
| | | } else if (shishiValue >= 0.25 && shishiValue < 0.8) { |
| | | } else if (shishiValue >= 0.16 && shishiValue < 0.8) { |
| | | data.setIs_warn(1); |
| | | pv.setPercent((float) (0.25 + shishiValue * (0.25 / 0.8))); |
| | | showStatus(1); |
| | |
| | | * @param result |
| | | */ |
| | | private void parseHoutData(String result) { |
| | | if (!TextUtils.isEmpty(result) && result.length() == 8 && result.startsWith("7A") && result.endsWith("7B")) { |
| | | int hourValue = Integer.parseInt(result.substring(2, 4), 16) * 256 + Integer.parseInt(result.substring(4, 6), 16); |
| | | if (result.startsWith("7A")) { |
| | | realHourResult.clear(); |
| | | realHourResult.add(result); |
| | | } else { |
| | | realHourResult.add(result); |
| | | } |
| | | String nowResult = ""; |
| | | for (String s : realHourResult) { |
| | | nowResult += s; |
| | | } |
| | | if (!TextUtils.isEmpty(nowResult)&& nowResult.length() == 8&&nowResult.startsWith("7A") && nowResult.endsWith("7B")) { |
| | | int hourValue = Integer.parseInt(nowResult.substring(2, 4), 16) * 256 + Integer.parseInt(nowResult.substring(4, 6), 16); |
| | | Log.d("haijiang", "收到消息小时数据="+ nowResult+"高位:"+nowResult.substring(2, 4)+"|"+Integer.parseInt(nowResult.substring(2, 4), 16) * 256+"低位:"+nowResult.substring(4, 6)+"|"+Integer.parseInt(nowResult.substring(4, 6), 16) +"数值:"+(hourValue/100.0)); |
| | | sendHourDataRec(); |
| | | RecData data = new RecData(); |
| | | data.setType(1); |
| | |
| | | * 孕妇哨连接后上传的数据 |
| | | */ |
| | | private void parseHisData(String result) { |
| | | if (!TextUtils.isEmpty(result) && result.length() == 16 && result.startsWith("3A") && result.endsWith("3B")) { |
| | | if (result.startsWith("3A")) { |
| | | realHisResult.clear(); |
| | | realHisResult.add(result); |
| | | } else { |
| | | realHisResult.add(result); |
| | | } |
| | | String nowResult = ""; |
| | | for (String s : realHisResult) { |
| | | nowResult += s; |
| | | } |
| | | if (!TextUtils.isEmpty(nowResult) && nowResult.length() == 16 && nowResult.startsWith("3A") && nowResult.endsWith("3B")) { |
| | | if (submitHisResult.size() == 0) { |
| | | //开启定时器检查 |
| | | checkResComplete(result); |
| | | } |
| | | String year = "20" + Integer.parseInt(result.substring(2, 4), 16); |
| | | String month = Integer.parseInt(result.substring(4, 6), 16) + ""; |
| | | String day = Integer.parseInt(result.substring(6, 8), 16) + ""; |
| | | String hour = Integer.parseInt(result.substring(8, 10), 16) + ""; |
| | | int resValue = Integer.parseInt(result.substring(10, 12), 16) * 256 + Integer.parseInt(result.substring(12, 14), 16); |
| | | String year = "20" + Integer.parseInt(nowResult.substring(2, 4), 16); |
| | | String month = Integer.parseInt(nowResult.substring(4, 6), 16) + ""; |
| | | String day = Integer.parseInt(nowResult.substring(6, 8), 16) + ""; |
| | | String hour = Integer.parseInt(nowResult.substring(8, 10), 16) + ""; |
| | | int resValue = Integer.parseInt(nowResult.substring(10, 12), 16) * 256 + Integer.parseInt(nowResult.substring(12, 14), 16); |
| | | RecData data = new RecData(); |
| | | StringBuilder time = new StringBuilder(); |
| | | //yyyy-MM-dd HH:mm:ss |