|
|
|
@ -11,6 +11,8 @@ import com.common.serialport.utils.HexUtils
|
|
|
|
|
import com.yinuo.library.vlc.TxtOverlay
|
|
|
|
|
import com.yinuo.library.vlc.utils.LogUtils
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.constant.GAS_CLOUD_UPLOAD_SIZE_ONCE
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.constant.getGasHighThreshold
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.constant.getGasLowThreshold
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.net.DevicesApi
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.cmd.CH4
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.cmd.CO
|
|
|
|
@ -92,11 +94,11 @@ object ParseHelper {
|
|
|
|
|
LogUtils.v("receive msg, unitBinaryString 3 = $unitBinaryString")
|
|
|
|
|
|
|
|
|
|
//小数点
|
|
|
|
|
val subSequence = unitBinaryString.subSequence(8, 12)
|
|
|
|
|
val subSequence = unitBinaryString.subSequence(8, 12).reversed()
|
|
|
|
|
val pointNum = ResponseHelper.getPointNum(subSequence)
|
|
|
|
|
LogUtils.v("receive msg, 小数点 = $subSequence,$pointNum")
|
|
|
|
|
// 单位
|
|
|
|
|
val subSequence2 = unitBinaryString.subSequence(12, 16)
|
|
|
|
|
val subSequence2 = unitBinaryString.subSequence(12, 16).reversed()
|
|
|
|
|
val unit = ResponseHelper.getGasUnit(subSequence2)
|
|
|
|
|
LogUtils.v("receive msg, 单位 = $subSequence2,$unit")
|
|
|
|
|
|
|
|
|
@ -149,9 +151,9 @@ object ParseHelper {
|
|
|
|
|
*/
|
|
|
|
|
private fun insertGasData(gasType: String, value: Double, unit: String, rangHexLong: Long) {
|
|
|
|
|
GlobalScope.launch {
|
|
|
|
|
// TODO 阈值范围
|
|
|
|
|
val min = 0.0
|
|
|
|
|
val max = 0.0
|
|
|
|
|
// 阈值范围
|
|
|
|
|
val min = getGasLowThreshold(gasType).toDouble()
|
|
|
|
|
val max = getGasHighThreshold(gasType).toDouble()
|
|
|
|
|
|
|
|
|
|
// 存储量程最大值
|
|
|
|
|
MMKVUtils.put("range_${gasType}", "0$unit~$rangHexLong$unit")
|
|
|
|
@ -162,7 +164,7 @@ object ParseHelper {
|
|
|
|
|
val gasDao = DBUtils.gasDao()
|
|
|
|
|
gasDao.insert(gas)
|
|
|
|
|
|
|
|
|
|
// TODO 告警处理
|
|
|
|
|
// 告警处理
|
|
|
|
|
val warningDao = DBUtils.warningDao()
|
|
|
|
|
val warning = warningDao.findLatestByName(gasType)
|
|
|
|
|
if (value < min || value > max) {
|
|
|
|
|