[6.2.6]
[shuttle-jl] [灯UI och]
This commit is contained in:
@@ -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,
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user