This commit is contained in:
zhongchao
2023-04-04 15:09:31 +08:00
parent 8d41c335d6
commit c52c3828f8
63 changed files with 875 additions and 426 deletions

View File

@@ -22,7 +22,7 @@ class MapBizProvider :IMoGoFunctionServerProvider{
MogoRouteOverlayManager.getInstance().init()
MapPointCloudSubscriber.instance
SpeedLimitDataManager.getInstance().start()
aiCloudIdentifyDataManager.init(AbsMogoApplication.getApp())
aiCloudIdentifyDataManager.initServer(AbsMogoApplication.getApp())
}
override fun onDestroy() {

View File

@@ -1,23 +1,46 @@
package com.mogo.eagle.core.function.business.ai
import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.mogo.aicloud.services.socket.IMogoOnMessageListener
import com.mogo.aicloud.services.socket.MogoAiCloudSocketManager
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.function.business.ai.net.AiCloudIdentifyNetWorkModel
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.data.deva.chain.ChainConstant
import com.mogo.eagle.core.data.multidisplay.TelematicConstant
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.IMogoRoma
import com.mogo.eagle.core.function.api.telematic.IReceivedMsgListener
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.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_MAP
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
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.call.telematic.CallerTelematicListenerManager
import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager
import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager.sendMsgToAllClients
import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager.sendMsgToServer
import com.mogo.eagle.core.function.utils.MapBizTrace
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.mogo.map.MogoMapUIController
import com.mogo.map.listener.IMogoMapListener
import com.mogo.map.listener.MogoMapListenerHandler
import com.mogo.map.uicontroller.VisualAngleMode
import com.zhjt.service.chain.ChainLog
import com.zhjt.service.chain.TracingConstants
import mogo.telematics.pad.MessagePad
import mogo.yycp.api.proto.SocketDownData
class AiCloudIdentifyDataManager : IMogoMapListener {
@Route(path = MogoServicePaths.PATH_ROMA)
class AiCloudIdentifyDataManager : IMogoMapListener, IReceivedMsgListener, IMogoRoma,
IMoGoPlanningRottingListener, IMoGoAutopilotStatusListener {
companion object {
private const val TAG = "AiCloudIdentifyData"
var START_METRE = 200
var START_METRE = 1
var END_METRE = 2000
@JvmStatic
@@ -26,66 +49,193 @@ class AiCloudIdentifyDataManager : IMogoMapListener {
}
}
private val aiCloudIdentifyNetWorkModel = AiCloudIdentifyNetWorkModel()
private var showAiCloud = false
private var serverSn = ""
fun init(mContext: Context) {
MogoAiCloudSocketManager.getInstance(mContext)
.registerOnMessageListener(
0x040003, //低频数据
object : IMogoOnMessageListener<SocketDownData.SocketDownDataProto> {
override fun target(): Class<SocketDownData.SocketDownDataProto> {
return SocketDownData.SocketDownDataProto::class.java
}
override fun init(context: Context?) {
override fun onMsgReceived(obj: SocketDownData.SocketDownDataProto?) {
if (!FunctionBuildConfig.isDrawAiCloudFusion) {
MapIdentifySubscriber.instance.clearAiCloudRoma()
return
}
fun initServer(mContext: Context) {
if (AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
MogoMapListenerHandler.mogoMapListenerHandler.registerHostMapListener(TAG, this)
CallerTelematicListenerManager.addListener(TAG, this)
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
MogoAiCloudSocketManager.getInstance(mContext)
.registerOnMessageListener(
0x040003, //低频数据
object : IMogoOnMessageListener<SocketDownData.SocketDownDataProto> {
override fun target(): Class<SocketDownData.SocketDownDataProto> {
return SocketDownData.SocketDownDataProto::class.java
}
obj?.let {
obj.data?.let {
if (showAiCloud) {
if (it.allListList == null || it.allListList.size == 0) {
MapIdentifySubscriber.instance.clearAiCloudRoma()
return
@ChainLog(
linkChainLog = ChainConstant.CHAIN_LINK_LOG_WEB_SOCKET_DATA_TRACKED,
linkCode = ChainConstant.CHAIN_LINK_ADAS,
endpoint = TracingConstants.Endpoint.PAD,
nodeAliasCode = ChainConstant.CHAIN_ALIAS_CODE_ADAS_MESSAGE_RECT_DATA,
paramIndexes = [0],
clientPkFileName = "sn"
)
override fun onMsgReceived(obj: SocketDownData.SocketDownDataProto?) {
obj?.let {
obj.data?.let {
if (showAiCloud) {
if (it.allListList == null || it.allListList.size == 0) {
MapIdentifySubscriber.instance.clearAiCloudRoma()
return
}
MapIdentifySubscriber.instance.renderAiCloudResult(it.allListList)
}
MapIdentifySubscriber.instance.renderAiCloudResult(it.allListList)
}
}
}
}
})
requestRangeOfIdentify()
})
}
}
fun requestRangeOfIdentify() {
aiCloudIdentifyNetWorkModel.requestIdentifyRange({
CallerLogger.d(
M_MAP + TAG,
"requestIdentifyRange ok startRange:$START_METRE, endRange:$END_METRE"
override fun trigger(romaStatus: Boolean) {
MapBizTrace.log(TAG, "trigger")
// 司机屏发送事件给乘客屏
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
if (romaStatus) {
sendMsgToAllClients(TelematicConstant.OPEN_ROMA_STATUS, "0".toByteArray())
} else {
sendMsgToAllClients(TelematicConstant.OPEN_ROMA_STATUS, "1".toByteArray())
}
}
// 乘客屏单独控制漫游
if (AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
if (romaStatus) {
// 开启roma当前非漫游开启
openRoma()
} else {
closeRoma()
}
}
}
// 乘客屏接收开启/关闭 roma
override fun onReceivedMsg(type: Int, byteArray: ByteArray) {
MapBizTrace.log(TAG, "onReceivedMsg type : $type")
when (type) {
TelematicConstant.OPEN_ROMA_STATUS -> {
when (String(byteArray)) {
"0" -> {
openRoma()
}
"1" -> {
closeRoma()
}
}
}
}
}
private fun openRoma() {
if (serverSn.isEmpty()) {
serverSn = CallerTelematicManager.getServerToken()
if (serverSn.isEmpty()) {
ToastUtils.showLong("未获取到司机屏设备信息")
return
}
}
if (!MogoMapUIController.getInstance().currentMapVisualAngle.isRoma) {
requestRangeOfIdentify(true)
updateLongSightLevel(true)
}
}
private fun closeRoma(manual: Boolean = true) {
if (serverSn.isEmpty()) {
serverSn = CallerTelematicManager.getServerToken()
if (serverSn.isEmpty()) {
ToastUtils.showLong("未获取到司机屏设备信息")
return
}
}
requestRangeOfIdentify(false)
updateLongSightLevel(false)
MapIdentifySubscriber.instance.clearAiCloudRoma()
// 主动关闭roma回到中景视角
if (manual) {
MogoMapUIController.getInstance()
.changeMapVisualAngle(VisualAngleMode.MODE_MEDIUM_SIGHT, null)
}
}
fun requestRangeOfIdentify(dataReceive: Boolean) {
aiCloudIdentifyNetWorkModel.requestIdentifyRange(dataReceive, serverSn, {
MapBizTrace.log(
TAG,
"requestIdentifyRange ok startRange:$START_METRE, endRange:$END_METRE , dataReceive:$dataReceive"
)
if (dataReceive) {
// 请求地图开始漫游
MogoMapUIController.getInstance().setRomaMode(FunctionBuildConfig.romaModeStyle)
sendMsgToServer(TelematicConstant.OPEN_ROMA_STATUS, "3".toByteArray())
} else {
sendMsgToServer(TelematicConstant.OPEN_ROMA_STATUS, "4".toByteArray())
}
}, {
CallerLogger.d(
M_MAP + TAG,
"requestIdentifyRange error : $it , startRange:$START_METRE, endRange:$END_METRE"
MapBizTrace.log(
TAG,
"requestIdentifyRange error : $it , startRange:$START_METRE, endRange:$END_METRE, dataReceive:$dataReceive"
)
updateLongSightLevel(false)
})
}
override fun onMapVisualAngleChanged(visualAngleMode: VisualAngleMode) {
super.onMapVisualAngleChanged(visualAngleMode)
when {
// 解除漫游限制
visualAngleMode.isRoma -> {
showAiCloud = true
FunctionBuildConfig.isDrawIdentifyData = false
}
else -> {
showAiCloud = false
FunctionBuildConfig.isDrawIdentifyData = true
MapIdentifySubscriber.instance.clearAiCloudRoma()
if (showAiCloud) {
showAiCloud = false
FunctionBuildConfig.isDrawIdentifyData = true
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 builder = StringBuilder()
it.wayPointsList.forEach { loc ->
builder.append(loc.longitude).append(",").append(loc.latitude).append(",")
}
val route = builder.toString()
if (route.endsWith(",")) {
route.substring(0, builder.toString().length - 1)
}
updateRomaStyle(false, route)
}
}
}
private fun updateRomaStyle(auto: Boolean, route: String? = null) {
CallerMapUIServiceManager.getMapUIController()?.setRoamTrajectory(route)
if (auto) {
FunctionBuildConfig.romaModeStyle = 0
MogoMapUIController.getInstance().setRomaMode(FunctionBuildConfig.romaModeStyle)
} else {
FunctionBuildConfig.romaModeStyle = 1
MogoMapUIController.getInstance().setRomaMode(FunctionBuildConfig.romaModeStyle)
}
}
}

View File

@@ -25,6 +25,6 @@ class AiCloudRangeBroadcastReceiver : BroadcastReceiver() {
START_METRE = startRange
END_METRE = endRange
CallerLogger.d("$M_MAP$TAG", "startRange:$startRange, endRange:$endRange")
aiCloudIdentifyDataManager.requestRangeOfIdentify()
aiCloudIdentifyDataManager.requestRangeOfIdentify(true)
}
}

View File

@@ -1,7 +1,6 @@
package com.mogo.eagle.core.function.business.ai.net
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.commons.constants.HostConst
import com.mogo.commons.debug.DebugConfig
import com.mogo.eagle.core.data.BaseResponse
import com.mogo.eagle.core.function.business.ai.AiCloudIdentifyDataManager.Companion.END_METRE
@@ -9,9 +8,8 @@ import com.mogo.eagle.core.function.business.ai.AiCloudIdentifyDataManager.Compa
import com.mogo.eagle.core.network.MoGoRetrofitFactory
import com.mogo.eagle.core.network.apiCall
import com.mogo.eagle.core.network.request
import com.zhjt.service_biz.FuncConfig
class AiCloudIdentifyNetWorkModel {
class AiCloudIdentifyNetWorkModel private constructor(){
companion object {
val aiCloudIdentifyNetWorkModel by lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
@@ -24,16 +22,20 @@ class AiCloudIdentifyNetWorkModel {
when (DebugConfig.getNetMode()) {
DebugConfig.NET_MODE_DEV,
DebugConfig.NET_MODE_QA -> host = "http://dzt-qa-city.zhidaozhixing.com"
// DebugConfig.NET_MODE_QA -> host = "http://dzt-test.zhidaozhixing.com"
}
return host
}
private fun getNetWorkApi(baseUrl: String = HostConst.getEagleHost()): IAiCloudIdentifyApiService {
return MoGoRetrofitFactory.getInstanceNoCallAdapter(baseUrl)
//todo test emArrow
private fun getNetWorkApi(baseUrl: String = getHost()): IAiCloudIdentifyApiService {
return MoGoRetrofitFactory.getInstanceNoCallAdapter("http://dzt-qa-city.zhidaozhixing.com")
.create(IAiCloudIdentifyApiService::class.java)
}
fun requestIdentifyRange(
dataReceive: Boolean,
serverSn:String,
onSuccess: (() -> Unit),
onError: ((String) -> Unit)
) {
@@ -41,10 +43,11 @@ class AiCloudIdentifyNetWorkModel {
val map = mutableMapOf<String, Any>()
start {
map["sn"] = MoGoAiCloudClientConfig.getInstance().sn
map["status"] = true
map["status"] = dataReceive
map["startMetre"] = START_METRE
map["endMetre"] = END_METRE
map["type"] = 1
map["relationSn"] = serverSn
}
loader {
apiCall {

View File

@@ -9,5 +9,6 @@ interface IAiCloudIdentifyApiService {
@Headers("Content-type:application/json;charset=UTF-8")
@POST("eagle-eye-dns/yycp-c-v2x-service/dataFusion/remoteDrivingSet")
// @POST("yycp-data-center-service1/remoteDrivingSet")
suspend fun identifyRange(@Body map: MutableMap<String, Any>): BaseResponse<Any>
}

View File

@@ -30,8 +30,4 @@ interface Identify {
fun clearAiMarker() {
}
fun getIdentifyObj(uuid: String): TrackedObject? {
return null
}
}

View File

@@ -135,10 +135,6 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener {
mDrawerHandler.sendMessage(message)
}
override fun getIdentifyObj(uuid: String): TrackedObject? {
return identify?.getIdentifyObj(uuid)
}
override fun updateTrackerWarningInfo(trafficData: TrafficData) {
super.updateTrackerWarningInfo(trafficData)
val message = Message.obtain()

View File

@@ -1,13 +1,9 @@
package com.mogo.eagle.core.function.business.identify
import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.constants.MogoServicePaths.PATH_IDENTIFY
import com.mogo.eagle.core.data.traffic.TrafficData
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener
import com.mogo.eagle.core.function.api.base.IMoGoSubscriber
import com.mogo.eagle.core.function.api.map.marker.IMoGoIdentifyListener
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
@@ -22,8 +18,7 @@ import mogo.yycp.api.proto.SocketDownData
*
* @author donghongyu
*/
@Route(path = PATH_IDENTIFY)
class MapIdentifySubscriber private constructor() : IMoGoIdentifyListener, IMoGoSubscriber,
class MapIdentifySubscriber private constructor() : IMoGoSubscriber,
IMoGoAutopilotIdentifyListener, IMoGoObuStatusListener {
private val TAG = "MapIdentifySubscriber"
@@ -64,12 +59,8 @@ class MapIdentifySubscriber private constructor() : IMoGoIdentifyListener, IMoGo
fun renderAiCloudResult(cloudData: List<SocketDownData.CloudRoadDataProto>) {
try {
if (FunctionBuildConfig.isDrawAiCloudFusion) {
ThreadUtils.getSinglePool().execute {
IdentifyFactory.renderAiCloudResult(cloudData)
}
} else {
clearAiCloudRoma()
ThreadUtils.getSinglePool().execute {
IdentifyFactory.renderAiCloudResult(cloudData)
}
} catch (e: Exception) {
e.printStackTrace()
@@ -120,12 +111,4 @@ class MapIdentifySubscriber private constructor() : IMoGoIdentifyListener, IMoGo
}
}
override fun getIdentifyObj(uuid: String): TrackedObject? {
return IdentifyFactory.getIdentifyObj(uuid)
}
override fun init(context: Context?) {
}
}

View File

@@ -46,7 +46,7 @@ object WarningHelper {
mMarkersCaches[trackId] ?: return@Consumer
if (planningObj.type == 0) { //0是leading障碍物障碍物车身红色提示
pncWarningBeautyTrafficData[trackId] = PlanningTrack(
"#D65D5AFF",
"#FF0000FF",
getCurWgs84SatelliteTime()
)
} else if (planningObj.type == 1) { //1是避障和择机的障碍物障碍物车身黄色提示

View File

@@ -144,6 +144,7 @@ class SmallMapView @JvmOverloads constructor(
SceneConstant.M_MAP + TAG, "SmallMapView clearPolyline mPolyline -----> ")
if (mPolyline != null) {
mPolyline!!.remove()
mPolyline = null
}
if (mStartMarker != null) {
mStartMarker!!.isVisible = false

View File

@@ -0,0 +1,28 @@
package com.mogo.eagle.core.function.utils
import com.mogo.commons.debug.DebugConfig
import com.mogo.eagle.core.data.deva.chain.ChainConstant
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_MAP
import com.zhjt.service.chain.ChainLog
import com.zhjt.service.chain.TracingConstants
class MapBizTrace {
companion object {
@ChainLog(
linkChainLog = ChainConstant.CHAIN_LINK_LOG_HD_MAP,
linkCode = ChainConstant.CHAIN_LINK_MAP,
endpoint = TracingConstants.Endpoint.PAD,
nodeAliasCode = ChainConstant.CHAIN_ALIAS_CODE_HD_MAP_BIZ,
paramIndexes = [0, 1],
clientPkFileName = "sn"
)
fun log(data: Any, data1: Any) {
if (DebugConfig.isDebug()) {
CallerLogger.d("$M_MAP${data.toString()}", data1)
}
}
}
}

View File

@@ -112,8 +112,8 @@ class MapBizView(context: Context?, attrs: AttributeSet?) : MogoMapView(context,
private fun turn(lightNum: Int) {
if (currentLevel != lightNum) {
when (lightNum) {
0 -> CallerMapUIServiceManager.getMapUIController()?.setCarLightsType(3, 500)
1 -> CallerMapUIServiceManager.getMapUIController()?.setCarLightsType(4, 500)
0 -> CallerMapUIServiceManager.getMapUIController()?.setCarLightsType(0, 500)
1 -> CallerMapUIServiceManager.getMapUIController()?.setCarLightsType(1, 500)
2 -> CallerMapUIServiceManager.getMapUIController()?.setCarLightsType(2, 500)
}
currentLevel = lightNum