[610][adas]添加能否启动平行驾驶接口,修改类型名
This commit is contained in:
@@ -2,7 +2,7 @@ package com.mogo.eagle.core.function.call.autopilot
|
||||
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotActionsListener
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import com.zhjt.mogo.adas.data.bean.UnableAutopilotReason
|
||||
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason
|
||||
|
||||
|
||||
/**
|
||||
@@ -12,7 +12,7 @@ object CallerAutopilotActionsListenerManager : CallerBase<IMoGoAutopilotActionsL
|
||||
@Volatile
|
||||
private var isConnected = false
|
||||
private var isAutopilotAbility: Boolean = false
|
||||
private var unableAutopilotReasons: ArrayList<UnableAutopilotReason>? = null
|
||||
private var unableAutopilotReasons: ArrayList<UnableLaunchReason>? = null
|
||||
|
||||
init {
|
||||
isAutopilotAbility = false
|
||||
@@ -20,9 +20,14 @@ object CallerAutopilotActionsListenerManager : CallerBase<IMoGoAutopilotActionsL
|
||||
// printLog("初始化")
|
||||
}
|
||||
|
||||
private fun disconnectedReason(): ArrayList<UnableAutopilotReason> {
|
||||
val list = ArrayList<UnableAutopilotReason>()
|
||||
list.add(UnableAutopilotReason(UnableAutopilotReason.SourceType.LIB, "未连接自动驾驶系统"))
|
||||
private fun disconnectedReason(): ArrayList<UnableLaunchReason> {
|
||||
val list = ArrayList<UnableLaunchReason>()
|
||||
list.add(
|
||||
UnableLaunchReason(
|
||||
UnableLaunchReason.SourceType.LIB,
|
||||
"未连接自动驾驶系统"
|
||||
)
|
||||
)
|
||||
return list
|
||||
}
|
||||
|
||||
@@ -37,7 +42,7 @@ object CallerAutopilotActionsListenerManager : CallerBase<IMoGoAutopilotActionsL
|
||||
* 获取不能启动自驾的原因
|
||||
* null:表示没有任何原因证,证明isAutopilotAbility为true
|
||||
*/
|
||||
fun getUnableAutopilotReasons(): ArrayList<UnableAutopilotReason>? {
|
||||
fun getUnableAutopilotReasons(): ArrayList<UnableLaunchReason>? {
|
||||
return unableAutopilotReasons
|
||||
}
|
||||
|
||||
@@ -53,15 +58,15 @@ object CallerAutopilotActionsListenerManager : CallerBase<IMoGoAutopilotActionsL
|
||||
|
||||
@Synchronized
|
||||
fun invokeAutopilotAbility(
|
||||
isAutopilotAbility: Boolean, unableAutopilotReasons: ArrayList<UnableAutopilotReason>?
|
||||
isAutopilotAbility: Boolean, unableAutopilotReasons: ArrayList<UnableLaunchReason>?
|
||||
) {
|
||||
if (isConnected) {
|
||||
var isEquals: Boolean = true
|
||||
if (unableAutopilotReasons != null && this.unableAutopilotReasons != null) {
|
||||
unableAutopilotReasons.let { onw ->
|
||||
onw.sortWith(compareBy(UnableAutopilotReason::hashCode));
|
||||
onw.sortWith(compareBy(UnableLaunchReason::hashCode));
|
||||
this.unableAutopilotReasons?.let { old ->
|
||||
old.sortWith(compareBy(UnableAutopilotReason::hashCode));
|
||||
old.sortWith(compareBy(UnableLaunchReason::hashCode));
|
||||
isEquals = onw.toTypedArray() contentEquals old.toTypedArray()
|
||||
// Log.i(
|
||||
// "ddd",
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.mogo.eagle.core.function.call.autopilot
|
||||
|
||||
import android.util.Log
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoParallelDrivingActionsListener
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason
|
||||
|
||||
|
||||
/**
|
||||
* 是否可以启动平行驾驶管理
|
||||
*/
|
||||
object CallerParallelDrivingActionsListenerManager :
|
||||
CallerBase<IMoGoParallelDrivingActionsListener>() {
|
||||
@Volatile
|
||||
private var isConnected = false
|
||||
private var isParallelDrivingAbility: Boolean = false
|
||||
private var unableParallelDrivingReasons: ArrayList<UnableLaunchReason>? = null
|
||||
|
||||
init {
|
||||
isParallelDrivingAbility = false
|
||||
unableParallelDrivingReasons = disconnectedReason()
|
||||
}
|
||||
|
||||
private fun disconnectedReason(): ArrayList<UnableLaunchReason> {
|
||||
val list = ArrayList<UnableLaunchReason>()
|
||||
list.add(
|
||||
UnableLaunchReason(
|
||||
UnableLaunchReason.SourceType.LIB,
|
||||
"未连接自动驾驶系统"
|
||||
)
|
||||
)
|
||||
return list
|
||||
}
|
||||
|
||||
/**
|
||||
* 能否启动平行驾驶
|
||||
*/
|
||||
fun isParallelDrivingAbility(): Boolean {
|
||||
return isParallelDrivingAbility
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取不能启动平行驾驶的原因
|
||||
* null:表示没有任何原因证,证明isParallelDrivingAbility为true
|
||||
*/
|
||||
fun getUnableParallelDrivingReasons(): ArrayList<UnableLaunchReason>? {
|
||||
return unableParallelDrivingReasons
|
||||
}
|
||||
|
||||
fun setConnected(isConnected: Boolean) {
|
||||
if (this.isConnected != isConnected) {
|
||||
this.isConnected = isConnected
|
||||
this.isParallelDrivingAbility = isConnected
|
||||
unableParallelDrivingReasons = if (isConnected) null else disconnectedReason()
|
||||
notification()
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun invokeParallelDrivingAbility(
|
||||
isAutopilotAbility: Boolean, unableAutopilotReasons: ArrayList<UnableLaunchReason>?
|
||||
) {
|
||||
if (isConnected) {
|
||||
var isEquals: Boolean = true
|
||||
if (unableAutopilotReasons != null && this.unableParallelDrivingReasons != null) {
|
||||
unableAutopilotReasons.let { onw ->
|
||||
onw.sortWith(compareBy(UnableLaunchReason::hashCode));
|
||||
this.unableParallelDrivingReasons?.let { old ->
|
||||
old.sortWith(compareBy(UnableLaunchReason::hashCode));
|
||||
isEquals = onw.toTypedArray() contentEquals old.toTypedArray()
|
||||
|
||||
}
|
||||
}
|
||||
} else isEquals =
|
||||
!(unableAutopilotReasons != null || this.unableParallelDrivingReasons != null)
|
||||
|
||||
if (this.isParallelDrivingAbility != isAutopilotAbility || !isEquals) {
|
||||
this.isParallelDrivingAbility = isAutopilotAbility
|
||||
this.unableParallelDrivingReasons = unableAutopilotReasons
|
||||
notification()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun notification() {
|
||||
Log.i(
|
||||
"xfk",
|
||||
"是否可以启动平行驾驶=" + isParallelDrivingAbility + if (unableParallelDrivingReasons == null) "" else unableParallelDrivingReasons.toString()
|
||||
)
|
||||
M_LISTENERS.forEach {
|
||||
val listener = it.value
|
||||
listener.onParallelDrivingAbility(
|
||||
isParallelDrivingAbility,
|
||||
unableParallelDrivingReasons
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user