应答器增加[固定报文]和[固定用户报文]状态及修改功能
This commit is contained in:
parent
46552b9b9d
commit
d184cd961d
@ -1 +1 @@
|
||||
Subproject commit d2d4e85e34a89d1b38ee8ed1aacc7a955a89b829
|
||||
Subproject commit 126ba5a7619f6c55f893683dd5a0a86a30b25bec
|
@ -234,10 +234,11 @@ type BaliseMoveReqDto struct {
|
||||
|
||||
// BaliseModifyTelegramReqDto 修改应答器报文
|
||||
type BaliseModifyTelegramReqDto struct {
|
||||
SimulationId string `json:"simulationId" form:"simulationId"` //仿真ID
|
||||
MapId int32 `json:"mapId" form:"mapId"` //地图ID
|
||||
BaliseId uint32 `json:"baliseId" form:"baliseId"` //应答器ID
|
||||
Telegram string `json:"telegram" from:"telegram"` //报文(16进制字符串)
|
||||
SimulationId string `json:"simulationId" form:"simulationId"` //仿真ID
|
||||
MapId int32 `json:"mapId" form:"mapId"` //地图ID
|
||||
BaliseId uint32 `json:"baliseId" form:"baliseId"` //应答器ID
|
||||
FixedTelegram string `json:"fixedTelegram" from:"fixedTelegram"` //固定报文(16进制字符串)
|
||||
FixedUserTelegram string `json:"fixedUserTelegram" from:"fixedUserTelegram"` //固定用户报文(16进制字符串)
|
||||
}
|
||||
|
||||
// BaliseReqDto 应答器请求
|
||||
|
File diff suppressed because it is too large
Load Diff
4
go.mod
4
go.mod
@ -9,7 +9,6 @@ require (
|
||||
github.com/golang/protobuf v1.5.3
|
||||
github.com/google/uuid v1.4.0
|
||||
github.com/sagikazarmark/slog-shim v0.1.0
|
||||
github.com/shopspring/decimal v1.3.1
|
||||
github.com/spf13/viper v1.18.1
|
||||
github.com/stretchr/testify v1.8.4
|
||||
github.com/swaggo/files v1.0.1
|
||||
@ -48,7 +47,6 @@ require (
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/sagikazarmark/locafero v0.4.0 // indirect
|
||||
github.com/simonvetter/modbus v1.6.0 // indirect
|
||||
github.com/snksoft/crc v1.1.0 // indirect
|
||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||
github.com/yohamta/donburi v1.3.9 // indirect
|
||||
go.uber.org/atomic v1.9.0 // indirect
|
||||
@ -97,7 +95,7 @@ require (
|
||||
golang.org/x/net v0.19.0 // indirect
|
||||
golang.org/x/sys v0.15.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
google.golang.org/protobuf v1.31.0
|
||||
google.golang.org/protobuf v1.32.0
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
8
go.sum
8
go.sum
@ -174,12 +174,8 @@ github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6g
|
||||
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
|
||||
github.com/samber/slog-gin v1.1.0 h1:dDvYEGJkJg0DxuNWo6m6gV5Bm+iSk85Ox9on7c7OjQU=
|
||||
github.com/samber/slog-gin v1.1.0/go.mod h1:vmMxOYIqDHbthu7SmiF/oOlMhpYukL62JB4Ct5etOvI=
|
||||
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
|
||||
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
||||
github.com/simonvetter/modbus v1.6.0 h1:RDHJevtc7LDIVoHAbhDun8fy+QwnGe+ZU+sLm9ZZzjc=
|
||||
github.com/simonvetter/modbus v1.6.0/go.mod h1:hh90ZaTaPLcK2REj6/fpTbiV0J6S7GWmd8q+GVRObPw=
|
||||
github.com/snksoft/crc v1.1.0 h1:HkLdI4taFlgGGG1KvsWMpz78PkOC9TkPVpTV/cuWn48=
|
||||
github.com/snksoft/crc v1.1.0/go.mod h1:5/gUOsgAm7OmIhb6WJzw7w5g2zfJi4FrHYgGPdshE+A=
|
||||
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
|
||||
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
|
||||
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
|
||||
@ -297,8 +293,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
|
||||
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
|
||||
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
@ -1,7 +1,6 @@
|
||||
package message_server
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"joylink.club/bj-rtsts-server/dto/common_proto"
|
||||
"reflect"
|
||||
@ -83,9 +82,11 @@ func collectBaliseStates(world ecs.World, mapId int32) ([]*state_proto.BaliseSta
|
||||
for id, structure := range uidStructure.TransponderIds {
|
||||
entry, ok := entity.GetEntityByUid(world, structure.Uid)
|
||||
if ok {
|
||||
baliseFixedTelegram := component.BaliseFixedTelegramType.Get(entry)
|
||||
baliseState := &state_proto.BaliseState{
|
||||
Id: id,
|
||||
Telegram: hex.EncodeToString(component.BaliseStateType.Get(entry).ValidTelegram),
|
||||
Id: id,
|
||||
FixedTelegram: fmt.Sprintf("%X", baliseFixedTelegram.Telegram),
|
||||
FixedUserTelegram: fmt.Sprintf("%X", baliseFixedTelegram.UserTelegram),
|
||||
}
|
||||
transponderStates = append(transponderStates, baliseState)
|
||||
km := component.KmType.Get(entry)
|
||||
|
2
third_party/can_btm/balise_detection.go
vendored
2
third_party/can_btm/balise_detection.go
vendored
@ -121,7 +121,7 @@ func (t *BaliseDetector) rcvTelegram(wd *component.WorldData, baliseId string) [
|
||||
if !ok {
|
||||
return nil
|
||||
} else {
|
||||
return component.BaliseStateType.Get(entry).ValidTelegram
|
||||
return component.BaliseFixedTelegramType.Get(entry).Telegram
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,14 +128,26 @@ func BaliseTelegramModify(simulation *VerifySimulation, req *dto.BaliseModifyTel
|
||||
if !ok {
|
||||
return sys_error.New(fmt.Sprintf("没有[mapId:%d id:%d]的应答器", req.MapId, req.BaliseId))
|
||||
}
|
||||
if len(req.Telegram) != 256 {
|
||||
return sys_error.New(fmt.Sprintf("报文长度必须为[%d]", 256))
|
||||
fixedTelegramLen := 256
|
||||
if len(req.FixedTelegram) != fixedTelegramLen {
|
||||
return sys_error.New(fmt.Sprintf("固定报文长度必须为[%d]", fixedTelegramLen))
|
||||
}
|
||||
bytes, err := hex.DecodeString(req.Telegram)
|
||||
fixedUserTelegramLen := 208
|
||||
if len(req.FixedUserTelegram) != fixedUserTelegramLen {
|
||||
return sys_error.New(fmt.Sprintf("固定用户报文长度必须为[%d]", fixedUserTelegramLen))
|
||||
}
|
||||
ft, err := hex.DecodeString(req.FixedTelegram)
|
||||
if err != nil {
|
||||
return sys_error.New("报文解析出错", err)
|
||||
return sys_error.New("固定报文解析出错", err)
|
||||
}
|
||||
component.BaliseStateType.SetValue(entry, component.BaliseState{ValidTelegram: bytes})
|
||||
fut, err := hex.DecodeString(req.FixedUserTelegram)
|
||||
if err != nil {
|
||||
return sys_error.New("固定用户报文解析出错", err)
|
||||
}
|
||||
component.BaliseFixedTelegramType.SetValue(entry, component.BaliseState{
|
||||
Telegram: ft,
|
||||
UserTelegram: fut,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -152,8 +164,8 @@ func BaliseTelegramReset(simulation *VerifySimulation, req *dto.BaliseReqDto) er
|
||||
|
||||
func baliseTelegramReset(simulation *VerifySimulation, balise *repository.Transponder) error {
|
||||
entry, _ := entity.GetEntityByUid(simulation.World, balise.Id())
|
||||
component.BaliseStateType.SetValue(entry, component.BaliseState{
|
||||
ValidTelegram: balise.FixedTelegram(),
|
||||
component.BaliseFixedTelegramType.SetValue(entry, component.BaliseState{
|
||||
Telegram: balise.FixedTelegram(),
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
@ -1034,13 +1034,18 @@ func fillProtoRepository(repo *proto.Repository, storage *data_proto.RtssGraphic
|
||||
for _, data := range storage.Transponders {
|
||||
fixedTelegram, err := hex.DecodeString(data.FixedTelegram)
|
||||
if err != nil {
|
||||
slog.Error(fmt.Sprintf("解析应答器[%s]的报文出错:", err.Error()))
|
||||
slog.Error(fmt.Sprintf("解析应答器[%s]的固定报文出错:", err.Error()))
|
||||
}
|
||||
fixedUserTelegram, err := hex.DecodeString(data.UserTelegram)
|
||||
if err != nil {
|
||||
slog.Error(fmt.Sprintf("解析应答器[%s]的固定用户报文出错:", err.Error()))
|
||||
}
|
||||
responder := &proto.Transponder{
|
||||
Id: uidsMap.TransponderIds[GetMapElementId(data.Common)].Uid,
|
||||
Km: convertKm(data.KilometerSystem),
|
||||
FixedTelegram: fixedTelegram,
|
||||
Type: convertToProtoBaliseType(data.Type),
|
||||
Id: uidsMap.TransponderIds[GetMapElementId(data.Common)].Uid,
|
||||
Km: convertKm(data.KilometerSystem),
|
||||
FixedTelegram: fixedTelegram,
|
||||
Type: convertToProtoBaliseType(data.Type),
|
||||
FixedUserTelegram: fixedUserTelegram,
|
||||
}
|
||||
switch data.TransponderRef.DeviceType {
|
||||
case data_proto.RelatedRef_Section:
|
||||
|
Loading…
Reference in New Issue
Block a user