From 099cb89bbb885e8712ec0d0c6e26d241b3233dd8 Mon Sep 17 00:00:00 2001 From: tiger_zhou Date: Wed, 29 May 2024 15:19:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=BF=97=E8=B0=83=E6=95=B4=E5=8F=8A?= =?UTF-8?q?=E7=8E=B0=E5=9C=BA=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- third_party/btm_vobc/btm_vobc.go | 5 ++-- third_party/train_pc_sim/train_pc_sim.go | 31 +++++++++++++++++++----- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/third_party/btm_vobc/btm_vobc.go b/third_party/btm_vobc/btm_vobc.go index 5cd95eb..c33b153 100644 --- a/third_party/btm_vobc/btm_vobc.go +++ b/third_party/btm_vobc/btm_vobc.go @@ -8,7 +8,6 @@ import ( "joylink.club/bj-rtsts-server/third_party/message" "joylink.club/bj-rtsts-server/third_party/udp" "log/slog" - "strconv" "sync" ) @@ -89,10 +88,10 @@ func (b *BtmVobcClient) handleBtmVobcFrames(cfs []byte) { req := &message.BtmVobcReq{} req.Decode(dataText) fmt.Println(req, "========================") - } else { + } /*else { slog.Error("btm vobc 解析未知命令帧类型", strconv.FormatInt(int64(frameType), 16), frameType, "原始数据:", hex.EncodeToString(cfs), "长度:", len(cfs)) return - } + }*/ } func (b *BtmVobcClient) SendData(data []byte) { if b.client != nil { diff --git a/third_party/train_pc_sim/train_pc_sim.go b/third_party/train_pc_sim/train_pc_sim.go index 87d4e86..fcfbc55 100644 --- a/third_party/train_pc_sim/train_pc_sim.go +++ b/third_party/train_pc_sim/train_pc_sim.go @@ -2,6 +2,7 @@ package train_pc_sim import ( "context" + "encoding/hex" "fmt" "joylink.club/bj-rtsts-server/config" "joylink.club/bj-rtsts-server/dto/state_proto" @@ -311,8 +312,12 @@ func (d *trainPcSimService) SendDriverActive(train *state_proto.TrainState) { msg.Type = SENDER_TRAIN_TC_NOT_ACTIVE } } - - client.Send(msg.Encode()) + da := msg.Encode() + slog.Info("发送驾驶激活 列车", train.Id, "数据", hex.EncodeToString(da)) + err := client.Send(da) + if err != nil { + slog.Error("发送驾驶激活 列车", train.Id, "数据", hex.EncodeToString(da), err) + } } func (d *trainPcSimService) SendHandleSwitch(oldTraction, oldBrakeForce int64, tractionState bool, train *state_proto.TrainState) { tc := train.ConnState @@ -348,7 +353,12 @@ func (d *trainPcSimService) SendHandleSwitch(oldTraction, oldBrakeForce int64, t msg.Type = RECIVE_TRAIN_HAND_KEY_BACKWARD } } - client.Send(msg.Encode()) + da := msg.Encode() + slog.Info("发送列车手柄消息", "clientKey", clientKey, "msg", hex.EncodeToString(da)) + err := client.Send(da) + if err != nil { + slog.Error("发送列车手柄消息失败", "clientKey", clientKey, "msg", hex.EncodeToString(da)) + } } } func (d *trainPcSimService) SendTrainDirection(train *state_proto.TrainState, trainForward, trainBackward bool) { @@ -365,7 +375,12 @@ func (d *trainPcSimService) SendTrainDirection(train *state_proto.TrainState, tr clientKey := FindTrainPcSimClientKey(train) client := d.pcSimClientMap[clientKey] for _, msg := range baseMsgs { - client.Send(msg.Encode()) + da := msg.Encode() + slog.Info("发送列车方向列车", train.Id, "数据", hex.EncodeToString(da)) + err := client.Send(da) + if err != nil { + slog.Error("发送列车方向失败列车", train.Id, "数据", hex.EncodeToString(da)) + } } } @@ -375,9 +390,13 @@ func (d *trainPcSimService) SendBaliseData(train *state_proto.TrainState, msgTyp msg.Data = data clientKey := FindTrainPcSimClientKey(train) client := d.pcSimClientMap[clientKey] - //fmt.Println(fmt.Sprintf("%X", msg.Encode())) + da := msg.Encode() + slog.Info("发送列车PC仿真应答器信息,数据", hex.EncodeToString(da)) - client.Send(msg.Encode()) + err := client.Send(da) + if err != nil { + slog.Info("发送列车PC仿真应答器信息失败,数据", hex.EncodeToString(da)) + } } /*