rts-sim-testing-service/dto/trainManage.go
tiger_zhou cf3d38a2f5
Some checks failed
local-test分支打包构建docker并发布运行 / Docker-Build (push) Failing after 3m4s
列车驾驶ato牵引,制动初始版,添加列车紧急制动属性,添加ato开关门指示灯
2024-08-30 18:08:14 +08:00

80 lines
3.4 KiB
Go

package dto
import (
"google.golang.org/protobuf/proto"
"joylink.club/bj-rtsts-server/dto/common_proto"
"joylink.club/bj-rtsts-server/dto/data_proto"
)
type PageTrainInfoReqDto struct {
PageQueryDto
Name string `json:"name" form:"name"`
}
type TrainInfoReqDto struct {
Name string `json:"name" form:"name"`
Pid int32 `json:"pid" form:"pid"`
}
type TrainInfoDto struct {
Id int32 `json:"id" form:"id"`
Name string `json:"name" form:"name"`
TrainModel int32 `json:"train_model" form:"train_model"`
CarriageLength int32 `json:"carriage_length" form:"carriage_length"`
TotalLength int32 `json:"total_length" form:"total_length"`
TrainLoad int32 `json:"train_load" form:"train_load"`
TrainMaxSpeed float32 `json:"train_max_speed" form:"train_max_speed"`
TrainMaxAcc float32 `json:"train_max_acc" form:"train_max_acc"`
TrainMaxBrake float32 `json:"train_max_brake" form:"train_max_brake"`
TrainEmergencyBrake float32 `json:"train_emergency_brake" form:"train_emergency_brake"`
//MinDiameter int32 `json:"min_diameter" form:"min_diameter"`
//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"`
//TrainControlMapCode string `json:"trainControlMapCode"` // 关联列车控制图形code
TrainControlMapId int32 `json:"trainControlMapId"` // 关联列车控制图形code
}
func ConvertToTrainDto(trailInfos []*PublishedDto) []*TrainInfoDto {
var result []*TrainInfoDto
for _, t := range trailInfos {
result = append(result, ConvertDtoFromTrain(t))
}
return result
}
func TrainConfigToDtoConvert(dc *common_proto.TrainDynamicConfig) *ConfigTrainData {
if dc != nil {
return &ConfigTrainData{
DavisParamA: dc.DavisParamA, DavisParamB: dc.DavisParamB, DavisParamC: dc.DavisParamC,
CurveResistanceParamR1: dc.CurveResistanceParamR1, CurveResistanceParamR2: dc.CurveResistanceParamR2, CurveResistanceParamR3: dc.CurveResistanceParamR3,
CurveResistanceParamR4: dc.CurveResistanceParamR4, RevolvingMassParam: dc.RevolvingMassParam,
Jump: dc.Jump, SlipA: dc.SlipA, SlipR: dc.SlipR, SlipD: dc.SlipD, Slide: dc.Slide, IdlingA: dc.IdlingA, IdlingR: dc.IdlingR, IdlingD: dc.IdlingD, StopSign: dc.StopSign,
}
}
return nil
}
func ConvertDtoFromTrain(t *PublishedDto) *TrainInfoDto {
message := &data_proto.Train{}
proto.Unmarshal(t.Proto, message)
return &TrainInfoDto{
Id: t.ID,
Name: t.Name,
Description: t.Note,
TrainModel: int32(message.TrainModel),
CarriageLength: message.CarriageLength,
TotalLength: message.TotalLength,
TrainControlMapId: message.TrainControlMapId,
TrainLoad: message.TrainLoad,
TrainMaxSpeed: message.TrainMaxSpeed,
TrainMaxAcc: message.TrainMaxAcc,
TrainMaxBrake: message.TrainMaxBrake,
TrainEmergencyBrake: message.TrainEmergencyBrake,
//TrainControlMapCode: message.TrainControlMapCode,
//MinDiameter: message.MinDiameter,
//MaxDiameter: message.MaxDiameter,
TrainSets: message.TrainSets,
TrainConfigData: TrainConfigToDtoConvert(message.DynamicConfig),
}
}