日志调整及现场测试
This commit is contained in:
parent
3bf7a146af
commit
a8c2a61106
1
third_party/acc/acc_vobc.go
vendored
1
third_party/acc/acc_vobc.go
vendored
@ -50,6 +50,7 @@ type accVobcService struct {
|
||||
func (acc *accVobcService) Start(accManager AccVobcManager) {
|
||||
config := accManager.GetRunAccConfig()
|
||||
if config.RemoteIp == "" || config.RemotePort <= 0 || !config.Open {
|
||||
return
|
||||
}
|
||||
acc.vobcClient = udp.NewClient(fmt.Sprintf("%v:%v", config.RemoteIp, config.RemotePort))
|
||||
acc.radarVobcManager = accManager
|
||||
|
31
third_party/btm_vobc/btm_vobc.go
vendored
31
third_party/btm_vobc/btm_vobc.go
vendored
@ -143,16 +143,19 @@ func (b *BtmVobcClient) checkTrainTTLIsOver(ctx context.Context) {
|
||||
if time.Now().UnixMilli()-reviceTimeStamp < 1000 {
|
||||
return
|
||||
}
|
||||
|
||||
slog.Info("检测网络中断情况 前沿ttl 超时...")
|
||||
newTel := make([]*state_proto.VobcBtmState_TelegramState, 0)
|
||||
for _, train := range b.manage.GetAllTrain() {
|
||||
for _, state := range train.VobcBtm.TelegramState {
|
||||
if time.Now().UnixMilli()-state.ArriveTime < 1000 {
|
||||
newTel = append(newTel, state)
|
||||
trains := b.manage.GetAllTrain()
|
||||
if len(trains) > 0 {
|
||||
slog.Info("检测网络中断情况 前沿ttl 超时...")
|
||||
newTel := make([]*state_proto.VobcBtmState_TelegramState, 0)
|
||||
for _, train := range b.manage.GetAllTrain() {
|
||||
for _, state := range train.VobcBtm.TelegramState {
|
||||
if time.Now().UnixMilli()-state.ArriveTime < 1000 {
|
||||
newTel = append(newTel, state)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
time.Sleep(time.Second * 1)
|
||||
}
|
||||
|
||||
@ -178,13 +181,13 @@ func (b *BtmVobcClient) handleBtmVobcFrames(cfs []byte) {
|
||||
idCommand := &message.BtmVobcIdCommand{}
|
||||
idCommand.Decode(dataText)
|
||||
slog.Info(fmt.Sprintf("成功接受btm vobc的id命令帧,requestId:%v,接受时间(微秒):%v", requestId, receiveDataTime))
|
||||
b.packets(requestId, idCommand, receiveDataTime, decodePayMicoTime, train.VobcBtm)
|
||||
b.packets(requestId, idCommand.VobcLifeNum, idCommand.AutoIdFrame, receiveDataTime, decodePayMicoTime, train.VobcBtm)
|
||||
|
||||
} else if frameType == message.REQUEST_TYPE {
|
||||
slog.Info(fmt.Sprintf("成功接受btm vobc的请求帧,requestId:%v,接受时间(微秒):%v", requestId, receiveDataTime))
|
||||
req := &message.BtmVobcReq{}
|
||||
req.Decode(dataText)
|
||||
b.RequestFramePackets(requestId, receiveDataTime, decodePayMicoTime, req, train.VobcBtm)
|
||||
b.RequestFramePackets(req.VobcLifeNum, req.AutoIdFrame, requestId, receiveDataTime, decodePayMicoTime, req, train.VobcBtm)
|
||||
} else {
|
||||
slog.Error(fmt.Sprintf("btm vobc 解析未知命令帧类型:0x%v,原始数据:%v,长度:%v,requestId:%v", strconv.FormatInt(int64(frameType), 16), hex.EncodeToString(cfs), len(cfs), requestId))
|
||||
return
|
||||
@ -202,12 +205,12 @@ func createFreeBalisePackets() []byte {
|
||||
const MAX_SEND_COUNT = 3
|
||||
|
||||
// 请求帧
|
||||
func (b *BtmVobcClient) RequestFramePackets(requestId string, receiveTime int64, decodePayMicoTime int64, req *message.BtmVobcReq, vobcbtm *state_proto.VobcBtmState) {
|
||||
func (b *BtmVobcClient) RequestFramePackets(vobcLifeNum uint32, autoId byte, requestId string, receiveTime int64, decodePayMicoTime int64, req *message.BtmVobcReq, vobcbtm *state_proto.VobcBtmState) {
|
||||
if req.FrameStatus == message.REQ_FRAME_STATUS_BOOT && req.MessageType == message.REQ_PACKETS_TYPE_BOOT {
|
||||
slog.Info(fmt.Sprintf("接受请求帧,准备发送空闲帧数据 帧状态:0x%v,消息类型:0x%v ,requestId:%v", strconv.FormatInt(int64(req.FrameStatus), 16), strconv.FormatInt(int64(req.MessageType), 16), requestId))
|
||||
vobcbtm.TelegramState = make([]*state_proto.VobcBtmState_TelegramState, 0)
|
||||
vobcbtm.History = make(map[uint32]*state_proto.VobcBtmState_VobcBtmHistoryState)
|
||||
b.packets(requestId, nil, receiveTime, decodePayMicoTime, vobcbtm)
|
||||
b.packets(requestId, vobcLifeNum, autoId, receiveTime, decodePayMicoTime, vobcbtm)
|
||||
|
||||
} else if req.FrameStatus == message.REQ_FRAME_STATUS_OK {
|
||||
//帧正确,删除之前发送的数据
|
||||
@ -344,12 +347,12 @@ func (b *BtmVobcClient) balisePacketsFree(requestId string, receiveTime int64, v
|
||||
}
|
||||
|
||||
// 应答器报文或空报文
|
||||
func (b *BtmVobcClient) packets(requestId string, idCommand *message.BtmVobcIdCommand, receiveTime int64, decodePayMicoTime int64, vobcbtm *state_proto.VobcBtmState) {
|
||||
func (b *BtmVobcClient) packets(requestId string, vobcLifeNum uint32, autoIdFrame byte, receiveTime int64, decodePayMicoTime int64, vobcbtm *state_proto.VobcBtmState) {
|
||||
|
||||
if len(vobcbtm.TelegramState) == 0 {
|
||||
b.balisePacketsFree(requestId, receiveTime, idCommand.VobcLifeNum, idCommand.AutoIdFrame, vobcbtm)
|
||||
b.balisePacketsFree(requestId, receiveTime, vobcLifeNum, autoIdFrame, vobcbtm)
|
||||
} else {
|
||||
b.balisePackets(requestId, vobcbtm.TelegramState[0], receiveTime, decodePayMicoTime, idCommand.VobcLifeNum, idCommand.AutoIdFrame, vobcbtm)
|
||||
b.balisePackets(requestId, vobcbtm.TelegramState[0], receiveTime, decodePayMicoTime, vobcLifeNum, autoIdFrame, vobcbtm)
|
||||
}
|
||||
}
|
||||
|
||||
|
14
third_party/btm_vobc/btm_vobc_test.go
vendored
14
third_party/btm_vobc/btm_vobc_test.go
vendored
@ -6,8 +6,10 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"joylink.club/bj-rtsts-server/third_party/message"
|
||||
"joylink.club/bj-rtsts-server/third_party/udp"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -17,6 +19,18 @@ const (
|
||||
|
||||
var message_id atomic.Uint32
|
||||
|
||||
func TestConn(t *testing.T) {
|
||||
source := ":fffee601804f004d00c1b401002a00e7ae839c4b59b2bf912275000000000000000000000000000001b4bf00000000000000000000dc4902d6e431fffd"
|
||||
d, _ := hex.DecodeString(source)
|
||||
udpClient := udp.NewClient(fmt.Sprintf("%v:%d", "127.0.0.1", 49491))
|
||||
err := udpClient.Send(d)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
time.Sleep(time.Second * 2)
|
||||
udpClient.Close()
|
||||
}
|
||||
func TestDecode(t *testing.T) {
|
||||
fmt.Println(code1[:4])
|
||||
d, _ := hex.DecodeString(code1)
|
||||
|
Loading…
Reference in New Issue
Block a user