diff --git a/app/src/main/java/com/casic/app/safetreecontroller/extensions/LineChart.kt b/app/src/main/java/com/casic/app/safetreecontroller/extensions/LineChart.kt index e092200..72a5b51 100644 --- a/app/src/main/java/com/casic/app/safetreecontroller/extensions/LineChart.kt +++ b/app/src/main/java/com/casic/app/safetreecontroller/extensions/LineChart.kt @@ -32,7 +32,7 @@ this.axisLeft.setDrawGridLines(false) //设置x轴上每个点对应的线 this.axisLeft.setDrawZeroLine(true) //添加限制线 - val threshold = SaveKeyValues.getValue(LocaleConstant.METHANE_DEFAULT_VALUE_KEY, 1.99f) as Float + val threshold = SaveKeyValues.getValue(LocaleConstant.METHANE_DEFAULT_VALUE_KEY, 0.1f) as Float val limitLine = LimitLine(threshold, "阈值:${threshold}% VOL") limitLine.lineWidth = 1f limitLine.lineColor = Color.RED diff --git a/app/src/main/java/com/casic/app/safetreecontroller/extensions/LineChart.kt b/app/src/main/java/com/casic/app/safetreecontroller/extensions/LineChart.kt index e092200..72a5b51 100644 --- a/app/src/main/java/com/casic/app/safetreecontroller/extensions/LineChart.kt +++ b/app/src/main/java/com/casic/app/safetreecontroller/extensions/LineChart.kt @@ -32,7 +32,7 @@ this.axisLeft.setDrawGridLines(false) //设置x轴上每个点对应的线 this.axisLeft.setDrawZeroLine(true) //添加限制线 - val threshold = SaveKeyValues.getValue(LocaleConstant.METHANE_DEFAULT_VALUE_KEY, 1.99f) as Float + val threshold = SaveKeyValues.getValue(LocaleConstant.METHANE_DEFAULT_VALUE_KEY, 0.1f) as Float val limitLine = LimitLine(threshold, "阈值:${threshold}% VOL") limitLine.lineWidth = 1f limitLine.lineColor = Color.RED diff --git a/app/src/main/java/com/casic/app/safetreecontroller/fragments/MethaneMonitorFragment.kt b/app/src/main/java/com/casic/app/safetreecontroller/fragments/MethaneMonitorFragment.kt index 4a86ca8..14794a4 100644 --- a/app/src/main/java/com/casic/app/safetreecontroller/fragments/MethaneMonitorFragment.kt +++ b/app/src/main/java/com/casic/app/safetreecontroller/fragments/MethaneMonitorFragment.kt @@ -111,8 +111,8 @@ binding.updateThresholdButton.setOnClickListener { //更新甲烷阈值 val threshold = binding.thresholdView.text.toString().toFloat() - if (threshold >= 20f) { - "报警阈值不能超过20% VOL".show(requireContext()) + if (threshold > 1f) { + "报警阈值不能超过1%VOL".show(requireContext()) return@setOnClickListener } @@ -122,8 +122,8 @@ ?: return@setOnClickListener val message = weakReferenceHandler.obtainMessage() message.what = LocaleConstant.UPDATE_GAS_THRESHOLD_CODE - //用户使用 % VOL,但是单片机只能设置ppm`m,所以需要转换一下 - message.obj = (threshold * 500).toInt() + //用户使用【%VOL】,但是单片机只能设置【ppm·m】,所以需要转换一下 + message.obj = (threshold * 10000).toInt() weakReferenceHandler.sendMessage(message) } @@ -161,9 +161,9 @@ LocaleConstant.QUERY_METHANE_RESPONSE_CODE -> { val ppm = msg.obj as Long //LEL百分比 = (X / 10000) / 0.05 × 100% = X / 500 - val formatValue = "%.2f".format(ppm / 500f) + val formatValue = "%.2f".format(ppm / 10000f) binding.currentGasValueView.text = "当前燃气浓度:${formatValue}% VOL" - if (ppm > binding.thresholdView.text.toString().toFloat() * 500) { + if (ppm > binding.thresholdView.text.toString().toFloat() * 10000) { binding.currentGasValueView.setTextColor(Color.RED) binding.currentGasValueView.typeface = Typeface.DEFAULT_BOLD } else { @@ -204,7 +204,8 @@ } //回显甲烷默认阈值 - val value = SaveKeyValues.getValue(LocaleConstant.METHANE_DEFAULT_VALUE_KEY, 1.99f) as Float - binding.thresholdView.setText(value.toString()) + val threshold = + SaveKeyValues.getValue(LocaleConstant.METHANE_DEFAULT_VALUE_KEY, 0.1f) as Float + binding.thresholdView.setText(threshold.toString()) } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/safetreecontroller/extensions/LineChart.kt b/app/src/main/java/com/casic/app/safetreecontroller/extensions/LineChart.kt index e092200..72a5b51 100644 --- a/app/src/main/java/com/casic/app/safetreecontroller/extensions/LineChart.kt +++ b/app/src/main/java/com/casic/app/safetreecontroller/extensions/LineChart.kt @@ -32,7 +32,7 @@ this.axisLeft.setDrawGridLines(false) //设置x轴上每个点对应的线 this.axisLeft.setDrawZeroLine(true) //添加限制线 - val threshold = SaveKeyValues.getValue(LocaleConstant.METHANE_DEFAULT_VALUE_KEY, 1.99f) as Float + val threshold = SaveKeyValues.getValue(LocaleConstant.METHANE_DEFAULT_VALUE_KEY, 0.1f) as Float val limitLine = LimitLine(threshold, "阈值:${threshold}% VOL") limitLine.lineWidth = 1f limitLine.lineColor = Color.RED diff --git a/app/src/main/java/com/casic/app/safetreecontroller/fragments/MethaneMonitorFragment.kt b/app/src/main/java/com/casic/app/safetreecontroller/fragments/MethaneMonitorFragment.kt index 4a86ca8..14794a4 100644 --- a/app/src/main/java/com/casic/app/safetreecontroller/fragments/MethaneMonitorFragment.kt +++ b/app/src/main/java/com/casic/app/safetreecontroller/fragments/MethaneMonitorFragment.kt @@ -111,8 +111,8 @@ binding.updateThresholdButton.setOnClickListener { //更新甲烷阈值 val threshold = binding.thresholdView.text.toString().toFloat() - if (threshold >= 20f) { - "报警阈值不能超过20% VOL".show(requireContext()) + if (threshold > 1f) { + "报警阈值不能超过1%VOL".show(requireContext()) return@setOnClickListener } @@ -122,8 +122,8 @@ ?: return@setOnClickListener val message = weakReferenceHandler.obtainMessage() message.what = LocaleConstant.UPDATE_GAS_THRESHOLD_CODE - //用户使用 % VOL,但是单片机只能设置ppm`m,所以需要转换一下 - message.obj = (threshold * 500).toInt() + //用户使用【%VOL】,但是单片机只能设置【ppm·m】,所以需要转换一下 + message.obj = (threshold * 10000).toInt() weakReferenceHandler.sendMessage(message) } @@ -161,9 +161,9 @@ LocaleConstant.QUERY_METHANE_RESPONSE_CODE -> { val ppm = msg.obj as Long //LEL百分比 = (X / 10000) / 0.05 × 100% = X / 500 - val formatValue = "%.2f".format(ppm / 500f) + val formatValue = "%.2f".format(ppm / 10000f) binding.currentGasValueView.text = "当前燃气浓度:${formatValue}% VOL" - if (ppm > binding.thresholdView.text.toString().toFloat() * 500) { + if (ppm > binding.thresholdView.text.toString().toFloat() * 10000) { binding.currentGasValueView.setTextColor(Color.RED) binding.currentGasValueView.typeface = Typeface.DEFAULT_BOLD } else { @@ -204,7 +204,8 @@ } //回显甲烷默认阈值 - val value = SaveKeyValues.getValue(LocaleConstant.METHANE_DEFAULT_VALUE_KEY, 1.99f) as Float - binding.thresholdView.setText(value.toString()) + val threshold = + SaveKeyValues.getValue(LocaleConstant.METHANE_DEFAULT_VALUE_KEY, 0.1f) as Float + binding.thresholdView.setText(threshold.toString()) } } \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_methane_monitor.xml b/app/src/main/res/layout/fragment_methane_monitor.xml index 64c1b6c..376f43c 100644 --- a/app/src/main/res/layout/fragment_methane_monitor.xml +++ b/app/src/main/res/layout/fragment_methane_monitor.xml @@ -76,7 +76,7 @@ android:maxLength="4" android:padding="@dimen/dp_5" android:singleLine="true" - android:text="1.99" + android:text="0.1" android:textColor="@color/black" android:textSize="@dimen/sp_16" />