将工控机感知数据回调与状态信息回调分离
CallerAutoPilotManager增加开启、停止自动驾驶方法 Signed-off-by: 董宏宇 <martindhy@gmail.com>
This commit is contained in:
@@ -40,11 +40,7 @@ class MoGoAutopilotProvider :
|
||||
|
||||
override fun startAutoPilot(result: AutopilotControlParameters) {
|
||||
if (AdasManager.getInstance().isSocketConnect) {
|
||||
val parameter =
|
||||
AutopilotControlCmdParameter(
|
||||
TAG,
|
||||
result
|
||||
)
|
||||
val parameter = AutopilotControlCmdParameter(TAG, result)
|
||||
AdasManager.getInstance().aiCloudToAdasData(GsonUtils.toJson(parameter))
|
||||
} else {
|
||||
LogUtils.eTag(TAG, "车机与工控机链接失败,无法开启自动驾驶")
|
||||
@@ -59,17 +55,6 @@ class MoGoAutopilotProvider :
|
||||
}
|
||||
}
|
||||
|
||||
override fun getAutopilotStatus(): Int {
|
||||
// int status = IMoGoAutoPilotStatusListener.STATUS_AUTOPILOT_DISABLE;
|
||||
// try {
|
||||
// status = adasProvider.autopilotStateCall().getState();
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
override fun recordPackage(): Boolean {
|
||||
return AdasManager.getInstance().recordPackage()
|
||||
}
|
||||
|
||||
@@ -44,14 +44,4 @@ public class MoGoAutopilotStatusListenerImpl implements IMoGoAutopilotStatusList
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotIdentifyDataUpdate(@Nullable ArrayList<TrafficData> trafficData) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotWarnMessage(@Nullable AutopilotWarnMessage autopilotWarnMessage) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,11 +7,13 @@ import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.eagle.core.data.app.AppConfigInfo
|
||||
import com.mogo.eagle.core.data.autopilot.*
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotCarStateInfo
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotGuardianStatusInfo
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStationInfo
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.constants.MoGoConfig
|
||||
import com.mogo.eagle.core.data.obu.ObuStatusInfo
|
||||
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.autopilot.CallerAutoPilotManager
|
||||
@@ -28,7 +30,6 @@ import com.mogo.utils.UiThreadHandler
|
||||
import com.mogo.utils.network.utils.GsonUtil
|
||||
import com.mogo.utils.storage.SharedPrefsMgr
|
||||
import kotlinx.android.synthetic.main.view_debug_setting.view.*
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
@@ -192,13 +193,4 @@ class DebugSettingView @JvmOverloads constructor(
|
||||
|
||||
}
|
||||
|
||||
override fun onAutopilotIdentifyDataUpdate(trafficData: ArrayList<TrafficData>?) {
|
||||
|
||||
}
|
||||
|
||||
override fun onAutopilotWarnMessage(autopilotWarnMessage: AutopilotWarnMessage?) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -5,13 +5,14 @@ import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStationInfo
|
||||
import com.mogo.eagle.core.data.autopilot.*
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiListenerManager
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.utilcode.util.LogUtils
|
||||
import com.mogo.module.common.MogoApisHandler
|
||||
import com.mogo.service.adas.IMogoAdasOCHCallback
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.utils.UiThreadHandler
|
||||
import kotlinx.android.synthetic.main.view_autopilot_status.view.*
|
||||
|
||||
@@ -23,7 +24,9 @@ import kotlinx.android.synthetic.main.view_autopilot_status.view.*
|
||||
class AutoPilotStatusView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet
|
||||
) : ConstraintLayout(context, attrs), View.OnClickListener, IMogoAdasOCHCallback {
|
||||
) : ConstraintLayout(context, attrs),
|
||||
View.OnClickListener,
|
||||
IMoGoAutopilotStatusListener {
|
||||
|
||||
private val TAG = "AutopilotStatusView"
|
||||
|
||||
@@ -41,10 +44,8 @@ class AutoPilotStatusView @JvmOverloads constructor(
|
||||
|
||||
// 设置点击监听
|
||||
setOnClickListener(this)
|
||||
// 首次查询自动驾驶状态
|
||||
mAutopilotStatus = MogoApisHandler.getInstance().apis.adasControllerApi.autopilotStatus
|
||||
// 自动驾驶状态监听
|
||||
MogoApisHandler.getInstance().apis.adasControllerApi.addAdasOCHCallback(this)
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
|
||||
|
||||
LogUtils.dTag(TAG, "autopilotStatus: $mAutopilotStatus")
|
||||
setAutoPilotStatus(mAutopilotStatus)
|
||||
@@ -54,9 +55,9 @@ class AutoPilotStatusView @JvmOverloads constructor(
|
||||
when (mAutopilotStatus) {
|
||||
0 -> {// 不可自动驾驶,adas与工控机没有链接,或工控机异常
|
||||
LogUtils.eTag(TAG, "不可自动驾驶,adas与工控机没有链接,或工控机异常,请检查")
|
||||
// ToastUtils.showShort("不可自动驾驶,adas与工控机没有链接,或工控机异常,请检查")
|
||||
ToastUtils.showShort("不可自动驾驶,adas与工控机没有链接,或工控机异常,请检查")
|
||||
// TODO 这里临时触发自动驾驶能力,测试功过这里删除
|
||||
CallerHmiListenerManager.invokeCheckAutoPilotBtnListener(true)
|
||||
//CallerHmiListenerManager.invokeCheckAutoPilotBtnListener(true)
|
||||
}
|
||||
1 -> {// 可自动驾驶,目前处于人工干预状态
|
||||
CallerHmiListenerManager.invokeCheckAutoPilotBtnListener(true)
|
||||
@@ -65,10 +66,14 @@ class AutoPilotStatusView @JvmOverloads constructor(
|
||||
CallerHmiListenerManager.invokeCheckAutoPilotBtnListener(false)
|
||||
}
|
||||
}
|
||||
startAutoPilot();
|
||||
startAutoPilot()
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启自动驾驶
|
||||
*/
|
||||
private fun startAutoPilot() {
|
||||
// TODO 测试数据,真实情况需要业务自己传入控制数据
|
||||
val currentAutopilot =
|
||||
AutopilotControlParameters()
|
||||
currentAutopilot.isSpeakVoice = false
|
||||
@@ -77,7 +82,8 @@ class AutoPilotStatusView @JvmOverloads constructor(
|
||||
currentAutopilot.endLatLon =
|
||||
AutopilotControlParameters.AutoPilotLonLat(40.199255159538758, 116.73274535677977);
|
||||
currentAutopilot.vehicleType = 10
|
||||
MogoApisHandler.getInstance().apis.adasControllerApi.aiCloudToAdasData(currentAutopilot)
|
||||
|
||||
CallerAutoPilotManager.startAutoPilot(currentAutopilot)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,17 +96,17 @@ class AutoPilotStatusView @JvmOverloads constructor(
|
||||
UiThreadHandler.post {
|
||||
mAutopilotStatus = autopilotStatus
|
||||
when (autopilotStatus) {
|
||||
0 -> {// 不可自动驾驶,adas与工控机没有链接,或工控机异常
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE -> {// 不可自动驾驶,adas与工控机没有链接,或工控机异常
|
||||
clAutopilotStatus.setBackgroundResource(R.drawable.module_hmi_autopilot_status_disabled_bg)
|
||||
tvStatusDes.setTextColor(resources.getColor(R.color.module_mogo_autopilot_status_disable))
|
||||
ivStatusIcon.setImageResource(R.drawable.icon_autopilot_status_disabled)
|
||||
}
|
||||
1 -> {// 可自动驾驶,目前处于人工干预状态
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE -> {// 可自动驾驶,目前处于人工干预状态
|
||||
clAutopilotStatus.setBackgroundResource(R.drawable.module_hmi_autopilot_status_enable_bg)
|
||||
tvStatusDes.setTextColor(resources.getColor(R.color.module_mogo_autopilot_status_enable))
|
||||
ivStatusIcon.setImageResource(R.drawable.icon_autopilot_status)
|
||||
}
|
||||
2 -> {// 自动驾驶中
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING -> {// 自动驾驶中
|
||||
clAutopilotStatus.setBackgroundResource(R.drawable.module_hmi_autopilot_status_checked_bg)
|
||||
tvStatusDes.setTextColor(resources.getColor(R.color.module_mogo_autopilot_status_enable))
|
||||
ivStatusIcon.setImageResource(R.drawable.icon_autopilot_status)
|
||||
@@ -109,12 +115,20 @@ class AutoPilotStatusView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun onArriveAt(data: AutopilotStationInfo?) {
|
||||
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
|
||||
setAutoPilotStatus(autoPilotStatusInfo.state)
|
||||
}
|
||||
|
||||
override fun onAutopilotArriveAtStation(autopilotWayArrive: AutopilotStationInfo?) {
|
||||
|
||||
}
|
||||
|
||||
override fun onStateChanged(state: Int, reason: String?) {
|
||||
setAutoPilotStatus(state)
|
||||
override fun onAutopilotCarStateData(autoPilotCarStateInfo: AutopilotCarStateInfo?) {
|
||||
|
||||
}
|
||||
|
||||
override fun onAutopilotGuardian(guardianInfo: AutopilotGuardianStatusInfo?) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
<com.mogo.eagle.core.function.hmi.ui.widget.CheckStatusView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="31dp"
|
||||
android:layout_marginLeft="25dp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/viewPerspectiveSwitch"
|
||||
app:layout_constraintStart_toEndOf="@+id/viewPerspectiveSwitch"
|
||||
app:layout_constraintTop_toTopOf="@+id/viewPerspectiveSwitch" />
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.mogo.eagle.core.function.api.autopilot
|
||||
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotWarnMessage
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/11/1 5:57 下午
|
||||
* 感知识别回调
|
||||
*/
|
||||
interface IMoGoAutopilotIdentifyListener {
|
||||
|
||||
/**
|
||||
* 识别交通元素数据发生更新
|
||||
*
|
||||
* @param trafficData 交通元素信息列表
|
||||
*/
|
||||
fun onAutopilotIdentifyDataUpdate(trafficData: ArrayList<TrafficData>?)
|
||||
|
||||
/**
|
||||
* 报警信息
|
||||
*
|
||||
* @param autopilotWarnMessage 预警信息
|
||||
*/
|
||||
fun onAutopilotWarnMessage(autopilotWarnMessage: AutopilotWarnMessage?)
|
||||
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import com.mogo.eagle.core.function.api.base.IMoGoFunctionServerProvider;
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/9/22 8:27 下午
|
||||
* 自动驾驶节点
|
||||
*
|
||||
*/
|
||||
public interface IMoGoAutopilotProvider extends IMoGoFunctionServerProvider {
|
||||
|
||||
@@ -19,22 +18,15 @@ public interface IMoGoAutopilotProvider extends IMoGoFunctionServerProvider {
|
||||
/**
|
||||
* 开启自动驾驶
|
||||
*
|
||||
* @param result
|
||||
* @param controlParameters 开启自动驾驶的控制参数
|
||||
*/
|
||||
void startAutoPilot(AutopilotControlParameters result);
|
||||
void startAutoPilot(AutopilotControlParameters controlParameters);
|
||||
|
||||
/**
|
||||
* 结束自动驾驶
|
||||
*/
|
||||
void cancelAutoPilot();
|
||||
|
||||
/**
|
||||
* 获取车辆自动驾驶状态
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int getAutopilotStatus();
|
||||
|
||||
/**
|
||||
* 开启域控制器录制bag包
|
||||
*
|
||||
|
||||
@@ -25,7 +25,6 @@ interface IMoGoAutopilotStatusListener {
|
||||
*/
|
||||
fun onAutopilotArriveAtStation(autopilotWayArrive: AutopilotStationInfo?)
|
||||
|
||||
|
||||
/**
|
||||
* 车辆状态数据
|
||||
*
|
||||
@@ -43,20 +42,6 @@ interface IMoGoAutopilotStatusListener {
|
||||
*/
|
||||
fun onAutopilotGuardian(guardianInfo: AutopilotGuardianStatusInfo?)
|
||||
|
||||
/**
|
||||
* 识别交通元素数据发生更新
|
||||
*
|
||||
* @param trafficData 交通元素信息列表
|
||||
*/
|
||||
fun onAutopilotIdentifyDataUpdate(trafficData: ArrayList<TrafficData>?)
|
||||
|
||||
/**
|
||||
* 报警信息
|
||||
*
|
||||
* @param autopilotWarnMessage 预警信息
|
||||
*/
|
||||
fun onAutopilotWarnMessage(autopilotWarnMessage: AutopilotWarnMessage?)
|
||||
|
||||
|
||||
companion object {
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.mogo.eagle.core.function.call.autopilot
|
||||
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotProvider
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
|
||||
/**
|
||||
*@author xiaoyuzhou
|
||||
@@ -10,14 +12,37 @@ import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
* 域控制器管理
|
||||
*/
|
||||
object CallerAutoPilotManager {
|
||||
private val TAG = "CallerAutoPilotManager"
|
||||
|
||||
private val providerApi: IMoGoAutopilotProvider
|
||||
get() = CallerBase.getApiInstance(
|
||||
IMoGoAutopilotProvider::class.java,
|
||||
MogoServicePaths.PATH_AUTO_PILOT
|
||||
)
|
||||
|
||||
/**
|
||||
* 开启自动驾驶
|
||||
*
|
||||
* @param controlParameters 开启自动驾驶的控制参数
|
||||
*/
|
||||
fun startAutoPilot(controlParameters: AutopilotControlParameters?) {
|
||||
if (controlParameters == null) {
|
||||
Logger.e(TAG, "自动驾驶控制参数异常,请检查参数信息")
|
||||
return
|
||||
}
|
||||
providerApi.startAutoPilot(controlParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束自动驾驶
|
||||
*/
|
||||
fun cancelAutoPilot() {
|
||||
providerApi.cancelAutoPilot()
|
||||
}
|
||||
|
||||
fun recordPackage() {
|
||||
providerApi.recordPackage()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,11 +1,14 @@
|
||||
package com.mogo.eagle.core.function.call.autopilot
|
||||
|
||||
import androidx.annotation.Nullable
|
||||
import com.mogo.eagle.core.data.autopilot.*
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotCarStateInfo
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotGuardianStatusInfo
|
||||
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.function.api.obu.IMoGoObuStatusListener
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||
|
||||
/**
|
||||
@@ -46,6 +49,10 @@ object CallerAutoPilotStatusListenerManager : CallerBase() {
|
||||
@Nullable tag: String,
|
||||
@Nullable listener: IMoGoAutopilotStatusListener
|
||||
) {
|
||||
if (M_AUTOPILOT_STATUS_LISTENERS.containsKey(tag)) {
|
||||
Logger.e(TAG, "Tag:$tag already exists,please use other tag")
|
||||
return
|
||||
}
|
||||
M_AUTOPILOT_STATUS_LISTENERS[tag] = listener
|
||||
listener.onAutopilotStatusResponse(mAutopilotStatusInfo)
|
||||
}
|
||||
@@ -55,6 +62,10 @@ object CallerAutoPilotStatusListenerManager : CallerBase() {
|
||||
* @param tag 标记,用来注销监听使用
|
||||
*/
|
||||
fun removeListener(@Nullable tag: String) {
|
||||
if (!M_AUTOPILOT_STATUS_LISTENERS.containsKey(tag)) {
|
||||
Logger.e(TAG, "Tag:$tag not exists")
|
||||
return
|
||||
}
|
||||
M_AUTOPILOT_STATUS_LISTENERS.remove(tag)
|
||||
}
|
||||
|
||||
@@ -154,32 +165,4 @@ object CallerAutoPilotStatusListenerManager : CallerBase() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 识别交通元素数据发生更新 回调
|
||||
*/
|
||||
@Synchronized
|
||||
fun invokeAutopilotIdentifyDataUpdate(trafficData: ArrayList<TrafficData>?) {
|
||||
//Logger.d(TAG, "$trafficData")
|
||||
M_AUTOPILOT_STATUS_LISTENERS.forEach {
|
||||
val tag = it.key
|
||||
val listener = it.value
|
||||
//Logger.d(TAG, "tag:$tag listener:$listener")
|
||||
listener.onAutopilotIdentifyDataUpdate(trafficData)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 报警信息 回调
|
||||
*/
|
||||
@Synchronized
|
||||
fun invokeAutopilotWarnMessage(autopilotWarnMessage: AutopilotWarnMessage?) {
|
||||
//Logger.d(TAG, "$autopilotWarnMessage")
|
||||
M_AUTOPILOT_STATUS_LISTENERS.forEach {
|
||||
val tag = it.key
|
||||
val listener = it.value
|
||||
//Logger.d(TAG, "tag:$tag listener:$listener")
|
||||
listener.onAutopilotWarnMessage(autopilotWarnMessage)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.mogo.eagle.core.function.call.autopilot
|
||||
|
||||
import androidx.annotation.Nullable
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotWarnMessage
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/9/30 5:48 下午
|
||||
* 域控制器感知数据
|
||||
*/
|
||||
object CallerAutopilotIdentifyListenerManager : CallerBase() {
|
||||
private val TAG = "CallerAutopilotIdentifyListenerManager"
|
||||
|
||||
// 存储所有注册了监听的对象,invokeXXXX进行遍历回调,将信息同步
|
||||
private val M_AUTOPILOT_IDENTIFY_LISTENERS: HashMap<String, IMoGoAutopilotIdentifyListener> =
|
||||
HashMap()
|
||||
|
||||
/**
|
||||
* 添加监听
|
||||
* @param tag 标记,用来注销监听使用
|
||||
* @param listener 监听回调
|
||||
*/
|
||||
fun addListener(
|
||||
@Nullable tag: String,
|
||||
@Nullable listener: IMoGoAutopilotIdentifyListener
|
||||
) {
|
||||
if (M_AUTOPILOT_IDENTIFY_LISTENERS.containsKey(tag)) {
|
||||
Logger.e(TAG, "Tag:$tag already exists,please use other tag")
|
||||
return
|
||||
}
|
||||
M_AUTOPILOT_IDENTIFY_LISTENERS[tag] = listener
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除监听
|
||||
* @param tag 标记,用来注销监听使用
|
||||
*/
|
||||
fun removeListener(@Nullable tag: String) {
|
||||
if (!M_AUTOPILOT_IDENTIFY_LISTENERS.containsKey(tag)) {
|
||||
Logger.e(TAG, "Tag:$tag not exists")
|
||||
return
|
||||
}
|
||||
M_AUTOPILOT_IDENTIFY_LISTENERS.remove(tag)
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除自动驾驶按钮选中监听
|
||||
* @param listener 要删除的监听对象
|
||||
*/
|
||||
fun removeListener(@Nullable listener: IMoGoAutopilotIdentifyListener) {
|
||||
M_AUTOPILOT_IDENTIFY_LISTENERS.forEach {
|
||||
if (it.value == listener) {
|
||||
M_AUTOPILOT_IDENTIFY_LISTENERS.remove(it.key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 识别交通元素数据发生更新 回调
|
||||
*/
|
||||
@Synchronized
|
||||
fun invokeAutopilotIdentifyDataUpdate(trafficData: ArrayList<TrafficData>?) {
|
||||
//Logger.d(TAG, "$trafficData")
|
||||
M_AUTOPILOT_IDENTIFY_LISTENERS.forEach {
|
||||
val tag = it.key
|
||||
val listener = it.value
|
||||
//Logger.d(TAG, "tag:$tag listener:$listener")
|
||||
listener.onAutopilotIdentifyDataUpdate(trafficData)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 报警信息 回调
|
||||
*/
|
||||
@Synchronized
|
||||
fun invokeAutopilotWarnMessage(autopilotWarnMessage: AutopilotWarnMessage?) {
|
||||
//Logger.d(TAG, "$autopilotWarnMessage")
|
||||
M_AUTOPILOT_IDENTIFY_LISTENERS.forEach {
|
||||
val tag = it.key
|
||||
val listener = it.value
|
||||
//Logger.d(TAG, "tag:$tag listener:$listener")
|
||||
listener.onAutopilotWarnMessage(autopilotWarnMessage)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import com.mogo.eagle.core.data.autopilot.AutopilotRouteInfo
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningListener
|
||||
import com.mogo.eagle.core.function.api.obu.IMoGoObuStatusListener
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
@@ -29,6 +30,10 @@ object CallerAutopilotPlanningListenerManager : CallerBase() {
|
||||
@Nullable tag: String,
|
||||
@Nullable listener: IMoGoAutopilotPlanningListener
|
||||
) {
|
||||
if (M_AUTOPILOT_PLANNING_LISTENER.containsKey(tag)) {
|
||||
Logger.e(TAG, "Tag:$tag already exists,please use other tag")
|
||||
return
|
||||
}
|
||||
M_AUTOPILOT_PLANNING_LISTENER[tag] = listener
|
||||
}
|
||||
|
||||
@@ -37,6 +42,10 @@ object CallerAutopilotPlanningListenerManager : CallerBase() {
|
||||
* @param tag 标记,用来注销监听使用
|
||||
*/
|
||||
fun removeListener(@Nullable tag: String) {
|
||||
if (!M_AUTOPILOT_PLANNING_LISTENER.containsKey(tag)) {
|
||||
Logger.e(TAG, "Tag:$tag not exists")
|
||||
return
|
||||
}
|
||||
M_AUTOPILOT_PLANNING_LISTENER.remove(tag)
|
||||
}
|
||||
|
||||
|
||||
@@ -13,9 +13,11 @@ import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotWarnMessage;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningListener;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager;
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
|
||||
import com.mogo.module.adas.model.AdasServiceModel;
|
||||
@@ -40,7 +42,8 @@ import io.reactivex.schedulers.Schedulers;
|
||||
public class AdasEventManager implements
|
||||
OnAdasMsgConnectStatusListener,
|
||||
IMoGoAutopilotStatusListener,
|
||||
IMoGoAutopilotPlanningListener {
|
||||
IMoGoAutopilotPlanningListener,
|
||||
IMoGoAutopilotIdentifyListener {
|
||||
|
||||
private final String TAG = "AdasEventManager";
|
||||
|
||||
@@ -63,6 +66,7 @@ public class AdasEventManager implements
|
||||
gson = GsonUtil.getGson();
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, this);
|
||||
CallerAutopilotPlanningListenerManager.INSTANCE.addListener(TAG, this);
|
||||
CallerAutopilotIdentifyListenerManager.INSTANCE.addListener(TAG, this);
|
||||
}
|
||||
|
||||
public static AdasEventManager getInstance() {
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotWarnMessage;
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.support.adas.high.AdasManager;
|
||||
@@ -43,7 +44,7 @@ public class OnAdasListenerAdapter implements OnAdasListener {
|
||||
@Override
|
||||
public void onRectData(RectInfo rectInfo) {
|
||||
ArrayList<TrafficData> recognizedListResults = AdasObjectUtils.INSTANCE.regroupTrafficDataData(rectInfo.getModels());
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.invokeAutopilotIdentifyDataUpdate(recognizedListResults);
|
||||
CallerAutopilotIdentifyListenerManager.INSTANCE.invokeAutopilotIdentifyDataUpdate(recognizedListResults);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -156,7 +157,7 @@ public class OnAdasListenerAdapter implements OnAdasListener {
|
||||
@Override
|
||||
public void onWarnMessage(WarnMessageInfo warnMessageInfo) {
|
||||
final AutopilotWarnMessage warnMessage = AdasObjectUtils.INSTANCE.fromAdasObject(warnMessageInfo);
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.invokeAutopilotWarnMessage(warnMessage);
|
||||
CallerAutopilotIdentifyListenerManager.INSTANCE.invokeAutopilotWarnMessage(warnMessage);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user