From be1e0d59d2ff9989cd1c0148a7c067a98fa9a1bc Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Thu, 23 Nov 2023 16:30:48 +0800 Subject: [PATCH] btm --- third_party/can_btm/balise_btm.go | 39 ++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/third_party/can_btm/balise_btm.go b/third_party/can_btm/balise_btm.go index cd03c63..52ba334 100644 --- a/third_party/can_btm/balise_btm.go +++ b/third_party/can_btm/balise_btm.go @@ -4,30 +4,39 @@ import ( "fmt" "joylink.club/bj-rtsts-server/third_party/message" "joylink.club/bj-rtsts-server/third_party/udp" + "joylink.club/ecs" + "joylink.club/rtsssimulation/fi" "log/slog" "sort" ) // btm与canet(网口-CAN口转换器) type btmCanetClient struct { - //udp + w ecs.World + //udp server udpServer udp.UdpServer - //udp - udpClient udp.UdpClient - localUdpPort int + //udp client + udpClient udp.UdpClient + //udp 本地侦听端口 + localUdpPort int + //udp 远程端口 remoteUdpPort int - remoteIp string - trainId string + //udp 远程ip + remoteIp string + //该CANET关联的唯一列车的id + trainId string + //车载ATP系统当前时间ms + atpSystemTime uint32 + //最近一次车载ATP系统查询帧序号 + atpReqSn byte + //最近一次车载ATP系统查询帧CRC16校验结果 + atpReqCrc16Check bool } type BtmCanetClient interface { Start() Stop() TrainId() string } -type BtmMessageManager interface { - BtmRcvAtpReqFrame(trainId string, atpReq *message.AtpRequestFrame) - BtmScanBaliseContent(trainId string) -} func NewBtmCanetClient(trainId string, remoteIp string, remoteUdpPort int, localUdpPort int) BtmCanetClient { return &btmCanetClient{trainId: trainId, remoteIp: remoteIp, remoteUdpPort: remoteUdpPort, localUdpPort: localUdpPort} @@ -102,10 +111,18 @@ func (s *btmCanetClient) dealWithAptReq(f *message.CanetFrame) { atpReq := &message.AtpRequestFrame{} if !atpReq.Decode(f) { slog.Warn("CanetFrame解码成AtpRequestFrame失败", "CanetFrame", f.String()) + return } //处理查询请求 slog.Debug(fmt.Sprintf("处理查询请求:%s", atpReq.String())) - //todo + // + s.atpSystemTime = atpReq.Time + s.atpReqSn = atpReq.FId.ID4 + s.atpReqCrc16Check = atpReq.Crc16CheckOk + se := fi.TrainBalisePowerAmplifierSwitch(s.w, s.trainId, atpReq.PowerAmplifierTurnOn) + if se != nil { + slog.Warn(fmt.Sprintf("列车[%s]车载BTM功率放大器开关控制异常[%s]", s.trainId, se.Error())) + } } //////////////////////////////////////////////////////////////////////////////////////////