[6.4.0][启自驾指引] 适配油门/刹车值展示;添加异常状态埋点

This commit is contained in:
renwj
2024-04-22 17:18:27 +08:00
parent f54d167d8e
commit c3a94b2db0
11 changed files with 138 additions and 44 deletions

View File

@@ -8,7 +8,7 @@ import com.zhjt.mogo_core_function_devatools.status.entity.RouteState.RouteStart
import com.zhjt.mogo_core_function_devatools.status.entity.TracingStatus.Tracing
import com.zhjt.mogo_core_function_devatools.status.entity.TracingStatus.Tracing.*
sealed class Status {
sealed class Status(var rawData: Any? = null) {
abstract fun isException(): Boolean
@@ -34,7 +34,7 @@ class IpcStatus(val enabled: Boolean = false): Status() {
}
override fun toString(): String {
return "IpcStatus(enabled=$enabled)"
return "IpcStatus(enabled=$enabled, raw_data:$rawData)"
}
override fun isException(): Boolean = !enabled
@@ -84,7 +84,7 @@ class GpsStatus(val enabled: Boolean = false, val isGranted: Boolean = false): S
}
override fun toString(): String {
return "GpsStatus(enabled=$enabled, isGranted=$isGranted)"
return "GpsStatus(enabled=$enabled, isGranted=$isGranted, raw_data:$rawData)"
}
override fun isException(): Boolean = !enabled || !isGranted
@@ -114,7 +114,7 @@ class RTKStatus(var desc: String = "", var state: Int): Status() {
}
override fun toString(): String {
return "RTKStatus(desc='$desc', state=$state)"
return "RTKStatus(desc='$desc', state=$state, raw_data:$rawData)"
}
override fun isException(): Boolean = desc.isEmpty() || (desc == "RTK") && state != 0
@@ -137,7 +137,7 @@ class CanStatus(var enabled: Boolean = false): Status() {
}
override fun toString(): String {
return "CanStatus(enabled=$enabled)"
return "CanStatus(enabled=$enabled, raw_data:$rawData)"
}
override fun isException(): Boolean = !enabled
@@ -211,7 +211,7 @@ class TracingStatus(var state: Tracing = UNKNOWN): Status() {
}
override fun toString(): String {
return "TracingStatus(state=$state)"
return "TracingStatus(state=$state, raw_data:$rawData)"
}
override fun equals(other: Any?): Boolean {
@@ -246,7 +246,6 @@ class OverViewStatus(var hasException: Boolean = false): Status() {
override fun hashCode(): Int {
return 0
}
}
fun String.toState(msg: String?): Tracing? {
@@ -333,6 +332,12 @@ data class SteerStatus(val angle: Float, var isError: Boolean = false): Status()
result = 31 * result + isError.hashCode()
return result
}
override fun toString(): String {
return "SteerStatus(angle=$angle, isError=$isError, raw_data:$rawData)"
}
}
/**
@@ -362,7 +367,9 @@ data class AcceleratorStatus(val angle: Float, var isError: Boolean = false): St
return result
}
override fun toString(): String {
return "AcceleratorStatus(angle=$angle, isError=$isError, raw_data:$rawData)"
}
}
/**
@@ -391,6 +398,10 @@ data class BrakeStatus(val angle: Float, var isError: Boolean = false): Status()
result = 31 * result + isError.hashCode()
return result
}
override fun toString(): String {
return "BrakeStatus(angle=$angle, isError=$isError, raw_data:$rawData)"
}
}
@@ -420,6 +431,12 @@ data class DoubleFlashStatus(val type: Int, var isError: Boolean = false): Statu
result = 31 * result + isError.hashCode()
return result
}
override fun toString(): String {
return "DoubleFlashStatus(type=$type, isError=$isError, raw_data:$rawData)"
}
}
/**
@@ -448,6 +465,12 @@ data class GearStatus(val value: Int, var isError: Boolean = false): Status(), I
result = 31 * result + isError.hashCode()
return result
}
override fun toString(): String {
return "GearStatus(value=$value, isError=$isError, raw_data:$rawData)"
}
}
enum class RouteState {
@@ -484,6 +507,10 @@ data class RouteDownloadStatus(val lineId: Long = -1, val state: RouteState = Ro
result = 31 * result + state.hashCode()
return result
}
override fun toString(): String {
return "RouteDownloadStatus(lineId=$lineId, state=$state, raw_data:$rawData)"
}
}

View File

@@ -3,6 +3,7 @@ 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.*
@@ -32,6 +33,11 @@ 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)
}

View File

@@ -46,9 +46,15 @@ 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 && unableAutopilotReasons != null && unableAutopilotReasons.find { it.unableType == CHASSIS_THROTTLE } != null) {
isError = true
send(AcceleratorStatus(last ?: 0.0f, true))
if (!isAutopilotAbility) {
val target = unableAutopilotReasons?.find { it.unableType == CHASSIS_THROTTLE }?.also {
isError = true
send(AcceleratorStatus(last ?: 0.0f, true).also { it.rawData = it })
}
if (target == null) {
isError = false
send(AcceleratorStatus(last ?: 0.0f, false))
}
} else {
isError = false
send(AcceleratorStatus(last ?: 0.0f, false))

View File

@@ -40,18 +40,23 @@ internal class BrakeImpl(ctx: Context): IFlow<BrakeStatus>(ctx), IMoGoChassisBra
override fun onAutopilotBrake(brake: Float) {
super.onAutopilotBrake(brake)
if (last != brake) {
send(BrakeStatus(brake, isError))
send(BrakeStatus(brake, isError).also { it.rawData = brake })
last = brake
}
}
override fun onAutopilotAbility(isAutopilotAbility: Boolean, unableLaunchData: UnableLaunchData?, unableAutopilotReasons: ArrayList<UnableLaunchReason>?) {
Logger.d(TAG, "onAutopilotAbility->($isAutopilotAbility, $unableLaunchData, ${unableAutopilotReasons?.joinToString(",")}")
if (!isAutopilotAbility && unableAutopilotReasons != null && unableAutopilotReasons.find { it.unableType == CHASSIS_BRAKE } != null) {
isError = true
send(BrakeStatus(last, true))
if (!isAutopilotAbility) {
val target = unableAutopilotReasons?.find { it.unableType == CHASSIS_BRAKE }?.also {
isError = true
send(BrakeStatus(last, true).also { it.rawData = it })
}
if (target == null) {
isError = false
send(BrakeStatus(last, false))
}
} else {
isError = false
send(BrakeStatus(last, false))

View File

@@ -25,6 +25,9 @@ internal class DoubleFlashImpl(ctx: Context): IFlow<DoubleFlashStatus>(ctx), IMo
@Volatile
private var isError: Boolean = false
@Volatile
private var last: LightSwitch? = null
override fun onCreate() {
CallerChassisLamplightListenerManager.addListener(TAG, this)
CallerAutopilotActionsListenerManager.addListener(TAG, this)
@@ -39,20 +42,29 @@ internal class DoubleFlashImpl(ctx: Context): IFlow<DoubleFlashStatus>(ctx), IMo
override fun onAutopilotLightSwitchData(lightSwitch: LightSwitch?) {
super.onAutopilotLightSwitchData(lightSwitch)
Logger.d(TAG, "-- onAutopilotLightSwitchData --: $lightSwitch")
if (lightSwitch == LIGHT_FLASH) {
send(DoubleFlashStatus(lightSwitch.number, isError))
if (last != lightSwitch) {
last = lightSwitch
if (lightSwitch == LIGHT_FLASH) {
send(DoubleFlashStatus(lightSwitch.number, isError))
}
}
}
override fun onAutopilotAbility(isAutopilotAbility: Boolean, unableLaunchData: UnableLaunchData?, unableAutopilotReasons: ArrayList<UnableLaunchReason>?) {
Logger.d(TAG, "onAutopilotAbility->($isAutopilotAbility, $unableLaunchData, ${unableAutopilotReasons?.joinToString(",")}")
if (!isAutopilotAbility && unableAutopilotReasons != null && unableAutopilotReasons.find { it.unableType == CHASSIS_HAZARD_LIGHTS } != null) {
isError = true
send(DoubleFlashStatus(LIGHT_FLASH.number, true))
if (!isAutopilotAbility) {
val target = unableAutopilotReasons?.find { it.unableType == CHASSIS_HAZARD_LIGHTS }?.also {
isError = true
send(DoubleFlashStatus(last?.number ?: Int.MIN_VALUE, true).also { it.rawData = last to it })
}
if (target == null) {
isError = false
send(DoubleFlashStatus(last?.number ?: Int.MIN_VALUE, false).also { it.rawData = last })
}
} else {
isError = false
send(DoubleFlashStatus(LIGHT_FLASH.number, false))
send(DoubleFlashStatus(last?.number ?: Int.MIN_VALUE, false).also { it.rawData = last })
}
}
}

View File

@@ -12,6 +12,7 @@ import com.zhjt.mogo.adas.data.bean.UnableLaunchData
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason.UnableType.CHASSIS_GEAR
import com.zhjt.mogo_core_function_devatools.status.entity.GearStatus
import com.zhjt.mogo_core_function_devatools.status.entity.SteerStatus
import com.zhjt.mogo_core_function_devatools.status.flow.IFlow
internal class GearImpl(ctx: Context): IFlow<GearStatus>(ctx), IMoGoChassisGearStateListener, IMoGoAutopilotActionsListener {
@@ -39,16 +40,22 @@ internal class GearImpl(ctx: Context): IFlow<GearStatus>(ctx), IMoGoChassisGearS
override fun onAutopilotGearData(gear: GearPosition) {
if (last != gear) {
send(GearStatus(gear.number, isError))
send(GearStatus(gear.number, isError).also { it.rawData = gear })
last = gear
}
}
override fun onAutopilotAbility(isAutopilotAbility: Boolean, unableLaunchData: UnableLaunchData?, unableAutopilotReasons: ArrayList<UnableLaunchReason>?) {
Logger.d(TAG, "onAutopilotAbility->($isAutopilotAbility, $unableLaunchData, ${unableAutopilotReasons?.joinToString(",")}")
if (!isAutopilotAbility && unableAutopilotReasons != null && unableAutopilotReasons.find { it.unableType == CHASSIS_GEAR } != null) {
isError = true
send(GearStatus(last.number, true))
if (!isAutopilotAbility) {
val target = unableAutopilotReasons?.find { it.unableType == CHASSIS_GEAR }?.also {
isError = true
send(GearStatus(last.number, true).also { it.rawData = last to it })
}
if (target == null) {
isError = false
send(GearStatus(last.number, false))
}
} else {
isError = false
send(GearStatus(last.number, false))

View File

@@ -4,10 +4,12 @@ import android.content.Context
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters.AutoPilotLine
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.zhjt.mogo.adas.data.bean.MogoReport
import com.zhjt.mogo_core_function_devatools.status.entity.RouteDownloadStatus
import com.zhjt.mogo_core_function_devatools.status.entity.RouteState.RouteComplete
import com.zhjt.mogo_core_function_devatools.status.entity.RouteState.RouteFailed
import com.zhjt.mogo_core_function_devatools.status.entity.RouteState.RouteNone
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
@@ -21,7 +23,7 @@ internal class RouteDownloadImpl(ctx: Context): IFlow<RouteDownloadStatus>(ctx),
}
@Volatile
private var toDownloadLineId: Long = Long.MIN_VALUE
private var toDownloadData: AutoPilotLine? = null
override fun onCreate() {
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
@@ -34,20 +36,25 @@ internal class RouteDownloadImpl(ctx: Context): IFlow<RouteDownloadStatus>(ctx),
override fun onAutopilotTrajectoryDownloadReq(autoPilotLine: AutoPilotLine, downloadType: Int) {
super.onAutopilotTrajectoryDownloadReq(autoPilotLine, downloadType)
Logger.d(TAG, "--- onAutopilotTrajectoryDownloadReq --: 1:$autoPilotLine, 2:$downloadType")
if (downloadType == 0) {
toDownloadLineId = autoPilotLine.lineId
toDownloadData = autoPilotLine
val lineId = autoPilotLine.lineId
send(RouteDownloadStatus(lineId = lineId, state = RouteNone).also { it.rawData = toDownloadData })
}
}
override fun onAutopilotGuardian(guardianInfo: MogoReportMessage?) {
super.onAutopilotGuardian(guardianInfo)
var lineId = -1L
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 ||
MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_FAILURE == guardianInfo?.code ||
MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_WARNING == guardianInfo?.code ||
MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_TIMEOUT == guardianInfo?.code
) {
Logger.d(TAG, "--- onAutopilotGuardian -- 2 --")
val msg = guardianInfo.msg
try {
val regex = Regex("lineid:(\\d+)")
@@ -66,24 +73,24 @@ internal class RouteDownloadImpl(ctx: Context): IFlow<RouteDownloadStatus>(ctx),
} catch (ignore: Exception) { }
}
}
if (toDownloadLineId != lineId) {
Logger.d(TAG, "--- onAutopilotGuardian -- 3 --:lineId => ${toDownloadData?.lineId}, parse_line_id: $lineId")
if (toDownloadData?.lineId != lineId) {
return
}
CallerAutoPilotStatusListenerManager.updateAutopilotControlParameters()
if (guardianInfo == null || !guardianInfo.hasCode())
return
Logger.d(TAG, "--- onAutopilotGuardian -- 4 --:line_id => $lineId, code: ${guardianInfo.code}")
when (guardianInfo.code) {
"ISYS_INIT_TRAJECTORY_START" -> { // 1. 轨迹管理_轨迹开始下载本地已有对应轨迹也触发
send(RouteDownloadStatus(lineId, RouteStart))
send(RouteDownloadStatus(lineId, RouteStart).also { it.rawData = toDownloadData to guardianInfo })
}
"ISYS_INIT_TRAJECTORY_SUCCESS" -> { // 2. 轨迹管理_轨迹下载成功本地已有对应轨迹也触发
send(RouteDownloadStatus(lineId, RouteComplete))
toDownloadLineId = Long.MIN_VALUE
send(RouteDownloadStatus(lineId, RouteComplete).also { it.rawData = toDownloadData to guardianInfo })
toDownloadData = null
}
"ISYS_INIT_TRAJECTORY_FAILURE" -> { // 3. 轨迹管理_轨迹下载失败本地无对应轨迹
send(RouteDownloadStatus(lineId, RouteFailed))
toDownloadLineId = Long.MIN_VALUE
send(RouteDownloadStatus(lineId, RouteFailed).also { it.rawData = toDownloadData to guardianInfo })
toDownloadData = null
}
}
}

View File

@@ -21,6 +21,9 @@ internal class SteerImpl(ctx: Context): IFlow<SteerStatus>(ctx), IMoGoChassisSte
@Volatile
private var last: Float = 0f
@Volatile
private var isError: Boolean = false
override fun onCreate() {
CallerChassisSteeringStateListenerManager.addListener(TAG, this)
CallerAutopilotActionsListenerManager.addListener(TAG, this)
@@ -34,17 +37,25 @@ internal class SteerImpl(ctx: Context): IFlow<SteerStatus>(ctx), IMoGoChassisSte
override fun onAutopilotSteeringData(steering: Float) {
if (last != steering) {
send(SteerStatus(steering))
send(SteerStatus(steering, isError).also { it.rawData = steering })
last = steering
}
}
override fun onAutopilotAbility(isAutopilotAbility: Boolean, unableLaunchData: UnableLaunchData?, unableAutopilotReasons: ArrayList<UnableLaunchReason>?) {
Logger.d(TAG, "onAutopilotAbility->($isAutopilotAbility, $unableLaunchData, ${unableAutopilotReasons?.joinToString(",")}")
if (!isAutopilotAbility && unableAutopilotReasons != null && unableAutopilotReasons.find { it.unableType == CHASSIS_STEERING } != null) {
send(SteerStatus(last, true))
if (!isAutopilotAbility) {
val target = unableAutopilotReasons?.find { it.unableType == CHASSIS_STEERING }?.also {
isError = true
send(SteerStatus(last, true).also { it.rawData = last to it })
}
if (target == null) {
isError = false
send(SteerStatus(last, false).also { it.rawData = last })
}
} else {
send(SteerStatus(last, false))
isError = false
send(SteerStatus(last, false).also { it.rawData = last })
}
}
}

View File

@@ -48,6 +48,8 @@ class AutoPilotLaunchBeforeView: LinearLayout, IStatusListener {
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
LayoutInflater.from(context).inflate(R.layout.layout_autopilot_launch_before, this, true)
background = ContextCompat.getDrawable(context, R.drawable.icon_bg_autopilot_status)
clipChildren = false
clipToPadding = false
setPadding(AutoSizeUtils.dp2px(context, 29f), AutoSizeUtils.dp2px(context, 35f), AutoSizeUtils.dp2px(context, 30f), AutoSizeUtils.dp2px(context, 30f))
}

View File

@@ -9,7 +9,9 @@
tools:paddingTop="@dimen/dp_35"
tools:paddingBottom="@dimen/dp_30"
tools:paddingStart="@dimen/dp_29"
tools:paddingEnd="@dimen/dp_30">
tools:paddingEnd="@dimen/dp_30"
tools:clipToPadding="false"
tools:clipChildren="false">
<LinearLayout
android:id="@+id/speed_chart_parent"
@@ -41,7 +43,9 @@
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center_vertical"
android:paddingEnd="@dimen/dp_34">
android:paddingEnd="@dimen/dp_34"
android:clipChildren="false"
android:clipToPadding="false">
<LinearLayout
android:layout_width="wrap_content"
@@ -100,7 +104,10 @@
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_34"
android:gravity="center_vertical"
android:layout_marginTop="@dimen/dp_23">
android:layout_marginTop="@dimen/dp_23"
android:paddingEnd="-30dp"
android:clipToPadding="false"
android:clipChildren="false">
<ImageView
android:id="@+id/iv_steer"
@@ -129,8 +136,9 @@
android:layout_height="wrap_content"
android:textSize="@dimen/dp_34"
android:layout_marginTop="-1dp"
android:maxLines="1"
android:textColor="@color/white"
android:text="a:-0.0"/>
android:text="a:-"/>
</LinearLayout>
</LinearLayout>
</merge>

View File

@@ -65,6 +65,9 @@ class StatusBarView @JvmOverloads constructor(
CallerDevaToolsManager.registerRouteDownloadListener(TAG) { state ->
routeDownloadStatusRoot?.visibility = View.VISIBLE
when(state) {
0 -> {
routeDownloadStatusRoot?.visibility = View.GONE
}
1 -> {
routeDownloadStatus?.background = ContextCompat.getDrawable(context, R.drawable.bg_autopilot_route_download_start)
routeDownloadFailMark?.visibility = View.GONE