[状态栏]RTK状态兼容旧Map版本
[状态栏]xxx [状态栏]
This commit is contained in:
@@ -7,11 +7,13 @@ import com.mogo.eagle.core.function.call.autopilot.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.*
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.RTKStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.flow.IFlow
|
||||
import kotlinx.coroutines.*
|
||||
import mogo.telematics.pad.MessagePad.GnssInfo
|
||||
import system_master.SystemStatusInfo.HealthInfo
|
||||
import system_master.SystemStatusInfo.StatusInfo
|
||||
import java.util.concurrent.atomic.*
|
||||
|
||||
internal class RTKImpl(ctx: Context): IFlow<RTKStatus>(ctx), IMoGoAutopilotStatusListener {
|
||||
internal class RTKImpl(ctx: Context): IFlow<RTKStatus>(ctx), IMoGoAutopilotStatusListener, IMoGoAutopilotCarStateListener {
|
||||
companion object {
|
||||
const val TAG = "RTKImpl"
|
||||
}
|
||||
@@ -20,13 +22,40 @@ internal class RTKImpl(ctx: Context): IFlow<RTKStatus>(ctx), IMoGoAutopilotStatu
|
||||
AtomicReference<HealthInfo>(null)
|
||||
}
|
||||
|
||||
private val isOldVersion = AtomicBoolean(false)
|
||||
|
||||
private var check: Job? = null
|
||||
|
||||
private var timeOutCheck: Job? = null
|
||||
|
||||
|
||||
override fun onCreate() {
|
||||
send(RTKStatus(getDesc(), getCode()))
|
||||
Logger.d(TAG, "-- onCreate --")
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
|
||||
CallerAutopilotCarStatusListenerManager.addListener(TAG, this)
|
||||
if (CallerAutoPilotManager.isConnected()) {
|
||||
check()
|
||||
}
|
||||
}
|
||||
|
||||
private fun check() {
|
||||
if (isOldVersion.get()) {
|
||||
return
|
||||
}
|
||||
check?.takeIf { it.isActive }?.cancel()
|
||||
launch {
|
||||
CallerAutoPilotManager.sendStatusQueryReq()
|
||||
delay(5000)
|
||||
isOldVersion.set(true)
|
||||
}.also {
|
||||
check = it
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotStatusRespByQuery(status: StatusInfo) {
|
||||
check?.takeIf { it.isActive }?.cancel()
|
||||
isOldVersion.set(false)
|
||||
val info = status.healthInfoList?.find { "localization".equals(it.name, true) }
|
||||
Log.d(TAG, "info: $info")
|
||||
if (info != null) {
|
||||
@@ -42,6 +71,36 @@ internal class RTKImpl(ctx: Context): IFlow<RTKStatus>(ctx), IMoGoAutopilotStatu
|
||||
healthInfo.set(null)
|
||||
send(RTKStatus("", -1))
|
||||
}
|
||||
|
||||
if (CallerAutoPilotManager.isConnected() && check == null && !isOldVersion.get()) {
|
||||
check()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotCarStateData(gnssInfo: GnssInfo?) {
|
||||
if (isOldVersion.get()) {
|
||||
if (isRTKEnabled()) {
|
||||
send(RTKStatus("RTK", 0))
|
||||
timeOutCheck?.takeIf { it.isActive }?.cancel()
|
||||
launch {
|
||||
delay(4000)
|
||||
send(RTKStatus("", -1))
|
||||
}.also {
|
||||
timeOutCheck = it
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun isRTKEnabled(): Boolean {
|
||||
val code = CallerAutoPilotStatusListenerManager.getAutoPilotReportMessageCode()
|
||||
val gnssInfo = CallerAutopilotCarStatusListenerManager.getCurrentGnssInfo()
|
||||
return CallerAutoPilotManager.isConnected() && (
|
||||
code != "EHW_RTK" &&
|
||||
code != "EHW_GNSS" &&
|
||||
code != "ESYS_RTK_STATUS_FAULT" &&
|
||||
code != "ELCT_RTK_STATUS_FAULT" &&
|
||||
code != "ELCT_RTK_STATUS_UNKNOWN") && gnssInfo != null
|
||||
}
|
||||
|
||||
private fun getDesc(): String {
|
||||
@@ -54,7 +113,9 @@ internal class RTKImpl(ctx: Context): IFlow<RTKStatus>(ctx), IMoGoAutopilotStatu
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
isOldVersion.set(false)
|
||||
Logger.d(TAG, "-- onDestroy --")
|
||||
CallerAutoPilotStatusListenerManager.removeListener(TAG)
|
||||
CallerAutopilotCarStatusListenerManager.removeListener(TAG)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user