[CodeFix]优化工控机状态上传逻辑
This commit is contained in:
@@ -22,11 +22,9 @@ import com.zhidao.support.adas.high.common.Constants
|
||||
import com.zhidao.support.adas.high.common.Constants.ENVIRONMENT.*
|
||||
import com.zhidao.support.adas.high.common.Constants.TERMINAL_ROLE.DRIVER
|
||||
import com.zhidao.support.adas.high.common.Constants.TERMINAL_ROLE.PASSENGER
|
||||
import io.reactivex.Flowable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.*
|
||||
import java.util.concurrent.atomic.*
|
||||
|
||||
/**
|
||||
* ADAS-SDK与工控机连接状态回调
|
||||
@@ -43,6 +41,10 @@ class MoGoAdasMsgConnectStatusListenerImpl : OnAdasConnectStatusListener,
|
||||
|
||||
private var connectStatus = false
|
||||
|
||||
private val hasUploadTaskLaunched by lazy { AtomicBoolean(false) }
|
||||
|
||||
private val timer = Timer()
|
||||
|
||||
init {
|
||||
CallerCloudListenerManager.registerCloudListener(TAG, this)
|
||||
}
|
||||
@@ -167,15 +169,16 @@ class MoGoAdasMsgConnectStatusListenerImpl : OnAdasConnectStatusListener,
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
private fun updateDriveStatusTask() {
|
||||
CallerLogger.d("$M_ADAS_IMPL$TAG", "updateDriveStatusTask")
|
||||
Flowable.interval(0, 5, TimeUnit.SECONDS)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.unsubscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
AdasServiceModel.getInstance()
|
||||
.updateDriveStatus(mCurrentAutopilotStatus, mCurrentAutopilotSpeed)
|
||||
}
|
||||
if (hasUploadTaskLaunched.compareAndSet(false, true)) {
|
||||
timer.schedule(object : TimerTask() {
|
||||
override fun run() {
|
||||
CallerLogger.d("$M_ADAS_IMPL$TAG", "updateDriveStatusTask")
|
||||
AdasServiceModel.getInstance()
|
||||
.updateDriveStatus(mCurrentAutopilotStatus, mCurrentAutopilotSpeed)
|
||||
}
|
||||
}, 0, 5000)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun tokenGot(sn: String) {
|
||||
|
||||
Reference in New Issue
Block a user