diff --git a/third_party/interlock/beijing12/interlock.go b/third_party/interlock/beijing12/interlock.go index 5d70cdf..5a2b1e5 100644 --- a/third_party/interlock/beijing12/interlock.go +++ b/third_party/interlock/beijing12/interlock.go @@ -2,6 +2,7 @@ package beijing12 import ( + "bytes" "context" "fmt" "joylink.club/bj-rtsts-server/sys_error" @@ -169,16 +170,22 @@ func (i *interlockProxy) initInterlockProxy() { func (i *interlockProxy) handleFromCiData(n int, data []byte) { data = data[:n] - logger().Info(fmt.Sprintf("收到联锁驱动及应答器报文数据:%x", data)) - if n+len(i.fromCIBytes) == fromCIBytesLen { //暂时以此作为报文尾判定条件 + logger().Info(fmt.Sprintf("收到联锁驱动及应答器报文数据,长度%d", n)) + if len(i.fromCIBytes) != 0 { //报文头已经存进去了 i.fromCIBytes = append(i.fromCIBytes, data...) - } else { //非报文尾 + if len(i.fromCIBytes) < fromCIBytesLen { //当存储的报文长度不足预期长度 + return + } + } else if bytes.HasPrefix(data, []byte{0xff, 0xff}) { //判断是否是报文头 i.fromCIBytes = append(i.fromCIBytes, data...) return + } else { + return } //处理联锁报文 msg := &fromCiMsg{} err := msg.decode(i.fromCIBytes) + logger().Info(fmt.Sprintf("解析完整联锁驱动及应答器报文数据:%x", i.fromCIBytes)) i.fromCIBytes = i.fromCIBytes[:0] //清空联锁报文存储 if err != nil { logger().Error(fmt.Sprintf("解析来自CI的数据出错:%s", err.Error())) @@ -186,9 +193,9 @@ func (i *interlockProxy) handleFromCiData(n int, data []byte) { } //处理驱动数据 if i.simulation != nil { + logger().Info(fmt.Sprintf("解析出的驱动数据:%x", msg.driveData)) i.simulation.HandleInterlockDriverInfo(i.runConfig.Code, msg.driveData) } - logger().Info(fmt.Sprintf("解析出联锁驱动数据:%x", msg.driveData)) //处理应答器数据 for _, datum := range msg.baliseTelegramData { indexBalise2 := i.indexBalise[datum.leuIndex] diff --git a/ts/simulation/wayside/memory/wayside_simulation.go b/ts/simulation/wayside/memory/wayside_simulation.go index 3d0f4fa..d456f3f 100644 --- a/ts/simulation/wayside/memory/wayside_simulation.go +++ b/ts/simulation/wayside/memory/wayside_simulation.go @@ -458,6 +458,9 @@ func (s *VerifySimulation) HandleInterlockDriverInfo(code string, driveBytes []b for i, b := range driveInfo { qdData := m.QdList[i] for _, relayId := range qdData.RefRelays { + if b { + + } err := wd.SetQdBit(relayId, b) if err != nil { slog.Error("联锁驱动数据设置出错", "error", err)