diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/RomaTaxiView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/RomaTaxiView.kt index 3049e5c979..83cc0f180e 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/RomaTaxiView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/RomaTaxiView.kt @@ -2,6 +2,7 @@ package com.mogo.eagle.core.function.hmi.ui.widget import android.content.Context import android.util.AttributeSet +import android.util.Log import android.view.LayoutInflater import android.view.View import androidx.appcompat.content.res.AppCompatResources @@ -78,11 +79,12 @@ class RomaTaxiView @JvmOverloads constructor( } override fun romaViewStatus(status: Boolean) { + Log.i("emArrow","romaViewStatus:$status") ThreadUtils.runOnUiThread { if(status){ this.visibility = View.VISIBLE } else { - this.visibility = View.GONE +// this.visibility = View.GONE } } } diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/MapBizProvider.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/MapBizProvider.kt index e960a03449..82e91d04b0 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/MapBizProvider.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/MapBizProvider.kt @@ -9,6 +9,7 @@ import com.mogo.eagle.core.function.api.map.roma.IMogoRoma import com.mogo.eagle.core.function.business.MapPointCloudSubscriber import com.mogo.eagle.core.function.business.SpeedLimitDataManager import com.mogo.eagle.core.function.business.ai.AiCloudIdentifyDataManager.Companion.aiCloudIdentifyDataManager +import com.mogo.eagle.core.function.business.ai.RomaManager.Companion.romaManager import com.mogo.eagle.core.function.business.identify.MapIdentifySubscriber import com.mogo.eagle.core.function.business.roadcross.RoadCrossCameraManager import com.mogo.eagle.core.function.business.routeoverlay.MogoRouteOverlayManager @@ -37,7 +38,7 @@ class MapBizProvider :IMoGoFunctionServerProvider, IMogoRoma { } override fun trigger(romaStatus: Boolean) { - aiCloudIdentifyDataManager.trigger(romaStatus) + romaManager.trigger(romaStatus) } override fun onDestroy() { diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/AiCloudIdentifyDataManager.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/AiCloudIdentifyDataManager.kt index a3dfe912d8..eabf93ed0d 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/AiCloudIdentifyDataManager.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/AiCloudIdentifyDataManager.kt @@ -1,118 +1,23 @@ package com.mogo.eagle.core.function.business.ai import android.content.Context -import android.os.Handler -import android.os.Looper -import android.os.Message import com.mogo.aicloud.services.socket.IMogoOnMessageListener import com.mogo.aicloud.services.socket.MogoAiCloudSocketManager -import com.mogo.commons.debug.DebugConfig -import com.mogo.commons.module.status.MogoStatusManager -import com.mogo.eagle.core.data.config.FunctionBuildConfig -import com.mogo.eagle.core.data.deva.chain.ChainConstant -import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_CLICK -import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_CLOSE_CLICK -import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_CLOUD_ERROR -import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_CLOUD_PUSH -import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_MAP_CHANGE_END -import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_MAP_END -import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_MAP_ERROR -import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_MAP_READY_START -import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_MAP_START -import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_RANGE -import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_REQUEST -import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_REQUEST_DELAY -import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_REQUEST_ERROR -import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_REQUEST_OK -import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_ROUTE_MODE -import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener -import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener -import com.mogo.eagle.core.function.api.map.roma.IMoGoRomaListener import com.mogo.eagle.core.function.business.ai.net.AiCloudIdentifyNetWorkModel.Companion.aiCloudIdentifyNetWorkModel -import com.mogo.eagle.core.function.business.identify.MapIdentifySubscriber -import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager -import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager -import com.mogo.eagle.core.function.call.map.CallerMapRomaListener -import com.mogo.eagle.core.function.call.map.CallerMapRomaListener.invokeRomaViewStatus -import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager -import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.updateLongSightLevel -import com.mogo.eagle.core.function.utils.MapRomaTrace -import com.mogo.eagle.core.function.utils.MapRomaTrace.Companion.getCurrentCNode -import com.mogo.eagle.core.utilcode.util.ToastUtils -import com.mogo.map.uicontroller.VisualAngleMode -import com.zhidaoauto.map.data.point.LonLatPoint -import com.zhjt.service.chain.ChainLog -import mogo.telematics.pad.MessagePad +import com.mogo.eagle.core.function.call.map.CallerMapAiCloudDataManager import mogo.yycp.api.proto.SocketDownData -import java.util.concurrent.atomic.AtomicBoolean -class AiCloudIdentifyDataManager : IMoGoPlanningRottingListener, - IMoGoAutopilotStatusListener, IMoGoRomaListener { +class AiCloudIdentifyDataManager { companion object { - private const val TAG = "AiCloudIdentifyData" - - private const val H_ERROR_CLOUD = 1 - private const val H_ERROR_MAP = 2 - private const val H_DELAY_TIME = 3_000L - - var START_METRE = 200 - var END_METRE = 2000 - @JvmStatic val aiCloudIdentifyDataManager by lazy(LazyThreadSafetyMode.SYNCHRONIZED) { AiCloudIdentifyDataManager() } } - private var showAiCloud = AtomicBoolean(false) - - private var aiCloudDataChange = AtomicBoolean(false) - - @Volatile - private var cloudDataSize = 0 - - @Volatile - private var inRange = false - - private val handler = Handler(Looper.getMainLooper()) { - if (it.what == H_ERROR_CLOUD) { - if (!aiCloudDataChange.get()) { - MapRomaTrace.log( - CHAIN_CODE_ROMA_MAP_START, CHAIN_CODE_ROMA_CLOUD_ERROR, TAG, - mutableMapOf( - "msg" to "云端 $H_DELAY_TIME 秒内无感知数据下发", - "socketStatus" to MogoStatusManager.getInstance().isSocketOnLine, - "cityCode" to CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().cityCode - ) - ) - } else { - MapRomaTrace.log( - CHAIN_CODE_ROMA_MAP_START, CHAIN_CODE_ROMA_CLOUD_PUSH, TAG, - mutableMapOf( - "msg" to "延迟 $H_DELAY_TIME 秒内获取云端下发感知数据大小", - "cloudDataSize" to cloudDataSize - ) - ) - } - } - if (it.what == H_ERROR_MAP) { - MapRomaTrace.log( - CHAIN_CODE_ROMA_MAP_START, CHAIN_CODE_ROMA_MAP_ERROR, TAG, - mutableMapOf("msg" to "地图漫游模式启动失败,原因:${it.obj}") - ) - if (DebugConfig.isDebug()) { - ToastUtils.showShort("进入漫游模式失败, code:${it.obj}") - } - } - true - } - fun initServer(mContext: Context) { - CallerAutoPilotStatusListenerManager.addListener(TAG, this) - CallerPlanningRottingListenerManager.addListener(TAG, this) - CallerMapRomaListener.addListener(TAG, this) MogoAiCloudSocketManager.getInstance(mContext) .registerOnMessageListener( 0x040003, //低频数据 @@ -121,260 +26,33 @@ class AiCloudIdentifyDataManager : IMoGoPlanningRottingListener, return SocketDownData.SocketDownDataProto::class.java } - @ChainLog( - linkChainLog = ChainConstant.CHAIN_TYPE_SOCKET_DATA_TRACKED, - linkCode = ChainConstant.CHAIN_SOURCE_ADAS, - nodeAliasCode = ChainConstant.CHAIN_CODE_ADAS_RECT_DATA, - paramIndexes = [0] - ) override fun onMsgReceived(obj: SocketDownData.SocketDownDataProto?) { - obj?.let { - obj.data?.let { - if (it.allListList != null && it.allListList.size > 0) { - if (!aiCloudDataChange.get()) { - aiCloudDataChange.set(true) - } - } - if (showAiCloud.get()) { - if (it.allListList == null || it.allListList.size == 0) { - MapIdentifySubscriber.instance.clearAiCloudRoma() - return - } - cloudDataSize = it.allListList.size - MapIdentifySubscriber.instance.renderAiCloudResult(it.allListList) - } - } - } + CallerMapAiCloudDataManager.invokeAiIdentifyData(obj) } }) } - fun trigger(romaStatus: Boolean) { - // 乘客司机屏屏各自单独控制漫游 - if (romaStatus) { - // 开启roma,当前非漫游,开启 - MapRomaTrace.log( - "", - CHAIN_CODE_ROMA_CLICK, - TAG, - mutableMapOf("trigger" to true) - ) - openRoma() - } else { - // 跟上次关联,需要确认parent进度 - MapRomaTrace.log(getCurrentCNode(), CHAIN_CODE_ROMA_CLOSE_CLICK, TAG, "") - handler.removeMessages(H_ERROR_CLOUD) - closeRoma() - } + fun trigger(romaStatus: Boolean, startDis: Int, endDis: Int) { + requestRangeOfIdentify(romaStatus, startDis, endDis) } - private fun openRoma() { - CallerMapUIServiceManager.getMapUIController()?.visualAngleLock(true) - CallerMapUIServiceManager.getMapUIController()?.setScrollGesturesEnable(false) - updateLongSightLevel(true) - requestRangeOfIdentify(true) - } - - @Synchronized - private fun closeRoma(manual: Boolean = true) { - CallerMapUIServiceManager.getMapUIController()?.visualAngleLock(false) - CallerMapUIServiceManager.getMapUIController()?.setScrollGesturesEnable(true) - updateLongSightLevel(false) - requestRangeOfIdentify(false) - MapIdentifySubscriber.instance.clearAiCloudRoma() - // 主动关闭roma,回到中景视角 - if (manual) { - CallerMapUIServiceManager.getMapUIController() - ?.changeMapVisualAngle(VisualAngleMode.MODE_MEDIUM_SIGHT, null) - } - } - - override fun mapRomaInRange(range: Boolean) { - val gnss = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().gnssInfo - MapRomaTrace.log( - "", CHAIN_CODE_ROMA_RANGE, TAG, mutableMapOf( - "range" to range, - "lon" to gnss.longitude, - "lat" to gnss.latitude - ), true - ) - inRange = range - if (FunctionBuildConfig.romaModeStyle == 1) { - return - } - invokeRomaViewStatus(range) - } - - fun requestRangeOfIdentify(dataReceive: Boolean) { - val gnss = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().gnssInfo - // false,改变父节点信息 - MapRomaTrace.log( - if (dataReceive) CHAIN_CODE_ROMA_CLICK else "", CHAIN_CODE_ROMA_REQUEST, TAG, - mutableMapOf( - "dataReceive" to dataReceive, - "lon" to gnss.longitude, - "lat" to gnss.latitude, - "heading" to gnss.heading, - "socketStatus" to MogoStatusManager.getInstance().isSocketOnLine, - "cityCode" to CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().cityCode - ), !dataReceive - ) + fun requestRangeOfIdentify( + romaStatus: Boolean, + startDis: Int, + endDis: Int + ) { + val loc = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().gnssInfo aiCloudIdentifyNetWorkModel.requestIdentifyRange( - dataReceive, - gnss.longitude, - gnss.latitude, + romaStatus, + startDis, endDis, + loc.longitude, + loc.latitude, { - // false,改变父节点信息 - MapRomaTrace.log( - if (dataReceive) CHAIN_CODE_ROMA_REQUEST else "", - CHAIN_CODE_ROMA_REQUEST_OK, - TAG, - mutableMapOf( - "dataResult" to dataReceive, - "startRange" to START_METRE, - "endRange" to END_METRE, - ), !dataReceive - ) - if (dataReceive) { - // 请求地图开始漫游 - CallerMapUIServiceManager.getMapUIController() - ?.setRomaMode(FunctionBuildConfig.romaModeStyle) - } else { - // 保底清除策略 - MapRomaTrace.log( - "", - CHAIN_CODE_ROMA_REQUEST_DELAY, - TAG, - mutableMapOf("delay" to true), - true - ) - MapIdentifySubscriber.instance.clearAiCloudRoma() - } + CallerMapAiCloudDataManager.invokeResponse(romaStatus) }, { errorMsg -> - // false,改变父节点信息 - MapRomaTrace.log( - if (dataReceive) CHAIN_CODE_ROMA_REQUEST else "", - CHAIN_CODE_ROMA_REQUEST_ERROR, - TAG, - mutableMapOf( - "errorMsg" to errorMsg, - "dataResult" to dataReceive, - "startRange" to START_METRE, - "endRange" to END_METRE - ), true - ) - updateLongSightLevel(false) - CallerMapRomaListener.invokeMapRoma(false) - if (DebugConfig.isDebug()) { - ToastUtils.showShort("漫游请求异常,msg:$errorMsg") - } + CallerMapAiCloudDataManager.invokeResponse(romaStatus, errorMsg) }) } - //status 0:进入漫游模式成功 1;进入漫游模式失败 2:正常结束漫游 3:切换视角结束漫游 - override fun mapRomaStatus(status: Int, msg: String) { - super.mapRomaStatus(status, msg) - when (status) { - 0 -> { - MapRomaTrace.log( - CHAIN_CODE_ROMA_REQUEST_OK, - CHAIN_CODE_ROMA_MAP_READY_START, - TAG, - mutableMapOf("romaStart" to "地图准备漫游动画") - ) - } - 4 -> { - MapRomaTrace.log( - CHAIN_CODE_ROMA_MAP_READY_START, - CHAIN_CODE_ROMA_MAP_START, - TAG, - mutableMapOf("romaStart" to "地图漫游动画结束,开始漫游") - ) - showAiCloud.set(true) -// FunctionBuildConfig.isDrawIdentifyData = false - CallerMapRomaListener.invokeMapRoma(true) - // 5秒没有触发 则预警日志写入 - handler.sendEmptyMessageDelayed(H_ERROR_CLOUD, H_DELAY_TIME) - } - 5 -> { - CallerMapRomaListener.invokeRomaDistance(msg) - } - 1 -> { - val m = Message.obtain() - m.what = H_ERROR_MAP - m.obj = msg - handler.sendMessage(m) - CallerMapRomaListener.invokeMapRoma(false) - closeRoma(false) - } - 2 -> { // 地图自动漫游结束,重置状态,调用close通知服务端 - MapRomaTrace.log( - CHAIN_CODE_ROMA_MAP_START, CHAIN_CODE_ROMA_MAP_END, TAG, - mutableMapOf("romaEnd" to "地图结束回调,状态:$status"), true - ) - reset() - } - 3 -> { // 业务释放地图视角锁定,回调切换视角结束漫游 - MapRomaTrace.log( - CHAIN_CODE_ROMA_CLOSE_CLICK, - CHAIN_CODE_ROMA_MAP_CHANGE_END, - TAG, mutableMapOf("romaEnd" to "地图结束回调,状态:$status"), true - ) - reset(false) - } - } - } - - private fun reset(invokeCloud: Boolean = true) { - if (showAiCloud.get()) { - showAiCloud.set(false) - aiCloudDataChange.set(false) - MapIdentifySubscriber.instance.clearAiCloudRoma() -// FunctionBuildConfig.isDrawIdentifyData = true - CallerMapRomaListener.invokeMapRoma(false) - if (invokeCloud) { - closeRoma(false) - } - } - } - - override fun onAutopilotRouteLineId(lineId: Long) { - super.onAutopilotRouteLineId(lineId) - if (lineId == 0L) { - updateRomaStyle(true) - } - } - - override fun onAutopilotRotting(globalPathResp: MessagePad.GlobalPathResp?) { - globalPathResp?.let { - if (it.wayPointsList != null && it.wayPointsList.size > 0) { - val roamList = ArrayList() - it.wayPointsList.forEach { loc -> - roamList.add(LonLatPoint(loc.longitude, loc.latitude)) - } - updateRomaStyle(false, roamList) - } - } - } - - private fun updateRomaStyle(auto: Boolean, routeList: ArrayList? = null) { - MapRomaTrace.log( - "", - CHAIN_CODE_ROMA_ROUTE_MODE, - TAG, - "updateRomaStyle auto status:$auto, route:${routeList?.size ?: "reset null"}" - ) - routeList?.let { - CallerMapUIServiceManager.getMapUIController()?.setRoamTrajectory(it) - } - if (auto) { - FunctionBuildConfig.romaModeStyle = 0 - invokeRomaViewStatus(inRange) - } else { - FunctionBuildConfig.romaModeStyle = 1 - invokeRomaViewStatus(true) - } - } - } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/AiCloudRangeBroadcastReceiver.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/AiCloudRangeBroadcastReceiver.kt index 84bb37c721..c571fa64e6 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/AiCloudRangeBroadcastReceiver.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/AiCloudRangeBroadcastReceiver.kt @@ -3,9 +3,8 @@ package com.mogo.eagle.core.function.business.ai import android.content.BroadcastReceiver import android.content.Context import android.content.Intent -import com.mogo.eagle.core.function.business.ai.AiCloudIdentifyDataManager.Companion.END_METRE -import com.mogo.eagle.core.function.business.ai.AiCloudIdentifyDataManager.Companion.START_METRE import com.mogo.eagle.core.function.business.ai.AiCloudIdentifyDataManager.Companion.aiCloudIdentifyDataManager +import com.mogo.eagle.core.function.call.map.CallerMapIdentifyManager import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_MAP @@ -13,18 +12,18 @@ class AiCloudRangeBroadcastReceiver : BroadcastReceiver() { companion object { private const val TAG = "AiCloudRangeBroadcastReceiver" + private const val REQUEST_STATUS = "status" private const val START_RANGE = "startRange" private const val END_RANGE = "endRange" - // adb shell am broadcast -a com.map.aiCloud.notification --ei startRange 140 --ei endRange 2000 + // adb shell am broadcast -a com.map.aiCloud.notification -f 0x011000000 --ez true --ei startRange 140 --ei endRange 2000 } override fun onReceive(context: Context, intent: Intent) { - val startRange = intent.getIntExtra(START_RANGE, START_METRE) - val endRange = intent.getIntExtra(END_RANGE, END_METRE) - START_METRE = startRange - END_METRE = endRange + val requestStatus = intent.getBooleanExtra(REQUEST_STATUS, false) + val startRange = intent.getIntExtra(START_RANGE, 140) + val endRange = intent.getIntExtra(END_RANGE, 2000) CallerLogger.d("$M_MAP$TAG", "startRange:$startRange, endRange:$endRange") - aiCloudIdentifyDataManager.requestRangeOfIdentify(true) + CallerMapIdentifyManager.romaTrigger(requestStatus) } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/RomaManager.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/RomaManager.kt new file mode 100644 index 0000000000..dab363741b --- /dev/null +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/RomaManager.kt @@ -0,0 +1,386 @@ +package com.mogo.eagle.core.function.business.ai + +import android.os.Handler +import android.os.Looper +import android.os.Message +import com.mogo.commons.debug.DebugConfig +import com.mogo.commons.module.status.MogoStatusManager +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.data.deva.chain.ChainConstant +import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_CLICK +import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_CLOSE_CLICK +import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_CLOUD_ERROR +import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_CLOUD_PUSH +import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_MAP_CHANGE_END +import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_MAP_END +import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_MAP_ERROR +import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_MAP_READY_START +import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_MAP_START +import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_RANGE +import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_REQUEST +import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_REQUEST_DELAY +import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_REQUEST_ERROR +import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_REQUEST_OK +import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ROMA_ROUTE_MODE +import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener +import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener +import com.mogo.eagle.core.function.api.map.roma.IMoGoAiCloudIdentifyDataListener +import com.mogo.eagle.core.function.api.map.roma.IMoGoRomaListener +import com.mogo.eagle.core.function.business.ai.AiCloudIdentifyDataManager.Companion.aiCloudIdentifyDataManager +import com.mogo.eagle.core.function.business.identify.MapIdentifySubscriber +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager +import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager +import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager +import com.mogo.eagle.core.function.call.map.CallerMapAiCloudDataManager +import com.mogo.eagle.core.function.call.map.CallerMapIdentifyManager +import com.mogo.eagle.core.function.call.map.CallerMapRomaListener +import com.mogo.eagle.core.function.call.map.CallerMapRomaListener.invokeRomaViewStatus +import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager +import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.updateLongSightLevel +import com.mogo.eagle.core.function.utils.MapRomaTrace +import com.mogo.eagle.core.function.utils.MapRomaTrace.Companion.getCurrentCNode +import com.mogo.eagle.core.utilcode.util.ToastUtils +import com.mogo.map.uicontroller.VisualAngleMode +import com.zhidaoauto.map.data.point.LonLatPoint +import com.zhjt.service.chain.ChainLog +import mogo.telematics.pad.MessagePad +import mogo.yycp.api.proto.SocketDownData +import java.util.concurrent.atomic.AtomicBoolean + +class RomaManager() : IMoGoPlanningRottingListener, + IMoGoAutopilotStatusListener, IMoGoRomaListener, IMoGoAiCloudIdentifyDataListener { + + companion object { + private const val TAG = "AiCloudIdentifyData" + + private const val H_ERROR_CLOUD = 1 + private const val H_ERROR_MAP = 2 + private const val H_DELAY_TIME = 3_000L + + var START_METRE = 200 + var END_METRE = 2000 + + @JvmStatic + val romaManager by lazy(LazyThreadSafetyMode.SYNCHRONIZED) { + RomaManager() + } + } + + private var showAiCloud = AtomicBoolean(false) + + private var aiCloudDataChange = AtomicBoolean(false) + + @Volatile + private var cloudDataSize = 0 + + @Volatile + private var inRange = false + + init { + CallerAutoPilotStatusListenerManager.addListener(TAG, this) + CallerPlanningRottingListenerManager.addListener(TAG, this) + CallerMapRomaListener.addListener(TAG, this) + CallerMapAiCloudDataManager.addListener(TAG, this) + } + + private val handler = Handler(Looper.getMainLooper()) { + if (it.what == H_ERROR_CLOUD) { + if (!aiCloudDataChange.get()) { + MapRomaTrace.log( + CHAIN_CODE_ROMA_MAP_START, CHAIN_CODE_ROMA_CLOUD_ERROR, TAG, + mutableMapOf( + "msg" to "云端 $H_DELAY_TIME 秒内无感知数据下发", + "socketStatus" to MogoStatusManager.getInstance().isSocketOnLine, + "cityCode" to CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().cityCode + ) + ) + } else { + MapRomaTrace.log( + CHAIN_CODE_ROMA_MAP_START, CHAIN_CODE_ROMA_CLOUD_PUSH, TAG, + mutableMapOf( + "msg" to "延迟 $H_DELAY_TIME 秒内获取云端下发感知数据大小", + "cloudDataSize" to cloudDataSize + ) + ) + } + } + if (it.what == H_ERROR_MAP) { + MapRomaTrace.log( + CHAIN_CODE_ROMA_MAP_START, CHAIN_CODE_ROMA_MAP_ERROR, TAG, + mutableMapOf("msg" to "地图漫游模式启动失败,原因:${it.obj}") + ) + if (DebugConfig.isDebug()) { + ToastUtils.showShort("进入漫游模式失败, code:${it.obj}") + } + } + true + } + + fun trigger(romaStatus: Boolean) { + if (CallerMapIdentifyManager.roma.first != TAG && CallerMapIdentifyManager.roma.second) { + ToastUtils.showLong("正在展示路口漫游,请稍后重试") + return + } + // 乘客司机屏屏各自单独控制漫游 + if (romaStatus) { + // 开启roma,当前非漫游,开启 + MapRomaTrace.log( + "", + CHAIN_CODE_ROMA_CLICK, + TAG, + mutableMapOf("trigger" to true) + ) + openRoma() + } else { + // 跟上次关联,需要确认parent进度 + MapRomaTrace.log(getCurrentCNode(), CHAIN_CODE_ROMA_CLOSE_CLICK, TAG, "") + handler.removeMessages(H_ERROR_CLOUD) + closeRoma() + } + } + + private fun openRoma() { + CallerMapIdentifyManager.roma = Pair(TAG, true) + CallerMapUIServiceManager.getMapUIController()?.visualAngleLock(true) + CallerMapUIServiceManager.getMapUIController()?.setScrollGesturesEnable(false) + updateLongSightLevel(true) + requestRangeOfIdentify(true) + } + + @Synchronized + private fun closeRoma(manual: Boolean = true) { + CallerMapIdentifyManager.roma = Pair("", false) + CallerMapUIServiceManager.getMapUIController()?.visualAngleLock(false) + CallerMapUIServiceManager.getMapUIController()?.setScrollGesturesEnable(true) + updateLongSightLevel(false) + requestRangeOfIdentify(false) + MapIdentifySubscriber.instance.clearAiCloudRoma() + // 主动关闭roma,回到中景视角 + if (manual) { + CallerMapUIServiceManager.getMapUIController() + ?.changeMapVisualAngle(VisualAngleMode.MODE_MEDIUM_SIGHT, null) + } + } + + override fun mapRomaInRange(range: Boolean) { + val gnss = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().gnssInfo + MapRomaTrace.log( + "", CHAIN_CODE_ROMA_RANGE, TAG, mutableMapOf( + "range" to range, + "lon" to gnss.longitude, + "lat" to gnss.latitude + ), true + ) + inRange = range + if (FunctionBuildConfig.romaModeStyle == 1) { + return + } + invokeRomaViewStatus(range) + } + + private fun requestRangeOfIdentify(dataReceive: Boolean) { + val loc = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().gnssInfo + // false,改变父节点信息 + MapRomaTrace.log( + if (dataReceive) CHAIN_CODE_ROMA_CLICK else "", CHAIN_CODE_ROMA_REQUEST, TAG, + mutableMapOf( + "dataReceive" to dataReceive, + "lon" to loc.longitude, + "lat" to loc.latitude, + "heading" to loc.heading, + "socketStatus" to MogoStatusManager.getInstance().isSocketOnLine, + "cityCode" to CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().cityCode + ), !dataReceive + ) + aiCloudIdentifyDataManager.trigger(dataReceive, START_METRE, END_METRE) + } + + override fun response(requestStatus: Boolean, errorMsg: String?) { + //错误情况 + if (errorMsg != null) { + // false,改变父节点信息 + MapRomaTrace.log( + if (requestStatus) CHAIN_CODE_ROMA_REQUEST else "", + CHAIN_CODE_ROMA_REQUEST_ERROR, + TAG, + mutableMapOf( + "errorMsg" to errorMsg, + "dataResult" to requestStatus, + "startRange" to START_METRE, + "endRange" to END_METRE + ), true + ) + updateLongSightLevel(false) + CallerMapRomaListener.invokeMapRoma(false) + if (DebugConfig.isDebug()) { + ToastUtils.showShort("漫游请求异常,msg:$errorMsg") + } + return + } + + // false,改变父节点信息 + MapRomaTrace.log( + if (requestStatus) CHAIN_CODE_ROMA_REQUEST else "", + CHAIN_CODE_ROMA_REQUEST_OK, + TAG, + mutableMapOf( + "dataResult" to requestStatus, + "startRange" to START_METRE, + "endRange" to END_METRE, + ), !requestStatus + ) + if (requestStatus) { + // 请求地图开始漫游 + CallerMapUIServiceManager.getMapUIController() + ?.setRomaMode(FunctionBuildConfig.romaModeStyle) + } else { + // 保底清除策略 + MapRomaTrace.log( + "", + CHAIN_CODE_ROMA_REQUEST_DELAY, + TAG, + mutableMapOf("delay" to true), + true + ) + MapIdentifySubscriber.instance.clearAiCloudRoma() + } + } + + @ChainLog( + linkChainLog = ChainConstant.CHAIN_TYPE_SOCKET_DATA_TRACKED, + linkCode = ChainConstant.CHAIN_SOURCE_ADAS, + nodeAliasCode = ChainConstant.CHAIN_CODE_ADAS_RECT_DATA, + paramIndexes = [0] + ) + override fun onAiIdentifyData(obj: SocketDownData.SocketDownDataProto?) { + obj?.let { + obj.data?.let { + if (it.allListList != null && it.allListList.size > 0) { + if (!aiCloudDataChange.get()) { + aiCloudDataChange.set(true) + } + } + if (showAiCloud.get()) { + if (it.allListList == null || it.allListList.size == 0) { + MapIdentifySubscriber.instance.clearAiCloudRoma() + return + } + cloudDataSize = it.allListList.size + MapIdentifySubscriber.instance.renderAiCloudResult(it.allListList) + } + } + } + } + + //status 0:进入漫游模式成功 1;进入漫游模式失败 2:正常结束漫游 3:切换视角结束漫游 + override fun mapRomaStatus(status: Int, msg: String) { + super.mapRomaStatus(status, msg) + when (status) { + 0 -> { + MapRomaTrace.log( + CHAIN_CODE_ROMA_REQUEST_OK, + CHAIN_CODE_ROMA_MAP_READY_START, + TAG, + mutableMapOf("romaStart" to "地图准备漫游动画") + ) + } + + 4 -> { + MapRomaTrace.log( + CHAIN_CODE_ROMA_MAP_READY_START, + CHAIN_CODE_ROMA_MAP_START, + TAG, + mutableMapOf("romaStart" to "地图漫游动画结束,开始漫游") + ) + showAiCloud.set(true) +// FunctionBuildConfig.isDrawIdentifyData = false + CallerMapRomaListener.invokeMapRoma(true) + // 5秒没有触发 则预警日志写入 + handler.sendEmptyMessageDelayed(H_ERROR_CLOUD, H_DELAY_TIME) + } + + 5 -> { + CallerMapRomaListener.invokeRomaDistance(msg) + } + + 1 -> { + val m = Message.obtain() + m.what = H_ERROR_MAP + m.obj = msg + handler.sendMessage(m) + CallerMapRomaListener.invokeMapRoma(false) + closeRoma(false) + } + + 2 -> { // 地图自动漫游结束,重置状态,调用close通知服务端 + MapRomaTrace.log( + CHAIN_CODE_ROMA_MAP_START, CHAIN_CODE_ROMA_MAP_END, TAG, + mutableMapOf("romaEnd" to "地图结束回调,状态:$status"), true + ) + reset() + } + + 3 -> { // 业务释放地图视角锁定,回调切换视角结束漫游 + MapRomaTrace.log( + CHAIN_CODE_ROMA_CLOSE_CLICK, + CHAIN_CODE_ROMA_MAP_CHANGE_END, + TAG, mutableMapOf("romaEnd" to "地图结束回调,状态:$status"), true + ) + reset(false) + } + } + } + + private fun reset(invokeCloud: Boolean = true) { + if (showAiCloud.get()) { + showAiCloud.set(false) + aiCloudDataChange.set(false) + MapIdentifySubscriber.instance.clearAiCloudRoma() +// FunctionBuildConfig.isDrawIdentifyData = true + CallerMapRomaListener.invokeMapRoma(false) + if (invokeCloud) { + closeRoma(false) + } + } + } + + override fun onAutopilotRouteLineId(lineId: Long) { + super.onAutopilotRouteLineId(lineId) + if (lineId == 0L) { + updateRomaStyle(true) + } + } + + override fun onAutopilotRotting(globalPathResp: MessagePad.GlobalPathResp?) { + globalPathResp?.let { + if (it.wayPointsList != null && it.wayPointsList.size > 0) { + val roamList = ArrayList() + it.wayPointsList.forEach { loc -> + roamList.add(LonLatPoint(loc.longitude, loc.latitude)) + } + updateRomaStyle(false, roamList) + } + } + } + + private fun updateRomaStyle(auto: Boolean, routeList: ArrayList? = null) { + MapRomaTrace.log( + "", + CHAIN_CODE_ROMA_ROUTE_MODE, + TAG, + "updateRomaStyle auto status:$auto, route:${routeList?.size ?: "reset null"}" + ) + routeList?.let { + CallerMapUIServiceManager.getMapUIController()?.setRoamTrajectory(it) + } + if (auto) { + FunctionBuildConfig.romaModeStyle = 0 + invokeRomaViewStatus(inRange) + } else { + FunctionBuildConfig.romaModeStyle = 1 + invokeRomaViewStatus(true) + } + } + + +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/net/AiCloudIdentifyNetWorkModel.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/net/AiCloudIdentifyNetWorkModel.kt index f11544d6f0..68ba7ba43b 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/net/AiCloudIdentifyNetWorkModel.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/net/AiCloudIdentifyNetWorkModel.kt @@ -3,8 +3,6 @@ package com.mogo.eagle.core.function.business.ai.net import com.mogo.commons.constants.HostConst.getEagleHost import com.mogo.commons.storage.SharedPrefsMgr import com.mogo.eagle.core.data.BaseResponse -import com.mogo.eagle.core.function.business.ai.AiCloudIdentifyDataManager.Companion.END_METRE -import com.mogo.eagle.core.function.business.ai.AiCloudIdentifyDataManager.Companion.START_METRE import com.mogo.eagle.core.network.MoGoRetrofitFactory import com.mogo.eagle.core.network.apiCall import com.mogo.eagle.core.network.request @@ -24,6 +22,7 @@ class AiCloudIdentifyNetWorkModel private constructor() { fun requestIdentifyRange( dataReceive: Boolean, + startDis:Int, endDis:Int, lon: Double, lat: Double, onSuccess: (() -> Unit), onError: ((String) -> Unit) @@ -34,8 +33,8 @@ class AiCloudIdentifyNetWorkModel private constructor() { val map = mutableMapOf() map["sn"] = SharedPrefsMgr.getInstance().sn map["status"] = dataReceive - map["startMetre"] = START_METRE - map["endMetre"] = END_METRE + map["startMetre"] = startDis + map["endMetre"] = endDis map["type"] = 1 if (lon != 0.0) { map["lon"] = lon diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/Identify.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/Identify.kt index 6e2581073e..ecf47c3ecc 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/Identify.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/Identify.kt @@ -11,7 +11,7 @@ interface Identify { } - fun renderAiCloudResult(resultList: List) { + fun renderAiCloudResult(resultList: List, mapInstance:String) { } @@ -27,7 +27,7 @@ interface Identify { } - fun clearAiMarker() { + fun clearAiMarker(mapInstance:String) { } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/IdentifyAiCloudDataDrawer.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/IdentifyAiCloudDataDrawer.kt index e04319443b..1eb6b8f061 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/IdentifyAiCloudDataDrawer.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/IdentifyAiCloudDataDrawer.kt @@ -3,6 +3,7 @@ package com.mogo.eagle.core.function.business.identify import android.annotation.SuppressLint import androidx.collection.ArraySet import com.mogo.commons.module.status.MogoStatusManager +import com.mogo.map.MogoMap import com.mogo.map.identify.MogoIdentifyManager import mogo.yycp.api.proto.SocketDownData import java.util.concurrent.ConcurrentHashMap @@ -27,7 +28,10 @@ class IdentifyAiCloudDataDrawer : Identify { private val mFilterTrafficData = HashMap() @SuppressLint("NewApi") - override fun renderAiCloudResult(resultList: List) { + override fun renderAiCloudResult( + resultList: List, + mapInstance: String + ) { if (resultList.isEmpty()) { clearOldMarker() return @@ -36,7 +40,6 @@ class IdentifyAiCloudDataDrawer : Identify { clearOldMarker() return } - //清除缓存 for (data in resultList) { if (trafficDataUuidList.size > 0 && trafficDataUuidList.contains("" + data.uuid)) { @@ -51,14 +54,14 @@ class IdentifyAiCloudDataDrawer : Identify { it.remove() mMarkersCaches.remove(key) MogoIdentifyManager.getInstance() - .removeMarker(key.hashCode().toString()) + .removeMarker(key.hashCode().toString(), mapInstance) } val filterList = filterTrafficData(resultList) if (filterList.size > 0) { // 绘制新数据 MogoIdentifyManager.getInstance() - .updateBatchAiMarkerPosition(filterList) + .updateBatchAiMarkerPosition(filterList, mapInstance) } } @@ -81,12 +84,12 @@ class IdentifyAiCloudDataDrawer : Identify { } @SuppressLint("NewApi") - override fun clearAiMarker() { + override fun clearAiMarker(mapInstance:String) { trafficDataUuidList.clear() mMarkersCaches.forEach { (uuid, _) -> mMarkersCaches.remove(uuid) MogoIdentifyManager.getInstance() - .removeMarker(uuid.hashCode().toString()) + .removeMarker(uuid.hashCode().toString(), mapInstance) } mFilterTrafficData.clear() } diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/IdentifyFactory.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/IdentifyFactory.kt index e1f881e940..f950b5109c 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/IdentifyFactory.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/IdentifyFactory.kt @@ -12,6 +12,7 @@ import com.mogo.eagle.core.function.call.obu.CallerObuWarningListenerManager import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils.isTaxi import com.mogo.eagle.core.utilcode.mogo.thread.WorkThreadHandler import com.mogo.eagle.core.utilcode.util.ParseVersionUtils +import com.mogo.map.MogoMap import com.zhjt.service.chain.ChainLog import mogo.telematics.pad.MessagePad import mogo.telematics.pad.MessagePad.TrackedObject @@ -111,7 +112,7 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener, IMoGoAutopilotCarConf } MSG_DATA_AI_TRACK -> { if (msg.obj is List<*>) { - aiCloudIdentify!!.renderAiCloudResult(msg.obj as List) + aiCloudIdentify!!.renderAiCloudResult(msg.obj as List, msg.data.getString("mapInstance")!!) } } MSG_DATA_WARNING -> { @@ -133,7 +134,7 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener, IMoGoAutopilotCarConf identify!!.clearOldMarker() } MSG_DATA_AI_CLEAR -> { - aiCloudIdentify!!.clearAiMarker() + aiCloudIdentify!!.clearAiMarker(msg.data.getString("mapInstance")!!) } } } @@ -146,10 +147,11 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener, IMoGoAutopilotCarConf mDrawerHandler.sendMessage(message) } - override fun renderAiCloudResult(resultList: List) { + override fun renderAiCloudResult(resultList: List, mapInstance:String) { val message = Message.obtain() message.what = MSG_DATA_AI_TRACK message.obj = resultList + message.data.putString("mapInstance",mapInstance) mDrawerHandler.sendMessage(message) } @@ -166,9 +168,10 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener, IMoGoAutopilotCarConf mDrawerHandler.sendMessage(message) } - override fun clearAiMarker() { + override fun clearAiMarker(mapInstance:String) { val message = Message.obtain() message.what = MSG_DATA_AI_CLEAR + message.data.putString("mapInstance",mapInstance) mDrawerHandler.sendMessage(message) } diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/MapIdentifySubscriber.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/MapIdentifySubscriber.kt index 44bc67a030..e59cef6c39 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/MapIdentifySubscriber.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/MapIdentifySubscriber.kt @@ -8,6 +8,7 @@ import com.mogo.eagle.core.function.api.datacenter.obu.IMoGoObuStatusListener import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager import com.mogo.eagle.core.function.call.obu.CallerObuWarningListenerManager import com.mogo.eagle.core.utilcode.util.ThreadUtils +import com.mogo.map.MogoMap import mogo.telematics.pad.MessagePad import mogo.telematics.pad.MessagePad.TrackedObject import mogo.yycp.api.proto.SocketDownData @@ -58,18 +59,18 @@ class MapIdentifySubscriber private constructor() : IMoGoSubscriber, } } - fun renderAiCloudResult(cloudData: List) { + fun renderAiCloudResult(cloudData: List, mapInstance:String = MogoMap.DEFAULT) { try { ThreadUtils.getSinglePool().execute { - IdentifyFactory.renderAiCloudResult(cloudData) + IdentifyFactory.renderAiCloudResult(cloudData, mapInstance) } } catch (e: Exception) { e.printStackTrace() } } - fun clearAiCloudRoma() { - IdentifyFactory.clearAiMarker() + fun clearAiCloudRoma(mapInstance:String = MogoMap.DEFAULT) { + IdentifyFactory.clearAiMarker(mapInstance) } override fun onAutopilotIdentifyPlanningObj(planningObjects: List?) { diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/TrackManager.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/TrackManager.java index 148760516a..e3c190b765 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/TrackManager.java +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/TrackManager.java @@ -1,17 +1,15 @@ package com.mogo.eagle.core.function.business.identify; import android.annotation.SuppressLint; -import android.os.Build; import android.util.ArraySet; -import androidx.annotation.RequiresApi; - import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import com.mogo.eagle.core.data.enums.TrafficTypeEnum; import com.mogo.eagle.core.data.traffic.TrafficData; import com.mogo.eagle.core.utilcode.geometry.S2CellId; import com.mogo.eagle.core.utilcode.geometry.S2LatLng; +import com.mogo.map.MogoMap; import com.mogo.map.identify.MogoIdentifyManager; import java.util.HashMap; @@ -96,7 +94,7 @@ public class TrackManager { if (cellIdCaches.containsValue(pos)) { String findSameValue = cellIdCaches.inverse().get(pos); //uuid处理 - if(findSameValue != null && !findSameValue.isEmpty()){ + if (findSameValue != null && !findSameValue.isEmpty()) { data = data.toBuilder().setUuid(Integer.parseInt(findSameValue)).build(); TrackObj cacheTrack = mMarkersCaches.get(findSameValue); if (cacheTrack != null) { @@ -114,14 +112,14 @@ public class TrackManager { uuid = findSameValue; trackObj.updateObj(data); } else { - trackObj = new TrackObj(data,s2CellId,s2LatLng); + trackObj = new TrackObj(data, s2CellId, s2LatLng); } } } else { - trackObj = new TrackObj(data,s2CellId,s2LatLng); + trackObj = new TrackObj(data, s2CellId, s2LatLng); } } - if(trackObj != null){ + if (trackObj != null) { mFilterTrafficData.put(uuid, trackObj.getCache()); cellIdCaches.forcePut(uuid, trackObj.getCellIdPos()); mMarkersCaches.put(uuid, trackObj); @@ -158,10 +156,10 @@ public class TrackManager { mMarkersCaches.remove(key); WarningHelper.INSTANCE.remove(key); MogoIdentifyManager.getInstance() - .removeMarker(key); + .removeMarker(key, MogoMap.DEFAULT); } - @RequiresApi(api = Build.VERSION_CODES.N) + @SuppressLint("NewApi") public void clearAll() { cellIdCaches.clear(); trafficDataUuid.clear(); @@ -169,7 +167,7 @@ public class TrackManager { mMarkersCaches.forEach((uuid, trackObj) -> { trackObj.clear(); MogoIdentifyManager.getInstance() - .removeMarker(uuid); + .removeMarker(uuid, MogoMap.DEFAULT); }); mMarkersCaches.clear(); } diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/MapRoamView.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/MapRoamView.kt index a5aac288fa..421a11f096 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/MapRoamView.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/MapRoamView.kt @@ -7,17 +7,24 @@ import android.util.AttributeSet import android.util.Log import androidx.lifecycle.LifecycleObserver import com.mogo.eagle.core.function.api.map.road.IMoGoMapRoadListener +import com.mogo.eagle.core.function.api.map.roma.IMoGoAiCloudIdentifyDataListener +import com.mogo.eagle.core.function.business.ai.AiCloudIdentifyDataManager +import com.mogo.eagle.core.function.business.ai.AiCloudIdentifyDataManager.Companion.aiCloudIdentifyDataManager +import com.mogo.eagle.core.function.business.ai.RomaManager +import com.mogo.eagle.core.function.business.identify.MapIdentifySubscriber import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager +import com.mogo.eagle.core.function.call.map.CallerMapAiCloudDataManager import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager import com.mogo.eagle.core.widget.media.video.TextureVideoViewOutlineProvider import com.mogo.map.MogoMap.Companion.MAP_ROAM import com.mogo.map.MogoMapView import com.mogo.map.uicontroller.IMogoMapUIController import com.mogo.map.uicontroller.VisualAngleMode +import mogo.yycp.api.proto.SocketDownData class MapRoamView(context: Context?, attrs: AttributeSet?) : MogoMapView(context, attrs), - LifecycleObserver, IMoGoMapRoadListener { + LifecycleObserver, IMoGoMapRoadListener , IMoGoAiCloudIdentifyDataListener { companion object { private const val TAG = "MapRoamView" @@ -30,7 +37,6 @@ class MapRoamView(context: Context?, attrs: AttributeSet?) : MogoMapView(context override fun onAttachedToWindow() { super.onAttachedToWindow() initMapView() - CallerMapRoadListenerManager.addListener(TAG, this) } private fun initMapView() { @@ -77,6 +83,7 @@ class MapRoamView(context: Context?, attrs: AttributeSet?) : MogoMapView(context fun openRoam() { this.onResume() + CallerMapAiCloudDataManager.addListener(TAG, this) // 更新地图视角 - 高视角 getUI()?.changeMapVisualAngle(VisualAngleMode.MAP_STYLE_VR_ANGLE_TOP, null) // 更新路口位置 @@ -89,17 +96,36 @@ class MapRoamView(context: Context?, attrs: AttributeSet?) : MogoMapView(context setExtraGPSData(loc) } // 开始漫游 + aiCloudIdentifyDataManager.trigger(true, 1, 300) + } + + override fun response(requestStatus: Boolean, errorMsg: String?) { + + } + + override fun onAiIdentifyData(obj: SocketDownData.SocketDownDataProto?) { + obj?.let { + obj.data?.let { + if (it.allListList == null || it.allListList.size == 0) { + MapIdentifySubscriber.instance.clearAiCloudRoma(MAP_ROAM) + return + } + MapIdentifySubscriber.instance.renderAiCloudResult(it.allListList, MAP_ROAM) + } + } } fun closeRoam(){ this.onPause() - + // 结束漫游 + aiCloudIdentifyDataManager.trigger(false, 1, 300) + CallerMapAiCloudDataManager.removeListener(TAG) + MapIdentifySubscriber.instance.clearAiCloudRoma(MAP_ROAM) } override fun onDestroy() { // 先取消注册数据,再onDestroy - CallerMapRoadListenerManager.removeListener(TAG) super.onDestroy() } diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/RoadCrossRoamView.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/RoadCrossRoamView.kt index e5e523c4f6..a9996ffbe8 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/RoadCrossRoamView.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/RoadCrossRoamView.kt @@ -8,17 +8,17 @@ import android.util.AttributeSet import android.util.Log import android.view.LayoutInflater import android.view.View -import android.view.animation.Animation -import android.view.animation.AnimationUtils import android.view.animation.LinearInterpolator import androidx.constraintlayout.widget.ConstraintLayout import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.mogo.eagle.core.function.api.map.road.IMoGoMapRoadListener +import com.mogo.eagle.core.function.call.map.CallerMapIdentifyManager import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager import com.mogo.eagle.core.function.map.R import com.mogo.eagle.core.utilcode.util.ThreadUtils +import com.mogo.eagle.core.utilcode.util.ToastUtils import com.zhidaoauto.map.data.road.StopLine import kotlinx.android.synthetic.main.view_road_cross_roam.view.ivCoverRoam import kotlinx.android.synthetic.main.view_road_cross_roam.view.ivRoadRoamClose @@ -33,7 +33,7 @@ class RoadCrossRoamView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 -) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoMapRoadListener { +) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoMapRoadListener{ companion object { private const val TAG = "RoadCrossRoamView" @@ -46,6 +46,7 @@ class RoadCrossRoamView @JvmOverloads constructor( } private var animator: ObjectAnimator? = null + private var rotationAnim: ObjectAnimator? = null private var lightMode = CallerSkinModeListenerManager.getMode() == 1 init { @@ -95,6 +96,14 @@ class RoadCrossRoamView @JvmOverloads constructor( } private fun attachView() { + // 处于漫游模式下不做处理 + if (CallerMapIdentifyManager.roma.second) { + if (CallerMapIdentifyManager.roma.first != TAG) { + ToastUtils.showLong("正在漫游中,不展示路口漫游") + } + return + } + CallerMapIdentifyManager.roma = Pair(TAG, true) this.visibility = View.VISIBLE ivZhiRoadRoamView.visibility = View.VISIBLE mapRoamView.visibility = View.VISIBLE @@ -116,16 +125,14 @@ class RoadCrossRoamView @JvmOverloads constructor( animator?.start() if (lightMode) { -// val rotateAnimation: Animation = AnimationUtils.loadAnimation( -// context, R.anim.anim_road_cross_roam -// ) -// ivZhiRoadRoamView.startAnimation(rotateAnimation) - val rotationAnim = ObjectAnimator.ofFloat(ivZhiRoadRoamView, "rotation", 0f, 360f) - rotationAnim.repeatCount = ValueAnimator.INFINITE - rotationAnim.repeatMode = ValueAnimator.RESTART - rotationAnim.duration = 1000 - rotationAnim.interpolator = LinearInterpolator() - rotationAnim.start() + if (rotationAnim == null) { + rotationAnim = ObjectAnimator.ofFloat(ivZhiRoadRoamView, "rotation", 0f, 360f) + } + rotationAnim?.repeatCount = ValueAnimator.INFINITE + rotationAnim?.repeatMode = ValueAnimator.RESTART + rotationAnim?.duration = 1000 + rotationAnim?.interpolator = LinearInterpolator() + rotationAnim?.start() tvRoadRoamTitle.setTextColor(context.getColor(R.color.color_131415)) } else { tvRoadRoamTitle.setTextColor(context.getColor(R.color.white)) @@ -133,11 +140,15 @@ class RoadCrossRoamView @JvmOverloads constructor( } private fun detachView() { + if (this.visibility == View.GONE) { + return + } mapRoamView.closeRoam() mapRoamView.visibility = View.GONE + CallerMapIdentifyManager.roma = Pair("", false) lvRoadCrossRoamTip.adapter = null animator?.cancel() - if(lightMode){ + if (lightMode) { ivZhiRoadRoamView.clearAnimation() } this.visibility = View.GONE @@ -146,11 +157,10 @@ class RoadCrossRoamView @JvmOverloads constructor( override fun onDetachedFromWindow() { super.onDetachedFromWindow() animator?.cancel() - if(lightMode){ + if (lightMode) { ivZhiRoadRoamView.clearAnimation() } CallerMapRoadListenerManager.removeListener(TAG) } - } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/res/layout/view_road_cross_roam.xml b/core/function-impl/mogo-core-function-map/src/main/res/layout/view_road_cross_roam.xml index e7a728e41a..51bd7902bb 100644 --- a/core/function-impl/mogo-core-function-map/src/main/res/layout/view_road_cross_roam.xml +++ b/core/function-impl/mogo-core-function-map/src/main/res/layout/view_road_cross_roam.xml @@ -28,6 +28,7 @@ tools:ignore="ContentDescription" /> () { + + fun invokeResponse(requestStatus: Boolean, errorMsg: String? = null) { + val tag = CallerMapIdentifyManager.roma.first + if(tag.isNotEmpty() && M_LISTENERS.containsKey(tag)){ + M_LISTENERS[tag]?.response(requestStatus, errorMsg) + } + } + + fun invokeAiIdentifyData(obj: SocketDownData.SocketDownDataProto?){ + val tag = CallerMapIdentifyManager.roma.first + if(tag.isNotEmpty() && M_LISTENERS.containsKey(tag)){ + M_LISTENERS[tag]?.onAiIdentifyData(obj) + } + } +} \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerMapIdentifyManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerMapIdentifyManager.kt index 7762e32361..b8eae0633d 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerMapIdentifyManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerMapIdentifyManager.kt @@ -3,14 +3,18 @@ package com.mogo.eagle.core.function.call.map import com.alibaba.android.arouter.launcher.ARouter import com.mogo.eagle.core.data.constants.MogoServicePaths import com.mogo.eagle.core.function.api.map.roma.IMogoRoma +import com.mogo.eagle.core.utilcode.util.ToastUtils object CallerMapIdentifyManager { - private val romaApi:IMogoRoma - get() = ARouter.getInstance().build( MogoServicePaths.PATH_MAP_BIZ) + @Volatile + var roma = Pair("", false) + + private val romaApi: IMogoRoma + get() = ARouter.getInstance().build(MogoServicePaths.PATH_MAP_BIZ) .navigation() as IMogoRoma - fun romaTrigger(romaStatus:Boolean){ + fun romaTrigger(romaStatus: Boolean) { romaApi.trigger(romaStatus) } diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/identity/IMogoIdentifyManager.kt b/libraries/mogo-map-api/src/main/java/com/mogo/map/identity/IMogoIdentifyManager.kt index 83c5adebf1..08b9acfa9d 100644 --- a/libraries/mogo-map-api/src/main/java/com/mogo/map/identity/IMogoIdentifyManager.kt +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/identity/IMogoIdentifyManager.kt @@ -1,5 +1,6 @@ package com.mogo.map.identity +import com.mogo.map.MogoMap import mogo.telematics.pad.MessagePad.TrackedObject import mogo.yycp.api.proto.SocketDownData import java.util.HashMap @@ -13,19 +14,19 @@ interface IMogoIdentifyManager { * * @param uuidString */ - fun removeMarker(uuidString: String?) + fun removeMarker(uuidString: String?, mapInstance:String = MogoMap.DEFAULT) /** * 批量更新锚点位置 * * @param optionsArrayList 锚点集合 */ - fun updateBatchMarkerPosition(optionsArrayList: HashMap) + fun updateBatchMarkerPosition(optionsArrayList: HashMap, mapInstance:String = MogoMap.DEFAULT) /** * 批量更新锚点位置 * * @param optionsArrayList 锚点集合 */ - fun updateBatchAiMarkerPosition(optionsArrayList: HashMap) + fun updateBatchAiMarkerPosition(optionsArrayList: HashMap, mapInstance:String = MogoMap.DEFAULT) } \ No newline at end of file diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/identify/MogoIdentifyManager.java b/libraries/mogo-map/src/main/java/com/mogo/map/identify/MogoIdentifyManager.java index bfd1882488..1ed3d51575 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/identify/MogoIdentifyManager.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/identify/MogoIdentifyManager.java @@ -31,7 +31,7 @@ public class MogoIdentifyManager implements IMogoIdentifyManager { } @Override - public void removeMarker(String uuidString) { + public void removeMarker(String uuidString, String mapInstance) { try { IMogoMap iMogoMap = MogoMap.Companion.getMapInstance().getMogoMap(MogoMap.DEFAULT); if(iMogoMap != null){ @@ -46,7 +46,7 @@ public class MogoIdentifyManager implements IMogoIdentifyManager { } @Override - public void updateBatchMarkerPosition(HashMap optionsArrayList) { + public void updateBatchMarkerPosition(HashMap optionsArrayList, String mapInstance) { try { IMogoMap iMogoMap = MogoMap.Companion.getMapInstance().getMogoMap(MogoMap.DEFAULT); if(iMogoMap != null){ @@ -58,7 +58,7 @@ public class MogoIdentifyManager implements IMogoIdentifyManager { } @Override - public void updateBatchAiMarkerPosition(HashMap optionsArrayList) { + public void updateBatchAiMarkerPosition(HashMap optionsArrayList, String mapInstance) { try { IMogoMap iMogoMap = MogoMap.Companion.getMapInstance().getMogoMap(MogoMap.DEFAULT); if(iMogoMap != null){