[3.4.0] add func of door state invoke
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
@@ -18,10 +18,11 @@
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="@dimen/dp_27"
|
||||
android:layout_height="@dimen/dp_27"
|
||||
android:layout_marginStart="@dimen/dp_95"
|
||||
android:layout_marginTop="@dimen/dp_35"
|
||||
android:src="@drawable/iv_light_set"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvSettingLight" />
|
||||
|
||||
@@ -40,10 +41,11 @@
|
||||
app:layout_constraintWidth_percent="0.253" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="@dimen/dp_34"
|
||||
android:layout_height="@dimen/dp_34"
|
||||
android:layout_marginStart="@dimen/dp_535"
|
||||
android:layout_marginTop="@dimen/dp_35"
|
||||
android:layout_marginTop="@dimen/dp_32"
|
||||
android:src="@drawable/iv_light_increase_set"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvSettingLight" />
|
||||
|
||||
@@ -72,10 +74,11 @@
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvSettingLight" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="@dimen/dp_27"
|
||||
android:layout_height="@dimen/dp_27"
|
||||
android:layout_marginStart="@dimen/dp_95"
|
||||
android:layout_marginTop="@dimen/dp_35"
|
||||
android:src="@drawable/iv_voice_set"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvSettingSound" />
|
||||
|
||||
@@ -94,10 +97,11 @@
|
||||
app:layout_constraintWidth_percent="0.253" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="@dimen/dp_34"
|
||||
android:layout_height="@dimen/dp_34"
|
||||
android:layout_marginStart="@dimen/dp_535"
|
||||
android:layout_marginTop="@dimen/dp_35"
|
||||
android:layout_marginTop="@dimen/dp_32"
|
||||
android:src="@drawable/iv_voice_increase_set"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvSettingSound" />
|
||||
|
||||
@@ -105,7 +109,7 @@
|
||||
android:id="@+id/tvVoicePer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_333"
|
||||
android:layout_marginTop="@dimen/dp_330"
|
||||
android:layout_marginRight="@dimen/dp_113"
|
||||
android:gravity="right"
|
||||
android:textColor="@color/taxi_p_303C52"
|
||||
|
||||
@@ -170,6 +170,8 @@ class MoGoAdasListenerImpl : OnAdasListener {
|
||||
CallerChassisThrottleStateListenerManager.invokeAutopilotThrottle(vehicleState.throttle)
|
||||
//刹车
|
||||
CallerChassisBrakeStateListenerManager.invokeAutopilotBrake(vehicleState.brake)
|
||||
//车门
|
||||
CallerChassisDoorStateListenerManager.invokeAutopilotDoorState(vehicleState.doorStateList)
|
||||
//电量
|
||||
if (vehicleState.hasBmsSoc()) {
|
||||
CallerBatteryManagementSystemListenerManager.invokeBatteryManagementSystemStates(
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.mogo.eagle.core.function.api.autopilot
|
||||
|
||||
import chassis.Chassis.DoorNumber
|
||||
import chassis.VehicleStateOuterClass
|
||||
|
||||
/**
|
||||
* 车门数据 回调监听
|
||||
*/
|
||||
interface IMoGoChassisDoorStateListener {
|
||||
|
||||
/**
|
||||
* 车门状态集合 底盘HZ
|
||||
*/
|
||||
fun onAutopilotDoorState(doorList: MutableList<VehicleStateOuterClass.DoorStateV2>) {}
|
||||
|
||||
/**
|
||||
* 单个车门状态回调(变化回调)
|
||||
* @param num 枚举 taxi(前左/右,后左/右) / bus(中)
|
||||
* @param open true:开门(1), false:关门(0)
|
||||
*/
|
||||
fun onAutopilotSingleDoorState(num:DoorNumber, open:Boolean){}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.mogo.eagle.core.function.call.autopilot
|
||||
|
||||
import chassis.Chassis
|
||||
import chassis.VehicleStateOuterClass
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisDoorStateListener
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import java.util.*
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
/**
|
||||
* 车门数据 回调监听
|
||||
*/
|
||||
object CallerChassisDoorStateListenerManager : CallerBase<IMoGoChassisDoorStateListener>() {
|
||||
|
||||
private val listCache = Collections.emptyList<VehicleStateOuterClass.DoorStateV2>()
|
||||
|
||||
private var frontLeft by Delegates.observable(0) { _, oldV, newV ->
|
||||
if (oldV != newV) {
|
||||
invokeSingleDoorState(Chassis.DoorNumber.FRONT_LEFT, newV)
|
||||
}
|
||||
}
|
||||
|
||||
private var frontRight by Delegates.observable(0) { _, oldV, newV ->
|
||||
if (oldV != newV) {
|
||||
invokeSingleDoorState(Chassis.DoorNumber.FRONT_RIGHT, newV)
|
||||
}
|
||||
}
|
||||
|
||||
private var backLeft by Delegates.observable(0) { _, oldV, newV ->
|
||||
if (oldV != newV) {
|
||||
invokeSingleDoorState(Chassis.DoorNumber.REAR_LEFT, newV)
|
||||
}
|
||||
}
|
||||
|
||||
private var backRight by Delegates.observable(0) { _, oldV, newV ->
|
||||
if (oldV != newV) {
|
||||
invokeSingleDoorState(Chassis.DoorNumber.REAR_RIGHT, newV)
|
||||
}
|
||||
}
|
||||
|
||||
private var middle by Delegates.observable(0) { _, oldV, newV ->
|
||||
if (oldV != newV) {
|
||||
invokeSingleDoorState(Chassis.DoorNumber.MIDDLE, newV)
|
||||
}
|
||||
}
|
||||
|
||||
override fun doSomeAfterAddListener(tag: String, listener: IMoGoChassisDoorStateListener) {
|
||||
super.doSomeAfterAddListener(tag, listener)
|
||||
if (listCache.size > 0) {
|
||||
listener.onAutopilotDoorState(listCache)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 车门状态
|
||||
*/
|
||||
fun invokeAutopilotDoorState(doorList: MutableList<VehicleStateOuterClass.DoorStateV2>) {
|
||||
listCache.addAll(doorList)
|
||||
doorList.forEach {
|
||||
when (it.number) {
|
||||
Chassis.DoorNumber.FRONT_LEFT -> frontLeft = it.status
|
||||
Chassis.DoorNumber.FRONT_RIGHT -> frontRight = it.status
|
||||
Chassis.DoorNumber.REAR_LEFT -> backLeft = it.status
|
||||
Chassis.DoorNumber.REAR_RIGHT -> backRight = it.status
|
||||
Chassis.DoorNumber.MIDDLE -> middle = it.status
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
M_LISTENERS.forEach {
|
||||
val listener = it.value
|
||||
listener.onAutopilotDoorState(doorList)
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
private fun invokeSingleDoorState(num: Chassis.DoorNumber, value: Int) {
|
||||
M_LISTENERS.forEach {
|
||||
val listener = it.value
|
||||
listener.onAutopilotSingleDoorState(num, value == 1)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回所有门状态
|
||||
*/
|
||||
fun getDoorList(): List<VehicleStateOuterClass.DoorStateV2>? {
|
||||
return if (listCache.size > 0) listCache else null
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某个门的状态
|
||||
* @param num
|
||||
* @return true:开门,false:关门
|
||||
*/
|
||||
fun getIndexDoorState(num: Chassis.DoorNumber): Boolean {
|
||||
return when (num) {
|
||||
Chassis.DoorNumber.FRONT_LEFT -> frontLeft == 1
|
||||
Chassis.DoorNumber.FRONT_RIGHT -> frontRight == 1
|
||||
Chassis.DoorNumber.REAR_LEFT -> backLeft == 1
|
||||
Chassis.DoorNumber.REAR_RIGHT -> backRight == 1
|
||||
Chassis.DoorNumber.MIDDLE -> middle == 1
|
||||
else -> {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user