[shuttle-jl]
[灯UI och]
This commit is contained in:
yangyakun
2023-12-06 13:50:27 +08:00
parent 1b676d34a3
commit d6ed5d59cb
5 changed files with 274 additions and 6 deletions

View File

@@ -0,0 +1,21 @@
package com.mogo.och.common.module.manager.lightmanager
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLamplightListener
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLamplightListenerManager
object BreakLightManager : IMoGoChassisLamplightListener {
private const val TAG = "BreakLightManager"
init {
CallerChassisLamplightListenerManager.addListener(TAG, this)
}
// 刹车灯
override fun onAutopilotBrakeLightData(brakeLight: Boolean) {
super.onAutopilotBrakeLightData(brakeLight)
}
enum class BreakLightStatus{
BREAK_LIGHT,
BREAK_NONE,
}
}

View File

@@ -0,0 +1,66 @@
package com.mogo.och.common.module.manager.lightmanager
import chassis.Chassis
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLamplightListener
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLamplightListenerManager
import java.util.concurrent.ConcurrentHashMap
import kotlin.properties.Delegates
object TurnLightManager : IMoGoChassisLamplightListener {
private const val TAG = "TurnLightManager"
private val lightStatusChange: ConcurrentHashMap<String, TurnLightListener> =
ConcurrentHashMap()
private var turnLightStatus:TurnLightStatus by Delegates.observable(TurnLightStatus.TURN_LIGHT_NONE) { _, oldValue, newValue ->
if (oldValue != newValue) {
if(lightStatusChange.size>0){
lightStatusChange.forEach {
it.value.statusChange(newValue)
}
}
}
}
init {
CallerChassisLamplightListenerManager.addListener(TAG, this)
}
fun addTurnLightStatusChangeListener(tag: String, listener: TurnLightListener) {
if (lightStatusChange.containsKey(tag)) {
return
}
lightStatusChange[tag] = listener
listener.statusChange(turnLightStatus)
}
// 转向灯
override fun onAutopilotLightSwitchData(lightSwitch: Chassis.LightSwitch?) {
super.onAutopilotLightSwitchData(lightSwitch)
lightSwitch?.let {
when (it.number) {
Chassis.LightSwitch.LIGHT_LEFT_VALUE -> {
turnLightStatus = TurnLightStatus.TURN_LIGHT_LEFT
}
Chassis.LightSwitch.LIGHT_RIGHT_VALUE -> {
turnLightStatus = TurnLightStatus.TURN_LIGHT_RIGHT
}
Chassis.LightSwitch.LIGHT_NONE_VALUE -> {
turnLightStatus = TurnLightStatus.TURN_LIGHT_NONE
}
else -> {}
}
}
}
interface TurnLightListener{
fun statusChange(newStatus: TurnLightStatus)
}
enum class TurnLightStatus{
TURN_LIGHT_LEFT,
TURN_LIGHT_RIGHT,
TURN_LIGHT_NONE,
}
}