Compare commits
No commits in common. "cc71c128cfad465e2aee999d2a464c5fdea5d400" and "f43de7bf7113a7cc3f6ee5f9ec6f52ec35654bd1" have entirely different histories.
cc71c128cf
...
f43de7bf71
1
third_party/interlock/beijing11/msg.go
vendored
1
third_party/interlock/beijing11/msg.go
vendored
@ -11,6 +11,7 @@ const ( //不知道对不对,问也不回,先瞎写吧
|
||||
)
|
||||
|
||||
const (
|
||||
SignalAspect_No = 0x99 //灭灯,这个值目前未知,先用一个应该没被使用的值占位
|
||||
SignalAspect_H = 0x01 //红灯
|
||||
SignalAspect_L = 0x04 //绿灯
|
||||
SignalAspect_U = 0x02 //黄灯
|
||||
|
4
third_party/interlock/beijing11/msg_test.go
vendored
4
third_party/interlock/beijing11/msg_test.go
vendored
@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
func TestFromInterlockFrame_Decode(t *testing.T) {
|
||||
str := "58bea4c65e0e583f5bdedc310800450000c949950000801100003d0b0a0d3d0b7814413c40d800b5fcfd8200a63c0363010003000400000500000900000200040000080000020004aaaa0008aaaa0000000f000d01000e01000f060010060021060023010011060012060026060027010013060014010022060024060025010010001300001400001500001600001700001800001900001a00002c00002d00002e00002f00003000003100003200003300000000000004000daaaa000eaaaa000faaaa0010aaaa0000000000000000000000007a91cfc2"
|
||||
str := "58bea4c65e0e583f5bdedc310800450000c9d0770000801100003d0b0a0d3d0b7814413c40d800b5fcfd8200a63c0363010003000400000500000900000200040000080000020004aaaa0008aaaa0000000f000d06000e01000f060010060021060023060011060012060026060027010013060014010022060024060025060010001300001400001500001600001700001800001900001a00002c00002d00002e00002f00003000003100003200003300000000000004000daaaa000eaaaa000faaaa0010aaaa00000000000000000000000058f24545"
|
||||
data, err := hex.DecodeString(str)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@ -112,7 +112,7 @@ func TestFromInterlockFrame_Decode(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestToInterlockFrame_Decode(t *testing.T) {
|
||||
str := "583f5bdedc315871778a9d89080045000172f6950000801146ae3d0b78143d0b0a0d40d8413c015ef35583014f63013c0200030004010005010009010006000202eeaaaaaa000302eeaaaaaa000402eeaaaaaa000602eeaaaaaa000702eeaaaaaa000802eeaaaaaa00060002aa000003aa000004aa000006aa000007aa000008aa000000001b000806000901000a06000b06000c06000d06000e01000f06001006001106001206001306001401001c01001d06001e01001f06002006002106002206002306002406002506002606002701002801002b01001e000b00000c00000d00000e00000f00001000001100001200001300001400001500001600001700001800001900001a00002600002700002800002900002a00002b00002c00002d00002e00002f0000300000310000320000330000000000000c0005aaff0006aaff0007aaff0008aaff0009aaff000aaaff000baaff000caaff000daaff000eaaff000faaff0010aa0400000100000000000000000000000000000000a0313220"
|
||||
str := "583f5bdedc3158bea4c65e0e080045000172b52c4000401188173d0b78143d0b0a0d40d8413c015ebe7f83014f63013c0200030004010005010009020006000202eeaaaaaa000302eeaaaaaa000402eeaaaaaa000602eeaaaaaa000702eeaaaaaa000802eeaaaaaa00060002aaaa0003aaaa0004aaaa0006aaaa0007aaaa0008aaaa0000001b000800000900000a00000b00000c00000d06000e01000f06001006001106001206001306001401001c00001d00001e00001f00002000002106002206002306002406002506002606002701002800002b00001e000b00000c00000d00000e00000f00001000001100001200001300001400001500001600001700001800001900001a00002600002700002800002900002a00002b00002c00002d00002e00002f0000300000310000320000330000000000000c0005aaaa0006aaaa0007aaaa0008aaaa0009aaaa000aaaaa000baaaa000caaaa000daaaa000eaaaa000faaaa0010aaaa00000100000000000000000000000000000000328ef0af"
|
||||
data, err := hex.DecodeString(str)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
157
third_party/interlock/beijing11/service.go
vendored
157
third_party/interlock/beijing11/service.go
vendored
@ -203,6 +203,9 @@ func (s *serviceContext) handleDriveMsg(data []byte) {
|
||||
if entry.HasComponent(component.Signal2XH1ElectronicType) { // 2XH1信号机
|
||||
signal2XH1 := component.Signal2XH1ElectronicType.Get(entry)
|
||||
switch cmd.Cmd {
|
||||
case SignalAspect_No:
|
||||
wd.SetQdBit(component.UidType.Get(signal2XH1.Z2XH1_DDJ).Id, true)
|
||||
wd.SetQdBit(component.UidType.Get(signal2XH1.Z2XH1_LXJ).Id, false)
|
||||
case SignalAspect_H:
|
||||
wd.SetQdBit(component.UidType.Get(signal2XH1.Z2XH1_DDJ).Id, false)
|
||||
wd.SetQdBit(component.UidType.Get(signal2XH1.Z2XH1_LXJ).Id, false)
|
||||
@ -210,12 +213,16 @@ func (s *serviceContext) handleDriveMsg(data []byte) {
|
||||
wd.SetQdBit(component.UidType.Get(signal2XH1.Z2XH1_DDJ).Id, false)
|
||||
wd.SetQdBit(component.UidType.Get(signal2XH1.Z2XH1_LXJ).Id, true)
|
||||
default:
|
||||
wd.SetQdBit(component.UidType.Get(signal2XH1.Z2XH1_DDJ).Id, true)
|
||||
wd.SetQdBit(component.UidType.Get(signal2XH1.Z2XH1_LXJ).Id, false)
|
||||
logger().Error(fmt.Sprintf("信号机[%s]无法开放[%x]信号", uid, cmd.Cmd))
|
||||
}
|
||||
} else if entry.HasComponent(component.Signal3XH1ElectronicType) { // 3XH1信号机
|
||||
signal3XH1 := component.Signal3XH1ElectronicType.Get(entry)
|
||||
switch cmd.Cmd {
|
||||
case SignalAspect_No:
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH1.Z3XH1_DDJ).Id, true)
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH1.Z3XH1_LXJ).Id, false)
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH1.Z3XH1_ZXJ).Id, false)
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH1.Z3XH1_YXJ).Id, false)
|
||||
case SignalAspect_H:
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH1.Z3XH1_DDJ).Id, false)
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH1.Z3XH1_LXJ).Id, false)
|
||||
@ -237,14 +244,15 @@ func (s *serviceContext) handleDriveMsg(data []byte) {
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH1.Z3XH1_ZXJ).Id, false)
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH1.Z3XH1_YXJ).Id, true)
|
||||
default:
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH1.Z3XH1_DDJ).Id, true)
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH1.Z3XH1_LXJ).Id, false)
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH1.Z3XH1_ZXJ).Id, false)
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH1.Z3XH1_YXJ).Id, false)
|
||||
logger().Error(fmt.Sprintf("信号机[%s]无法开放[%x]信号", uid, cmd.Cmd))
|
||||
}
|
||||
} else if entry.HasComponent(component.Signal3XH2ElectronicType) { // 3XH2信号机
|
||||
signal3XH2 := component.Signal3XH2ElectronicType.Get(entry)
|
||||
switch cmd.Cmd {
|
||||
case SignalAspect_No:
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH2.Z3XH2_DDJ).Id, true)
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH2.Z3XH2_LXJ).Id, false)
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH2.Z3XH2_YXJ).Id, false)
|
||||
case SignalAspect_H:
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH2.Z3XH2_DDJ).Id, false)
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH2.Z3XH2_LXJ).Id, false)
|
||||
@ -258,13 +266,15 @@ func (s *serviceContext) handleDriveMsg(data []byte) {
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH2.Z3XH2_LXJ).Id, false)
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH2.Z3XH2_YXJ).Id, true)
|
||||
default:
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH2.Z3XH2_DDJ).Id, true)
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH2.Z3XH2_LXJ).Id, false)
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH2.Z3XH2_YXJ).Id, false)
|
||||
logger().Error(fmt.Sprintf("信号机[%s]无法开放[%x]信号", uid, cmd.Cmd))
|
||||
}
|
||||
} else if entry.HasComponent(component.Signal3XH3ElectronicType) { // 3XH3信号机
|
||||
signal3XH3 := component.Signal3XH3ElectronicType.Get(entry)
|
||||
switch cmd.Cmd {
|
||||
case SignalAspect_No:
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH3.Z3XH3_DDJ).Id, true)
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH3.Z3XH3_LXJ).Id, false)
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH3.Z3XH3_YXJ).Id, false)
|
||||
case SignalAspect_H:
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH3.Z3XH3_DDJ).Id, false)
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH3.Z3XH3_LXJ).Id, false)
|
||||
@ -278,13 +288,15 @@ func (s *serviceContext) handleDriveMsg(data []byte) {
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH3.Z3XH3_LXJ).Id, false)
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH3.Z3XH3_YXJ).Id, true)
|
||||
default:
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH3.Z3XH3_DDJ).Id, true)
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH3.Z3XH3_LXJ).Id, false)
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH3.Z3XH3_YXJ).Id, false)
|
||||
logger().Error(fmt.Sprintf("信号机[%s]无法开放[%x]信号", uid, cmd.Cmd))
|
||||
}
|
||||
} else if entry.HasComponent(component.Signal3XH4ElectronicType) { // 3XH4信号机
|
||||
signal3XH4 := component.Signal3XH4ElectronicType.Get(entry)
|
||||
switch cmd.Cmd {
|
||||
case SignalAspect_No:
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH4.Z3XH4_DDJ).Id, true)
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH4.Z3XH4_LXJ).Id, false)
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH4.Z3XH4_ZXJ).Id, false)
|
||||
case SignalAspect_H:
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH4.Z3XH4_DDJ).Id, false)
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH4.Z3XH4_LXJ).Id, false)
|
||||
@ -298,29 +310,24 @@ func (s *serviceContext) handleDriveMsg(data []byte) {
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH4.Z3XH4_LXJ).Id, true)
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH4.Z3XH4_ZXJ).Id, false)
|
||||
default:
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH4.Z3XH4_DDJ).Id, true)
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH4.Z3XH4_LXJ).Id, false)
|
||||
wd.SetQdBit(component.UidType.Get(signal3XH4.Z3XH4_ZXJ).Id, false)
|
||||
logger().Error(fmt.Sprintf("信号机[%s]无法开放[%x]信号", uid, cmd.Cmd))
|
||||
}
|
||||
|
||||
} else {
|
||||
logger().Error(fmt.Sprintf("信号机[%s]的型号未知", uid))
|
||||
}
|
||||
}
|
||||
//{ //采集状态赋值
|
||||
// signalAspectMap := make(map[uint16]byte)
|
||||
// for _, cmd := range frame.SignalData.CmdList {
|
||||
// signalAspectMap[cmd.Id] = cmd.Cmd
|
||||
// }
|
||||
// for _, interlockFrame := range s.toInterlockFrames {
|
||||
// for _, state := range interlockFrame.SignalStates {
|
||||
// b := signalAspectMap[state.Id]
|
||||
// if b != 0 {
|
||||
// state.State = b
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
{ //采集状态赋值
|
||||
signalAspectMap := make(map[uint16]byte)
|
||||
for _, cmd := range frame.SignalData.CmdList {
|
||||
signalAspectMap[cmd.Id] = cmd.Cmd
|
||||
}
|
||||
for _, interlockFrame := range s.toInterlockFrames {
|
||||
for _, state := range interlockFrame.SignalStates {
|
||||
state.State = signalAspectMap[state.Id]
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, cmd := range frame.AxleSectionData.CmdList {
|
||||
if cmd.Cmd == 0x80 {
|
||||
uid := s.deviceTable.AxleSectionMap[cmd.Id].uid
|
||||
@ -660,54 +667,50 @@ func (s *serviceContext) collectDeviceState() {
|
||||
state.State = GetStateByte(!component.BitStateType.Get(relay).Val)
|
||||
state.PlState = GetStateByte(component.BitStateType.Get(pla).Val)
|
||||
}
|
||||
//信号机
|
||||
for _, state := range frame.SignalStates {
|
||||
row := s.deviceTable.SignalMap[state.Id]
|
||||
entry := wd.EntityMap[row.uid]
|
||||
if entry == nil {
|
||||
continue
|
||||
}
|
||||
lights := component.SignalLightsType.Get(entry)
|
||||
isL := false
|
||||
isH := false
|
||||
isU := false
|
||||
isA := false
|
||||
isB := false
|
||||
for _, light := range lights.Lights {
|
||||
switch {
|
||||
case light.HasComponent(component.LdTag):
|
||||
isL = component.BitStateType.Get(light).Val
|
||||
case light.HasComponent(component.HdTag):
|
||||
isH = component.BitStateType.Get(light).Val
|
||||
case light.HasComponent(component.UdTag):
|
||||
isU = component.BitStateType.Get(light).Val
|
||||
case light.HasComponent(component.BdTag):
|
||||
isB = component.BitStateType.Get(light).Val
|
||||
case light.HasComponent(component.AdTag):
|
||||
isA = component.BitStateType.Get(light).Val
|
||||
}
|
||||
}
|
||||
var stateByte byte
|
||||
if isH && isU {
|
||||
stateByte = 0x03
|
||||
} else {
|
||||
switch {
|
||||
case isL:
|
||||
stateByte = 0x04
|
||||
case isH:
|
||||
stateByte = 0x01
|
||||
case isU:
|
||||
stateByte = 0x02
|
||||
case isB:
|
||||
stateByte = 0x08
|
||||
case isA:
|
||||
stateByte = 0x09
|
||||
default:
|
||||
stateByte = 0x06
|
||||
}
|
||||
}
|
||||
state.State = stateByte
|
||||
}
|
||||
////信号机
|
||||
//for _, state := range frame.SignalStates {
|
||||
// row := s.deviceTable.SignalMap[state.Id]
|
||||
// entry := wd.EntityMap[row.uid]
|
||||
// lights := component.SignalLightsType.Get(entry)
|
||||
// isL := false
|
||||
// isH := false
|
||||
// isU := false
|
||||
// isA := false
|
||||
// isB := false
|
||||
// for _, light := range lights.Lights {
|
||||
// switch {
|
||||
// case light.HasComponent(component.LdTag):
|
||||
// isL = component.BitStateType.Get(light).Val
|
||||
// case light.HasComponent(component.HdTag):
|
||||
// isH = component.BitStateType.Get(light).Val
|
||||
// case light.HasComponent(component.UdTag):
|
||||
// isU = component.BitStateType.Get(light).Val
|
||||
// case light.HasComponent(component.BdTag):
|
||||
// isB = component.BitStateType.Get(light).Val
|
||||
// case light.HasComponent(component.AdTag):
|
||||
// isA = component.BitStateType.Get(light).Val
|
||||
// }
|
||||
// }
|
||||
// var stateByte byte
|
||||
// if isH && isU {
|
||||
// stateByte = 0x03
|
||||
// } else {
|
||||
// switch {
|
||||
// case isL:
|
||||
// stateByte = 0x04
|
||||
// case isH:
|
||||
// stateByte = 0x01
|
||||
// case isU:
|
||||
// stateByte = 0x02
|
||||
// case isB:
|
||||
// stateByte = 0x08
|
||||
// case isA:
|
||||
// stateByte = 0x09
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// state.State = stateByte
|
||||
//}
|
||||
//计轴区段
|
||||
for _, state := range frame.AxleSectionStates {
|
||||
row := s.deviceTable.AxleSectionMap[state.Id]
|
||||
|
Loading…
Reference in New Issue
Block a user