完成新架构的域控制器的监听及数据改造

Signed-off-by: 董宏宇 <martindhy@gmail.com>
This commit is contained in:
董宏宇
2021-10-18 19:16:41 +08:00
parent a4650ca514
commit 8a3e122518
76 changed files with 1895 additions and 1516 deletions

View File

@@ -1,7 +1,7 @@
package com.mogo.eagle.core.function.call.autopilot
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutoPilotProvider
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotProvider
import com.mogo.eagle.core.function.call.base.CallerBase
/**
@@ -10,9 +10,9 @@ import com.mogo.eagle.core.function.call.base.CallerBase
* 域控制器管理
*/
object CallerAutoPilotManager {
private val providerApi: IMoGoAutoPilotProvider
private val providerApi: IMoGoAutopilotProvider
get() = CallerBase.getApiInstance(
IMoGoAutoPilotProvider::class.java,
IMoGoAutopilotProvider::class.java,
MogoServicePaths.PATH_AUTO_PILOT
)

View File

@@ -1,9 +1,9 @@
package com.mogo.eagle.core.function.call.autopilot
import androidx.annotation.Nullable
import com.mogo.eagle.core.data.autopilot.AutoPilotStationInfo
import com.mogo.eagle.core.data.autopilot.AutoPilotStatusInfo
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutoPilotStatusListener
import com.mogo.eagle.core.data.autopilot.*
import com.mogo.eagle.core.data.traffic.TrafficData
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.api.obu.IMoGoObuStatusListener
import com.mogo.eagle.core.function.call.base.CallerBase
import com.mogo.eagle.core.utilcode.util.GsonUtils
@@ -15,26 +15,27 @@ import com.mogo.eagle.core.utilcode.util.LogUtils
* 域控制器相关的回调监听
*/
object CallerAutoPilotStatusListenerManager : CallerBase() {
private val TAG = "CallerAutopilotListenerManager"
private val TAG = "CallerAutoPilotStatusListenerManager"
// 存储最后一次回调的数据,当有新当位置注册了监听将此数据回调过去,防止有些模块注册顺序问题导致无法获取最新状态
private var mAutoPilotStatusInfo: AutoPilotStatusInfo = AutoPilotStatusInfo()
private var mAutopilotStatusInfo: AutopilotStatusInfo = AutopilotStatusInfo()
// 存储所有注册了监听的对象invokeXXXX进行遍历回调将信息同步
private val mAutoPilotStatusListeners: HashMap<String, IMoGoAutoPilotStatusListener> = HashMap()
private val M_AUTOPILOT_STATUS_LISTENERS: HashMap<String, IMoGoAutopilotStatusListener> =
HashMap()
/**
* 查询AutoPilot状态
*/
fun getAutoPilotStatusInfo(): AutoPilotStatusInfo {
return mAutoPilotStatusInfo
fun getAutoPilotStatusInfo(): AutopilotStatusInfo {
return mAutopilotStatusInfo
}
/**
* 查询AutoPilot状态
*/
fun getAutoPilotStatusInfoJsonString(): String {
return GsonUtils.toJson(mAutoPilotStatusInfo)
return GsonUtils.toJson(mAutopilotStatusInfo)
}
/**
@@ -44,10 +45,10 @@ object CallerAutoPilotStatusListenerManager : CallerBase() {
*/
fun addListener(
@Nullable tag: String,
@Nullable listener: IMoGoAutoPilotStatusListener
@Nullable listener: IMoGoAutopilotStatusListener
) {
mAutoPilotStatusListeners[tag] = listener
listener.onAutoPilotStatusResponse(mAutoPilotStatusInfo)
M_AUTOPILOT_STATUS_LISTENERS[tag] = listener
listener.onAutopilotStatusResponse(mAutopilotStatusInfo)
}
/**
@@ -55,7 +56,7 @@ object CallerAutoPilotStatusListenerManager : CallerBase() {
* @param tag 标记,用来注销监听使用
*/
fun removeListener(@Nullable tag: String) {
mAutoPilotStatusListeners.remove(tag)
M_AUTOPILOT_STATUS_LISTENERS.remove(tag)
}
/**
@@ -63,9 +64,9 @@ object CallerAutoPilotStatusListenerManager : CallerBase() {
* @param listener 要删除的监听对象
*/
fun removeListener(@Nullable listener: IMoGoObuStatusListener) {
mAutoPilotStatusListeners.forEach {
M_AUTOPILOT_STATUS_LISTENERS.forEach {
if (it.value == listener) {
mAutoPilotStatusListeners.remove(it.key)
M_AUTOPILOT_STATUS_LISTENERS.remove(it.key)
}
}
}
@@ -74,53 +75,125 @@ object CallerAutoPilotStatusListenerManager : CallerBase() {
* 自动驾驶状态信息回调
*/
@Synchronized
fun invokeAutoPilotStatusListener() {
LogUtils.dTag(TAG, "$mAutoPilotStatusInfo")
invokeAutoPilotStatusListener(mAutoPilotStatusInfo)
fun invokeAutoPilotStatus() {
LogUtils.dTag(TAG, "$mAutopilotStatusInfo")
invokeAutoPilotStatus(mAutopilotStatusInfo)
}
/**
* 自动驾驶状态信息回调
* @param autoPilotStatusInfo 自动驾驶状态信息
* 自动驾驶状态信息 回调
* @param autopilotStatusInfo 自动驾驶状态信息
*/
@Synchronized
fun invokeAutoPilotStatusListener(autoPilotStatusInfo: AutoPilotStatusInfo) {
LogUtils.dTag(TAG, "$autoPilotStatusInfo")
mAutoPilotStatusInfo = autoPilotStatusInfo
mAutoPilotStatusListeners.forEach {
fun invokeAutoPilotStatus(autopilotStatusInfo: AutopilotStatusInfo) {
LogUtils.dTag(TAG, "$autopilotStatusInfo")
mAutopilotStatusInfo = autopilotStatusInfo
M_AUTOPILOT_STATUS_LISTENERS.forEach {
val tag = it.key
val listener = it.value
LogUtils.dTag(TAG, "tag:$tag listener:$listener")
listener.onAutoPilotStatusResponse(mAutoPilotStatusInfo)
listener.onAutopilotStatusResponse(mAutopilotStatusInfo)
}
}
/**
* 自动驾驶网约车回调数据 回调
* @param autoPilotStationInfo 自动驾驶网约车回调数据
* 自动驾驶站点信息 回调
* @param autopilotStationInfo 自动驾驶网约车回调数据
*/
fun invokeArriveAtStationListener(autoPilotStationInfo: AutoPilotStationInfo) {
LogUtils.dTag(TAG, "$autoPilotStationInfo")
mAutoPilotStatusListeners.forEach {
@Synchronized
fun invokeArriveAtStation(autopilotStationInfo: AutopilotStationInfo) {
LogUtils.dTag(TAG, "$autopilotStationInfo")
M_AUTOPILOT_STATUS_LISTENERS.forEach {
val tag = it.key
val listener = it.value
LogUtils.dTag(TAG, "tag:$tag listener:$listener")
listener.onAutoPilotArriveAtStation(autoPilotStationInfo)
listener.onAutopilotArriveAtStation(autopilotStationInfo)
}
}
/**
* 自动驾驶状态回调
* @param state
* @param reason
* 车辆状态数据 回调
* @param autoPilotCarStateInfo
*/
fun invokeStateChangedListener(state: Int, reason: String) {
LogUtils.dTag(TAG, "$state $reason")
mAutoPilotStatusListeners.forEach {
@Synchronized
fun invokeAutopilotCarStateData(autoPilotCarStateInfo: AutopilotCarStateInfo?) {
LogUtils.dTag(TAG, "$autoPilotCarStateInfo")
M_AUTOPILOT_STATUS_LISTENERS.forEach {
val tag = it.key
val listener = it.value
LogUtils.dTag(TAG, "tag:$tag listener:$listener")
listener.onAutoPilotStateChanged(state, reason)
listener.onAutopilotCarStateData(autoPilotCarStateInfo)
}
}
/**
* 自动驾驶路径 回调
* @param routeInfo
*/
@Synchronized
fun invokeAutopilotRoute(routeInfo: AutopilotRouteInfo?) {
LogUtils.dTag(TAG, "$routeInfo")
M_AUTOPILOT_STATUS_LISTENERS.forEach {
val tag = it.key
val listener = it.value
LogUtils.dTag(TAG, "tag:$tag listener:$listener")
listener.onAutopilotRoute(routeInfo)
}
}
/**
* 工控机获取SN 回调
*/
@Synchronized
fun invokeAutopilotSNRequest() {
LogUtils.dTag(TAG, "")
M_AUTOPILOT_STATUS_LISTENERS.forEach {
val tag = it.key
val listener = it.value
LogUtils.dTag(TAG, "tag:$tag listener:$listener")
listener.onAutopilotSNRequest()
}
}
/**
* 工控机监控节点 回调
*/
@Synchronized
fun invokeAutopilotGuardian(guardianInfo: AutopilotGuardianStatusInfo?) {
LogUtils.dTag(TAG, "$guardianInfo")
M_AUTOPILOT_STATUS_LISTENERS.forEach {
val tag = it.key
val listener = it.value
LogUtils.dTag(TAG, "tag:$tag listener:$listener")
listener.onAutopilotGuardian(guardianInfo)
}
}
/**
* 识别交通元素数据发生更新 回调
*/
@Synchronized
fun invokeIdentifyDataUpdate(trafficData: List<TrafficData>?) {
LogUtils.dTag(TAG, "$trafficData")
M_AUTOPILOT_STATUS_LISTENERS.forEach {
val tag = it.key
val listener = it.value
LogUtils.dTag(TAG, "tag:$tag listener:$listener")
listener.onAutopilotIdentifyDataUpdate(trafficData)
}
}
/**
* 报警信息 回调
*/
@Synchronized
fun invokeAutopilotWarnMessage(autopilotWarnMessage: AutopilotWarnMessage?) {
LogUtils.dTag(TAG, "$autopilotWarnMessage")
M_AUTOPILOT_STATUS_LISTENERS.forEach {
val tag = it.key
val listener = it.value
LogUtils.dTag(TAG, "tag:$tag listener:$listener")
listener.onAutopilotWarnMessage(autopilotWarnMessage)
}
}