desc:传感器列表展示修改

main
xiaowusky 1 year ago
parent 13b44d6f53
commit d1c8263b25

@ -63,19 +63,8 @@ class App : CommonApplication() {
} }
} }
} }
// 初始时,所以串口连接状态都应该是未连接
val gasAsync = async(Dispatchers.IO) {
val gasTypeDao = DBUtils.gasTypeDao()
val all = gasTypeDao.getAll()
all.onEach { gasType ->
gasType.status = GasPortStatus.OUTLINE
gasTypeDao.insert(gasType)
}
}
warningAsync.await() warningAsync.await()
videoAsync.await() videoAsync.await()
gasAsync.await()
} }
} }

@ -1,8 +1,9 @@
package com.yinuo.safetywatcher.watcher.port package com.yinuo.safetywatcher.watcher.port
import android.os.Process
import com.common.commonlib.db.DBUtils
import com.common.serialport.ComMultiPortUtils import com.common.serialport.ComMultiPortUtils
import com.yinuo.safetywatcher.watcher.port.cmd.CMD import com.yinuo.safetywatcher.watcher.port.cmd.CMD
import android.os.Process
import com.yinuo.safetywatcher.watcher.port.cmd.CalibrationCmd import com.yinuo.safetywatcher.watcher.port.cmd.CalibrationCmd
object GasPortUtils { object GasPortUtils {
@ -37,6 +38,9 @@ object GasPortUtils {
readGasMsgThread = Thread { readGasMsgThread = Thread {
try { try {
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
// 删除老的传感器列表数据
val gasTypeDao = DBUtils.gasTypeDao()
gasTypeDao.deleteAll()
while (true) { while (true) {
// 延时一段时间后,发送指令读取气体数据 // 延时一段时间后,发送指令读取气体数据
Thread.sleep(READ_MSG_INTERVAL) Thread.sleep(READ_MSG_INTERVAL)

@ -27,4 +27,7 @@ interface GasTypeDao {
@Delete @Delete
suspend fun delete(gas: GasType) suspend fun delete(gas: GasType)
@Query("DELETE FROM gas_type")
fun deleteAll()
} }
Loading…
Cancel
Save