|
@@ -45,6 +45,15 @@ class ThreadGlobalParam: LifecycleObserver {
|
|
|
field = value
|
|
|
}
|
|
|
|
|
|
+ //读取后台数据
|
|
|
+ var jobPreheatOff: Job? = null
|
|
|
+ get() = field
|
|
|
+ var isActivePreheatOff: Boolean = true
|
|
|
+ get() = field
|
|
|
+ set(value) {
|
|
|
+ field = value
|
|
|
+ }
|
|
|
+
|
|
|
fun startInit() {
|
|
|
stopInit()
|
|
|
isActiveSbcInit=true
|
|
@@ -84,6 +93,25 @@ class ThreadGlobalParam: LifecycleObserver {
|
|
|
jobHeartbeat?.cancel()
|
|
|
}
|
|
|
|
|
|
+ fun startPreheatOff() {
|
|
|
+ stopPreheatOff()
|
|
|
+ isActivePreheatOff=true
|
|
|
+ // 启动协程
|
|
|
+ jobPreheatOff = CoroutineScope(Dispatchers.Main).launch {
|
|
|
+ while (isActivePreheatOff) {
|
|
|
+ VboxSerialPortSendQueue.getInstance()
|
|
|
+ .sendCommand(VboxWriteCommand(VboxCommand.CMD_IO,
|
|
|
+ VboxCommand.DEBUG_ID+"0500"))
|
|
|
+ // 执行定时任务的操作
|
|
|
+ Log.d(TAG, "start:startPreheatOff")
|
|
|
+ delay(1000) // 每隔1秒重复执行
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fun stopPreheatOff() {
|
|
|
+ jobPreheatOff?.cancel()
|
|
|
+ }
|
|
|
+
|
|
|
fun startBackData() {
|
|
|
stopBackData()
|
|
|
// 启动协程
|
|
@@ -107,5 +135,6 @@ class ThreadGlobalParam: LifecycleObserver {
|
|
|
//避免线程池关不掉
|
|
|
stopInit()
|
|
|
stopHeartbeat()
|
|
|
+ stopPreheatOff()
|
|
|
}
|
|
|
}
|