[状态栏]优化循迹/算路状态逻辑获取
This commit is contained in:
@@ -230,18 +230,13 @@ class TracingStatus(var state: Tracing = UNKNOWN): Status() {
|
||||
override fun isException(): Boolean = state.isException()
|
||||
}
|
||||
|
||||
fun String.toState(): Tracing? {
|
||||
val ss = split("|")
|
||||
var code = ""
|
||||
if (ss.isNotEmpty()) {
|
||||
code = ss[0]
|
||||
}
|
||||
fun String.toState(msg: String?): Tracing? {
|
||||
val ss = msg?.split("|")
|
||||
var extra: Map<String, String>? = null
|
||||
if (ss.size > 1) {
|
||||
|
||||
if (ss != null && ss.isNotEmpty()) {
|
||||
val sb = StringBuilder()
|
||||
for (i in 1 until ss.size) {
|
||||
sb.append(ss[i])
|
||||
for (element in ss) {
|
||||
sb.append(element)
|
||||
sb.append(",")
|
||||
}
|
||||
if (sb.isNotEmpty()) {
|
||||
@@ -249,7 +244,7 @@ fun String.toState(): Tracing? {
|
||||
}
|
||||
extra = mutableMapOf("extra" to sb.toString())
|
||||
}
|
||||
return when(code) {
|
||||
return when(this) {
|
||||
"IMAP_TRA_EXIST" -> TRACK_FINDED.apply {
|
||||
this.extra = extra
|
||||
}
|
||||
|
||||
@@ -21,7 +21,8 @@ internal class TracingImpl(ctx: Context): IFlow<TracingStatus>(ctx), IMoGoAutopi
|
||||
|
||||
override fun onCreate() {
|
||||
val code = CallerAutoPilotStatusListenerManager.getAutoPilotReportMessageCode()
|
||||
val state = code.toState() ?: UNKNOWN
|
||||
val msg = CallerAutoPilotStatusListenerManager.getAutoPilotReportMessageContent()
|
||||
val state = code.toState(msg) ?: UNKNOWN
|
||||
old = state
|
||||
send(TracingStatus(state))
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
|
||||
@@ -31,7 +32,7 @@ internal class TracingImpl(ctx: Context): IFlow<TracingStatus>(ctx), IMoGoAutopi
|
||||
override fun onAutopilotGuardian(guardianInfo: MogoReportMessage?) {
|
||||
super.onAutopilotGuardian(guardianInfo)
|
||||
val current = guardianInfo?.code
|
||||
val newState = current?.toState()
|
||||
val newState = current?.toState(guardianInfo.msg)
|
||||
if (newState != null && newState != old) {
|
||||
send(TracingStatus(newState))
|
||||
old = newState
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.mogo.eagle.core.function.call.autopilot
|
||||
|
||||
import android.util.*
|
||||
import androidx.annotation.Nullable
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import com.mogo.eagle.core.utilcode.kotlin.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.*
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import mogo_msg.MogoReportMsg
|
||||
@@ -29,6 +31,10 @@ object CallerAutoPilotStatusListenerManager : CallerBase() {
|
||||
@Volatile
|
||||
private var autoPilotMessageCode: String = ""
|
||||
|
||||
|
||||
@Volatile
|
||||
private var autoPilotMessageContent: String = ""
|
||||
|
||||
/**
|
||||
* 查询AutoPilot状态
|
||||
*/
|
||||
@@ -45,6 +51,8 @@ object CallerAutoPilotStatusListenerManager : CallerBase() {
|
||||
|
||||
fun getAutoPilotReportMessageCode(): String = autoPilotMessageCode
|
||||
|
||||
fun getAutoPilotReportMessageContent(): String = autoPilotMessageContent
|
||||
|
||||
/**
|
||||
* 通过Gnss定位更新来同步更新自动驾驶状态
|
||||
*/
|
||||
@@ -171,6 +179,8 @@ object CallerAutoPilotStatusListenerManager : CallerBase() {
|
||||
M_AUTOPILOT_STATUS_LISTENERS.forEach {
|
||||
val listener = it.value
|
||||
autoPilotMessageCode = guardianInfo?.code ?: ""
|
||||
autoPilotMessageContent = guardianInfo?.msg ?: ""
|
||||
Logger.d("XXXXX", "code: ${guardianInfo?.code}, msg: ${guardianInfo?.msg}")
|
||||
listener.onAutopilotGuardian(guardianInfo)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user