|
|
|
@ -4,13 +4,12 @@ import android.content.Context
|
|
|
|
|
import com.common.commonlib.db.entity.Warning
|
|
|
|
|
import com.common.commonlib.utils.MMKVUtils
|
|
|
|
|
import com.yinuo.safetywatcher.R
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.cmd.CO2
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.cmd.CH4
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.cmd.CH4_H2
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.cmd.CL2
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.cmd.CO
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.cmd.CO2
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.cmd.GasPortStatus
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.cmd.GasTypeEnum
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.cmd.H2
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.cmd.H2S
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.cmd.HF
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.cmd.NH3
|
|
|
|
@ -36,7 +35,7 @@ private fun getHighThresHoldKey(gasType: String): String {
|
|
|
|
|
fun saveLowThreshold(gasType: String, value: Float, localGasUnit: String) {
|
|
|
|
|
var localValue = value
|
|
|
|
|
// 氧气 可燃气体 和 挥发气体不转换数值
|
|
|
|
|
if (O2 == gasType || H2 == gasType || CH4 == gasType || VOCS == gasType) {
|
|
|
|
|
if (O2 == gasType || CH4_H2 == gasType || VOCS == gasType) {
|
|
|
|
|
MMKVUtils.put(getLowThresHoldKey(gasType), localValue)
|
|
|
|
|
} else {
|
|
|
|
|
if (UNIT_MGM3 == localGasUnit) {
|
|
|
|
@ -55,7 +54,7 @@ fun saveLowThreshold(gasType: String, value: Float, localGasUnit: String) {
|
|
|
|
|
*/
|
|
|
|
|
fun saveHighThreshold(gasType: String, value: Float, localGasUnit: String) {
|
|
|
|
|
var localValue = value
|
|
|
|
|
if (O2 == gasType || H2 == gasType || CH4 == gasType || VOCS == gasType) {
|
|
|
|
|
if (O2 == gasType || CH4_H2 == gasType || VOCS == gasType) {
|
|
|
|
|
MMKVUtils.put(getLowThresHoldKey(gasType), localValue)
|
|
|
|
|
} else {
|
|
|
|
|
if (UNIT_MGM3 == localGasUnit) {
|
|
|
|
@ -79,7 +78,7 @@ fun getGasLowThreshold(gasType: String, unit: String): Float {
|
|
|
|
|
// 氧气特殊处理
|
|
|
|
|
if (O2 == gasType) {
|
|
|
|
|
return O2_MIN
|
|
|
|
|
} else if (H2 == gasType || CH4 == gasType) {
|
|
|
|
|
} else if (CH4_H2 == gasType) {
|
|
|
|
|
return CH4_MIN_LEL
|
|
|
|
|
} else if (VOCS == gasType) {
|
|
|
|
|
return VOCS_MIN_PPM
|
|
|
|
@ -87,7 +86,7 @@ fun getGasLowThreshold(gasType: String, unit: String): Float {
|
|
|
|
|
return (default_threshold_map_unit[unit])?.get(lowThresholdKey) ?: -1f
|
|
|
|
|
} else {
|
|
|
|
|
// 氧气 可燃气体 和 挥发气体不转换数值
|
|
|
|
|
if (O2 == gasType || H2 == gasType || CH4 == gasType || VOCS == gasType) {
|
|
|
|
|
if (O2 == gasType || CH4_H2 == gasType || VOCS == gasType) {
|
|
|
|
|
return localVlaue
|
|
|
|
|
}
|
|
|
|
|
if (UNIT_MGM3 == unit) {
|
|
|
|
@ -111,7 +110,7 @@ fun getGasHighThreshold(gasType: String, unit: String): Float {
|
|
|
|
|
// 氧气特殊处理
|
|
|
|
|
if (O2 == gasType) {
|
|
|
|
|
return O2_MAX
|
|
|
|
|
} else if (H2 == gasType || CH4 == gasType) {
|
|
|
|
|
} else if (CH4_H2 == gasType) {
|
|
|
|
|
return CH4_MAX_LEL
|
|
|
|
|
} else if (VOCS == gasType) {
|
|
|
|
|
return VOCS_MAX_PPM
|
|
|
|
@ -119,7 +118,7 @@ fun getGasHighThreshold(gasType: String, unit: String): Float {
|
|
|
|
|
return (default_threshold_map_unit[unit])?.get(highThresholdKey) ?: -1f
|
|
|
|
|
} else {
|
|
|
|
|
// 氧气 可燃气体 和 挥发气体不转换数值
|
|
|
|
|
if (O2 == gasType || H2 == gasType || CH4 == gasType || VOCS == gasType) {
|
|
|
|
|
if (O2 == gasType || CH4_H2 == gasType || VOCS == gasType) {
|
|
|
|
|
return localVlaue
|
|
|
|
|
}
|
|
|
|
|
if (UNIT_MGM3 == unit) {
|
|
|
|
@ -147,7 +146,7 @@ fun getLocalGasUnit(gasType: String): String {
|
|
|
|
|
fun getDefaultUnit(gasType: String): String {
|
|
|
|
|
return when (gasType.uppercase()) {
|
|
|
|
|
O2 -> UNIT_VOL
|
|
|
|
|
CH4, H2 -> UNIT_LEL
|
|
|
|
|
CH4_H2 -> UNIT_LEL
|
|
|
|
|
VOCS -> UNIT_PPM
|
|
|
|
|
CO, H2S, NH3, SO2, CL2, NO2, NO, HF, CO2 -> UNIT_PPM
|
|
|
|
|
else -> UNIT_PPM
|
|
|
|
|