[Update]一次查询所有车辆配置信息

This commit is contained in:
chenfufeng
2022-05-19 19:21:40 +08:00
parent 4f02b82a51
commit 844482ca78
2 changed files with 16 additions and 39 deletions

View File

@@ -1,5 +1,6 @@
package com.mogo.eagle.core.function.autopilot.telematic
import com.google.protobuf.TextFormat
import com.mogo.eagle.core.data.app.AppConfigInfo
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.deva.chain.ChainConstant
@@ -17,6 +18,7 @@ import com.zhidao.support.adas.high.chain.AdasChain
import com.zhjt.service.chain.ChainLog
import com.zhjt.service.chain.TracingConstants
import io.netty.channel.Channel
import mogo.telematics.pad.MessagePad
class TeleMsgHandler : IMsgHandler {
@@ -28,9 +30,6 @@ class TeleMsgHandler : IMsgHandler {
@Volatile
private var wrTimeStamp = 0L
@Volatile
private var hasQueryCarConfig = false
override fun handleMsgFromServer(msg: MogoProtocolMsg?, channel: Channel?) {
msg?.let {
when (it.protocolType) {
@@ -53,13 +52,11 @@ class TeleMsgHandler : IMsgHandler {
}
setDemoMode(FunctionBuildConfig.isDemoMode)
}
MogoProtocolMsg.REQ_CAR_NUMBER -> {
AppConfigInfo.plateNumber = String(msg.body)
invokeNettyConnResult("司机屏发送给乘客屏车牌号为:${AppConfigInfo.plateNumber}")
}
MogoProtocolMsg.REQ_MAC_ADDRESS -> {
val macAddress = String(msg.body)
invokeNettyConnResult("司机屏发送给乘客屏Mac地址为:$macAddress")
val carConfig = MessagePad.CarConfigResp.parseFrom(msg.body)
AppConfigInfo.plateNumber = carConfig.plateNumber
AppConfigInfo.iPCMacAddress = carConfig.macAddress
invokeNettyConnResult("司机屏发送给乘客屏配置信息为:${TextFormat.printer().escapingNonAscii(false).printToString(carConfig)}")
}
else -> {
}
@@ -70,31 +67,18 @@ class TeleMsgHandler : IMsgHandler {
override fun handleMsgFromClient(msg: MogoProtocolMsg?, channel: Channel?) {
msg?.let {
when (it.protocolType) {
MogoProtocolMsg.REQ_CAR_NUMBER -> {
if (!AppConfigInfo.plateNumber.isNullOrEmpty()) {
val platNumberArray = AppConfigInfo.plateNumber!!.toByteArray()
NSDNettyManager.getInstance().sendMsgToSpecifiedClient(
MogoProtocolMsg(
MogoProtocolMsg.REQ_CAR_NUMBER,
platNumberArray.size, platNumberArray
), channel
) {
invokeNettyConnResult("司机屏发送车牌号到乘客屏是否成功:${it.isSuccess}")
}
} else {
queryCarConfig()
}
}
MogoProtocolMsg.REQ_MAC_ADDRESS -> {
if (!AppConfigInfo.iPCMacAddress.isNullOrEmpty()) {
val macAddressArray = AppConfigInfo.iPCMacAddress!!.toByteArray()
val carConfig = AdasManager.getInstance().carConfig
if (carConfig != null) {
val configArray = carConfig.toByteArray()
NSDNettyManager.getInstance().sendMsgToSpecifiedClient(
MogoProtocolMsg(
MogoProtocolMsg.REQ_MAC_ADDRESS,
macAddressArray.size, macAddressArray
configArray.size, configArray
), channel
) {
invokeNettyConnResult("司机屏发送Mac地址到乘客屏是否成功:${it.isSuccess}")
invokeNettyConnResult("司机屏发送配置信息到乘客屏是否成功:${it.isSuccess}")
}
} else {
queryCarConfig()
@@ -107,11 +91,8 @@ class TeleMsgHandler : IMsgHandler {
}
private fun queryCarConfig() {
if (!hasQueryCarConfig) {
hasQueryCarConfig = true
invokeNettyConnResult("乘客屏请求司机屏向工控机查询配置信息")
CallerAutoPilotManager.getCarConfig()
}
invokeNettyConnResult("乘客屏请求司机屏向工控机查询配置信息")
CallerAutoPilotManager.getCarConfig()
}
override fun handleClientConn2Server(channel: Channel?) {
@@ -139,15 +120,10 @@ class TeleMsgHandler : IMsgHandler {
ToastUtils.showShort("连接司机屏成功!")
invokeNettyConnResult("乘客屏连接司机屏成功")
val byteArray = byteArrayOf(0)
NSDNettyManager.getInstance().sendMogoProtocolMsgToServer(
MogoProtocolMsg(MogoProtocolMsg.REQ_CAR_NUMBER, byteArray.size, byteArray)
) {
invokeNettyConnResult("乘客屏请求车牌号数据发送是否成功:${it}")
}
NSDNettyManager.getInstance().sendMogoProtocolMsgToServer(
MogoProtocolMsg(MogoProtocolMsg.REQ_MAC_ADDRESS, byteArray.size, byteArray)
) {
invokeNettyConnResult("乘客屏请求MAC地址数据发送是否成功:${it}")
invokeNettyConnResult("乘客屏请求配置信息的数据发送是否成功:${it}")
}
}
ConnectState.STATUS_CONNECT_CLOSED -> {// 由于重连机制会回调多次