[3.3.0] reset vipcar manager of logger

This commit is contained in:
zhongchao
2023-06-20 19:11:25 +08:00
parent 68d887299b
commit 8c396ee135
2 changed files with 57 additions and 74 deletions

View File

@@ -8,24 +8,22 @@ import android.util.Log
import com.mogo.aicloud.services.socket.IMogoOnMessageListener
import com.mogo.aicloud.services.socket.MogoAiCloudSocketManager
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.eagle.core.data.biz.trafficlight.TrafficLightResult
import com.mogo.eagle.core.data.biz.trafficlight.currentRoadTrafficLight
import com.mogo.eagle.core.data.biz.trafficlight.isGreen
import com.mogo.eagle.core.data.deva.bizconfig.FuncBizConfig.Companion.BIZ_VIP
import com.mogo.eagle.core.data.deva.bizconfig.FuncBizConfig.Companion.V2N
import com.mogo.eagle.core.data.enums.EventTypeEnumNew
import com.mogo.eagle.core.data.msgbox.MsgBoxBean
import com.mogo.eagle.core.data.msgbox.MsgBoxType
import com.mogo.eagle.core.data.msgbox.V2XMsg
import com.mogo.eagle.core.data.biz.trafficlight.TrafficLightResult
import com.mogo.eagle.core.data.biz.trafficlight.currentRoadTrafficLight
import com.mogo.eagle.core.data.biz.trafficlight.isGreen
import com.mogo.eagle.core.data.biz.trafficlight.isRed
import com.mogo.eagle.core.data.v2x.VipMessage
import com.mogo.eagle.core.function.api.datacenter.union.IMoGoTrafficLightListener
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager
import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager
import com.mogo.eagle.core.function.call.v2x.CallVipSetListenerManager
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_V2X
import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
@@ -49,12 +47,16 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
}
private var mContext: Context? = null
@Volatile
private var turnLight = false
@Volatile
private var vip: Boolean = false
@Volatile
private var exit: Boolean = false
@Volatile
private var result: TrafficLightResult? = null
private val vipNetWorkModel = VipNetWorkModel()
@@ -87,14 +89,14 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
@BizConfig(V2N, "", BIZ_VIP)
override fun onMsgReceived(vipMessage: VipMessage?) {
CallerLogger.d("$M_V2X$TAG", "onMsgReceived vipMessage : ${vipMessage.toString()}")
V2XBizTrace.onAck("$M_V2X$TAG", "onMsgReceived vipMessage : ${vipMessage.toString()}")
vipMessage?.let {
when (it.vipType) {
0 -> { //取消VIP
cancelVip()
}
1 -> { //设置VIP
CallerLogger.d(
V2XBizTrace.onAck(
"$M_V2X$TAG",
"设置handler超时时间 " + ", time : ${System.currentTimeMillis() - vipMessage.timeOut}"
)
@@ -110,36 +112,25 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
}
if (exit) {
CallerLogger.d("$M_V2X$TAG", "驶离路口,返回 , then resetConditions")
V2XBizTrace.onAck("驶离路口","resetConditions")
V2XBizTrace.onAck("$M_V2X$TAG", "驶离路口 resetConditions")
resetConditions()
exit = false
return
}
if (trafficLightResult.currentRoadTrafficLight() == null) {
CallerLogger.d(
"$M_V2X$TAG",
"vip 获取到灯态,但没找到对应车道数据 trafficLightResult : $trafficLightResult , then resetConditions"
)
V2XBizTrace.onAck("$M_V2X$TAG", "vip获取到灯态但没找到对应车道数据 trafficLight:$$trafficLightResult")
result = null
return
}
val currentResult = trafficLightResult.currentRoadTrafficLight()
val lastResult = result?.currentRoadTrafficLight()
CallerLogger.d(
"$M_V2X$TAG",
"检查是否变灯 last.remain : ${lastResult?.remain} , color : ${lastResult?.color} , current.remain : ${currentResult?.remain} , color : ${currentResult?.color}, turnLight : $turnLight"
)
this.result = trafficLightResult
if (!turnLight) {
// 首次判断,变灯
turnLight = true
val controlTime = if (currentResult!!.isGreen()) 45 - currentResult.remain else 45
CallerLogger.d("$M_V2X$TAG", "触发变灯 , controlTime : $controlTime")
turnLight(controlTime)
}
@@ -157,7 +148,7 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
MSG_WHAT_VIP_CANCEL,
cancelDelayTime - System.currentTimeMillis()
)
V2XBizTrace.onAck("setVip","time:$cancelDelayTime")
V2XBizTrace.onAck("$M_V2X$TAG", "setVip time:$cancelDelayTime")
CallVipSetListenerManager.invokeVipSetStatus(true)
CallerTrafficLightListenerManager.addListener(TAG, this)
}
@@ -167,7 +158,7 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
if (handler.hasMessages(MSG_WHAT_VIP_CANCEL)) {
handler.removeMessages(MSG_WHAT_VIP_CANCEL)
}
V2XBizTrace.onAck("cancelVip","resetConditions")
V2XBizTrace.onAck("$M_V2X$TAG", "cancelVip resetConditions")
resetConditions()
CallVipSetListenerManager.invokeVipSetStatus(false)
CallerTrafficLightListenerManager.removeListener(TAG)
@@ -184,7 +175,6 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
cancelVip()
}
}, {
CallerLogger.e("$M_V2X$TAG", "获取VIP信息失败, 准备间隔5秒重新获取")
handler.sendEmptyMessageDelayed(MSG_WHAT_VIP_SEARCH, 5_000L)
})
}
@@ -198,41 +188,39 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
private fun turnLight(controlTime: Int) {
if (result == null || mContext == null) return
val mogoLocation = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
if (mogoLocation != null) {
val bearing = mogoLocation.heading
CallerLogger.d("$M_V2X$TAG", "-- turnLight -- ")
MogoTrafficLightManager.INSTANCE.turnLightToGreen(
result!!.lightId, result!!.crossId, bearing, controlTime,
val bearing = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().heading
V2XBizTrace.onAck("$M_V2X$TAG", "触发变灯 controlTime : $controlTime , bearing: $bearing")
MogoTrafficLightManager.INSTANCE.turnLightToGreen(
result!!.lightId, result!!.crossId, bearing, controlTime,
// 100445, "10037", 90.0, controlTime, //衡阳25号路口测试数据
{
V2XBizTrace.onAck(
TAG + "turnLight", "code:${it.code}" +
",light:${this.result ?: ""}" +
",lightId:${result?.lightId}" +
",crossId:${result?.crossId}" +
",bearing:$bearing" +
",controlTime:$controlTime"
)
// 请求变灯成功,直接提示
if (it.sn == MoGoAiCloudClientConfig.getInstance().sn && it.code == 0) {
CallerLogger.d("$M_V2X$TAG", "变灯请求成功")
val light = this.result?.currentRoadTrafficLight()
if (light != null && light.isGreen()) {
showWarning(
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_EXTEND.poiType,
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_EXTEND.content,
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_EXTEND.tts
)
} else {
showWarning(
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_PASS.poiType,
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_PASS.content,
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_PASS.tts
)
}
return@turnLightToGreen
{
V2XBizTrace.onAck(
"$M_V2X$TAG turnLight", "code:${it.code}" +
",light:${this.result ?: ""}" +
",lightId:${result?.lightId}" +
",crossId:${result?.crossId}" +
",bearing:$bearing" +
",controlTime:$controlTime"
)
// 请求变灯成功,直接提示
if (it.sn == MoGoAiCloudClientConfig.getInstance().sn && it.code == 0) {
V2XBizTrace.onAck("$M_V2X$TAG", "变灯请求成功")
val light = this.result?.currentRoadTrafficLight()
if (light != null && light.isGreen()) {
showWarning(
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_EXTEND.poiType,
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_EXTEND.content,
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_EXTEND.tts
)
} else {
showWarning(
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_PASS.poiType,
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_PASS.content,
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_PASS.tts
)
}
return@turnLightToGreen
}
// // 如果当前为红灯,则提示
// if (this.result!!.currentRoadTrafficLight()!!.isRed()) {
@@ -257,19 +245,18 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
// "变灯请求失败,当前为非红灯不做展示 , light : ${result.toString()} , trafficLightControl : $it"
// )
// }
},
{ errorMsg ->
CallerLogger.e("$M_V2X$TAG", "变灯请求失败 msg : $errorMsg")
V2XBizTrace.onAck(
TAG + "turnLight", "变灯请求失败 msg:$errorMsg" +
",lightId:${result?.lightId}" +
",crossId:${result?.crossId}" +
",bearing:$bearing" +
",controlTime:$controlTime"
)
ToastUtils.showLong("服务异常,请稍后重试")
})
}
},
{ errorMsg ->
V2XBizTrace.onAck(
"$M_V2X$TAG turnLight", "变灯请求失败 msg:$errorMsg" +
",loc:${CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()}" +
",lightId:${result?.lightId}" +
",crossId:${result?.crossId}" +
",bearing:$bearing" +
",controlTime:$controlTime"
)
ToastUtils.showLong("服务异常,请稍后重试")
})
}
private fun showWarning(

View File

@@ -279,10 +279,6 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener {
*/
override fun onGnssInfo(gnssInfo: MessagePad.GnssInfo?) {
if (gnssInfo != null) {
CallerLogger.d(
"$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}",
"onGnssInfo lon = ${gnssInfo.longitude} --- lat = ${gnssInfo.latitude} ---speed = ${gnssInfo.gnssSpeed} ---heading = ${gnssInfo.heading} --acceleration = ${gnssInfo.acceleration} --yawRate = ${gnssInfo.yawRate}"
)
// 使用与渠道配置一样的gps提供者提供的数据,app/productFlavors/fPadLenovo.gradle GPS_PROVIDER 0-Android系统1-工控机2-OBU
if (2 == FunctionBuildConfig.gpsProvider) {
// 同步给MAP地图