[6.4.0][启自驾指引] 优化埋点逻辑;优化轨迹下载逻辑
This commit is contained in:
@@ -8,6 +8,7 @@ import androidx.lifecycle.*
|
||||
import androidx.lifecycle.Lifecycle.Event
|
||||
import androidx.lifecycle.Lifecycle.Event.ON_CREATE
|
||||
import androidx.lifecycle.Lifecycle.Event.ON_DESTROY
|
||||
import com.mogo.commons.utils.MogoAnalyticUtils
|
||||
import com.mogo.eagle.core.function.call.autopilot.*
|
||||
import com.mogo.eagle.core.utilcode.kotlin.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.*
|
||||
@@ -183,6 +184,12 @@ object StatusManager {
|
||||
var ret = 0
|
||||
model.status.value?.second?.filter {
|
||||
it is IAutopilotPreLaunchStatus
|
||||
}?.takeIf {
|
||||
it.isNotEmpty()
|
||||
}?.also { l ->
|
||||
runCatching {
|
||||
MogoAnalyticUtils.track("vehicle_state_exp", HashMap<String, Any>().also { itx -> itx["data"] = l.joinToString(",") { it.toString() } })
|
||||
}
|
||||
}?.forEachIndexed { index, status ->
|
||||
val shl = 1 shl index
|
||||
if (status.isException()) {
|
||||
|
||||
@@ -484,7 +484,7 @@ enum class RouteState {
|
||||
/**
|
||||
* 轨迹下载状态
|
||||
*/
|
||||
data class RouteDownloadStatus(val lineId: Long = -1, val state: RouteState = RouteNone): Status(), IAutopilotPreLaunchStatus {
|
||||
data class RouteDownloadStatus(val lineId: Long = Long.MIN_VALUE, val state: RouteState = RouteNone): Status(), IAutopilotPreLaunchStatus {
|
||||
|
||||
override fun isException(): Boolean {
|
||||
return (state == RouteStart || state == RouteFailed) && CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.zhjt.mogo_core_function_devatools.status.flow
|
||||
import android.content.*
|
||||
import android.util.*
|
||||
import androidx.annotation.*
|
||||
import com.mogo.commons.utils.MogoAnalyticUtils
|
||||
import com.mogo.eagle.core.utilcode.kotlin.*
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.Status
|
||||
import kotlinx.coroutines.*
|
||||
@@ -33,11 +32,6 @@ internal abstract class IFlow< T : Status>(val ctx: Context) : CoroutineScope {
|
||||
}
|
||||
|
||||
fun send(t: T) {
|
||||
if (t.isException()) {
|
||||
runCatching {
|
||||
MogoAnalyticUtils.track("vehicle_state_exp", HashMap<String, Any>().also { it["data"] = t.toString() })
|
||||
}
|
||||
}
|
||||
chl.trySend(t)
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ internal class AcceleratorImpl(ctx: Context): IFlow<AcceleratorStatus>(ctx), IMo
|
||||
}
|
||||
|
||||
override fun onAutopilotAbility(isAutopilotAbility: Boolean, unableLaunchData: UnableLaunchData?, unableAutopilotReasons: ArrayList<UnableLaunchReason>?) {
|
||||
Logger.d(TAG, "onAutopilotAbility->($isAutopilotAbility, $unableLaunchData, ${unableAutopilotReasons?.joinToString(",")}")
|
||||
if (!isAutopilotAbility) {
|
||||
val target = unableAutopilotReasons?.find { it.unableType == CHASSIS_THROTTLE }?.also {
|
||||
isError = true
|
||||
|
||||
@@ -47,7 +47,6 @@ internal class BrakeImpl(ctx: Context): IFlow<BrakeStatus>(ctx), IMoGoChassisBra
|
||||
}
|
||||
|
||||
override fun onAutopilotAbility(isAutopilotAbility: Boolean, unableLaunchData: UnableLaunchData?, unableAutopilotReasons: ArrayList<UnableLaunchReason>?) {
|
||||
Logger.d(TAG, "onAutopilotAbility->($isAutopilotAbility, $unableLaunchData, ${unableAutopilotReasons?.joinToString(",")}")
|
||||
if (!isAutopilotAbility) {
|
||||
val target = unableAutopilotReasons?.find { it.unableType == CHASSIS_BRAKE }?.also {
|
||||
isError = true
|
||||
|
||||
@@ -52,7 +52,6 @@ internal class DoubleFlashImpl(ctx: Context): IFlow<DoubleFlashStatus>(ctx), IMo
|
||||
}
|
||||
|
||||
override fun onAutopilotAbility(isAutopilotAbility: Boolean, unableLaunchData: UnableLaunchData?, unableAutopilotReasons: ArrayList<UnableLaunchReason>?) {
|
||||
Logger.d(TAG, "onAutopilotAbility->($isAutopilotAbility, $unableLaunchData, ${unableAutopilotReasons?.joinToString(",")}")
|
||||
if (!isAutopilotAbility) {
|
||||
val target = unableAutopilotReasons?.find { it.unableType == CHASSIS_HAZARD_LIGHTS }?.also {
|
||||
isError = true
|
||||
|
||||
@@ -46,7 +46,6 @@ internal class GearImpl(ctx: Context): IFlow<GearStatus>(ctx), IMoGoChassisGearS
|
||||
}
|
||||
|
||||
override fun onAutopilotAbility(isAutopilotAbility: Boolean, unableLaunchData: UnableLaunchData?, unableAutopilotReasons: ArrayList<UnableLaunchReason>?) {
|
||||
Logger.d(TAG, "onAutopilotAbility->($isAutopilotAbility, $unableLaunchData, ${unableAutopilotReasons?.joinToString(",")}")
|
||||
if (!isAutopilotAbility) {
|
||||
val target = unableAutopilotReasons?.find { it.unableType == CHASSIS_GEAR }?.also {
|
||||
isError = true
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.zhjt.mogo_core_function_devatools.status.entity.RouteState.RouteStart
|
||||
import com.zhjt.mogo_core_function_devatools.status.flow.IFlow
|
||||
import mogo_msg.MogoReportMsg.MogoReportMessage
|
||||
import java.lang.Exception
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
|
||||
internal class RouteDownloadImpl(ctx: Context): IFlow<RouteDownloadStatus>(ctx), IMoGoAutopilotStatusListener {
|
||||
@@ -25,6 +26,8 @@ internal class RouteDownloadImpl(ctx: Context): IFlow<RouteDownloadStatus>(ctx),
|
||||
@Volatile
|
||||
private var toDownloadData: AutoPilotLine? = null
|
||||
|
||||
private val linked by lazy { ConcurrentHashMap<Int, Any>() }
|
||||
|
||||
override fun onCreate() {
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
|
||||
}
|
||||
@@ -34,19 +37,32 @@ internal class RouteDownloadImpl(ctx: Context): IFlow<RouteDownloadStatus>(ctx),
|
||||
CallerAutoPilotStatusListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
override fun onAutopilotStatusResponse(state: Int) {
|
||||
super.onAutopilotStatusResponse(state)
|
||||
Logger.d(TAG, "--- onAutopilotStatusResponse -- 1 --: $state")
|
||||
if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
Logger.d(TAG, "--- onAutopilotStatusResponse -- 2 --")
|
||||
linked.clear()
|
||||
send(RouteDownloadStatus(toDownloadData?.lineId ?: Long.MIN_VALUE, RouteComplete))
|
||||
toDownloadData = null
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotTrajectoryDownloadReq(autoPilotLine: AutoPilotLine, downloadType: Int) {
|
||||
super.onAutopilotTrajectoryDownloadReq(autoPilotLine, downloadType)
|
||||
Logger.d(TAG, "--- onAutopilotTrajectoryDownloadReq --: 1:$autoPilotLine, 2:$downloadType")
|
||||
if (downloadType == 0) {
|
||||
linked.clear()
|
||||
linked[0] = autoPilotLine.lineId
|
||||
toDownloadData = autoPilotLine
|
||||
val lineId = autoPilotLine.lineId
|
||||
send(RouteDownloadStatus(lineId = lineId, state = RouteNone).also { it.rawData = toDownloadData })
|
||||
send(RouteDownloadStatus(lineId = lineId, state = RouteNone).also { it.rawData = toDownloadData })
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotGuardian(guardianInfo: MogoReportMessage?) {
|
||||
super.onAutopilotGuardian(guardianInfo)
|
||||
var lineId = -1L
|
||||
var lineId = Long.MIN_VALUE
|
||||
Logger.d(TAG, "--- onAutopilotGuardian -- 1 --: ${ guardianInfo?.code }")
|
||||
if (MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_START == guardianInfo?.code ||
|
||||
MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_SUCCESS == guardianInfo?.code ||
|
||||
@@ -63,7 +79,7 @@ internal class RouteDownloadImpl(ctx: Context): IFlow<RouteDownloadStatus>(ctx),
|
||||
lineId = matchResult.groupValues[1].toLong()
|
||||
}
|
||||
} catch (ignore: Exception) { }
|
||||
if (lineId == -1L) {
|
||||
if (lineId == Long.MIN_VALUE) {
|
||||
try {
|
||||
val regex = Regex("lineID=(\\d+)")
|
||||
val matchResult = regex.find(msg)
|
||||
@@ -82,14 +98,17 @@ internal class RouteDownloadImpl(ctx: Context): IFlow<RouteDownloadStatus>(ctx),
|
||||
Logger.d(TAG, "--- onAutopilotGuardian -- 4 --:line_id => $lineId, code: ${guardianInfo.code}")
|
||||
when (guardianInfo.code) {
|
||||
"ISYS_INIT_TRAJECTORY_START" -> { // 1. 轨迹管理_轨迹开始下载(本地已有对应轨迹也触发)
|
||||
send(RouteDownloadStatus(lineId, RouteStart).also { it.rawData = toDownloadData to guardianInfo })
|
||||
linked[1] = lineId
|
||||
send(RouteDownloadStatus(lineId, RouteStart).also { it.rawData = linked })
|
||||
}
|
||||
"ISYS_INIT_TRAJECTORY_SUCCESS" -> { // 2. 轨迹管理_轨迹下载成功(本地已有对应轨迹也触发)
|
||||
send(RouteDownloadStatus(lineId, RouteComplete).also { it.rawData = toDownloadData to guardianInfo })
|
||||
linked[2] = lineId
|
||||
send(RouteDownloadStatus(lineId, RouteComplete).also { it.rawData = linked })
|
||||
toDownloadData = null
|
||||
}
|
||||
"ISYS_INIT_TRAJECTORY_FAILURE" -> { // 3. 轨迹管理_轨迹下载失败,本地无对应轨迹
|
||||
send(RouteDownloadStatus(lineId, RouteFailed).also { it.rawData = toDownloadData to guardianInfo })
|
||||
linked[3] = lineId
|
||||
send(RouteDownloadStatus(lineId, RouteFailed).also { it.rawData = linked })
|
||||
toDownloadData = null
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user