与前端传递的应答器报文改为16进制字符串

This commit is contained in:
joylink_zhangsai 2024-01-16 13:44:28 +08:00
parent b22202ac21
commit 14896b2dce
6 changed files with 35 additions and 16 deletions

@ -1 +1 @@
Subproject commit 1a21f13ccef1c7b274b9b5b7d704dc3bfe8660a5 Subproject commit 411729dc6a357f8bab7df24d66ea93cb5ba77c0a

View File

@ -2116,12 +2116,12 @@ type Station struct {
// string kilometerCode = 5; //公里标 // string kilometerCode = 5; //公里标
KilometerSystem *KilometerSystem `protobuf:"bytes,6,opt,name=kilometerSystem,proto3" json:"kilometerSystem,omitempty"` //公里标 KilometerSystem *KilometerSystem `protobuf:"bytes,6,opt,name=kilometerSystem,proto3" json:"kilometerSystem,omitempty"` //公里标
// int32 index = 7; // int32 index = 7;
RefIbpMapCode string `protobuf:"bytes,8,opt,name=refIbpMapCode,proto3" json:"refIbpMapCode,omitempty"` // 关联IBP地图Code RefIbpMapCode string `protobuf:"bytes,8,opt,name=refIbpMapCode,proto3" json:"refIbpMapCode,omitempty"` // 关联IBP地图Code
StationName string `protobuf:"bytes,9,opt,name=stationName,proto3" json:"stationName,omitempty"` //车站名 StationName string `protobuf:"bytes,9,opt,name=stationName,proto3" json:"stationName,omitempty"` //车站名
// string stationNameAcronym = 10; // 车站名缩 StationNameAcronym string `protobuf:"bytes,10,opt,name=stationNameAcronym,proto3" json:"stationNameAcronym,omitempty"` // 车站名拼音简
Depots bool `protobuf:"varint,11,opt,name=depots,proto3" json:"depots,omitempty"` //是否车辆段 Depots bool `protobuf:"varint,11,opt,name=depots,proto3" json:"depots,omitempty"` //是否车辆段
OldmanageStations []string `protobuf:"bytes,12,rep,name=oldmanageStations,proto3" json:"oldmanageStations,omitempty"` // 如果是集中站——管理的车站-id OldmanageStations []string `protobuf:"bytes,12,rep,name=oldmanageStations,proto3" json:"oldmanageStations,omitempty"` // 如果是集中站——管理的车站-id
ManageStations []uint32 `protobuf:"varint,13,rep,packed,name=manageStations,proto3" json:"manageStations,omitempty"` // 如果是集中站——管理的车站-id ManageStations []uint32 `protobuf:"varint,13,rep,packed,name=manageStations,proto3" json:"manageStations,omitempty"` // 如果是集中站——管理的车站-id
} }
func (x *Station) Reset() { func (x *Station) Reset() {
@ -2198,6 +2198,13 @@ func (x *Station) GetStationName() string {
return "" return ""
} }
func (x *Station) GetStationNameAcronym() string {
if x != nil {
return x.StationNameAcronym
}
return ""
}
func (x *Station) GetDepots() bool { func (x *Station) GetDepots() bool {
if x != nil { if x != nil {
return x.Depots return x.Depots
@ -5490,7 +5497,7 @@ var file_stationLayoutGraphics_proto_rawDesc = []byte{
0x74, 0x61, 0x72, 0x74, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x44, 0x6f, 0x6f, 0x72, 0x12, 0x22, 0x0a, 0x74, 0x61, 0x72, 0x74, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x44, 0x6f, 0x6f, 0x72, 0x12, 0x22, 0x0a,
0x0c, 0x65, 0x6e, 0x64, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x44, 0x6f, 0x6f, 0x72, 0x18, 0x03, 0x20, 0x0c, 0x65, 0x6e, 0x64, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x44, 0x6f, 0x6f, 0x72, 0x18, 0x03, 0x20,
0x01, 0x28, 0x05, 0x52, 0x0c, 0x65, 0x6e, 0x64, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x44, 0x6f, 0x6f, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x65, 0x6e, 0x64, 0x53, 0x6d, 0x61, 0x6c, 0x6c, 0x44, 0x6f, 0x6f,
0x72, 0x22, 0x82, 0x03, 0x0a, 0x07, 0x53, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2f, 0x0a, 0x72, 0x22, 0xb2, 0x03, 0x0a, 0x07, 0x53, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2f, 0x0a,
0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e,
0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x43, 0x6f, 0x6d, 0x6d,
0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x12, 0x12, 0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x12, 0x12,
@ -5507,7 +5514,10 @@ var file_stationLayoutGraphics_proto_rawDesc = []byte{
0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x72, 0x65, 0x66, 0x49, 0x62, 0x70, 0x4d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x72, 0x65, 0x66, 0x49, 0x62, 0x70, 0x4d,
0x61, 0x70, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x61, 0x70, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x74, 0x61, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x74, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x65, 0x70, 0x6f, 0x74, 0x69, 0x6f, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x2e, 0x0a, 0x12, 0x73, 0x74, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x41, 0x63, 0x72, 0x6f, 0x6e, 0x79, 0x6d, 0x18, 0x0a,
0x20, 0x01, 0x28, 0x09, 0x52, 0x12, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4e, 0x61, 0x6d,
0x65, 0x41, 0x63, 0x72, 0x6f, 0x6e, 0x79, 0x6d, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x65, 0x70, 0x6f,
0x74, 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x64, 0x65, 0x70, 0x6f, 0x74, 0x73, 0x74, 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x64, 0x65, 0x70, 0x6f, 0x74, 0x73,
0x12, 0x2c, 0x0a, 0x11, 0x6f, 0x6c, 0x64, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x53, 0x74, 0x61, 0x12, 0x2c, 0x0a, 0x11, 0x6f, 0x6c, 0x64, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x53, 0x74, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x09, 0x52, 0x11, 0x6f, 0x6c, 0x64, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x09, 0x52, 0x11, 0x6f, 0x6c, 0x64,

View File

@ -183,7 +183,7 @@ type BaliseModifyTelegramReqDto struct {
SimulationId string `json:"simulationId" form:"simulationId"` //仿真ID SimulationId string `json:"simulationId" form:"simulationId"` //仿真ID
MapId int32 `json:"mapId" form:"mapId"` //地图ID MapId int32 `json:"mapId" form:"mapId"` //地图ID
BaliseId uint32 `json:"baliseId" form:"baliseId"` //应答器ID BaliseId uint32 `json:"baliseId" form:"baliseId"` //应答器ID
Telegram []byte Telegram string `json:"telegram" from:"telegram"` //报文16进制字符串
} }
// BaliseReqDto 应答器请求 // BaliseReqDto 应答器请求

View File

@ -2531,7 +2531,7 @@ type BaliseState struct {
Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
Km *data_proto.KilometerSystem `protobuf:"bytes,2,opt,name=km,proto3" json:"km,omitempty"` //当前公里标 Km *data_proto.KilometerSystem `protobuf:"bytes,2,opt,name=km,proto3" json:"km,omitempty"` //当前公里标
Telegram []byte `protobuf:"bytes,3,opt,name=telegram,proto3" json:"telegram,omitempty"` //当前报文 Telegram string `protobuf:"bytes,3,opt,name=telegram,proto3" json:"telegram,omitempty"` //当前报文16进制字符串
} }
func (x *BaliseState) Reset() { func (x *BaliseState) Reset() {
@ -2580,11 +2580,11 @@ func (x *BaliseState) GetKm() *data_proto.KilometerSystem {
return nil return nil
} }
func (x *BaliseState) GetTelegram() []byte { func (x *BaliseState) GetTelegram() string {
if x != nil { if x != nil {
return x.Telegram return x.Telegram
} }
return nil return ""
} }
// 仿真运行时状态变化量,当前时刻与上一时刻比较得到 // 仿真运行时状态变化量,当前时刻与上一时刻比较得到
@ -3347,7 +3347,7 @@ var file_device_state_proto_rawDesc = []byte{
0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x44, 0x61, 0x74, 0x61, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x44, 0x61, 0x74, 0x61,
0x2e, 0x4b, 0x69, 0x6c, 0x6f, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4b, 0x69, 0x6c, 0x6f, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d,
0x52, 0x02, 0x6b, 0x6d, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x65, 0x6c, 0x65, 0x67, 0x72, 0x61, 0x6d, 0x52, 0x02, 0x6b, 0x6d, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x65, 0x6c, 0x65, 0x67, 0x72, 0x61, 0x6d,
0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x74, 0x65, 0x6c, 0x65, 0x67, 0x72, 0x61, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x65, 0x6c, 0x65, 0x67, 0x72, 0x61, 0x6d,
0x22, 0xa1, 0x02, 0x0a, 0x0f, 0x56, 0x61, 0x72, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x22, 0xa1, 0x02, 0x0a, 0x0f, 0x56, 0x61, 0x72, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74,
0x61, 0x74, 0x75, 0x73, 0x12, 0x38, 0x0a, 0x0c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x54, 0x61, 0x74, 0x75, 0x73, 0x12, 0x38, 0x0a, 0x0c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x54,
0x72, 0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x73, 0x74, 0x61, 0x72, 0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x73, 0x74, 0x61,

View File

@ -1,6 +1,7 @@
package message_server package message_server
import ( import (
"encoding/hex"
"fmt" "fmt"
"joylink.club/bj-rtsts-server/dto/state_proto" "joylink.club/bj-rtsts-server/dto/state_proto"
"joylink.club/rtsssimulation/repository/model/proto" "joylink.club/rtsssimulation/repository/model/proto"
@ -79,7 +80,7 @@ func collectBaliseStates(world ecs.World, mapId int32) ([]*state_proto.BaliseSta
if ok { if ok {
baliseState := &state_proto.BaliseState{ baliseState := &state_proto.BaliseState{
Id: id, Id: id,
Telegram: component.BaliseStateType.Get(entry).ValidTelegram, Telegram: hex.EncodeToString(component.BaliseStateType.Get(entry).ValidTelegram),
} }
transponderStates = append(transponderStates, baliseState) transponderStates = append(transponderStates, baliseState)
km := component.KmType.Get(entry) km := component.KmType.Get(entry)

View File

@ -1,6 +1,7 @@
package memory package memory
import ( import (
"encoding/hex"
"fmt" "fmt"
"strings" "strings"
@ -127,7 +128,14 @@ func BaliseTelegramModify(simulation *VerifySimulation, req *dto.BaliseModifyTel
if !ok { if !ok {
return sys_error.New(fmt.Sprintf("没有[mapId:%d id:%d]的应答器", req.MapId, req.BaliseId)) return sys_error.New(fmt.Sprintf("没有[mapId:%d id:%d]的应答器", req.MapId, req.BaliseId))
} }
component.BaliseStateType.SetValue(entry, component.BaliseState{ValidTelegram: req.Telegram}) if len(req.Telegram) != 256 {
return sys_error.New(fmt.Sprintf("报文长度必须为[%d]", 256))
}
bytes, err := hex.DecodeString(req.Telegram)
if err != nil {
return sys_error.New("报文解析出错", err)
}
component.BaliseStateType.SetValue(entry, component.BaliseState{ValidTelegram: bytes})
return nil return nil
} }