[修改]11号线联锁数据解析删除洗车机数据;删除紧急停车后两个命令
All checks were successful
local-test分支打包构建docker并发布运行 / Docker-Build (push) Successful in 1m37s

This commit is contained in:
thesai 2024-05-31 14:25:59 +08:00
parent 0a25ee3170
commit 497bbad8ed
2 changed files with 21 additions and 17 deletions

View File

@ -19,7 +19,7 @@ type FromInterlockFrame struct {
FymData *DeviceData //防淹门数据
SPKSData *SPKSData //SPKS数据
CkmData *DeviceData //车库门数据
XcjData *DeviceData //洗车机数据
//XcjData *DeviceData //洗车机数据
}
func (f *FromInterlockFrame) Decode(data []byte) error {
@ -50,8 +50,8 @@ func (f *FromInterlockFrame) Decode(data []byte) error {
f.SPKSData = spksData
ckmData, i := decodeDeviceData(data, i)
f.CkmData = ckmData
xcjData, i := decodeDeviceData(data, i)
f.XcjData = xcjData
//xcjData, i := decodeDeviceData(data, i)
//f.XcjData = xcjData
return nil
}
@ -77,16 +77,16 @@ func decodeDeviceData(data []byte, index uint16) (*DeviceData, uint16) {
func decodeESBData(data []byte, index uint16) (*ESBData, uint16) {
data = data[index:]
num := binary.BigEndian.Uint16(data[0:2])
nextIndex := 2 + 6*num
nextIndex := 2 + 4*num
data = data[2:nextIndex]
var cmdList []*ESBCmd
for i := 0; i < len(data); i += 6 {
for i := 0; i < len(data); i += 4 {
cmdList = append(cmdList, &ESBCmd{
Id: binary.BigEndian.Uint16(data[i : i+2]),
JjtcCmd: data[i+2],
JjtcplCmd: data[i+3],
JjtcfmqCmd: data[i+4],
Ess1Cmd: data[i+5],
//JjtcfmqCmd: data[i+4],
//Ess1Cmd: data[i+5],
})
}
deviceData := &ESBData{
@ -162,8 +162,8 @@ type ESBCmd struct {
Id uint16 //紧急停车ID
JjtcCmd byte //紧急停车按钮命令
JjtcplCmd byte //紧急停车旁路按钮命令
JjtcfmqCmd byte //紧急停车蜂鸣器命令
Ess1Cmd byte //Ess1指示灯状态
//JjtcfmqCmd byte //紧急停车蜂鸣器命令
//Ess1Cmd byte //Ess1指示灯状态
}
type HoldTrainCmd struct {

View File

@ -16,7 +16,7 @@ func TestFromInterlockFrame_Decode(t *testing.T) {
data = binary.BigEndian.AppendUint16(data, interlockCode)
data = binary.BigEndian.AppendUint16(data, waysideCode)
//填充设备数据
deviceCmdCount := []int{1, 1, 4, 4, 1, 1, 1, 1, 2, 1, 1}
deviceCmdCount := []int{1, 1, 2, 4, 1, 1, 1, 1, 2, 1}
for i, count := range deviceCmdCount {
data = binary.BigEndian.AppendUint16(data, uint16(i)) //设备数量
for j := 0; j < i; j++ {
@ -26,6 +26,10 @@ func TestFromInterlockFrame_Decode(t *testing.T) {
}
}
}
//保留字节及CRC先瞎填吧现在没有校验
for i := 0; i < 14; i++ {
data = append(data, 0)
}
//替换长度
len := uint16(len(data) - 3)
data[1] = byte(len >> 8)
@ -38,7 +42,7 @@ func TestFromInterlockFrame_Decode(t *testing.T) {
t.FailNow()
}
marshal, _ := json.Marshal(f)
fmt.Println(marshal)
fmt.Println(string(marshal))
//if f.InterlockCode != interlockCode {
// t.Error()
//}