diff --git a/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/adapter/MoGoAutopilotStatusListenerImpl.java b/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/adapter/MoGoAutopilotStatusListenerImpl.java index 5850e18a69..0dcc5de694 100644 --- a/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/adapter/MoGoAutopilotStatusListenerImpl.java +++ b/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/adapter/MoGoAutopilotStatusListenerImpl.java @@ -28,11 +28,6 @@ public class MoGoAutopilotStatusListenerImpl implements IMoGoAutopilotStatusList } - @Override - public void onAutopilotCarStateData(@Nullable AutopilotCarStateInfo autoPilotCarStateInfo) { - - } - @Override public void onAutopilotSNRequest() { diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt index 86eb923cb0..7a9a29c71a 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt @@ -14,10 +14,12 @@ 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.function.api.autopilot.IMoGoAutopilotCarStateListener 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 import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager +import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarStatusListenerManager import com.mogo.eagle.core.function.call.obu.CallerOBUManager import com.mogo.eagle.core.function.call.obu.CallerObuListenerManager import com.mogo.eagle.core.function.hmi.R @@ -42,7 +44,7 @@ class DebugSettingView @JvmOverloads constructor( attrs: AttributeSet? = null, defStyleAttr: Int = 0 ) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoObuStatusListener, - IMoGoAutopilotStatusListener { + IMoGoAutopilotStatusListener, IMoGoAutopilotCarStateListener { private val TAG = "DebugSettingView" @@ -55,12 +57,14 @@ class DebugSettingView @JvmOverloads constructor( super.onAttachedToWindow() CallerObuListenerManager.addListener(TAG, this) CallerAutoPilotStatusListenerManager.addListener(TAG, this) + CallerAutopilotCarStatusListenerManager.addListener(TAG, this) } override fun onDetachedFromWindow() { super.onDetachedFromWindow() CallerObuListenerManager.removeListener(TAG) CallerAutoPilotStatusListenerManager.removeListener(TAG) + CallerAutopilotCarStatusListenerManager.removeListener(TAG) } private fun initView() { diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/AutoPilotStatusView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/AutoPilotStatusView.kt index 357a06e5a3..1acb90b84d 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/AutoPilotStatusView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/AutoPilotStatusView.kt @@ -5,7 +5,10 @@ import android.util.AttributeSet import android.view.LayoutInflater import android.view.View import androidx.constraintlayout.widget.ConstraintLayout -import com.mogo.eagle.core.data.autopilot.* +import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters +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.call.autopilot.CallerAutoPilotManager import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager @@ -123,9 +126,6 @@ class AutoPilotStatusView @JvmOverloads constructor( } - override fun onAutopilotCarStateData(autoPilotCarStateInfo: AutopilotCarStateInfo?) { - - } override fun onAutopilotGuardian(guardianInfo: AutopilotGuardianStatusInfo?) { diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoAutopilotCarStateListener.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoAutopilotCarStateListener.kt new file mode 100644 index 0000000000..ee2abac64a --- /dev/null +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoAutopilotCarStateListener.kt @@ -0,0 +1,18 @@ +package com.mogo.eagle.core.function.api.autopilot + +import com.mogo.eagle.core.data.autopilot.AutopilotCarStateInfo + +/** + *@author xiaoyuzhou + *@date 2021/11/2 2:06 下午 + * 车辆状态&定位 数据 数据 回调监听 + */ +interface IMoGoAutopilotCarStateListener { + + /** + * 车辆状态&定位 数据 + * + * @param autoPilotCarStateInfo + */ + fun onAutopilotCarStateData(autoPilotCarStateInfo: AutopilotCarStateInfo?) +} \ No newline at end of file diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoAutopilotStatusListener.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoAutopilotStatusListener.kt index 195c001fd9..aa2be2e665 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoAutopilotStatusListener.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoAutopilotStatusListener.kt @@ -1,8 +1,8 @@ package com.mogo.eagle.core.function.api.autopilot -import com.mogo.eagle.core.data.autopilot.* -import com.mogo.eagle.core.data.traffic.TrafficData -import java.util.* +import com.mogo.eagle.core.data.autopilot.AutopilotGuardianStatusInfo +import com.mogo.eagle.core.data.autopilot.AutopilotStationInfo +import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo /** * @author xiaoyuzhou @@ -25,13 +25,6 @@ interface IMoGoAutopilotStatusListener { */ fun onAutopilotArriveAtStation(autopilotWayArrive: AutopilotStationInfo?) - /** - * 车辆状态数据 - * - * @param autoPilotCarStateInfo - */ - fun onAutopilotCarStateData(autoPilotCarStateInfo: AutopilotCarStateInfo?) - /** * 工控机获取SN */ diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutoPilotStatusListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutoPilotStatusListenerManager.kt index 3e6c9a6d45..9032e85bef 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutoPilotStatusListenerManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutoPilotStatusListenerManager.kt @@ -1,7 +1,6 @@ package com.mogo.eagle.core.function.call.autopilot import androidx.annotation.Nullable -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 @@ -121,22 +120,6 @@ object CallerAutoPilotStatusListenerManager : CallerBase() { } } - /** - * 车辆状态数据 回调 - * @param autoPilotCarStateInfo - */ - @Synchronized - fun invokeAutopilotCarStateData(autoPilotCarStateInfo: AutopilotCarStateInfo?) { - //Logger.d(TAG, "$autoPilotCarStateInfo") - M_AUTOPILOT_STATUS_LISTENERS.forEach { - val tag = it.key - val listener = it.value - //Logger.d(TAG, "tag:$tag listener:$listener") - listener.onAutopilotCarStateData(autoPilotCarStateInfo) - } - } - - /** * 工控机获取SN 回调 */ diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutopilotCarStatusListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutopilotCarStatusListenerManager.kt new file mode 100644 index 0000000000..e7f2ad4cc8 --- /dev/null +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutopilotCarStatusListenerManager.kt @@ -0,0 +1,78 @@ +package com.mogo.eagle.core.function.call.autopilot + +import androidx.annotation.Nullable +import com.mogo.eagle.core.data.autopilot.AutopilotCarStateInfo +import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarStateListener +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 CallerAutopilotCarStatusListenerManager : CallerBase() { + private val TAG = "CallerAutopilotCarStatusListenerManager" + + // 存储所有注册了监听的对象,invokeXXXX进行遍历回调,将信息同步 + private val M_AUTOPILOT_STATUS_LISTENERS: HashMap = + HashMap() + + + /** + * 添加监听 + * @param tag 标记,用来注销监听使用 + * @param listener 监听回调 + */ + fun addListener( + @Nullable tag: String, + @Nullable listener: IMoGoAutopilotCarStateListener + ) { + 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 + } + + /** + * 删除监听 + * @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) + } + + /** + * 删除自动驾驶按钮选中监听 + * @param listener 要删除的监听对象 + */ + fun removeListener(@Nullable listener: IMoGoAutopilotCarStateListener) { + M_AUTOPILOT_STATUS_LISTENERS.forEach { + if (it.value == listener) { + M_AUTOPILOT_STATUS_LISTENERS.remove(it.key) + } + } + } + + /** + * 车辆状态数据 回调 + * @param autoPilotCarStateInfo + */ + @Synchronized + fun invokeAutopilotCarStateData(autoPilotCarStateInfo: AutopilotCarStateInfo?) { + //Logger.d(TAG, "$autoPilotCarStateInfo") + M_AUTOPILOT_STATUS_LISTENERS.forEach { + val tag = it.key + val listener = it.value + //Logger.d(TAG, "tag:$tag listener:$listener") + listener.onAutopilotCarStateData(autoPilotCarStateInfo) + } + } + + +} \ No newline at end of file diff --git a/modules/mogo-module-adas/src/main/java/com/mogo/module/adas/AdasEventManager.java b/modules/mogo-module-adas/src/main/java/com/mogo/module/adas/AdasEventManager.java index 4934dac714..58ce90ecf9 100644 --- a/modules/mogo-module-adas/src/main/java/com/mogo/module/adas/AdasEventManager.java +++ b/modules/mogo-module-adas/src/main/java/com/mogo/module/adas/AdasEventManager.java @@ -13,10 +13,12 @@ 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.IMoGoAutopilotCarStateListener; 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.CallerAutopilotCarStatusListenerManager; 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; @@ -43,7 +45,8 @@ public class AdasEventManager implements OnAdasMsgConnectStatusListener, IMoGoAutopilotStatusListener, IMoGoAutopilotPlanningListener, - IMoGoAutopilotIdentifyListener { + IMoGoAutopilotIdentifyListener , + IMoGoAutopilotCarStateListener { private final String TAG = "AdasEventManager"; @@ -67,6 +70,7 @@ public class AdasEventManager implements CallerAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, this); CallerAutopilotPlanningListenerManager.INSTANCE.addListener(TAG, this); CallerAutopilotIdentifyListenerManager.INSTANCE.addListener(TAG, this); + CallerAutopilotCarStatusListenerManager.INSTANCE.addListener(TAG, this); } public static AdasEventManager getInstance() { diff --git a/modules/mogo-module-adas/src/main/java/com/mogo/module/adas/OnAdasListenerAdapter.java b/modules/mogo-module-adas/src/main/java/com/mogo/module/adas/OnAdasListenerAdapter.java index 41bb783d11..bf21126538 100644 --- a/modules/mogo-module-adas/src/main/java/com/mogo/module/adas/OnAdasListenerAdapter.java +++ b/modules/mogo-module-adas/src/main/java/com/mogo/module/adas/OnAdasListenerAdapter.java @@ -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.CallerAutopilotCarStatusListenerManager; import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager; import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager; import com.mogo.utils.logger.Logger; @@ -50,7 +51,7 @@ public class OnAdasListenerAdapter implements OnAdasListener { @Override public void onCarStateData(CarStateInfo carStateInfo) { AutopilotCarStateInfo autopilotCarStateInfo = AdasObjectUtils.INSTANCE.fromAdasCarStateInfoObject(carStateInfo); - CallerAutoPilotStatusListenerManager.INSTANCE.invokeAutopilotCarStateData(autopilotCarStateInfo); + CallerAutopilotCarStatusListenerManager.INSTANCE.invokeAutopilotCarStateData(autopilotCarStateInfo); //can数据转发 CarStateInfo.ValuesBean bean = carStateInfo.getValues();