动力学列车数据配置

This commit is contained in:
tiger_zhou 2024-01-17 17:02:17 +08:00
parent 7cf33862be
commit 79356df717
8 changed files with 2098 additions and 1957 deletions

@ -1 +1 @@
Subproject commit 923e04f548ef2d5c6571912468ae16829b1594d8
Subproject commit 8469ef8778e98f43caa6cdf6e18a19ecb7f490de

View File

@ -0,0 +1,392 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.32.0
// protoc v4.23.1
// source: common_data.proto
package common_proto
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// 动力学列车配置
type TrainDynamicConfig struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// 列车的质量100=1ton
//
// int32 mass=1;
//
// 基本阻力参数A
BaseResistanceParamA float32 `protobuf:"fixed32,1,opt,name=baseResistanceParamA,proto3" json:"baseResistanceParamA,omitempty"`
// 基本阻力参数B
BaseResistanceParamB float32 `protobuf:"fixed32,2,opt,name=baseResistanceParamB,proto3" json:"baseResistanceParamB,omitempty"`
// 基本阻力参数C
BaseResistanceParamC float32 `protobuf:"fixed32,3,opt,name=baseResistanceParamC,proto3" json:"baseResistanceParamC,omitempty"`
// 曲线阻力参数R1
CurveResistanceParamR1 float32 `protobuf:"fixed32,4,opt,name=curveResistanceParamR1,proto3" json:"curveResistanceParamR1,omitempty"`
// 曲线阻力参数R2
CurveResistanceParamR2 float32 `protobuf:"fixed32,5,opt,name=curveResistanceParamR2,proto3" json:"curveResistanceParamR2,omitempty"`
// 曲线阻力参数R3
CurveResistanceParamR3 float32 `protobuf:"fixed32,6,opt,name=curveResistanceParamR3,proto3" json:"curveResistanceParamR3,omitempty"`
// 曲线阻力参数R4
CurveResistanceParamR4 float32 `protobuf:"fixed32,7,opt,name=curveResistanceParamR4,proto3" json:"curveResistanceParamR4,omitempty"`
// 旋转质量参数
RevolvingMassParam float32 `protobuf:"fixed32,8,opt,name=revolvingMassParam,proto3" json:"revolvingMassParam,omitempty"`
// 是否跳跃
Jump bool `protobuf:"varint,9,opt,name=jump,proto3" json:"jump,omitempty"`
// 打滑(%
Slip float32 `protobuf:"fixed32,10,opt,name=slip,proto3" json:"slip,omitempty"`
// 前溜/后溜mm正数前溜负数后溜
Slide int32 `protobuf:"varint,11,opt,name=slide,proto3" json:"slide,omitempty"`
// 过标/欠标mm正数过标负数欠标
StopSign int32 `protobuf:"varint,12,opt,name=stopSign,proto3" json:"stopSign,omitempty"`
}
func (x *TrainDynamicConfig) Reset() {
*x = TrainDynamicConfig{}
if protoimpl.UnsafeEnabled {
mi := &file_common_data_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *TrainDynamicConfig) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TrainDynamicConfig) ProtoMessage() {}
func (x *TrainDynamicConfig) ProtoReflect() protoreflect.Message {
mi := &file_common_data_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TrainDynamicConfig.ProtoReflect.Descriptor instead.
func (*TrainDynamicConfig) Descriptor() ([]byte, []int) {
return file_common_data_proto_rawDescGZIP(), []int{0}
}
func (x *TrainDynamicConfig) GetBaseResistanceParamA() float32 {
if x != nil {
return x.BaseResistanceParamA
}
return 0
}
func (x *TrainDynamicConfig) GetBaseResistanceParamB() float32 {
if x != nil {
return x.BaseResistanceParamB
}
return 0
}
func (x *TrainDynamicConfig) GetBaseResistanceParamC() float32 {
if x != nil {
return x.BaseResistanceParamC
}
return 0
}
func (x *TrainDynamicConfig) GetCurveResistanceParamR1() float32 {
if x != nil {
return x.CurveResistanceParamR1
}
return 0
}
func (x *TrainDynamicConfig) GetCurveResistanceParamR2() float32 {
if x != nil {
return x.CurveResistanceParamR2
}
return 0
}
func (x *TrainDynamicConfig) GetCurveResistanceParamR3() float32 {
if x != nil {
return x.CurveResistanceParamR3
}
return 0
}
func (x *TrainDynamicConfig) GetCurveResistanceParamR4() float32 {
if x != nil {
return x.CurveResistanceParamR4
}
return 0
}
func (x *TrainDynamicConfig) GetRevolvingMassParam() float32 {
if x != nil {
return x.RevolvingMassParam
}
return 0
}
func (x *TrainDynamicConfig) GetJump() bool {
if x != nil {
return x.Jump
}
return false
}
func (x *TrainDynamicConfig) GetSlip() float32 {
if x != nil {
return x.Slip
}
return 0
}
func (x *TrainDynamicConfig) GetSlide() int32 {
if x != nil {
return x.Slide
}
return 0
}
func (x *TrainDynamicConfig) GetStopSign() int32 {
if x != nil {
return x.StopSign
}
return 0
}
// 列车一端的状态
type TrainEndsState struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// 速度传感器
SpeedSensorEnableA bool `protobuf:"varint,1,opt,name=speedSensorEnableA,proto3" json:"speedSensorEnableA,omitempty"`
SpeedSensorEnableB bool `protobuf:"varint,2,opt,name=speedSensorEnableB,proto3" json:"speedSensorEnableB,omitempty"`
// 雷达是否有效
RadarEnable bool `protobuf:"varint,3,opt,name=radarEnable,proto3" json:"radarEnable,omitempty"`
// 雷达测速数值
RadarCheckSpeed float32 `protobuf:"fixed32,4,opt,name=radarCheckSpeed,proto3" json:"radarCheckSpeed,omitempty"`
// 雷达检测时间(秒)
RadarCheckTime int32 `protobuf:"varint,5,opt,name=radarCheckTime,proto3" json:"radarCheckTime,omitempty"`
}
func (x *TrainEndsState) Reset() {
*x = TrainEndsState{}
if protoimpl.UnsafeEnabled {
mi := &file_common_data_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *TrainEndsState) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TrainEndsState) ProtoMessage() {}
func (x *TrainEndsState) ProtoReflect() protoreflect.Message {
mi := &file_common_data_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TrainEndsState.ProtoReflect.Descriptor instead.
func (*TrainEndsState) Descriptor() ([]byte, []int) {
return file_common_data_proto_rawDescGZIP(), []int{1}
}
func (x *TrainEndsState) GetSpeedSensorEnableA() bool {
if x != nil {
return x.SpeedSensorEnableA
}
return false
}
func (x *TrainEndsState) GetSpeedSensorEnableB() bool {
if x != nil {
return x.SpeedSensorEnableB
}
return false
}
func (x *TrainEndsState) GetRadarEnable() bool {
if x != nil {
return x.RadarEnable
}
return false
}
func (x *TrainEndsState) GetRadarCheckSpeed() float32 {
if x != nil {
return x.RadarCheckSpeed
}
return 0
}
func (x *TrainEndsState) GetRadarCheckTime() int32 {
if x != nil {
return x.RadarCheckTime
}
return 0
}
var File_common_data_proto protoreflect.FileDescriptor
var file_common_data_proto_rawDesc = []byte{
0x0a, 0x11, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x12, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x22, 0x9a, 0x04, 0x0a, 0x12,
0x54, 0x72, 0x61, 0x69, 0x6e, 0x44, 0x79, 0x6e, 0x61, 0x6d, 0x69, 0x63, 0x43, 0x6f, 0x6e, 0x66,
0x69, 0x67, 0x12, 0x32, 0x0a, 0x14, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x69, 0x73, 0x74,
0x61, 0x6e, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x41, 0x18, 0x01, 0x20, 0x01, 0x28, 0x02,
0x52, 0x14, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65,
0x50, 0x61, 0x72, 0x61, 0x6d, 0x41, 0x12, 0x32, 0x0a, 0x14, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65,
0x73, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x42, 0x18, 0x02,
0x20, 0x01, 0x28, 0x02, 0x52, 0x14, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x69, 0x73, 0x74,
0x61, 0x6e, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x42, 0x12, 0x32, 0x0a, 0x14, 0x62, 0x61,
0x73, 0x65, 0x52, 0x65, 0x73, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61,
0x6d, 0x43, 0x18, 0x03, 0x20, 0x01, 0x28, 0x02, 0x52, 0x14, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65,
0x73, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x43, 0x12, 0x36,
0x0a, 0x16, 0x63, 0x75, 0x72, 0x76, 0x65, 0x52, 0x65, 0x73, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63,
0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x52, 0x31, 0x18, 0x04, 0x20, 0x01, 0x28, 0x02, 0x52, 0x16,
0x63, 0x75, 0x72, 0x76, 0x65, 0x52, 0x65, 0x73, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x50,
0x61, 0x72, 0x61, 0x6d, 0x52, 0x31, 0x12, 0x36, 0x0a, 0x16, 0x63, 0x75, 0x72, 0x76, 0x65, 0x52,
0x65, 0x73, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x52, 0x32,
0x18, 0x05, 0x20, 0x01, 0x28, 0x02, 0x52, 0x16, 0x63, 0x75, 0x72, 0x76, 0x65, 0x52, 0x65, 0x73,
0x69, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x52, 0x32, 0x12, 0x36,
0x0a, 0x16, 0x63, 0x75, 0x72, 0x76, 0x65, 0x52, 0x65, 0x73, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63,
0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x52, 0x33, 0x18, 0x06, 0x20, 0x01, 0x28, 0x02, 0x52, 0x16,
0x63, 0x75, 0x72, 0x76, 0x65, 0x52, 0x65, 0x73, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x50,
0x61, 0x72, 0x61, 0x6d, 0x52, 0x33, 0x12, 0x36, 0x0a, 0x16, 0x63, 0x75, 0x72, 0x76, 0x65, 0x52,
0x65, 0x73, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x52, 0x34,
0x18, 0x07, 0x20, 0x01, 0x28, 0x02, 0x52, 0x16, 0x63, 0x75, 0x72, 0x76, 0x65, 0x52, 0x65, 0x73,
0x69, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x52, 0x34, 0x12, 0x2e,
0x0a, 0x12, 0x72, 0x65, 0x76, 0x6f, 0x6c, 0x76, 0x69, 0x6e, 0x67, 0x4d, 0x61, 0x73, 0x73, 0x50,
0x61, 0x72, 0x61, 0x6d, 0x18, 0x08, 0x20, 0x01, 0x28, 0x02, 0x52, 0x12, 0x72, 0x65, 0x76, 0x6f,
0x6c, 0x76, 0x69, 0x6e, 0x67, 0x4d, 0x61, 0x73, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x12, 0x12,
0x0a, 0x04, 0x6a, 0x75, 0x6d, 0x70, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x6a, 0x75,
0x6d, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x6c, 0x69, 0x70, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x02,
0x52, 0x04, 0x73, 0x6c, 0x69, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x6c, 0x69, 0x64, 0x65, 0x18,
0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x73, 0x6c, 0x69, 0x64, 0x65, 0x12, 0x1a, 0x0a, 0x08,
0x73, 0x74, 0x6f, 0x70, 0x53, 0x69, 0x67, 0x6e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08,
0x73, 0x74, 0x6f, 0x70, 0x53, 0x69, 0x67, 0x6e, 0x22, 0xe4, 0x01, 0x0a, 0x0e, 0x54, 0x72, 0x61,
0x69, 0x6e, 0x45, 0x6e, 0x64, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x2e, 0x0a, 0x12, 0x73,
0x70, 0x65, 0x65, 0x64, 0x53, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65,
0x41, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x12, 0x73, 0x70, 0x65, 0x65, 0x64, 0x53, 0x65,
0x6e, 0x73, 0x6f, 0x72, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x41, 0x12, 0x2e, 0x0a, 0x12, 0x73,
0x70, 0x65, 0x65, 0x64, 0x53, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65,
0x42, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x12, 0x73, 0x70, 0x65, 0x65, 0x64, 0x53, 0x65,
0x6e, 0x73, 0x6f, 0x72, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x42, 0x12, 0x20, 0x0a, 0x0b, 0x72,
0x61, 0x64, 0x61, 0x72, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08,
0x52, 0x0b, 0x72, 0x61, 0x64, 0x61, 0x72, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x28, 0x0a,
0x0f, 0x72, 0x61, 0x64, 0x61, 0x72, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x53, 0x70, 0x65, 0x65, 0x64,
0x18, 0x04, 0x20, 0x01, 0x28, 0x02, 0x52, 0x0f, 0x72, 0x61, 0x64, 0x61, 0x72, 0x43, 0x68, 0x65,
0x63, 0x6b, 0x53, 0x70, 0x65, 0x65, 0x64, 0x12, 0x26, 0x0a, 0x0e, 0x72, 0x61, 0x64, 0x61, 0x72,
0x43, 0x68, 0x65, 0x63, 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52,
0x0e, 0x72, 0x61, 0x64, 0x61, 0x72, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x42,
0x2f, 0x5a, 0x2d, 0x6a, 0x6f, 0x79, 0x6c, 0x69, 0x6e, 0x6b, 0x2e, 0x63, 0x6c, 0x75, 0x62, 0x2f,
0x62, 0x6a, 0x2d, 0x72, 0x74, 0x73, 0x74, 0x73, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f,
0x64, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_common_data_proto_rawDescOnce sync.Once
file_common_data_proto_rawDescData = file_common_data_proto_rawDesc
)
func file_common_data_proto_rawDescGZIP() []byte {
file_common_data_proto_rawDescOnce.Do(func() {
file_common_data_proto_rawDescData = protoimpl.X.CompressGZIP(file_common_data_proto_rawDescData)
})
return file_common_data_proto_rawDescData
}
var file_common_data_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_common_data_proto_goTypes = []interface{}{
(*TrainDynamicConfig)(nil), // 0: common.TrainDynamicConfig
(*TrainEndsState)(nil), // 1: common.TrainEndsState
}
var file_common_data_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
0, // [0:0] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_common_data_proto_init() }
func file_common_data_proto_init() {
if File_common_data_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_common_data_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*TrainDynamicConfig); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_common_data_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*TrainEndsState); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_common_data_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_common_data_proto_goTypes,
DependencyIndexes: file_common_data_proto_depIdxs,
MessageInfos: file_common_data_proto_msgTypes,
}.Build()
File_common_data_proto = out.File
file_common_data_proto_rawDesc = nil
file_common_data_proto_goTypes = nil
file_common_data_proto_depIdxs = nil
}

File diff suppressed because it is too large Load Diff

View File

@ -77,6 +77,8 @@ type AddTrainReqDtoNew struct {
WheelDiameter int32 `json:"wheelDiameter" from:"wheelDiameter"`
// 列车数据配置
ConfigTrain ConfigTrainData `json:"ConfigTrain" from:"mapId"`
TrainEndsA ConfigTrainEnds `json:"TrainEndsA"` // 车辆A端
TrainEndsB ConfigTrainEnds `json:"TrainEndsB"` // 车辆B端
}
// 为反正列车修改对应的测试配置
@ -86,6 +88,8 @@ type ConfigTrainReqDto struct {
TrainId int `json:"TrainId" form:"TrainId"`
Length int64 `json:"length"` // 列车的长度cm
ConfigData ConfigTrainData
TrainEndsA ConfigTrainEnds `json:"TrainEndsA"` // 车辆A端
TrainEndsB ConfigTrainEnds `json:"TrainEndsB"` // 车辆B端
WheelDiameter int32 `json:"wheelDiameter"` // 轮径mm
}
type ConfigTrainEnds struct {
@ -109,8 +113,8 @@ type ConfigTrainData struct {
Slip float32 `json:"slip"` // 打滑(%
Slide int32 `json:"slide"` // 前溜/后溜mm正数前溜负数后溜
StopSign int32 `json:"stopSign"` // 过标/欠标mm正数过标负数欠标
TrainEndsA ConfigTrainEnds `json:"TrainEndsA"` // 车辆A端
TrainEndsB ConfigTrainEnds `json:"TrainEndsB"` // 车辆B端
//TrainEndsA ConfigTrainEnds `json:"TrainEndsA"` // 车辆A端
//TrainEndsB ConfigTrainEnds `json:"TrainEndsB"` // 车辆B端
}
// 为仿真添加测试车请求

File diff suppressed because it is too large Load Diff

View File

@ -25,6 +25,7 @@ type TrainInfoDto struct {
MaxDiameter int32 `json:"max_diameter" form:"max_diameter"`
TrainSets string `json:"train_sets" form:"train_sets"`
Description string `json:"description" form:"description"`
TrainConfigData ConfigTrainData `json:"TrainConfigData" form:"TrainConfigData"`
}
func ConvertToTrainDto(trailInfos []*PublishedDto) []*TrainInfoDto {

View File

@ -2,6 +2,7 @@ package service
import (
"fmt"
"joylink.club/bj-rtsts-server/dto/common_proto"
"time"
"google.golang.org/protobuf/proto"
@ -63,6 +64,21 @@ func CreateTrain(td *dto.TrainInfoDto, user *model.User) bool {
}, true)
return true
}
func TrainConfigToProtoConvert(t dto.ConfigTrainData) *common_proto.TrainDynamicConfig {
return &common_proto.TrainDynamicConfig{
BaseResistanceParamA: t.BaseResistanceParamA,
BaseResistanceParamB: t.BaseResistanceParamB,
BaseResistanceParamC: t.BaseResistanceParamC,
CurveResistanceParamR1: t.CurveResistanceParamR1,
CurveResistanceParamR2: t.CurveResistanceParamR2,
CurveResistanceParamR3: t.CurveResistanceParamR3,
CurveResistanceParamR4: t.CurveResistanceParamR4,
Jump: t.Jump,
Slip: t.Slip,
Slide: t.Slide,
StopSign: t.StopSign,
}
}
// 转成列车proto
func convertTrainProto(t *dto.TrainInfoDto) []byte {
@ -73,6 +89,7 @@ func convertTrainProto(t *dto.TrainInfoDto) []byte {
MinDiameter: t.MinDiameter,
MaxDiameter: t.MaxDiameter,
TrainSets: t.TrainSets,
DynamicConfig: TrainConfigToProtoConvert(t.TrainConfigData),
}
b, _ := proto.Marshal(message)
return b

View File

@ -2,6 +2,8 @@ package memory
import (
"fmt"
"joylink.club/bj-rtsts-server/dto/common_proto"
"joylink.club/bj-rtsts-server/service"
"joylink.club/bj-rtsts-server/third_party/can_btm"
"log/slog"
"math"
@ -19,8 +21,8 @@ import (
"joylink.club/bj-rtsts-server/dto/state_proto"
)
func DtoTrainEndsToStateProto(ends dto.ConfigTrainEnds) *state_proto.TrainEndsState {
return &state_proto.TrainEndsState{SpeedSensorEnableA: ends.SpeedSensorEnableA, SpeedSensorEnableB: ends.SpeedSensorEnableB,
func DtoTrainEndsToStateProto(ends dto.ConfigTrainEnds) *common_proto.TrainEndsState {
return &common_proto.TrainEndsState{SpeedSensorEnableA: ends.SpeedSensorEnableA, SpeedSensorEnableB: ends.SpeedSensorEnableB,
RadarEnable: ends.RadarEnable, RadarCheckSpeed: ends.RadarCheckSpeed, RadarCheckTime: ends.RadarCheckTime}
}
func CreateMsgTrainConfig(trainId int, trainLen int64, configTrainData dto.ConfigTrainData) *message.TrainOperationConfig {
@ -34,7 +36,8 @@ func CreateMsgTrainConfig(trainId int, trainLen int64, configTrainData dto.Confi
}
// 增加列车状态
func AddTrainStateNew(vs *VerifySimulation, status *state_proto.TrainState, configTrainData dto.ConfigTrainData, mapId int32) *state_proto.TrainState {
func AddTrainStateNew(vs *VerifySimulation, status *state_proto.TrainState, configTrainData dto.ConfigTrainData, trainEndsA dto.ConfigTrainEnds,
trainEndsB dto.ConfigTrainEnds, mapId int32) *state_proto.TrainState {
allTrainMap := &vs.Memory.Status.TrainStateMap
_, ok := allTrainMap.Load(status.Id)
if ok {
@ -85,7 +88,7 @@ func AddTrainStateNew(vs *VerifySimulation, status *state_proto.TrainState, conf
TrainEndsA: DtoTrainEndsToStateProto(configTrainData.TrainEndsA),
TrainEndsB: DtoTrainEndsToStateProto(configTrainData.TrainEndsB)}*/
//初始化列车参数状态
createOrUpdateStateDynamicConfig(status, configTrainData)
createOrUpdateStateDynamicConfig(status, configTrainData, trainEndsA, trainEndsB)
status.VobcState = &state_proto.TrainVobcState{}
slog.Debug("列车初始化", "trainIndex", trainIndex, "linkId", linkId, "loffset", loffset)
linkIdInt, _ := strconv.Atoi(linkId)
@ -188,9 +191,12 @@ func AddTrainStateNew(vs *VerifySimulation, status *state_proto.TrainState, conf
return status
}*/
func createOrUpdateStateDynamicConfig(trainState *state_proto.TrainState, configTrainData dto.ConfigTrainData) {
if trainState.TrainDynamicConfig == nil {
trainState.TrainDynamicConfig = &state_proto.TrainDynamicConfig{}
func createOrUpdateStateDynamicConfig(trainState *state_proto.TrainState, configTrainData dto.ConfigTrainData, trainEndsA dto.ConfigTrainEnds,
trainEndsB dto.ConfigTrainEnds) {
trainState.TrainDynamicConfig = service.TrainConfigToProtoConvert(configTrainData)
/*if trainState.TrainDynamicConfig == nil {
trainState.TrainDynamicConfig = &common_proto.TrainDynamicConfig{}
}
trainState.TrainDynamicConfig.BaseResistanceParamA = configTrainData.BaseResistanceParamA
trainState.TrainDynamicConfig.BaseResistanceParamB = configTrainData.BaseResistanceParamB
@ -202,16 +208,16 @@ func createOrUpdateStateDynamicConfig(trainState *state_proto.TrainState, config
trainState.TrainDynamicConfig.Jump = configTrainData.Jump
trainState.TrainDynamicConfig.Slip = configTrainData.Slip
trainState.TrainDynamicConfig.Slide = configTrainData.Slide
trainState.TrainDynamicConfig.StopSign = configTrainData.StopSign
copyTrainEnds(trainState.TrainDynamicConfig, "TrainEndsA", configTrainData.TrainEndsA)
copyTrainEnds(trainState.TrainDynamicConfig, "TrainEndsB", configTrainData.TrainEndsB)
trainState.TrainDynamicConfig.StopSign = configTrainData.StopSign*/
copyTrainEnds(trainState, "TrainEndsA", trainEndsA)
copyTrainEnds(trainState, "TrainEndsB", trainEndsB)
}
func copyTrainEnds(trainState *state_proto.TrainDynamicConfig, fieldName string, configData dto.ConfigTrainEnds) {
func copyTrainEnds(trainState *state_proto.TrainState, fieldName string, configData dto.ConfigTrainEnds) {
fieldVal := reflect.ValueOf(trainState).Elem().FieldByName(fieldName)
endsVal := fieldVal.Interface().(*state_proto.TrainEndsState)
endsVal := fieldVal.Interface().(*common_proto.TrainEndsState)
if endsVal == nil {
endsVal = &state_proto.TrainEndsState{}
endsVal = &common_proto.TrainEndsState{}
fieldVal.Set(reflect.ValueOf(endsVal))
}
endsVal.SpeedSensorEnableA = configData.SpeedSensorEnableA
@ -230,7 +236,7 @@ func UpdateConfigTrain(vs *VerifySimulation, ct *dto.ConfigTrainReqDto) {
if !ok {
panic(sys_error.New(fmt.Sprintf("列车参数修改断言:列车【%s】不存在", ct.TrainId)))
}
createOrUpdateStateDynamicConfig(trainState, ct.ConfigData)
createOrUpdateStateDynamicConfig(trainState, ct.ConfigData, ct.TrainEndsA, ct.TrainEndsB)
/* if trainState.TrainDynamicConfig == nil {
trainState.TrainDynamicConfig = &state_proto.TrainDynamicConfig{}
}*/