【提取列车中的动力学数据】

This commit is contained in:
weizhihong 2023-08-25 16:09:04 +08:00
parent 5610230d08
commit fb8d23e14a
7 changed files with 862 additions and 423 deletions

View File

@ -0,0 +1,130 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.1
// protoc v4.23.1
// source: picture.proto
package graphicData
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 PictureType int32
const (
// * 平面布置图
PictureType_StationLayout PictureType = 0
// * Psl界面
PictureType_Psl PictureType = 1
)
// Enum value maps for PictureType.
var (
PictureType_name = map[int32]string{
0: "StationLayout",
1: "Psl",
}
PictureType_value = map[string]int32{
"StationLayout": 0,
"Psl": 1,
}
)
func (x PictureType) Enum() *PictureType {
p := new(PictureType)
*p = x
return p
}
func (x PictureType) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (PictureType) Descriptor() protoreflect.EnumDescriptor {
return file_picture_proto_enumTypes[0].Descriptor()
}
func (PictureType) Type() protoreflect.EnumType {
return &file_picture_proto_enumTypes[0]
}
func (x PictureType) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use PictureType.Descriptor instead.
func (PictureType) EnumDescriptor() ([]byte, []int) {
return file_picture_proto_rawDescGZIP(), []int{0}
}
var File_picture_proto protoreflect.FileDescriptor
var file_picture_proto_rawDesc = []byte{
0x0a, 0x0d, 0x70, 0x69, 0x63, 0x74, 0x75, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2a,
0x29, 0x0a, 0x0b, 0x50, 0x69, 0x63, 0x74, 0x75, 0x72, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x11,
0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x61, 0x79, 0x6f, 0x75, 0x74, 0x10,
0x00, 0x12, 0x07, 0x0a, 0x03, 0x50, 0x73, 0x6c, 0x10, 0x01, 0x42, 0x21, 0x5a, 0x1f, 0x2e, 0x2f,
0x61, 0x74, 0x73, 0x2f, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x73, 0x2f, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x44, 0x61, 0x74, 0x61, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_picture_proto_rawDescOnce sync.Once
file_picture_proto_rawDescData = file_picture_proto_rawDesc
)
func file_picture_proto_rawDescGZIP() []byte {
file_picture_proto_rawDescOnce.Do(func() {
file_picture_proto_rawDescData = protoimpl.X.CompressGZIP(file_picture_proto_rawDescData)
})
return file_picture_proto_rawDescData
}
var file_picture_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_picture_proto_goTypes = []interface{}{
(PictureType)(0), // 0: PictureType
}
var file_picture_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_picture_proto_init() }
func file_picture_proto_init() {
if File_picture_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_picture_proto_rawDesc,
NumEnums: 1,
NumMessages: 0,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_picture_proto_goTypes,
DependencyIndexes: file_picture_proto_depIdxs,
EnumInfos: file_picture_proto_enumTypes,
}.Build()
File_picture_proto = out.File
file_picture_proto_rawDesc = nil
file_picture_proto_goTypes = nil
file_picture_proto_depIdxs = nil
}

View File

@ -0,0 +1,226 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.1
// protoc v4.23.1
// source: pslGraphics.proto
package graphicData
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 PslGraphicStorage struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Psllights []*PslLight `protobuf:"bytes,1,rep,name=psllights,proto3" json:"psllights,omitempty"` // psl圆形灯
}
func (x *PslGraphicStorage) Reset() {
*x = PslGraphicStorage{}
if protoimpl.UnsafeEnabled {
mi := &file_pslGraphics_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PslGraphicStorage) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PslGraphicStorage) ProtoMessage() {}
func (x *PslGraphicStorage) ProtoReflect() protoreflect.Message {
mi := &file_pslGraphics_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 PslGraphicStorage.ProtoReflect.Descriptor instead.
func (*PslGraphicStorage) Descriptor() ([]byte, []int) {
return file_pslGraphics_proto_rawDescGZIP(), []int{0}
}
func (x *PslGraphicStorage) GetPsllights() []*PslLight {
if x != nil {
return x.Psllights
}
return nil
}
// PSL圆形灯
type PslLight struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Common *CommonInfo `protobuf:"bytes,1,opt,name=common,proto3" json:"common,omitempty"`
Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"`
}
func (x *PslLight) Reset() {
*x = PslLight{}
if protoimpl.UnsafeEnabled {
mi := &file_pslGraphics_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PslLight) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PslLight) ProtoMessage() {}
func (x *PslLight) ProtoReflect() protoreflect.Message {
mi := &file_pslGraphics_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 PslLight.ProtoReflect.Descriptor instead.
func (*PslLight) Descriptor() ([]byte, []int) {
return file_pslGraphics_proto_rawDescGZIP(), []int{1}
}
func (x *PslLight) GetCommon() *CommonInfo {
if x != nil {
return x.Common
}
return nil
}
func (x *PslLight) GetCode() string {
if x != nil {
return x.Code
}
return ""
}
var File_pslGraphics_proto protoreflect.FileDescriptor
var file_pslGraphics_proto_rawDesc = []byte{
0x0a, 0x11, 0x70, 0x73, 0x6c, 0x47, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x70, 0x73, 0x6c, 0x47, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x44,
0x61, 0x74, 0x61, 0x1a, 0x1b, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x61, 0x79, 0x6f,
0x75, 0x74, 0x47, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x22, 0x4b, 0x0a, 0x11, 0x50, 0x73, 0x6c, 0x47, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x53, 0x74,
0x6f, 0x72, 0x61, 0x67, 0x65, 0x12, 0x36, 0x0a, 0x09, 0x70, 0x73, 0x6c, 0x6c, 0x69, 0x67, 0x68,
0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x73, 0x6c, 0x47, 0x72,
0x61, 0x70, 0x68, 0x69, 0x63, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x50, 0x73, 0x6c, 0x4c, 0x69, 0x67,
0x68, 0x74, 0x52, 0x09, 0x70, 0x73, 0x6c, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x73, 0x22, 0x4f, 0x0a,
0x08, 0x50, 0x73, 0x6c, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x12, 0x2f, 0x0a, 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, 0x6f, 0x6e, 0x49, 0x6e,
0x66, 0x6f, 0x52, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f,
0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x42, 0x21,
0x5a, 0x1f, 0x2e, 0x2f, 0x61, 0x74, 0x73, 0x2f, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x2f, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x44, 0x61, 0x74,
0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_pslGraphics_proto_rawDescOnce sync.Once
file_pslGraphics_proto_rawDescData = file_pslGraphics_proto_rawDesc
)
func file_pslGraphics_proto_rawDescGZIP() []byte {
file_pslGraphics_proto_rawDescOnce.Do(func() {
file_pslGraphics_proto_rawDescData = protoimpl.X.CompressGZIP(file_pslGraphics_proto_rawDescData)
})
return file_pslGraphics_proto_rawDescData
}
var file_pslGraphics_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_pslGraphics_proto_goTypes = []interface{}{
(*PslGraphicStorage)(nil), // 0: pslGraphicData.PslGraphicStorage
(*PslLight)(nil), // 1: pslGraphicData.PslLight
(*CommonInfo)(nil), // 2: graphicData.CommonInfo
}
var file_pslGraphics_proto_depIdxs = []int32{
1, // 0: pslGraphicData.PslGraphicStorage.psllights:type_name -> pslGraphicData.PslLight
2, // 1: pslGraphicData.PslLight.common:type_name -> graphicData.CommonInfo
2, // [2:2] is the sub-list for method output_type
2, // [2:2] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_pslGraphics_proto_init() }
func file_pslGraphics_proto_init() {
if File_pslGraphics_proto != nil {
return
}
file_stationLayoutGraphics_proto_init()
if !protoimpl.UnsafeEnabled {
file_pslGraphics_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PslGraphicStorage); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_pslGraphics_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PslLight); 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_pslGraphics_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_pslGraphics_proto_goTypes,
DependencyIndexes: file_pslGraphics_proto_depIdxs,
MessageInfos: file_pslGraphics_proto_msgTypes,
}.Build()
File_pslGraphics_proto = out.File
file_pslGraphics_proto_rawDesc = nil
file_pslGraphics_proto_goTypes = nil
file_pslGraphics_proto_depIdxs = nil
}

File diff suppressed because it is too large Load Diff

View File

@ -54,8 +54,8 @@ func init() {
zap.S().Info("接收到vobc发送的列车消息", trainInfo)
// 发送给动力学
dynamics.SendDynamicsTrainMsg(append(info, uint8(trainId)))
// 存放至仿真
simulation.Memory.Status.VobcTrainStateMap.Store(train.Id, trainInfo)
// 存放至列车
train.VobcState = trainInfo
}
return false
})
@ -151,43 +151,40 @@ func GetSimulationArr() []*memory.VerifySimulation {
func convert(info *dynamics.TrainInfo, sta *state.TrainState, simulation *memory.VerifySimulation) *state.TrainState {
vs := memory.QueryMapVerifyStructure(simulation.MapId)
zap.S().Debugf("原始消息:[%d-%d-%d]", info.Number, info.Link, info.LinkOffset)
sta.HeadLinkId = strconv.Itoa(int(info.Link))
sta.HeadLinkOffset = int64(info.LinkOffset)
//sta.Up = info.Up
id, port, offset, runDirection, pointTo := memory.QueryDeviceByCalcLink(vs, int32(info.Link), sta.HeadLinkOffset, info.Up, sta.RunDirection)
id, port, offset, runDirection, pointTo := memory.QueryDeviceByCalcLink(vs, int32(info.Link), int64(info.LinkOffset), info.Up, sta.RunDirection)
zap.S().Debugf("转换后的消息:[%d-车头:%s-偏移:%d-上行:%v-是否ab:%v]", info.Number, id, offset, runDirection, pointTo)
sta.HeadDeviceId = id
sta.DevicePort = port
sta.HeadOffset = offset
sta.PointTo = pointTo
sta.RunDirection = runDirection
sta.Slope = int32(info.Slope)
sta.Upslope = info.UpSlope
sta.RunningUp = info.Up
sta.RunningResistanceSum = float32(info.TotalResistance) / 1000
sta.AirResistance = float32(info.AirResistance) / 1000
sta.RampResistance = float32(info.SlopeResistance) / 1000
sta.CurveResistance = float32(info.CurveResistance) / 1000
sta.Speed = info.Speed * 3.6
sta.HeadSensorSpeed1 = info.HeadSpeed1 * 3.6
sta.HeadSensorSpeed2 = info.HeadSpeed2 * 3.6
sta.TailSensorSpeed1 = info.TailSpeed1 * 3.6
sta.TailSensorSpeed2 = info.TailSpeed2 * 3.6
sta.HeadRadarSpeed = info.HeadRadarSpeed * 3.6
sta.TailRadarSpeed = info.TailRadarSpeed * 3.6
//判定车头方向
v, ok := simulation.Memory.Status.VobcTrainStateMap.Load(sta.Id)
if ok {
vobcState := v.(*state.TrainVobcState)
if vobcState.DirectionForward {
if sta.VobcState != nil {
if sta.VobcState.DirectionForward {
sta.HeadDirection = info.Up
} else if vobcState.DirectionBackward {
} else if sta.VobcState.DirectionBackward {
sta.HeadDirection = !info.Up
}
}
// 赋值动力学信息
sta.DynamicState.Heartbeat = int32(info.LifeSignal)
sta.DynamicState.HeadLinkId = strconv.Itoa(int(info.Link))
sta.DynamicState.HeadLinkOffset = int64(info.LinkOffset)
sta.DynamicState.Slope = int32(info.Slope)
sta.DynamicState.Upslope = info.UpSlope
sta.DynamicState.RunningUp = info.Up
sta.DynamicState.RunningResistanceSum = float32(info.TotalResistance) / 1000
sta.DynamicState.AirResistance = float32(info.AirResistance) / 1000
sta.DynamicState.RampResistance = float32(info.SlopeResistance) / 1000
sta.DynamicState.CurveResistance = float32(info.CurveResistance) / 1000
sta.DynamicState.Speed = info.Speed * 3.6
sta.DynamicState.HeadSensorSpeed1 = info.HeadSpeed1 * 3.6
sta.DynamicState.HeadSensorSpeed2 = info.HeadSpeed2 * 3.6
sta.DynamicState.TailSensorSpeed1 = info.TailSpeed1 * 3.6
sta.DynamicState.TailSensorSpeed2 = info.TailSpeed2 * 3.6
sta.DynamicState.HeadRadarSpeed = info.HeadRadarSpeed * 3.6
sta.DynamicState.TailRadarSpeed = info.TailRadarSpeed * 3.6
return sta
}

View File

@ -22,8 +22,6 @@ type VerifyStatus struct {
LogicSectionStateMap sync.Map
//信号机状态key为信号机id,即索引 state.SignalState
SignalStateMap sync.Map
//vobc发来的列车状态,索引为列车id
VobcTrainStateMap sync.Map
}
// 轨旁仿真模型状态(变更)

View File

@ -39,11 +39,13 @@ func AddTrainState(simulation *VerifySimulation, status *state.TrainState) {
Up: status.Up,
TrainLength: uint16(status.TrainLength),
})
zap.S().Debugf("添加列车:[%d-%s-%d]", trainIndex, status.HeadLinkId, status.HeadLinkOffset)
zap.S().Debugf("添加列车:[%d-%s-%d]", trainIndex, status.HeadDeviceId, status.HeadOffset)
zap.S().Debugf("列车初始化:[%d-%d-%d]", trainIndex, linkId, loffset)
if err != nil || httpCode != http.StatusOK {
panic(dto.ErrorDto{Code: dto.LogicError, Message: fmt.Sprintf("动力学接口调用失败:[%d][%s]", httpCode, err)})
}
// 调用成功后初始化列车的动力学
status.DynamicState = &state.TrainDynamicState{}
// 将信息合并到当前设备状态中
allTrainMap.Store(status.Id, status)
// 将变更信息放入变更状态队列中
@ -58,10 +60,6 @@ func UpdateTrainState(simulation *VerifySimulation, status *state.TrainState) {
panic(fmt.Sprintf("列车【%s】不存在", status.Id))
}
t := d.(*state.TrainState)
// bool型信息单独处理
t.Up = status.Up
t.Upslope = status.Upslope
t.RunningUp = status.RunningUp
t.RunDirection = status.RunDirection
t.PointTo = status.PointTo
// 合并其他信息

@ -1 +1 @@
Subproject commit 8cb151ed76afd59832edd044253ed1d8a8325016
Subproject commit e8d0e1e67593db6463c0b36870a6865e380e7a9e