[8.1.0]
[fea] [Vlm 接入]
This commit is contained in:
@@ -10,6 +10,7 @@ import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager
|
||||
import com.mogo.eagle.core.utilcode.kotlin.onClick
|
||||
import com.mogo.eagle.core.utilcode.util.AppUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UriUtils
|
||||
import com.mogo.och.common.module.biz.birdge.data.RoadMsg
|
||||
import com.mogo.och.common.module.biz.media.MediaManager
|
||||
import com.mogo.och.common.module.manager.loop.BizLoopManager
|
||||
import com.mogo.och.common.module.manager.transform.OchTransform
|
||||
@@ -126,11 +127,11 @@ class PM2BaseFragment :
|
||||
CallerMapRoadListenerManager.invokeCrossDevice(true)
|
||||
}
|
||||
test3.onClick {
|
||||
val one = AIMessage.RoadMsg(201,1,true,false)
|
||||
val two = AIMessage.RoadMsg(202,2,false,false)
|
||||
val three = AIMessage.RoadMsg(203,3,false,true)
|
||||
val one = RoadMsg(201,1,true,false)
|
||||
val two = RoadMsg(202,2,false,false)
|
||||
val three = RoadMsg(203,3,false,true)
|
||||
|
||||
val sortedList = ArrayList<AIMessage.RoadMsg>()
|
||||
val sortedList = ArrayList<RoadMsg>()
|
||||
sortedList.add(one)
|
||||
sortedList.add(two)
|
||||
sortedList.add(three)
|
||||
|
||||
@@ -10,14 +10,14 @@ import android.widget.TextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.mogo.och.common.module.biz.birdge.data.RoadMsg
|
||||
import com.mogo.och.shuttle.weaknet.passenger.R
|
||||
import com.mogo.och.shuttle.weaknet.passenger.ui.mind.bean.AIMessage
|
||||
|
||||
class AINDERoadAdapter(private val context: Context): RecyclerView.Adapter<AINDERoadAdapter.AIRoadHolder>() {
|
||||
|
||||
private var roadList: List<AIMessage.RoadMsg>?= null
|
||||
private var roadList: List<RoadMsg>?= null
|
||||
|
||||
fun setData(list: List<AIMessage.RoadMsg>){
|
||||
fun setData(list: List<RoadMsg>){
|
||||
roadList = list
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.mogo.och.shuttle.weaknet.passenger.ui.mind.bean
|
||||
import android.os.CountDownTimer
|
||||
import android.util.Log
|
||||
import com.mogo.eagle.core.data.v2x.RoadV2NEventType
|
||||
import com.mogo.och.common.module.biz.birdge.data.RoadMsg
|
||||
import com.mogo.och.common.module.biz.birdge.data.VlmData
|
||||
import kotlin.math.floor
|
||||
|
||||
|
||||
@@ -175,11 +177,11 @@ sealed class AIMessage(
|
||||
var roadList: List<RoadMsg>
|
||||
): AIMessage(id,title)
|
||||
|
||||
data class RoadMsg(
|
||||
var arrowType: Int, // 车道类型,如直行201(详情参考文件:message_pad.proto)
|
||||
var laneNum: Int,// 车道号
|
||||
var isRecommend: Boolean,// 是否是推荐车道
|
||||
var isCheLong: Boolean// 是否有车龙,代表拥堵、行驶缓慢
|
||||
)
|
||||
data class AiVlmData(
|
||||
override val id: String,
|
||||
override val title: String,
|
||||
var desc: String,
|
||||
var vlmData: VlmData
|
||||
):AIMessage(id,title)
|
||||
|
||||
}
|
||||
@@ -3,85 +3,33 @@ package com.mogo.och.shuttle.weaknet.passenger.ui.mind.data
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager
|
||||
import com.mogo.och.common.module.biz.birdge.BridgeListener
|
||||
import com.mogo.och.common.module.biz.birdge.BridgeManager
|
||||
import com.mogo.och.common.module.biz.birdge.data.RoadMsg
|
||||
import com.mogo.och.shuttle.weaknet.passenger.ui.mind.AIMessageManager
|
||||
import com.mogo.och.shuttle.weaknet.passenger.ui.mind.bean.AIMessage
|
||||
import mogo.telematics.pad.MessagePad.TrackedObject
|
||||
|
||||
/**
|
||||
* 车龙信息
|
||||
*/
|
||||
class NDEViewModel: ViewModel(), IMoGoAutopilotIdentifyListener {
|
||||
class NDEViewModel: ViewModel(), BridgeListener {
|
||||
|
||||
companion object{
|
||||
private const val TAG = "NDEViewModel"
|
||||
}
|
||||
|
||||
private var lastMap2 = HashMap<Int, String>()
|
||||
private var lastTime = 0L
|
||||
|
||||
fun init(){
|
||||
CallerAutopilotIdentifyListenerManager.addListener(TAG, this)
|
||||
BridgeManager.addBridgeListener(TAG,this)
|
||||
}
|
||||
|
||||
override fun onAutopilotIdentifyDataUpdate(trafficData: List<TrackedObject>?){
|
||||
super.onAutopilotIdentifyDataUpdate(trafficData)
|
||||
handleCheLong(trafficData)
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
BridgeManager.removeBridgeListener(TAG)
|
||||
}
|
||||
|
||||
private fun handleCheLong(trafficData: List<TrackedObject>?) {
|
||||
var hasCheLong = false
|
||||
var isNewData = false
|
||||
val roadMsgList = ArrayList<AIMessage.RoadMsg>()
|
||||
val curMap = HashMap<Int, String>()
|
||||
if (lastTime > 0 && System.currentTimeMillis() - lastTime > 60000) {
|
||||
lastMap2.clear()// 清除上次车龙事件的缓存
|
||||
}
|
||||
var lastLocStr: String? = ""
|
||||
trafficData?.forEach { obj ->
|
||||
if (obj.type == 707) {// 当前方向所有车道
|
||||
if (obj.polygonCount > 1) {// 当次数据有车龙事件
|
||||
lastLocStr = lastMap2[obj.laneNum]
|
||||
// 1. 上次无车龙但此次有车龙,认为是新车龙事件
|
||||
// 2. 两次都有车龙,则判断车龙的长度是否相同
|
||||
if (lastLocStr == null || lastLocStr == "0" || lastLocStr != "${obj.polygonList[0]}-${obj.polygonList[obj.polygonCount - 1]}") {
|
||||
isNewData = true
|
||||
}
|
||||
hasCheLong = true
|
||||
|
||||
// key: 车道号,value: 非0代表有车龙且首、尾两个点可计算车龙长度
|
||||
curMap[obj.laneNum] =
|
||||
"${obj.polygonList[0]}-${obj.polygonList[obj.polygonCount - 1]}"
|
||||
} else {// 当次没有车龙
|
||||
if (lastMap2[obj.laneNum] != null && lastMap2[obj.laneNum] != "0") {// 3. 上次有车龙,这次无车龙
|
||||
isNewData = true
|
||||
}
|
||||
// key: 车道号,value: 0代表无车龙
|
||||
curMap[obj.laneNum] = "0"
|
||||
}
|
||||
// 保存所有车道信息
|
||||
roadMsgList.add(
|
||||
AIMessage.RoadMsg(
|
||||
obj.arrowType,
|
||||
laneNum = obj.laneNum,
|
||||
isRecommend = obj.suggestedLanes,
|
||||
isCheLong = obj.polygonCount > 1
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
if (isNewData) {
|
||||
// 清除上次车道信息
|
||||
lastMap2.clear()
|
||||
if (hasCheLong) {
|
||||
// 缓存当次车龙事件所有车道信息
|
||||
lastMap2.putAll(curMap)
|
||||
lastTime = System.currentTimeMillis()
|
||||
|
||||
val sortedList = roadMsgList.sortedWith(compareByDescending { it.laneNum })
|
||||
val ndeEvent = AIMessage.NDEData(System.currentTimeMillis().toString(),"路口车龙","前方路口有车龙",sortedList)
|
||||
AIMessageManager.post(ndeEvent)
|
||||
}
|
||||
}
|
||||
override fun onNdeDataListener(title: String, desc: String, sortedList: List<RoadMsg>) {
|
||||
val ndeEvent = AIMessage.NDEData(System.currentTimeMillis().toString(),title,desc,sortedList)
|
||||
AIMessageManager.post(ndeEvent)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user