[8.1.2][opt]新增决策的路口场景

This commit is contained in:
chenfufeng
2025-07-10 17:53:30 +08:00
parent 67ce8b1c8c
commit f275e27b03

View File

@@ -7,10 +7,15 @@ import android.os.SystemClock
import android.util.AttributeSet
import android.view.LayoutInflater
import androidx.constraintlayout.widget.ConstraintLayout
import chassis.Chassis
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningActionsListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisStatesListener
import com.mogo.eagle.core.function.api.map.road.IMoGoMapRoadListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisStatesListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningActionsListenerManager
import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager
import com.mogo.eagle.core.function.map.R
import com.mogo.eagle.core.utilcode.util.ThreadUtils
import com.shuyu.gsyvideoplayer.GSYVideoManager
@@ -19,6 +24,7 @@ import com.shuyu.gsyvideoplayer.model.VideoOptionModel
import com.shuyu.gsyvideoplayer.player.IjkPlayerManager
import com.shuyu.gsyvideoplayer.player.PlayerFactory
import com.shuyu.gsyvideoplayer.utils.GSYVideoType
import com.zhidaoauto.map.data.road.StopLine
import kotlinx.android.synthetic.main.layout_decision_container.view.tvPre1
import kotlinx.android.synthetic.main.layout_decision_container.view.tvPre2
import kotlinx.android.synthetic.main.layout_decision_container.view.tvPre3
@@ -36,7 +42,7 @@ class DecisionLayout @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null
) : ConstraintLayout(context, attrs), IMoGoAutopilotIdentifyListener,
IMoGoAutopilotPlanningActionsListener {
IMoGoAutopilotPlanningActionsListener, IMoGoMapRoadListener, IMoGoChassisStatesListener {
companion object {
private const val TAG = "DecisionLayout"
@@ -84,12 +90,16 @@ class DecisionLayout @JvmOverloads constructor(
super.onAttachedToWindow()
CallerAutopilotIdentifyListenerManager.addListener(TAG, this)
CallerPlanningActionsListenerManager.addListener(TAG, this)
CallerMapRoadListenerManager.addListener(TAG, this)
CallerChassisStatesListenerManager.addListener(TAG, this)
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
CallerAutopilotIdentifyListenerManager.removeListener(TAG)
CallerPlanningActionsListenerManager.removeListener(TAG)
CallerMapRoadListenerManager.removeListener(TAG)
CallerChassisStatesListenerManager.removeListener(TAG)
}
fun onCreate(savedInstanceState: Bundle?) {
@@ -147,6 +157,53 @@ class DecisionLayout @JvmOverloads constructor(
}
}
@Volatile
private var turnLightStatus: Int = -1
override fun onAutopilotLightSwitchData(lightSwitch: Chassis.LightSwitch?) {
lightSwitch?.let {
turnLightStatus = when (it.number) {
Chassis.LightSwitch.LIGHT_LEFT_VALUE -> {
1
}
Chassis.LightSwitch.LIGHT_RIGHT_VALUE -> {
2
}
Chassis.LightSwitch.LIGHT_NONE_VALUE -> {
0
}
else -> {
-1
}
}
}
}
private var lastUpdateTime = 0L
override fun onStopLineInfo(info: StopLine) {
if (info.distance < 15) {
val time = System.currentTimeMillis()
if (time - lastUpdateTime > 500) {
lastUpdateTime = time
ThreadUtils.runOnUiThread {
when (turnLightStatus) {
0 -> {
updateAnim(8)
}
1 -> {
updateAnim(7)
}
2 -> {
updateAnim(9)
}
}
}
}
}
}
@SuppressLint("SetTextI18n")
private fun updateAnim(type: Int) {
val randomNum = 80 + Random(SystemClock.elapsedRealtime()).nextInt(16)