[6.0.0][adas-data][data-centre]能否启动自驾接口修改,加入消息来源字段,以及修改为多条消息同时上报;鹰眼数据中心中修改为事件触发式回调,以及融合域控连接状态原因等;加入主动获取当前状态接口;
This commit is contained in:
@@ -1,19 +1,103 @@
|
||||
package com.mogo.eagle.core.function.call.autopilot
|
||||
|
||||
import android.util.Log
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotActionsListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.isConnected
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import com.zhjt.mogo.adas.data.bean.UnableAutopilotReason
|
||||
|
||||
|
||||
/**
|
||||
* pnc actions 决策 驾驶的意图
|
||||
* 能否启动自驾管理类
|
||||
*/
|
||||
object CallerAutopilotActionsListenerManager : CallerBase<IMoGoAutopilotActionsListener>() {
|
||||
@Volatile
|
||||
private var isConnected = false
|
||||
private var isAutopilotAbility: Boolean = false
|
||||
private var unableAutopilotReasons: ArrayList<UnableAutopilotReason>? = null
|
||||
|
||||
@Synchronized
|
||||
fun invokeAutopilotAbility(isAutopilotAbility: Boolean, unableAutopilotReason: String?) {
|
||||
M_LISTENERS.forEach {
|
||||
val listener = it.value
|
||||
listener.onAutopilotAbility(isAutopilotAbility, unableAutopilotReason)
|
||||
init {
|
||||
isConnected = isConnected()
|
||||
isAutopilotAbility = false
|
||||
unableAutopilotReasons = disconnectedReason()
|
||||
printLog("初始化")
|
||||
}
|
||||
|
||||
private fun disconnectedReason(): ArrayList<UnableAutopilotReason> {
|
||||
val list = ArrayList<UnableAutopilotReason>()
|
||||
list.add(UnableAutopilotReason(UnableAutopilotReason.SourceType.LIB, "未连接自动驾驶系统"))
|
||||
return list
|
||||
}
|
||||
|
||||
/**
|
||||
* 能否启动自动驾驶
|
||||
*/
|
||||
fun isAutopilotAbility(): Boolean {
|
||||
return isAutopilotAbility
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取不能启动自驾的原因
|
||||
* null:表示没有任何原因证,证明isAutopilotAbility为true
|
||||
*/
|
||||
fun getUnableAutopilotReasons(): ArrayList<UnableAutopilotReason>? {
|
||||
return unableAutopilotReasons
|
||||
}
|
||||
|
||||
fun setConnected(isConnected: Boolean) {
|
||||
if (this.isConnected != isConnected) {
|
||||
this.isConnected = isConnected
|
||||
this.isAutopilotAbility = isConnected
|
||||
unableAutopilotReasons = if (isConnected) null else disconnectedReason()
|
||||
notification()
|
||||
printLog("更新数据 连接状态变更")
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun invokeAutopilotAbility(
|
||||
isAutopilotAbility: Boolean, unableAutopilotReasons: ArrayList<UnableAutopilotReason>?
|
||||
) {
|
||||
if (isConnected) {
|
||||
var isEquals: Boolean = true
|
||||
if (unableAutopilotReasons != null && this.unableAutopilotReasons != null) {
|
||||
unableAutopilotReasons.let { onw ->
|
||||
onw.sortWith(compareBy(UnableAutopilotReason::hashCode));
|
||||
this.unableAutopilotReasons?.let { old ->
|
||||
old.sortWith(compareBy(UnableAutopilotReason::hashCode));
|
||||
isEquals = onw.toTypedArray() contentEquals old.toTypedArray()
|
||||
Log.i(
|
||||
"ddd",
|
||||
"都不为null时=${isEquals}=${this.isAutopilotAbility} ${(if (this.unableAutopilotReasons == null) null else this.unableAutopilotReasons.toString())}"
|
||||
)
|
||||
}
|
||||
}
|
||||
} else isEquals =
|
||||
!(unableAutopilotReasons != null || this.unableAutopilotReasons != null)
|
||||
Log.i(
|
||||
"ddd",
|
||||
" 两个List是否相同=${isEquals} 新是否能启动自驾=${isAutopilotAbility} 老是否能启动自驾=${this.isAutopilotAbility} 新List是否为空=${unableAutopilotReasons == null} 老List是否为空=${this.unableAutopilotReasons == null}"
|
||||
)
|
||||
if (this.isAutopilotAbility != isAutopilotAbility || !isEquals) {
|
||||
this.isAutopilotAbility = isAutopilotAbility
|
||||
this.unableAutopilotReasons = unableAutopilotReasons
|
||||
notification()
|
||||
printLog("更新数据")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun notification() {
|
||||
M_LISTENERS.forEach {
|
||||
val listener = it.value
|
||||
listener.onAutopilotAbility(isAutopilotAbility, unableAutopilotReasons)
|
||||
}
|
||||
}
|
||||
|
||||
fun printLog(tag: String) {
|
||||
Log.i(
|
||||
"ddd",
|
||||
"${tag}=${isAutopilotAbility} ${(if (unableAutopilotReasons == null) null else unableAutopilotReasons.toString())}"
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user