【修改地图缓存数据】
This commit is contained in:
parent
bccdb424a9
commit
bd376293a6
@ -34,7 +34,8 @@ func InitSimulationRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddle
|
||||
|
||||
// 初始化地图信息
|
||||
initPublishMapInfo()
|
||||
apiproto.RegisterMsgServer(&apiproto.SimulationServer{})
|
||||
//apiproto.RegisterMsgServer(&apiproto.SimulationServer{})
|
||||
apiproto.RegisterMsgServer(&apiproto.SimulationMapServer{})
|
||||
apiproto.RegisterMsgServer(&apiproto.MemoryChangeServer{SimulationMap: make(map[string]*state.SimulationStatus)})
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.23.1
|
||||
// source: picture.proto
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.23.1
|
||||
// source: pslGraphics.proto
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.23.1
|
||||
// source: relayCabinetLayoutGraphics.proto
|
||||
|
||||
@ -25,11 +25,12 @@ type RelayCabinetGraphicStorage struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Canvas *Canvas `protobuf:"bytes,1,opt,name=canvas,proto3" json:"canvas,omitempty"`
|
||||
RelayCabinets []*RelayCabinet `protobuf:"bytes,2,rep,name=relayCabinets,proto3" json:"relayCabinets,omitempty"`
|
||||
Relays []*Relay `protobuf:"bytes,3,rep,name=relays,proto3" json:"relays,omitempty"`
|
||||
DeviceRelateRelayList []*DeviceRelateRelay `protobuf:"bytes,4,rep,name=deviceRelateRelayList,proto3" json:"deviceRelateRelayList,omitempty"`
|
||||
BelongsConcentrationStation string `protobuf:"bytes,5,opt,name=belongsConcentrationStation,proto3" json:"belongsConcentrationStation,omitempty"` //继电器柜图所属集中站
|
||||
Canvas *Canvas `protobuf:"bytes,1,opt,name=canvas,proto3" json:"canvas,omitempty"`
|
||||
RelayCabinets []*RelayCabinet `protobuf:"bytes,2,rep,name=relayCabinets,proto3" json:"relayCabinets,omitempty"`
|
||||
Relays []*Relay `protobuf:"bytes,3,rep,name=relays,proto3" json:"relays,omitempty"`
|
||||
DeviceRelateRelayList []*DeviceRelateRelay `protobuf:"bytes,4,rep,name=deviceRelateRelayList,proto3" json:"deviceRelateRelayList,omitempty"`
|
||||
// string belongsConcentrationStation = 5;//继电器柜图所属集中站
|
||||
UniqueIdPrefix *UniqueIdType `protobuf:"bytes,6,opt,name=UniqueIdPrefix,proto3" json:"UniqueIdPrefix,omitempty"` //设备唯一编码--前缀
|
||||
}
|
||||
|
||||
func (x *RelayCabinetGraphicStorage) Reset() {
|
||||
@ -92,11 +93,11 @@ func (x *RelayCabinetGraphicStorage) GetDeviceRelateRelayList() []*DeviceRelateR
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *RelayCabinetGraphicStorage) GetBelongsConcentrationStation() string {
|
||||
func (x *RelayCabinetGraphicStorage) GetUniqueIdPrefix() *UniqueIdType {
|
||||
if x != nil {
|
||||
return x.BelongsConcentrationStation
|
||||
return x.UniqueIdPrefix
|
||||
}
|
||||
return ""
|
||||
return nil
|
||||
}
|
||||
|
||||
type RelayCabinet struct {
|
||||
@ -338,6 +339,69 @@ func (x *Combinationtype) GetRefRelays() []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
type UniqueIdType struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
City string `protobuf:"bytes,1,opt,name=city,proto3" json:"city,omitempty"` //城市
|
||||
LineId string `protobuf:"bytes,2,opt,name=lineId,proto3" json:"lineId,omitempty"` //线路号
|
||||
BelongsConcentrationStation string `protobuf:"bytes,3,opt,name=belongsConcentrationStation,proto3" json:"belongsConcentrationStation,omitempty"` //继电器柜图所属集中站
|
||||
}
|
||||
|
||||
func (x *UniqueIdType) Reset() {
|
||||
*x = UniqueIdType{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_relayCabinetLayoutGraphics_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *UniqueIdType) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*UniqueIdType) ProtoMessage() {}
|
||||
|
||||
func (x *UniqueIdType) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_relayCabinetLayoutGraphics_proto_msgTypes[5]
|
||||
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 UniqueIdType.ProtoReflect.Descriptor instead.
|
||||
func (*UniqueIdType) Descriptor() ([]byte, []int) {
|
||||
return file_relayCabinetLayoutGraphics_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *UniqueIdType) GetCity() string {
|
||||
if x != nil {
|
||||
return x.City
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *UniqueIdType) GetLineId() string {
|
||||
if x != nil {
|
||||
return x.LineId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *UniqueIdType) GetBelongsConcentrationStation() string {
|
||||
if x != nil {
|
||||
return x.BelongsConcentrationStation
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_relayCabinetLayoutGraphics_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_relayCabinetLayoutGraphics_proto_rawDesc = []byte{
|
||||
@ -346,7 +410,7 @@ var file_relayCabinetLayoutGraphics_proto_rawDesc = []byte{
|
||||
0x74, 0x6f, 0x12, 0x17, 0x72, 0x65, 0x6c, 0x61, 0x79, 0x43, 0x61, 0x62, 0x69, 0x6e, 0x65, 0x74,
|
||||
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, 0xf2, 0x02, 0x0a, 0x1a, 0x52, 0x65, 0x6c,
|
||||
0x63, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xff, 0x02, 0x0a, 0x1a, 0x52, 0x65, 0x6c,
|
||||
0x61, 0x79, 0x43, 0x61, 0x62, 0x69, 0x6e, 0x65, 0x74, 0x47, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63,
|
||||
0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x12, 0x2b, 0x0a, 0x06, 0x63, 0x61, 0x6e, 0x76, 0x61,
|
||||
0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69,
|
||||
@ -365,39 +429,48 @@ var file_relayCabinetLayoutGraphics_proto_rawDesc = []byte{
|
||||
0x43, 0x61, 0x62, 0x69, 0x6e, 0x65, 0x74, 0x47, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x44, 0x61,
|
||||
0x74, 0x61, 0x2e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x65, 0x52,
|
||||
0x65, 0x6c, 0x61, 0x79, 0x52, 0x15, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x6c, 0x61,
|
||||
0x74, 0x65, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x40, 0x0a, 0x1b, 0x62,
|
||||
0x74, 0x65, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x4d, 0x0a, 0x0e, 0x55,
|
||||
0x6e, 0x69, 0x71, 0x75, 0x65, 0x49, 0x64, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x18, 0x06, 0x20,
|
||||
0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x79, 0x43, 0x61, 0x62, 0x69, 0x6e,
|
||||
0x65, 0x74, 0x47, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x55, 0x6e,
|
||||
0x69, 0x71, 0x75, 0x65, 0x49, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x0e, 0x55, 0x6e, 0x69, 0x71,
|
||||
0x75, 0x65, 0x49, 0x64, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x22, 0x53, 0x0a, 0x0c, 0x52, 0x65,
|
||||
0x6c, 0x61, 0x79, 0x43, 0x61, 0x62, 0x69, 0x6e, 0x65, 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, 0x22,
|
||||
0x62, 0x0a, 0x05, 0x52, 0x65, 0x6c, 0x61, 0x79, 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, 0x12, 0x14, 0x0a,
|
||||
0x05, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6d, 0x6f,
|
||||
0x64, 0x65, 0x6c, 0x22, 0x91, 0x01, 0x0a, 0x11, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65,
|
||||
0x6c, 0x61, 0x74, 0x65, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70,
|
||||
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a,
|
||||
0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64,
|
||||
0x65, 0x12, 0x54, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x62, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x74, 0x79, 0x70, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x72, 0x65,
|
||||
0x6c, 0x61, 0x79, 0x43, 0x61, 0x62, 0x69, 0x6e, 0x65, 0x74, 0x47, 0x72, 0x61, 0x70, 0x68, 0x69,
|
||||
0x63, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x43, 0x6f, 0x6d, 0x62, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x74, 0x79, 0x70, 0x65, 0x52, 0x10, 0x63, 0x6f, 0x6d, 0x62, 0x69, 0x6e, 0x61, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x22, 0x43, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x62, 0x69,
|
||||
0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x74, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f,
|
||||
0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x1c,
|
||||
0x0a, 0x09, 0x72, 0x65, 0x66, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28,
|
||||
0x09, 0x52, 0x09, 0x72, 0x65, 0x66, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x73, 0x22, 0x7c, 0x0a, 0x0c,
|
||||
0x55, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x49, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04,
|
||||
0x63, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x69, 0x74, 0x79,
|
||||
0x12, 0x16, 0x0a, 0x06, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x06, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x64, 0x12, 0x40, 0x0a, 0x1b, 0x62, 0x65, 0x6c, 0x6f,
|
||||
0x6e, 0x67, 0x73, 0x43, 0x6f, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x53, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x1b, 0x62,
|
||||
0x65, 0x6c, 0x6f, 0x6e, 0x67, 0x73, 0x43, 0x6f, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x72, 0x61, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x1b, 0x62, 0x65, 0x6c, 0x6f, 0x6e, 0x67, 0x73, 0x43, 0x6f, 0x6e, 0x63, 0x65, 0x6e, 0x74,
|
||||
0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x53, 0x0a,
|
||||
0x0c, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x43, 0x61, 0x62, 0x69, 0x6e, 0x65, 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, 0x22, 0x62, 0x0a, 0x05, 0x52, 0x65, 0x6c, 0x61, 0x79, 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,
|
||||
0x12, 0x14, 0x0a, 0x05, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x05, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x22, 0x91, 0x01, 0x0a, 0x11, 0x44, 0x65, 0x76, 0x69, 0x63,
|
||||
0x65, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x12, 0x12, 0x0a, 0x04,
|
||||
0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65,
|
||||
0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
|
||||
0x63, 0x6f, 0x64, 0x65, 0x12, 0x54, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x62, 0x69, 0x6e, 0x61, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28,
|
||||
0x2e, 0x72, 0x65, 0x6c, 0x61, 0x79, 0x43, 0x61, 0x62, 0x69, 0x6e, 0x65, 0x74, 0x47, 0x72, 0x61,
|
||||
0x70, 0x68, 0x69, 0x63, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x43, 0x6f, 0x6d, 0x62, 0x69, 0x6e, 0x61,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x74, 0x79, 0x70, 0x65, 0x52, 0x10, 0x63, 0x6f, 0x6d, 0x62, 0x69, 0x6e,
|
||||
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x22, 0x43, 0x0a, 0x0f, 0x43, 0x6f,
|
||||
0x6d, 0x62, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x74, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a,
|
||||
0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64,
|
||||
0x65, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x66, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x73, 0x18, 0x02,
|
||||
0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x66, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x73, 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,
|
||||
0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 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 (
|
||||
@ -412,29 +485,31 @@ func file_relayCabinetLayoutGraphics_proto_rawDescGZIP() []byte {
|
||||
return file_relayCabinetLayoutGraphics_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_relayCabinetLayoutGraphics_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
|
||||
var file_relayCabinetLayoutGraphics_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
|
||||
var file_relayCabinetLayoutGraphics_proto_goTypes = []interface{}{
|
||||
(*RelayCabinetGraphicStorage)(nil), // 0: relayCabinetGraphicData.RelayCabinetGraphicStorage
|
||||
(*RelayCabinet)(nil), // 1: relayCabinetGraphicData.RelayCabinet
|
||||
(*Relay)(nil), // 2: relayCabinetGraphicData.Relay
|
||||
(*DeviceRelateRelay)(nil), // 3: relayCabinetGraphicData.DeviceRelateRelay
|
||||
(*Combinationtype)(nil), // 4: relayCabinetGraphicData.Combinationtype
|
||||
(*Canvas)(nil), // 5: graphicData.Canvas
|
||||
(*CommonInfo)(nil), // 6: graphicData.CommonInfo
|
||||
(*UniqueIdType)(nil), // 5: relayCabinetGraphicData.UniqueIdType
|
||||
(*Canvas)(nil), // 6: graphicData.Canvas
|
||||
(*CommonInfo)(nil), // 7: graphicData.CommonInfo
|
||||
}
|
||||
var file_relayCabinetLayoutGraphics_proto_depIdxs = []int32{
|
||||
5, // 0: relayCabinetGraphicData.RelayCabinetGraphicStorage.canvas:type_name -> graphicData.Canvas
|
||||
6, // 0: relayCabinetGraphicData.RelayCabinetGraphicStorage.canvas:type_name -> graphicData.Canvas
|
||||
1, // 1: relayCabinetGraphicData.RelayCabinetGraphicStorage.relayCabinets:type_name -> relayCabinetGraphicData.RelayCabinet
|
||||
2, // 2: relayCabinetGraphicData.RelayCabinetGraphicStorage.relays:type_name -> relayCabinetGraphicData.Relay
|
||||
3, // 3: relayCabinetGraphicData.RelayCabinetGraphicStorage.deviceRelateRelayList:type_name -> relayCabinetGraphicData.DeviceRelateRelay
|
||||
6, // 4: relayCabinetGraphicData.RelayCabinet.common:type_name -> graphicData.CommonInfo
|
||||
6, // 5: relayCabinetGraphicData.Relay.common:type_name -> graphicData.CommonInfo
|
||||
4, // 6: relayCabinetGraphicData.DeviceRelateRelay.combinationtypes:type_name -> relayCabinetGraphicData.Combinationtype
|
||||
7, // [7:7] is the sub-list for method output_type
|
||||
7, // [7:7] is the sub-list for method input_type
|
||||
7, // [7:7] is the sub-list for extension type_name
|
||||
7, // [7:7] is the sub-list for extension extendee
|
||||
0, // [0:7] is the sub-list for field type_name
|
||||
5, // 4: relayCabinetGraphicData.RelayCabinetGraphicStorage.UniqueIdPrefix:type_name -> relayCabinetGraphicData.UniqueIdType
|
||||
7, // 5: relayCabinetGraphicData.RelayCabinet.common:type_name -> graphicData.CommonInfo
|
||||
7, // 6: relayCabinetGraphicData.Relay.common:type_name -> graphicData.CommonInfo
|
||||
4, // 7: relayCabinetGraphicData.DeviceRelateRelay.combinationtypes:type_name -> relayCabinetGraphicData.Combinationtype
|
||||
8, // [8:8] is the sub-list for method output_type
|
||||
8, // [8:8] is the sub-list for method input_type
|
||||
8, // [8:8] is the sub-list for extension type_name
|
||||
8, // [8:8] is the sub-list for extension extendee
|
||||
0, // [0:8] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_relayCabinetLayoutGraphics_proto_init() }
|
||||
@ -504,6 +579,18 @@ func file_relayCabinetLayoutGraphics_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_relayCabinetLayoutGraphics_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*UniqueIdType); 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{
|
||||
@ -511,7 +598,7 @@ func file_relayCabinetLayoutGraphics_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_relayCabinetLayoutGraphics_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 5,
|
||||
NumMessages: 6,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.23.1
|
||||
// source: device_state.proto
|
||||
|
||||
|
@ -3,11 +3,14 @@ package simulation
|
||||
import (
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"joylink.club/rtsssimulation/repository"
|
||||
"joylink.club/rtsssimulation/repository/model/proto"
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/repository"
|
||||
"joylink.club/rtsssimulation/repository/model/proto"
|
||||
ecsSimulation "joylink.club/rtsssimulation/simulation"
|
||||
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
@ -101,41 +104,22 @@ func CreateSimulation(projectId int32, mapIds []int32) string {
|
||||
if httpCode != http.StatusOK || err != nil {
|
||||
panic(dto.ErrorDto{Code: dto.DynamicsError, Message: fmt.Sprintf("动力学接口调用失败:[%d][%s]", httpCode, err)})
|
||||
}
|
||||
|
||||
simulationMap.Store(simulationId, verifySimulation)
|
||||
dynamicsRun(verifySimulation)
|
||||
}
|
||||
return simulationId
|
||||
|
||||
//simulationId := createSimulationId(projectId)
|
||||
//_, e := simulationMap.Load(simulationId)
|
||||
//if !e && IsExistSimulation() {
|
||||
// panic(dto.ErrorDto{Code: dto.DataAlreadyExist, Message: "已有仿真在运行"})
|
||||
//}
|
||||
//if !e {
|
||||
// verifySimulation := memory.CreateSimulation(projectId, mapIds)
|
||||
// verifySimulation.SimulationId = simulationId
|
||||
// lineDataInfo := &dynamics.LineBaseInfo{}
|
||||
// for _, mapId := range mapIds {
|
||||
// b := buildLineBaseInfo(memory.QueryMapVerifyStructure(mapId))
|
||||
// lineDataInfo.CurveList = append(lineDataInfo.CurveList, b.CurveList...)
|
||||
// lineDataInfo.LinkList = append(lineDataInfo.LinkList, b.LinkList...)
|
||||
// lineDataInfo.SlopeList = append(lineDataInfo.SlopeList, b.SlopeList...)
|
||||
// }
|
||||
// //通知动力学
|
||||
// httpCode, _, err := dynamics.SendSimulationStartReq(lineDataInfo)
|
||||
// if httpCode != http.StatusOK || err != nil {
|
||||
// panic(dto.ErrorDto{Code: dto.DynamicsError, Message: fmt.Sprintf("动力学接口调用失败:[%d][%s]", httpCode, err)})
|
||||
// }
|
||||
// simulationMap.Store(simulationId, verifySimulation)
|
||||
// dynamicsRun(verifySimulation)
|
||||
//}
|
||||
//return simulationId
|
||||
}
|
||||
|
||||
// 删除仿真对象
|
||||
func DestroySimulation(simulationId string) {
|
||||
s, e := simulationMap.Load(simulationId)
|
||||
if !e {
|
||||
return
|
||||
}
|
||||
simulationInfo := s.(*memory.VerifySimulation)
|
||||
simulationMap.Delete(simulationId)
|
||||
// 停止ecs world
|
||||
ecsSimulation.DestroySimulation(ecs.WorldId(simulationInfo.WorldId))
|
||||
//移除道岔状态发送
|
||||
dynamics.Stop()
|
||||
//通知动力学
|
||||
@ -323,62 +307,6 @@ func buildLineBaseInfo(repo *repository.Repository) *dynamics.LineBaseInfo {
|
||||
return info
|
||||
}
|
||||
|
||||
//func buildLineBaseInfo(vs *memory.VerifyStructure) *dynamics.LineBaseInfo {
|
||||
// var links []*dynamics.Link
|
||||
// var slopes []*dynamics.Slope
|
||||
// var curves []*dynamics.Curve
|
||||
// for _, link := range vs.LinkModelMap {
|
||||
// id, _ := strconv.Atoi(link.Index)
|
||||
// var aTurnoutId int
|
||||
// var aPort string
|
||||
// if link.ARelatedSwitchRef != nil && link.ARelatedSwitchRef.SwitchDevice != nil {
|
||||
// aTurnoutId, _ = strconv.Atoi(link.ARelatedSwitchRef.SwitchDevice.GetIndex())
|
||||
// aPort = link.ARelatedSwitchRef.Port.Name()
|
||||
// }
|
||||
// var bTurnoutId int
|
||||
// var bPort string
|
||||
// if link.BRelatedSwitchRef != nil && link.BRelatedSwitchRef.SwitchDevice != nil {
|
||||
// bTurnoutId, _ = strconv.Atoi(link.BRelatedSwitchRef.SwitchDevice.GetIndex())
|
||||
// bPort = link.BRelatedSwitchRef.Port.Name()
|
||||
// }
|
||||
// links = append(links, &dynamics.Link{
|
||||
// ID: int32(id),
|
||||
// Len: link.Length,
|
||||
// ARelTurnoutId: int32(aTurnoutId),
|
||||
// ARelTurnoutPoint: aPort,
|
||||
// BRelTurnoutId: int32(bTurnoutId),
|
||||
// BRelTurnoutPoint: bPort,
|
||||
// })
|
||||
// }
|
||||
// for _, slope := range vs.SlopeModelMap {
|
||||
// id, _ := strconv.Atoi(slope.Index)
|
||||
// slopes = append(slopes, &dynamics.Slope{
|
||||
// ID: int32(id),
|
||||
// StartLinkId: slope.StartLinkIndex,
|
||||
// StartLinkOffset: slope.StartLinkOffset,
|
||||
// EndLinkId: slope.EndLinkIndex,
|
||||
// EndLinkOffset: slope.EndLinkOffset,
|
||||
// DegreeTrig: slope.DegreeTrig,
|
||||
// })
|
||||
// }
|
||||
// for _, curve := range vs.CurveModelMap {
|
||||
// id, _ := strconv.Atoi(curve.Index)
|
||||
// curves = append(curves, &dynamics.Curve{
|
||||
// ID: int32(id),
|
||||
// StartLinkId: curve.StartLinkIndex,
|
||||
// StartLinkOffset: curve.StartLinkOffset,
|
||||
// EndLinkId: curve.EndLinkIndex,
|
||||
// EndLinkOffset: curve.EndLinkOffset,
|
||||
// Curvature: curve.Curvature,
|
||||
// })
|
||||
// }
|
||||
// return &dynamics.LineBaseInfo{
|
||||
// LinkList: links,
|
||||
// SlopeList: slopes,
|
||||
// CurveList: curves,
|
||||
// }
|
||||
//}
|
||||
|
||||
// 解析VOBC列车信息
|
||||
func decoderVobcTrainState(buf []byte) *state.TrainVobcState {
|
||||
trainVobcInfo := &state.TrainVobcState{}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package memory
|
||||
|
||||
import (
|
||||
"container/list"
|
||||
"fmt"
|
||||
"joylink.club/rtsssimulation/repository"
|
||||
"math"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"go.uber.org/zap"
|
||||
"joylink.club/rtsssimulation/repository"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
|
||||
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/face"
|
||||
@ -21,12 +20,30 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
graphicStorageMap sync.Map
|
||||
graphicStorageMap sync.Map
|
||||
graphicMapElementIdMap sync.Map
|
||||
//// 仿真存储集合 ID
|
||||
//graphicDataMap sync.Map
|
||||
//graphicSourceDataMap sync.Map
|
||||
)
|
||||
|
||||
type ElementIdStructure struct {
|
||||
CommonId string
|
||||
Index int32
|
||||
Uid string
|
||||
}
|
||||
|
||||
// 数组为Index为 common.Id, index, uid
|
||||
type GraphicMapElementIdStructure struct {
|
||||
AxlePointIds map[string]*ElementIdStructure
|
||||
TurnoutIds map[string]*ElementIdStructure
|
||||
PhysicalSectionIds map[string]*ElementIdStructure
|
||||
SignalIds map[string]*ElementIdStructure
|
||||
TransponderIds map[string]*ElementIdStructure
|
||||
SlopeIds map[string]*ElementIdStructure
|
||||
CurvatureIds map[string]*ElementIdStructure
|
||||
}
|
||||
|
||||
// VerifyStructure 轨旁仿真模型结构
|
||||
type VerifyStructure struct {
|
||||
//计轴检测点设备模型集合,key为索引编号
|
||||
@ -82,38 +99,7 @@ type calcLinkPositionStruct struct {
|
||||
}
|
||||
|
||||
// 将发布的地图数据放入内存中
|
||||
func PublishMapVerifyStructure(graphic *model.PublishedGi) *VerifyStructure {
|
||||
// 创建一个地图数据模型结构数据
|
||||
verifyStructure := &VerifyStructure{
|
||||
AxlePointDeviceModelMap: make(map[string]face.AxlePointDeviceModeller),
|
||||
SwitchDeviceModelMap: make(map[string]face.SwitchDeviceModeller),
|
||||
LinkSectionModelMap: make(map[string]face.LinkSectionModeller),
|
||||
AxleSectionModelMap: make(map[string]face.AxleSectionModeller),
|
||||
PhysicalSectionModelMap: make(map[string]face.PhysicalSectionModeller),
|
||||
LogicalSectionModelMap: make(map[string]face.LogicalSectionModeller),
|
||||
SignalDeviceModelMap: make(map[string]face.SignalDeviceModeller),
|
||||
LinkModelMap: make(map[int32]*device.LinkModel),
|
||||
SlopeModelMap: make(map[string]*section.SlopeModel),
|
||||
CurveModelMap: make(map[string]*section.CurveModel),
|
||||
PointMap: make(map[string]*device.PointModel),
|
||||
}
|
||||
// 地图数据转为map存储,建立关系时方便使用
|
||||
graphicInfoMap := &GraphicInfoMapStructure{
|
||||
AxlePointMap: make(map[string]*graphicData.AxleCounting),
|
||||
TurnoutMap: make(map[string]*graphicData.Turnout),
|
||||
SectionLinkMap: make(map[string]*graphicData.SectionLink),
|
||||
AxleSectionMap: make(map[string]*graphicData.AxleCountingSection),
|
||||
PhysicalSectionMap: make(map[string]*graphicData.Section),
|
||||
LogicSectionMap: make(map[string]*graphicData.LogicSection),
|
||||
SignalMap: make(map[string]*graphicData.Signal),
|
||||
CalcLinkMap: make(map[int32]*graphicData.CalculateLink),
|
||||
DevicePositionMap: make(map[string]*ref.DevicePosition[*device.LinkModel]),
|
||||
TransponderMap: make(map[string]*graphicData.Transponder),
|
||||
SlopeMap: make(map[string]*graphicData.Slope),
|
||||
SlopeKiloMarkerMap: make(map[string]*graphicData.SlopeKiloMarker),
|
||||
CurvatureMap: make(map[string]*graphicData.Curvature),
|
||||
CurvatureKiloMarkerMap: make(map[string]*graphicData.CurvatureKiloMarker),
|
||||
}
|
||||
func PublishMapVerifyStructure(graphic *model.PublishedGi) {
|
||||
graphicStorage := &graphicData.RtssGraphicStorage{}
|
||||
err := proto.Unmarshal(graphic.Proto, graphicStorage)
|
||||
if err != nil {
|
||||
@ -121,13 +107,152 @@ func PublishMapVerifyStructure(graphic *model.PublishedGi) *VerifyStructure {
|
||||
}
|
||||
graphicStorageMap.Store(graphic.ID, graphicStorage)
|
||||
// 初始化地图结构
|
||||
initGraphicStructure(graphicStorage, verifyStructure, graphicInfoMap)
|
||||
//// 构建设备间的关联关系(8.8 注释掉构建逻辑)
|
||||
//buildDeviceRef(graphicInfoMap, verifyStructure)
|
||||
//graphicDataMap.Store(graphic.ID, verifyStructure)
|
||||
//// 地图原始数据
|
||||
//graphicSourceDataMap.Store(graphic.ID, graphicInfoMap)
|
||||
return verifyStructure
|
||||
mapElementIdStructure := &GraphicMapElementIdStructure{
|
||||
AxlePointIds: make(map[string]*ElementIdStructure),
|
||||
TurnoutIds: make(map[string]*ElementIdStructure),
|
||||
PhysicalSectionIds: make(map[string]*ElementIdStructure),
|
||||
SignalIds: make(map[string]*ElementIdStructure),
|
||||
TransponderIds: make(map[string]*ElementIdStructure),
|
||||
SlopeIds: make(map[string]*ElementIdStructure),
|
||||
CurvatureIds: make(map[string]*ElementIdStructure),
|
||||
}
|
||||
initGraphicStructure(graphicStorage, mapElementIdStructure)
|
||||
graphicMapElementIdMap.Store(graphic.ID, mapElementIdStructure)
|
||||
}
|
||||
|
||||
// 通过地图Index获取Uid
|
||||
func GetDeviceUidByIndex(mapId, index int32, m interface{}) string {
|
||||
elementIdMap := getElementIdStructure(mapId, m)
|
||||
for _, elementId := range elementIdMap {
|
||||
if elementId.Index == index {
|
||||
return elementId.Uid
|
||||
}
|
||||
}
|
||||
panic(&dto.ErrorDto{Code: dto.DataNotExist, Message: "无ID映射信息"})
|
||||
}
|
||||
|
||||
// 通过地图CommonId获取Uid
|
||||
func GetDeviceUidByCommonId(mapId int32, commonId string, m interface{}) string {
|
||||
elementIdMap := getElementIdStructure(mapId, m)
|
||||
elementId := elementIdMap[commonId]
|
||||
if elementId != nil {
|
||||
return elementId.Uid
|
||||
}
|
||||
panic(&dto.ErrorDto{Code: dto.DataNotExist, Message: "无ID映射信息"})
|
||||
}
|
||||
|
||||
// 根据Uid获取地图Index
|
||||
func GetDeviceIndexByUid(mapId int32, uid string, m interface{}) int32 {
|
||||
elementIdMap := getElementIdStructure(mapId, m)
|
||||
for _, elementId := range elementIdMap {
|
||||
if elementId.Uid == uid {
|
||||
return elementId.Index
|
||||
}
|
||||
}
|
||||
panic(&dto.ErrorDto{Code: dto.DataNotExist, Message: "无ID映射信息"})
|
||||
}
|
||||
|
||||
// 获取元素的UID映射
|
||||
func getElementIdStructure(mapId int32, m interface{}) map[string]*ElementIdStructure {
|
||||
idStructure := getMapElementIdMap(mapId)
|
||||
switch m.(type) {
|
||||
case *graphicData.AxleCounting:
|
||||
return idStructure.AxlePointIds
|
||||
case *graphicData.Turnout:
|
||||
return idStructure.TurnoutIds
|
||||
case *graphicData.Section:
|
||||
return idStructure.PhysicalSectionIds
|
||||
case *graphicData.Signal:
|
||||
return idStructure.SignalIds
|
||||
case *graphicData.Transponder:
|
||||
return idStructure.TransponderIds
|
||||
case *graphicData.Slope:
|
||||
return idStructure.SlopeIds
|
||||
case *graphicData.Curvature:
|
||||
return idStructure.CurvatureIds
|
||||
default:
|
||||
panic(&dto.ErrorDto{Code: dto.ArgumentParseError, Message: "元素类型未映射ID"})
|
||||
}
|
||||
}
|
||||
|
||||
func getMapElementIdMap(mapId int32) *GraphicMapElementIdStructure {
|
||||
mapElementIdMap, ok := graphicMapElementIdMap.Load(mapId)
|
||||
if !ok {
|
||||
panic(&dto.ErrorDto{Code: dto.DataNotExist, Message: "无ID映射信息"})
|
||||
}
|
||||
return mapElementIdMap.(*GraphicMapElementIdStructure)
|
||||
}
|
||||
|
||||
// 初始化地图结构
|
||||
func initGraphicStructure(graphicData *graphicData.RtssGraphicStorage, mapElementIdMap *GraphicMapElementIdStructure) {
|
||||
// 初始化计轴信息
|
||||
for _, a := range graphicData.AxleCountings {
|
||||
mapElementIdMap.AxlePointIds[a.Common.Id] = &ElementIdStructure{
|
||||
CommonId: a.Common.Id,
|
||||
Index: a.Index,
|
||||
Uid: generateElementUid(graphicData.UniqueIdPrefix, a.Common.Id, a.CentralizedStations),
|
||||
}
|
||||
}
|
||||
// 初始化道岔信息
|
||||
for _, t := range graphicData.Turnouts {
|
||||
mapElementIdMap.TurnoutIds[t.Common.Id] = &ElementIdStructure{
|
||||
CommonId: t.Common.Id,
|
||||
Index: t.Index,
|
||||
Uid: generateElementUid(graphicData.UniqueIdPrefix, t.Common.Id, t.CentralizedStations),
|
||||
}
|
||||
}
|
||||
// 初始化物理区段信息
|
||||
for _, s := range graphicData.Section {
|
||||
mapElementIdMap.PhysicalSectionIds[s.Common.Id] = &ElementIdStructure{
|
||||
CommonId: s.Common.Id,
|
||||
Index: s.Index,
|
||||
Uid: generateElementUid(graphicData.UniqueIdPrefix, s.Common.Id, s.CentralizedStations),
|
||||
}
|
||||
}
|
||||
// 初始化信号机信息
|
||||
for _, s := range graphicData.Signals {
|
||||
mapElementIdMap.SignalIds[s.Common.Id] = &ElementIdStructure{
|
||||
CommonId: s.Common.Id,
|
||||
Index: s.Index,
|
||||
Uid: generateElementUid(graphicData.UniqueIdPrefix, s.Common.Id, s.CentralizedStations),
|
||||
}
|
||||
}
|
||||
// 初始化应答器
|
||||
for _, t := range graphicData.Transponders {
|
||||
mapElementIdMap.TransponderIds[t.Common.Id] = &ElementIdStructure{
|
||||
CommonId: t.Common.Id,
|
||||
Index: t.Index,
|
||||
Uid: generateElementUid(graphicData.UniqueIdPrefix, t.Common.Id, t.CentralizedStations),
|
||||
}
|
||||
}
|
||||
// 初始化坡度
|
||||
for _, s := range graphicData.Slopes {
|
||||
mapElementIdMap.SlopeIds[s.Common.Id] = &ElementIdStructure{
|
||||
CommonId: s.Common.Id,
|
||||
Index: 0,
|
||||
Uid: generateElementUid(graphicData.UniqueIdPrefix, s.Common.Id, nil),
|
||||
}
|
||||
}
|
||||
// 初始化曲线
|
||||
for _, c := range graphicData.Curvatures {
|
||||
mapElementIdMap.CurvatureIds[c.Common.Id] = &ElementIdStructure{
|
||||
CommonId: c.Common.Id,
|
||||
Index: 0,
|
||||
Uid: generateElementUid(graphicData.UniqueIdPrefix, c.Common.Id, nil),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 生成Uid, 等加上集中站再做修改
|
||||
func generateElementUid(ui *graphicData.UniqueIdOfStationLayout, code string, stationName []string) string {
|
||||
sort.Strings(stationName)
|
||||
var idArr []string
|
||||
if ui != nil {
|
||||
idArr = append(idArr, ui.City, ui.LineId)
|
||||
}
|
||||
idArr = append(idArr, stationName...)
|
||||
idArr = append(idArr, code)
|
||||
return strings.Join(idArr, "_")
|
||||
}
|
||||
|
||||
// 移除内存中的地图信息
|
||||
@ -159,16 +284,6 @@ func QueryMapVerifyStructure(mapId int32) *VerifyStructure {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 获取内存中地图原始信息
|
||||
func QueryMapSourceDataStructure(mapId int32) *GraphicInfoMapStructure {
|
||||
//d, ok := graphicSourceDataMap.Load(mapId)
|
||||
//if ok {
|
||||
// return d.(*GraphicInfoMapStructure)
|
||||
//}
|
||||
//panic(fmt.Sprintf("地图【id:%d】数据不存在", mapId))
|
||||
return nil
|
||||
}
|
||||
|
||||
// 根据区段,道岔偏移量返回linkID和link相对偏移量
|
||||
func QueryMapCalcLinkByDeviceInfo(mapId int32, id string, devicePort string, offset int64, runDirection bool) (int32, int64, bool, bool, int64) {
|
||||
vm := QueryMapVerifyStructure(mapId)
|
||||
@ -528,608 +643,6 @@ func QueryDeviceByCalcLink(repo *repository.Repository, id int32, offset int64,
|
||||
// }
|
||||
//}
|
||||
|
||||
func linkOffsetQuerySection(vm *VerifyStructure, devicePosition, calcPosition *calcLinkPositionStruct) (*section.PhysicalSectionModel, bool) {
|
||||
var sectionModel *section.PhysicalSectionModel
|
||||
for _, s := range vm.PhysicalSectionModelMap {
|
||||
sectionModel = s.(*section.PhysicalSectionModel)
|
||||
if sectionModel.AxlePoints[devicePosition.index] != nil && (calcPosition == nil || sectionModel.AxlePoints[calcPosition.index] != nil) {
|
||||
return sectionModel, true
|
||||
}
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// 初始化地图结构
|
||||
func initGraphicStructure(graphicData *graphicData.RtssGraphicStorage, verifyStructure *VerifyStructure, graphicDataMap *GraphicInfoMapStructure) {
|
||||
// 初始化计轴信息
|
||||
initGraphicAxlePoints(graphicData.AxleCountings, verifyStructure, graphicDataMap)
|
||||
// 初始化道岔信息
|
||||
initGraphicTurnout(graphicData.Turnouts, verifyStructure, graphicDataMap)
|
||||
// 初始化link信息
|
||||
initGraphicLink(graphicData.SectionLinks, verifyStructure, graphicDataMap)
|
||||
// 初始化计轴区段信息
|
||||
initGraphicAxleSection(graphicData.AxleCountingSections, verifyStructure, graphicDataMap)
|
||||
// 初始化物理区段信息
|
||||
initGraphicPhysicalSections(graphicData.Section, verifyStructure, graphicDataMap)
|
||||
// 初始化逻辑区段信息
|
||||
initGraphicLogicSections(graphicData.LogicSections, verifyStructure, graphicDataMap)
|
||||
// 初始化信号机信息
|
||||
initGraphicSignal(graphicData.Signals, verifyStructure, graphicDataMap)
|
||||
// 初始化坡度和曲线端点
|
||||
initPoints(graphicData, verifyStructure, graphicDataMap)
|
||||
// 初始化Link信息
|
||||
initLinks(graphicData.CalculateLink, verifyStructure, graphicDataMap)
|
||||
// 初始化坡度
|
||||
initSlopes(graphicData.Slopes, verifyStructure, graphicDataMap)
|
||||
// 初始化曲线
|
||||
initCurves(graphicData.Curvatures, verifyStructure, graphicDataMap)
|
||||
// 初始化应答器
|
||||
initTransponder(graphicData.Transponders, graphicDataMap)
|
||||
}
|
||||
|
||||
func initCurves(curves []*graphicData.Curvature, vs *VerifyStructure, dataMap *GraphicInfoMapStructure) {
|
||||
for _, curve := range curves {
|
||||
dataMap.CurvatureMap[curve.Common.Id] = curve
|
||||
c := §ion.CurveModel{
|
||||
DeviceModel: face.DeviceModel{
|
||||
GraphicId: curve.GetCommon().GetId(),
|
||||
Index: curve.GetCommon().GetId(),
|
||||
},
|
||||
Curvature: curve.CurvatureNumber,
|
||||
}
|
||||
startDp := dataMap.DevicePositionMap[curve.RefDeviceId[0]]
|
||||
if startDp != nil {
|
||||
startIndex, _ := strconv.Atoi(startDp.Device.GetIndex())
|
||||
c.StartLinkIndex = int32(startIndex)
|
||||
c.StartLinkOffset = startDp.Offset
|
||||
}
|
||||
endDp := dataMap.DevicePositionMap[curve.RefDeviceId[1]]
|
||||
if endDp != nil {
|
||||
endIndex, _ := strconv.Atoi(endDp.Device.GetIndex())
|
||||
c.EndLinkIndex = int32(endIndex)
|
||||
c.EndLinkOffset = endDp.Offset
|
||||
}
|
||||
vs.CurveModelMap[curve.Common.Id] = c
|
||||
}
|
||||
}
|
||||
|
||||
func initSlopes(slopes []*graphicData.Slope, vs *VerifyStructure, dataMap *GraphicInfoMapStructure) {
|
||||
for _, slope := range slopes {
|
||||
dataMap.SlopeMap[slope.Common.Id] = slope
|
||||
s := §ion.SlopeModel{
|
||||
DeviceModel: face.DeviceModel{
|
||||
GraphicId: slope.GetCommon().GetId(),
|
||||
Index: slope.GetCommon().GetId(),
|
||||
},
|
||||
DegreeTrig: slope.SlopeNumber,
|
||||
}
|
||||
startDp := dataMap.DevicePositionMap[slope.RefDeviceId[0]]
|
||||
if startDp != nil {
|
||||
startIndex, _ := strconv.Atoi(startDp.Device.GetIndex())
|
||||
s.StartLinkIndex = int32(startIndex)
|
||||
s.StartLinkOffset = startDp.Offset
|
||||
}
|
||||
endDp := dataMap.DevicePositionMap[slope.RefDeviceId[1]]
|
||||
if endDp != nil {
|
||||
endIndex, _ := strconv.Atoi(endDp.Device.GetIndex())
|
||||
s.EndLinkIndex = int32(endIndex)
|
||||
s.EndLinkOffset = endDp.Offset
|
||||
}
|
||||
vs.SlopeModelMap[slope.Common.Id] = s
|
||||
}
|
||||
}
|
||||
|
||||
func initPoints(storage *graphicData.RtssGraphicStorage, vs *VerifyStructure, dataMap *GraphicInfoMapStructure) {
|
||||
for _, slopeKm := range storage.SlopeKiloMarker {
|
||||
dataMap.SlopeKiloMarkerMap[slopeKm.Common.Id] = slopeKm
|
||||
vs.PointMap[slopeKm.Common.Id] = &device.PointModel{
|
||||
DeviceModel: face.DeviceModel{
|
||||
GraphicId: slopeKm.Common.Id,
|
||||
Index: slopeKm.Common.Id,
|
||||
},
|
||||
Kms: slopeKm.KilometerSystem,
|
||||
}
|
||||
}
|
||||
for _, curvatureKm := range storage.CurvatureKiloMarker {
|
||||
dataMap.CurvatureKiloMarkerMap[curvatureKm.Common.Id] = curvatureKm
|
||||
vs.PointMap[curvatureKm.Common.Id] = &device.PointModel{
|
||||
DeviceModel: face.DeviceModel{
|
||||
GraphicId: curvatureKm.Common.Id,
|
||||
Index: curvatureKm.Common.Id,
|
||||
},
|
||||
Kms: curvatureKm.KilometerSystem,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func initLinks(links []*graphicData.CalculateLink, vs *VerifyStructure, dataMap *GraphicInfoMapStructure) {
|
||||
deviceIdMap := make(map[string]face.DeviceModeller)
|
||||
for _, modeller := range vs.AxlePointDeviceModelMap {
|
||||
deviceIdMap[modeller.GetGraphicId()] = modeller
|
||||
}
|
||||
for _, modeller := range vs.SwitchDeviceModelMap {
|
||||
deviceIdMap[modeller.GetGraphicId()] = modeller
|
||||
}
|
||||
for _, pointModel := range vs.PointMap {
|
||||
deviceIdMap[pointModel.GetGraphicId()] = pointModel
|
||||
}
|
||||
|
||||
for _, link := range links {
|
||||
linkModel := &device.LinkModel{
|
||||
DeviceModel: face.DeviceModel{
|
||||
GraphicId: link.Common.Id,
|
||||
Index: strconv.Itoa(int(link.Index)),
|
||||
},
|
||||
Length: link.Length,
|
||||
}
|
||||
if link.ARelatedRef != nil {
|
||||
modeller := deviceIdMap[link.ARelatedRef.Id]
|
||||
port := face.GetPortEnum(int8(link.ARelatedRef.DevicePort))
|
||||
linkModel.ARelatedSwitchRef = &ref.SwitchRef{
|
||||
SwitchDevice: modeller,
|
||||
Port: port,
|
||||
}
|
||||
turnoutModel, ok := modeller.(*device.SwitchDeviceModel)
|
||||
if ok {
|
||||
linkPort := &ref.DevicePort[*device.LinkModel]{
|
||||
Device: linkModel,
|
||||
Port: face.A,
|
||||
}
|
||||
switch port {
|
||||
case face.A:
|
||||
turnoutModel.ALinkPort = linkPort
|
||||
case face.B:
|
||||
turnoutModel.BLinkPort = linkPort
|
||||
case face.C:
|
||||
turnoutModel.CLinkPort = linkPort
|
||||
}
|
||||
}
|
||||
}
|
||||
if link.BRelatedRef != nil {
|
||||
modeller := deviceIdMap[link.ARelatedRef.Id]
|
||||
port := face.GetPortEnum(int8(link.ARelatedRef.DevicePort))
|
||||
linkModel.BRelatedSwitchRef = &ref.SwitchRef{
|
||||
SwitchDevice: deviceIdMap[link.BRelatedRef.Id],
|
||||
Port: face.GetPortEnum(int8(link.BRelatedRef.DevicePort)),
|
||||
}
|
||||
turnoutModel, ok := modeller.(*device.SwitchDeviceModel)
|
||||
if ok {
|
||||
linkPort := &ref.DevicePort[*device.LinkModel]{
|
||||
Device: linkModel,
|
||||
Port: face.B,
|
||||
}
|
||||
switch port {
|
||||
case face.A:
|
||||
turnoutModel.ALinkPort = linkPort
|
||||
case face.B:
|
||||
turnoutModel.BLinkPort = linkPort
|
||||
case face.C:
|
||||
turnoutModel.CLinkPort = linkPort
|
||||
}
|
||||
}
|
||||
}
|
||||
vs.LinkModelMap[link.Index] = linkModel
|
||||
dataMap.CalcLinkMap[link.Index] = link
|
||||
//构建DevicePosition(DP)切片
|
||||
var dps []*ref.DevicePosition[face.DeviceModeller]
|
||||
for _, dp := range link.DevicePositions {
|
||||
modeller := deviceIdMap[dp.DeviceId]
|
||||
if modeller == nil {
|
||||
continue
|
||||
}
|
||||
dps = append(dps, &ref.DevicePosition[face.DeviceModeller]{
|
||||
Device: modeller,
|
||||
Offset: dp.Offset,
|
||||
})
|
||||
dataMap.DevicePositionMap[dp.DeviceId] = &ref.DevicePosition[*device.LinkModel]{
|
||||
Device: linkModel,
|
||||
Offset: dp.Offset,
|
||||
}
|
||||
}
|
||||
//对DP切片按Offset排序
|
||||
sort.Slice(dps, func(i, j int) bool {
|
||||
return dps[i].Offset < dps[j].Offset
|
||||
})
|
||||
//赋值
|
||||
linkModel.DevicePositions = dps
|
||||
}
|
||||
}
|
||||
|
||||
func initTransponder(transponders []*graphicData.Transponder, dataMap *GraphicInfoMapStructure) {
|
||||
for _, t := range transponders {
|
||||
dataMap.TransponderMap[t.Common.Id] = t
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化计轴信息
|
||||
func initGraphicAxlePoints(axlePoints []*graphicData.AxleCounting, data *VerifyStructure, graphicDataMap *GraphicInfoMapStructure) {
|
||||
for _, a := range axlePoints {
|
||||
graphicDataMap.AxlePointMap[a.Common.Id] = a
|
||||
id := strconv.Itoa(int(a.Index))
|
||||
data.AxlePointDeviceModelMap[id] = &device.AxlePointDeviceModel{
|
||||
DeviceModel: face.DeviceModel{
|
||||
GraphicId: a.Common.Id,
|
||||
Index: id,
|
||||
},
|
||||
KilometerSystem: a.GetKilometerSystem(),
|
||||
SwitchDevices: make(map[string]*ref.SwitchRef),
|
||||
AreaPhysicalSections: make(map[string]face.PhysicalSectionModeller),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化道岔信息
|
||||
func initGraphicTurnout(turnouts []*graphicData.Turnout, data *VerifyStructure, graphicDataMap *GraphicInfoMapStructure) {
|
||||
for _, t := range turnouts {
|
||||
graphicDataMap.TurnoutMap[t.Common.Id] = t
|
||||
id := strconv.Itoa(int(t.Index))
|
||||
data.SwitchDeviceModelMap[id] = &device.SwitchDeviceModel{
|
||||
DeviceModel: face.DeviceModel{
|
||||
GraphicId: t.Common.Id,
|
||||
Index: id,
|
||||
},
|
||||
KilometerSystems: t.GetKilometerSystem(),
|
||||
AxlePoints: make(map[string]*device.AxlePointDeviceModel),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化link信息
|
||||
func initGraphicLink(links []*graphicData.SectionLink, data *VerifyStructure, graphicDataMap *GraphicInfoMapStructure) {
|
||||
for _, s := range links {
|
||||
graphicDataMap.SectionLinkMap[s.Common.Id] = s
|
||||
id := strconv.Itoa(int(s.Index))
|
||||
data.LinkSectionModelMap[id] = §ion.LinkSectionModel{
|
||||
DeviceModel: face.DeviceModel{
|
||||
GraphicId: s.Common.Id,
|
||||
Index: id,
|
||||
},
|
||||
Up: s.Up,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化计轴区段信息
|
||||
func initGraphicAxleSection(axleSections []*graphicData.AxleCountingSection, data *VerifyStructure, graphicDataMap *GraphicInfoMapStructure) {
|
||||
for _, s := range axleSections {
|
||||
graphicDataMap.AxleSectionMap[s.Common.Id] = s
|
||||
id := strconv.Itoa(int(s.Index))
|
||||
data.AxleSectionModelMap[id] = §ion.AxleSectionModel{
|
||||
DeviceModel: face.DeviceModel{
|
||||
GraphicId: s.Common.Id,
|
||||
Index: id,
|
||||
},
|
||||
ViaSwitchPositions: list.New(),
|
||||
ViaLinks: list.New(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化物理区段信息
|
||||
func initGraphicPhysicalSections(physicalSections []*graphicData.Section, data *VerifyStructure, graphicDataMap *GraphicInfoMapStructure) {
|
||||
for _, s := range physicalSections {
|
||||
graphicDataMap.PhysicalSectionMap[s.Common.Id] = s
|
||||
id := strconv.Itoa(int(s.Index))
|
||||
data.PhysicalSectionModelMap[id] = §ion.PhysicalSectionModel{
|
||||
DeviceModel: face.DeviceModel{
|
||||
GraphicId: s.Common.Id,
|
||||
Index: id,
|
||||
},
|
||||
SwitchArea: len(s.AxleCountings) > 2,
|
||||
AxlePoints: make(map[string]face.AxlePointDeviceModeller),
|
||||
AxleSections: make(map[string]face.AxleSectionModeller),
|
||||
PortAxlePoints: make(map[string]face.AxlePointDeviceModeller),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化逻辑区段信息
|
||||
func initGraphicLogicSections(logicSections []*graphicData.LogicSection, data *VerifyStructure, graphicDataMap *GraphicInfoMapStructure) {
|
||||
for _, s := range logicSections {
|
||||
graphicDataMap.LogicSectionMap[s.Common.Id] = s
|
||||
id := strconv.Itoa(int(s.Index))
|
||||
data.LogicalSectionModelMap[id] = §ion.LogicalSectionModel{
|
||||
DeviceModel: face.DeviceModel{
|
||||
GraphicId: s.Common.Id,
|
||||
Index: id,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化信号机信息
|
||||
func initGraphicSignal(signals []*graphicData.Signal, data *VerifyStructure, graphicDataMap *GraphicInfoMapStructure) {
|
||||
for _, s := range signals {
|
||||
graphicDataMap.SignalMap[s.Common.Id] = s
|
||||
id := strconv.Itoa(int(s.Index))
|
||||
kilometerSystem := &graphicData.KilometerSystem{}
|
||||
if s.KilometerSystem != nil {
|
||||
kilometerSystem.CoordinateSystem = s.KilometerSystem.CoordinateSystem
|
||||
kilometerSystem.Kilometer = s.KilometerSystem.Kilometer
|
||||
}
|
||||
data.SignalDeviceModelMap[id] = &device.SignalDeviceModel{
|
||||
DeviceModel: face.DeviceModel{
|
||||
GraphicId: s.Common.Id,
|
||||
Index: id,
|
||||
},
|
||||
KilometerSystem: kilometerSystem,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 构建设备间的关系
|
||||
func buildDeviceRef(graphicData *GraphicInfoMapStructure, verifyStructure *VerifyStructure) {
|
||||
// 构建link的关联关系
|
||||
buildLinkDeviceRef(graphicData, verifyStructure)
|
||||
// 道岔,分析轨道中轨道与道岔的关系来构建道岔与轨道的关系
|
||||
buildTurnoutDeviceRef(verifyStructure)
|
||||
// 计轴区段
|
||||
buildAxleSectionDeviceRef(graphicData, verifyStructure)
|
||||
// 物理区段
|
||||
buildPhysicalSectionsDeviceRef(graphicData, verifyStructure)
|
||||
// 逻辑区段
|
||||
buildLogicSectionsDeviceRef(graphicData, verifyStructure)
|
||||
// 计轴检测点-从计轴点角度(非岔区物理区段和道岔)
|
||||
buildAxlePointDeviceRef(graphicData, verifyStructure)
|
||||
// 计轴检测点-从物理区段角度
|
||||
buildPhysicalAxlePointDeviceRef(verifyStructure)
|
||||
}
|
||||
|
||||
// 构建link的关联关系(端点间的轨道)
|
||||
func buildLinkDeviceRef(mapData *GraphicInfoMapStructure, verifyStructure *VerifyStructure) {
|
||||
for _, v := range mapData.SectionLinkMap {
|
||||
link := (verifyStructure.LinkSectionModelMap[strconv.Itoa(int(v.Index))]).(*section.LinkSectionModel)
|
||||
// 轨道A端端点
|
||||
linkSimRefBuildCommMethod(v.Common.Id, v.ASimRef, mapData, verifyStructure, func(f face.AxlePointDeviceModeller) {
|
||||
link.AxlePointA = f
|
||||
}, func(t *ref.SwitchRef) {
|
||||
link.SwitchRefA = t
|
||||
})
|
||||
// 轨道B端端点
|
||||
linkSimRefBuildCommMethod(v.Common.Id, v.BSimRef, mapData, verifyStructure, func(f face.AxlePointDeviceModeller) {
|
||||
link.AxlePointB = f
|
||||
}, func(t *ref.SwitchRef) {
|
||||
link.SwitchRefB = t
|
||||
})
|
||||
// A端点关联设备
|
||||
linkRefBuildCommMethod(v, mapData, verifyStructure, func() *graphicData.RelatedRef {
|
||||
return v.ARef
|
||||
}, func(l *ref.LinkRef) {
|
||||
link.LinkRefA = l
|
||||
}, func(pe face.PortEnum) {
|
||||
link.SwitchRefA.Port = pe
|
||||
})
|
||||
// B端点关联设备
|
||||
linkRefBuildCommMethod(v, mapData, verifyStructure, func() *graphicData.RelatedRef {
|
||||
return v.BRef
|
||||
}, func(l *ref.LinkRef) {
|
||||
link.LinkRefB = l
|
||||
}, func(pe face.PortEnum) {
|
||||
link.SwitchRefB.Port = pe
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func linkSimRefBuildCommMethod(linkGraphicId string, simRef *graphicData.SimpleRef, mapData *GraphicInfoMapStructure, verifyStructure *VerifyStructure,
|
||||
fp func(face.AxlePointDeviceModeller), ft func(*ref.SwitchRef)) {
|
||||
switch simRef.DeviceType {
|
||||
case graphicData.SimpleRef_AxleCounting:
|
||||
axlePoint := mapData.AxlePointMap[simRef.Id]
|
||||
if axlePoint != nil {
|
||||
fp(verifyStructure.AxlePointDeviceModelMap[strconv.Itoa(int(axlePoint.Index))])
|
||||
} else {
|
||||
zap.S().Warnf("id为[%s]的轨道的计轴端点[%s]不存在", linkGraphicId, simRef.Id)
|
||||
}
|
||||
case graphicData.SimpleRef_Turnout:
|
||||
turnout := mapData.TurnoutMap[simRef.Id]
|
||||
if turnout != nil {
|
||||
ft(&ref.SwitchRef{SwitchDevice: verifyStructure.SwitchDeviceModelMap[strconv.Itoa(int(turnout.Index))]})
|
||||
} else {
|
||||
zap.S().Warnf("id为[%s]的轨道的道岔端点[%s]不存在", linkGraphicId, simRef.Id)
|
||||
}
|
||||
default:
|
||||
zap.S().Warnf("link[%s]端点设备类型[%v]未关联", linkGraphicId, simRef.DeviceType)
|
||||
}
|
||||
}
|
||||
|
||||
func linkRefBuildCommMethod(v *graphicData.SectionLink, mapData *GraphicInfoMapStructure, verifyStructure *VerifyStructure,
|
||||
gr func() *graphicData.RelatedRef, lr func(*ref.LinkRef), ft func(face.PortEnum)) {
|
||||
r := gr()
|
||||
if r != nil {
|
||||
switch r.DeviceType {
|
||||
case graphicData.RelatedRef_SectionLink:
|
||||
d := mapData.SectionLinkMap[r.Id]
|
||||
if d != nil {
|
||||
ls := verifyStructure.LinkSectionModelMap[strconv.Itoa(int(d.Index))]
|
||||
lr(&ref.LinkRef{LinkSection: ls, Port: face.PortEnum(r.DevicePort)})
|
||||
} else {
|
||||
zap.S().Warnf("id为[%s]的轨道的连接的轨道[%s]不存在", v.Common.Id, r.Id)
|
||||
}
|
||||
case graphicData.RelatedRef_Turnout:
|
||||
t := mapData.TurnoutMap[r.Id]
|
||||
if t != nil {
|
||||
ft(face.PortEnum(v.ARef.DevicePort))
|
||||
} else {
|
||||
zap.S().Warnf("id为[%s]的轨道的连接的道岔[%s]不存在", v.Common.Id, r.Id)
|
||||
}
|
||||
default:
|
||||
zap.S().Warnf("link[%s]端点设备类型[%v]未关联", v.Common.Id, r.DeviceType)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 道岔,分析轨道中轨道与道岔的关系来构建道岔与轨道的关系
|
||||
func buildTurnoutDeviceRef(verifyStructure *VerifyStructure) {
|
||||
for _, v := range verifyStructure.LinkSectionModelMap {
|
||||
s := v.(*section.LinkSectionModel)
|
||||
buildTurnoutCommMethod(s, s.SwitchRefA, face.A)
|
||||
buildTurnoutCommMethod(s, s.SwitchRefB, face.B)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func buildTurnoutCommMethod(s *section.LinkSectionModel, linkSwitch *ref.SwitchRef, p face.PortEnum) {
|
||||
if linkSwitch != nil {
|
||||
switchDevice := (linkSwitch.SwitchDevice).(*device.SwitchDeviceModel)
|
||||
switch linkSwitch.Port {
|
||||
case face.A:
|
||||
switchDevice.LinkRefA = &ref.LinkRef{LinkSection: s, Port: p}
|
||||
case face.B:
|
||||
switchDevice.LinkRefB = &ref.LinkRef{LinkSection: s, Port: p}
|
||||
case face.C:
|
||||
switchDevice.LinkRefC = &ref.LinkRef{LinkSection: s, Port: p}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 计轴区段
|
||||
func buildAxleSectionDeviceRef(mapData *GraphicInfoMapStructure, verifyStructure *VerifyStructure) {
|
||||
for _, v := range mapData.AxleSectionMap {
|
||||
axleSectionModel := (verifyStructure.AxleSectionModelMap[strconv.Itoa(int(v.Index))]).(*section.AxleSectionModel)
|
||||
//计轴区段A端计轴检测点
|
||||
axleCountingA := mapData.AxlePointMap[v.PaRef.Id]
|
||||
if axleCountingA != nil {
|
||||
axlePointDeviceModelA := verifyStructure.AxlePointDeviceModelMap[strconv.Itoa(int(axleCountingA.Index))]
|
||||
axleSectionModel.AxlePointA = axlePointDeviceModelA
|
||||
} else {
|
||||
zap.S().Warnf("id为[%s]的计轴区段的A端关联的计轴点[%s]不存在", v.Common.Id, v.PaRef.Id)
|
||||
}
|
||||
//计轴区段B端计轴检测点
|
||||
axleCountingB := mapData.AxlePointMap[v.PbRef.Id]
|
||||
if axleCountingB != nil {
|
||||
axlePointDeviceModelB := verifyStructure.AxlePointDeviceModelMap[strconv.Itoa(int(axleCountingB.Index))]
|
||||
axleSectionModel.AxlePointB = axlePointDeviceModelB
|
||||
} else {
|
||||
zap.S().Warnf("id为[%s]的计轴区段的B端关联的计轴点[%s]不存在", v.Common.Id, v.PbRef.Id)
|
||||
}
|
||||
//如果该计轴区段在岔区,则描述在该计轴区段中的道岔的位置
|
||||
vaildMap := make(map[string]int)
|
||||
for _, turnoutPosRef := range v.TurnoutPos {
|
||||
turnout := mapData.TurnoutMap[turnoutPosRef.Id]
|
||||
if turnout != nil {
|
||||
switchDeviceModel := (verifyStructure.SwitchDeviceModelMap[strconv.Itoa(int(turnout.Index))]).(*device.SwitchDeviceModel)
|
||||
positionRef := &ref.SwitchPositionRef{SwitchDevice: switchDeviceModel, Normal: turnoutPosRef.Position == 0}
|
||||
// 校验道岔设备只能添加一次 todo
|
||||
if vaildMap[switchDeviceModel.Index] == 0 {
|
||||
vaildMap[switchDeviceModel.Index] = 1
|
||||
} else {
|
||||
zap.S().Warnf("id为[%s]的计轴区段经过的道岔[%s]的次数大于1", v.Common.Id, turnoutPosRef.Id)
|
||||
}
|
||||
axleSectionModel.ViaSwitchPositions.PushBack(positionRef)
|
||||
} else {
|
||||
zap.S().Warnf("id为[%s]的计轴区段经过的道岔[%s]不存在", v.Common.Id, turnoutPosRef.Id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 物理区段
|
||||
func buildPhysicalSectionsDeviceRef(mapData *GraphicInfoMapStructure, verifyStructure *VerifyStructure) {
|
||||
for id, physicalSection := range mapData.PhysicalSectionMap {
|
||||
physicalSectionModel := (verifyStructure.PhysicalSectionModelMap[strconv.Itoa(int(physicalSection.Index))]).(*section.PhysicalSectionModel)
|
||||
for _, axlePointId := range physicalSection.AxleCountings {
|
||||
axlePoint := mapData.AxlePointMap[axlePointId]
|
||||
if axlePoint != nil {
|
||||
axlePointDevice := (verifyStructure.AxlePointDeviceModelMap[strconv.Itoa(int(axlePoint.Index))]).(*device.AxlePointDeviceModel)
|
||||
physicalSectionModel.AxlePoints[axlePointDevice.Index] = axlePointDevice
|
||||
} else {
|
||||
zap.S().Warnf("id为[%s]的物理区段的关联计轴点[%s]不存在", id, axlePointId)
|
||||
}
|
||||
}
|
||||
pl := len(physicalSectionModel.AxlePoints)
|
||||
if physicalSectionModel.SwitchArea {
|
||||
if pl <= 2 {
|
||||
zap.S().Warnf("id为[%s]的岔区物理区段的计轴检测点数量为[%d]", id, pl)
|
||||
}
|
||||
} else {
|
||||
if pl != 2 {
|
||||
zap.S().Warnf("id为[%s]的非岔区物理区段的计轴检测点数量为[%d]", id, pl)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 逻辑区段
|
||||
func buildLogicSectionsDeviceRef(mapData *GraphicInfoMapStructure, verifyStructure *VerifyStructure) {
|
||||
for id, logicSection := range mapData.LogicSectionMap {
|
||||
logicalSectionModel := (verifyStructure.LogicalSectionModelMap[strconv.Itoa(int(logicSection.Index))]).(*section.LogicalSectionModel)
|
||||
axleCountingSection := mapData.AxleSectionMap[logicSection.AxleSectionId]
|
||||
if axleCountingSection == nil {
|
||||
zap.S().Warnf("id为[%s]的逻辑区段所在的计轴区段[%s]不存在", id, logicSection.AxleSectionId)
|
||||
} else {
|
||||
sectionModeller := verifyStructure.AxleSectionModelMap[strconv.Itoa(int(axleCountingSection.Index))]
|
||||
if sectionModeller != nil {
|
||||
axleSectionModel := sectionModeller.(*section.AxleSectionModel)
|
||||
logicalSectionModel.AxleSection = axleSectionModel
|
||||
}
|
||||
}
|
||||
if logicSection.TurnoutId != "" {
|
||||
turnout := mapData.TurnoutMap[logicSection.TurnoutId]
|
||||
if turnout != nil {
|
||||
logicalSectionModel.SwitchDevice = verifyStructure.SwitchDeviceModelMap[strconv.Itoa(int(turnout.Index))]
|
||||
} else {
|
||||
zap.S().Warnf("id为[%s]的逻辑区段所在的道岔[%s]不存在", id, logicSection.TurnoutId)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 计轴检测点-从计轴点角度(非岔区物理区段和道岔)
|
||||
func buildAxlePointDeviceRef(mapData *GraphicInfoMapStructure, verifyStructure *VerifyStructure) {
|
||||
for id, axlePoint := range mapData.AxlePointMap {
|
||||
axlePointDeviceModel := (verifyStructure.AxlePointDeviceModelMap[strconv.Itoa(int(axlePoint.Index))]).(*device.AxlePointDeviceModel)
|
||||
for _, relatedRef := range axlePoint.AxleCountingRef {
|
||||
switch relatedRef.DeviceType {
|
||||
case graphicData.RelatedRef_Turnout:
|
||||
turnout := mapData.TurnoutMap[relatedRef.Id]
|
||||
if turnout == nil {
|
||||
zap.S().Warnf("id为[%s]的计轴检测点关联的道岔[%s]不存在", id, relatedRef.Id)
|
||||
} else {
|
||||
switchDeviceModeller := verifyStructure.SwitchDeviceModelMap[strconv.Itoa(int(turnout.Index))]
|
||||
if switchDeviceModeller != nil {
|
||||
switchDeviceModel := switchDeviceModeller.(*device.SwitchDeviceModel)
|
||||
// 道岔端口对应的计轴
|
||||
switchDeviceModel.AxlePoints[relatedRef.DevicePort.String()] = axlePointDeviceModel
|
||||
axlePointDeviceModel.SwitchDevices[switchDeviceModel.Index] = &ref.SwitchRef{
|
||||
SwitchDevice: switchDeviceModel,
|
||||
Port: face.PortEnum(relatedRef.DevicePort),
|
||||
}
|
||||
}
|
||||
}
|
||||
case graphicData.RelatedRef_Section:
|
||||
s := mapData.PhysicalSectionMap[relatedRef.Id]
|
||||
if s == nil {
|
||||
zap.S().Warnf("id为[%s]的计轴检测点关联的物理区段[%s]不存在", id, relatedRef.Id)
|
||||
} else {
|
||||
physicalSectionModeller := verifyStructure.PhysicalSectionModelMap[strconv.Itoa(int(s.Index))]
|
||||
physicalSectionModel := physicalSectionModeller.(*section.PhysicalSectionModel)
|
||||
if physicalSectionModel.SwitchArea {
|
||||
zap.S().Warnf("id为[%s]的计轴检测点proto数据关联岔区物理区段[%s]不存在", id, relatedRef.Id)
|
||||
}
|
||||
physicalSectionModel.PortAxlePoints[relatedRef.DevicePort.String()] = axlePointDeviceModel
|
||||
switch relatedRef.DevicePort {
|
||||
case graphicData.RelatedRef_A:
|
||||
axlePointDeviceModel.LinePhysicalSectionA = physicalSectionModel
|
||||
case graphicData.RelatedRef_B:
|
||||
axlePointDeviceModel.LinePhysicalSectionB = physicalSectionModel
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 计轴检测点-从物理区段角度
|
||||
func buildPhysicalAxlePointDeviceRef(verifyStructure *VerifyStructure) {
|
||||
for _, v := range verifyStructure.PhysicalSectionModelMap {
|
||||
physicalSection := v.(*section.PhysicalSectionModel)
|
||||
for _, a := range physicalSection.AxlePoints {
|
||||
axlePointDeviceModel := a.(*device.AxlePointDeviceModel)
|
||||
axlePointDeviceModel.AreaPhysicalSections[physicalSection.Index] = physicalSection
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 将linkPosition转换为计算对象
|
||||
func convertPositionToCalcPosition(link *device.LinkModel) []*calcLinkPositionStruct {
|
||||
result := []*calcLinkPositionStruct{}
|
||||
|
@ -32,3 +32,9 @@ func GetAllPhysicalSectionState(simulation *VerifySimulation) []*state.SectionSt
|
||||
})
|
||||
return sectionArr
|
||||
}
|
||||
|
||||
// 获取地图全部的物理区段状态
|
||||
func GetMapAllPhysicalSectionState(simulation *VerifySimulation, mid string) []*state.SectionState {
|
||||
var sectionArr []*state.SectionState
|
||||
return sectionArr
|
||||
}
|
||||
|
@ -131,6 +131,12 @@ func GetAllTrainState(vs *VerifySimulation) []*state.TrainState {
|
||||
return trainArr
|
||||
}
|
||||
|
||||
// 获取地图内的列车信息
|
||||
func GetMapAllTrainState(vs *VerifySimulation, mid string) []*state.TrainState {
|
||||
var trainArr []*state.TrainState
|
||||
return trainArr
|
||||
}
|
||||
|
||||
// 获取变更列车状态并清空
|
||||
func GetUpdatedTrainState(vs *VerifySimulation) []*state.TrainState {
|
||||
changeTrainMap := &vs.Memory.ChangeStatus.TrainStateMap
|
||||
|
@ -36,6 +36,12 @@ func GetAllTurnoutState(simulation *VerifySimulation) []*state.SwitchState {
|
||||
return switchArr
|
||||
}
|
||||
|
||||
// 获取仿真地图的道岔状态
|
||||
func GetMapAllTurnoutState(simulation *VerifySimulation, mid string) []*state.SwitchState {
|
||||
var switchArr []*state.SwitchState
|
||||
return switchArr
|
||||
}
|
||||
|
||||
// 获取增量道岔状态
|
||||
func GetChangeTurnoutState(simulation *VerifySimulation) []*state.SwitchState {
|
||||
changeSwitchMap := &simulation.Memory.ChangeStatus.SwitchStateMap
|
||||
|
@ -2,14 +2,17 @@ package memory
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
|
||||
"joylink.club/bj-rtsts-server/ats/verify/protos/state"
|
||||
"joylink.club/rtsssimulation/repository"
|
||||
"joylink.club/rtsssimulation/repository/model/proto"
|
||||
"joylink.club/rtsssimulation/simulation"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
|
||||
"joylink.club/bj-rtsts-server/ats/verify/protos/state"
|
||||
"joylink.club/bj-rtsts-server/dto"
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/repository"
|
||||
"joylink.club/rtsssimulation/repository/model/proto"
|
||||
"joylink.club/rtsssimulation/simulation"
|
||||
)
|
||||
|
||||
// 轨旁仿真定义
|
||||
@ -43,10 +46,16 @@ func CreateSimulation(projectId int32, mapIds []int32) (*VerifySimulation, error
|
||||
repo := repository.FindRepository(repoId, repoVersion)
|
||||
if repo == nil {
|
||||
var storages []*graphicData.RtssGraphicStorage
|
||||
var rmapIds []int32
|
||||
for _, mapId := range mapIds {
|
||||
storages = append(storages, QueryGraphicStorage(mapId))
|
||||
storage := QueryGraphicStorage(mapId)
|
||||
if storage == nil {
|
||||
continue
|
||||
}
|
||||
storages = append(storages, storage)
|
||||
rmapIds = append(rmapIds, mapId)
|
||||
}
|
||||
protoRepo := buildProtoRepository(storages)
|
||||
protoRepo := buildProtoRepository(storages, rmapIds)
|
||||
newRepo, err := repository.BuildRepository(protoRepo)
|
||||
repo = newRepo
|
||||
if err != nil {
|
||||
@ -63,19 +72,6 @@ func CreateSimulation(projectId int32, mapIds []int32) (*VerifySimulation, error
|
||||
WorldId: worldId,
|
||||
}
|
||||
return verifySimulation, nil
|
||||
|
||||
//m := &WaysideMemory{}
|
||||
//verifySimulation := &VerifySimulation{
|
||||
// MapIds: mapIds,
|
||||
// ProjectId: projectId,
|
||||
// Memory: m.Create(),
|
||||
//}
|
||||
//s := verifySimulation.Memory.Status
|
||||
//// 初始化构地图设备状态
|
||||
//for _, mapId := range mapIds {
|
||||
// InitFromMap(s, QueryMapVerifyStructure(mapId))
|
||||
//}
|
||||
//return verifySimulation
|
||||
}
|
||||
|
||||
// 获取全量状态
|
||||
@ -90,27 +86,36 @@ func (s *VerifySimulation) GetAllState() *state.PushedDevicesStatus {
|
||||
}
|
||||
}
|
||||
|
||||
// 获取变量状态
|
||||
func (s *VerifySimulation) GetChangeState() *state.PushedDevicesStatus {
|
||||
// 获取仿真地图数据
|
||||
func (s *VerifySimulation) GetMapAllState(mid string) *state.PushedDevicesStatus {
|
||||
return &state.PushedDevicesStatus{
|
||||
All: false,
|
||||
VarStatus: &state.VariationStatus{
|
||||
UpdatedSwitch: GetChangeTurnoutState(s),
|
||||
RemovedTrainId: GetRemovedTrainId(s),
|
||||
UpdatedTrain: GetUpdatedTrainState(s),
|
||||
All: true,
|
||||
AllStatus: &state.AllDevicesStatus{
|
||||
SwitchState: GetMapAllTurnoutState(s, mid),
|
||||
TrainState: GetMapAllTrainState(s, mid),
|
||||
SectionState: GetMapAllPhysicalSectionState(s, mid),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func buildProtoRepository(storages []*graphicData.RtssGraphicStorage) *proto.Repository {
|
||||
// 获取仿真世界信息
|
||||
func (s *VerifySimulation) GetSimulationWorld() {
|
||||
ecsSimulation := simulation.FindSimulation(ecs.WorldId(s.WorldId))
|
||||
if ecsSimulation == nil {
|
||||
panic(&dto.ErrorDto{Code: dto.DataNotExist, Message: "ecs 仿真不存在"})
|
||||
}
|
||||
//return ecsSimulation.getWorld()
|
||||
}
|
||||
|
||||
func buildProtoRepository(storages []*graphicData.RtssGraphicStorage, mapIds []int32) *proto.Repository {
|
||||
repo := &proto.Repository{}
|
||||
for _, storage := range storages {
|
||||
fillProtoRepository(repo, storage)
|
||||
for i, storage := range storages {
|
||||
fillProtoRepository(repo, storage, mapIds[i])
|
||||
}
|
||||
return repo
|
||||
}
|
||||
|
||||
func fillProtoRepository(repo *proto.Repository, storage *graphicData.RtssGraphicStorage) {
|
||||
func fillProtoRepository(repo *proto.Repository, storage *graphicData.RtssGraphicStorage, mapId int32) {
|
||||
axleCountingMap := make(map[string]*graphicData.AxleCounting)
|
||||
for _, data := range storage.AxleCountings {
|
||||
if data.KilometerSystem == nil {
|
||||
@ -119,11 +124,11 @@ func fillProtoRepository(repo *proto.Repository, storage *graphicData.RtssGraphi
|
||||
}
|
||||
axleCountingMap[data.Common.Id] = data
|
||||
cpType := proto.CheckPointType_AxleCounter
|
||||
if data.Invent {
|
||||
if data.Type == graphicData.AxleCounting_SectionBoundary {
|
||||
cpType = proto.CheckPointType_Boundary
|
||||
}
|
||||
cp := &proto.CheckPoint{
|
||||
Id: data.Common.Id,
|
||||
Id: GetDeviceUidByCommonId(mapId, data.Common.Id, data),
|
||||
Km: convertKm(data.KilometerSystem),
|
||||
Type: cpType,
|
||||
DevicePorts: convertDevicePorts(data.AxleCountingRef),
|
||||
@ -136,7 +141,7 @@ func fillProtoRepository(repo *proto.Repository, storage *graphicData.RtssGraphi
|
||||
turnoutIds = findTurnoutIds(axleCountingMap, data.AxleCountings)
|
||||
}
|
||||
physicalSection := &proto.PhysicalSection{
|
||||
Id: data.Common.Id,
|
||||
Id: GetDeviceUidByCommonId(mapId, data.Common.Id, data),
|
||||
ADevicePort: convertDevicePort(data.PaRef),
|
||||
BDevicePort: convertDevicePort(data.PbRef),
|
||||
TurnoutIds: turnoutIds,
|
||||
@ -151,11 +156,9 @@ func fillProtoRepository(repo *proto.Repository, storage *graphicData.RtssGraphi
|
||||
break
|
||||
}
|
||||
}
|
||||
for _, kc := range buildKmConverts(data.KilometerSystem) {
|
||||
repo.KilometerConverts = append(repo.KilometerConverts, kc)
|
||||
}
|
||||
repo.KilometerConverts = append(repo.KilometerConverts, buildKmConverts(data.KilometerSystem)...)
|
||||
turnout := &proto.Turnout{
|
||||
Id: data.Common.Id,
|
||||
Id: GetDeviceUidByCommonId(mapId, data.Common.Id, data),
|
||||
Km: km,
|
||||
ADevicePort: convertDevicePort(data.PaRef),
|
||||
BDevicePort: convertDevicePort(data.PbRef),
|
||||
@ -173,7 +176,7 @@ func fillProtoRepository(repo *proto.Repository, storage *graphicData.RtssGraphi
|
||||
turnoutPort = convertDevicePort(data.RefDev)
|
||||
}
|
||||
signal := &proto.Signal{
|
||||
Id: data.Common.Id,
|
||||
Id: GetDeviceUidByCommonId(mapId, data.Common.Id, data),
|
||||
Km: convertKm(data.KilometerSystem),
|
||||
SectionId: sectionId,
|
||||
TurnoutPort: turnoutPort,
|
||||
@ -190,7 +193,7 @@ func fillProtoRepository(repo *proto.Repository, storage *graphicData.RtssGraphi
|
||||
turnoutPort = convertDevicePort(data.TransponderRef)
|
||||
}
|
||||
responder := &proto.Transponder{
|
||||
Id: data.Common.Id,
|
||||
Id: GetDeviceUidByCommonId(mapId, data.Common.Id, data),
|
||||
Km: convertKm(data.KilometerSystem),
|
||||
SectionId: sectionId,
|
||||
TurnoutPort: turnoutPort,
|
||||
@ -200,16 +203,12 @@ func fillProtoRepository(repo *proto.Repository, storage *graphicData.RtssGraphi
|
||||
slopeKsMap := make(map[string]*graphicData.SlopeKiloMarker)
|
||||
for _, data := range storage.SlopeKiloMarker {
|
||||
slopeKsMap[data.Common.Id] = data
|
||||
for _, kc := range buildKmConverts(data.KilometerSystem) {
|
||||
repo.KilometerConverts = append(repo.KilometerConverts, kc)
|
||||
}
|
||||
repo.KilometerConverts = append(repo.KilometerConverts, buildKmConverts(data.KilometerSystem)...)
|
||||
}
|
||||
curveKsMap := make(map[string]*graphicData.CurvatureKiloMarker)
|
||||
for _, data := range storage.CurvatureKiloMarker {
|
||||
curveKsMap[data.Common.Id] = data
|
||||
for _, kc := range buildKmConverts(data.KilometerSystem) {
|
||||
repo.KilometerConverts = append(repo.KilometerConverts, kc)
|
||||
}
|
||||
repo.KilometerConverts = append(repo.KilometerConverts, buildKmConverts(data.KilometerSystem)...)
|
||||
}
|
||||
for _, data := range storage.Slopes {
|
||||
var kms []*proto.Kilometer
|
||||
@ -217,7 +216,7 @@ func fillProtoRepository(repo *proto.Repository, storage *graphicData.RtssGraphi
|
||||
kms = append(kms, convertKm(slopeKsMap[id].KilometerSystem[0]))
|
||||
}
|
||||
slope := &proto.Slope{
|
||||
Id: data.Common.Id,
|
||||
Id: GetDeviceUidByCommonId(mapId, data.Common.Id, data),
|
||||
Kms: kms,
|
||||
Degree: data.SlopeNumber,
|
||||
}
|
||||
@ -229,7 +228,7 @@ func fillProtoRepository(repo *proto.Repository, storage *graphicData.RtssGraphi
|
||||
kms = append(kms, convertKm(curveKsMap[id].KilometerSystem[0]))
|
||||
}
|
||||
slope := &proto.SectionalCurvature{
|
||||
Id: data.Common.Id,
|
||||
Id: GetDeviceUidByCommonId(mapId, data.Common.Id, data),
|
||||
Kms: kms,
|
||||
Radius: data.CurvatureNumber,
|
||||
}
|
||||
@ -309,7 +308,7 @@ func findTurnoutIds(axleCountingMap map[string]*graphicData.AxleCounting, axleId
|
||||
}
|
||||
}
|
||||
var turnoutIds []string
|
||||
for id, _ := range turnoutMap {
|
||||
for id := range turnoutMap {
|
||||
turnoutIds = append(turnoutIds, id)
|
||||
}
|
||||
return turnoutIds
|
||||
|
@ -51,7 +51,6 @@ func RegisterMsgServer(server IMsgServer) {
|
||||
if r := recover(); r != nil {
|
||||
zap.S().Debug("定时器发生错误,%v\n", r)
|
||||
}
|
||||
// ticker.Stop() // 意外退出时关闭定时器
|
||||
}()
|
||||
// 循环推送信息
|
||||
for {
|
||||
@ -74,17 +73,6 @@ func RegisterMsgServer(server IMsgServer) {
|
||||
}
|
||||
}
|
||||
|
||||
// 用户初次进入系统后执行消息发送(这里可以使用对个人消息发送,但目前命名空间没有调试通)
|
||||
// 这个有问题暂时注释掉
|
||||
//func Subscription() {
|
||||
// for key, server := range serverMap {
|
||||
// data := (*server).allMsgData()
|
||||
// if data != nil && len(data) > 0 {
|
||||
// PublishMsg(key, data)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
// 注销消息服务
|
||||
func UnRegisterMsgServer(key string) {
|
||||
channel := serverExitChannelMap[key]
|
||||
|
70
grpcproto/simulation_map_server.go
Normal file
70
grpcproto/simulation_map_server.go
Normal file
@ -0,0 +1,70 @@
|
||||
package apiproto
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
"joylink.club/bj-rtsts-server/ats/verify/simulation"
|
||||
"joylink.club/bj-rtsts-server/dto"
|
||||
)
|
||||
|
||||
type SimulationMapServer struct{}
|
||||
|
||||
// 返回通道格式
|
||||
func (t *SimulationMapServer) getChannelName() string {
|
||||
return "simulation-{sid}_{mid}-devices-status"
|
||||
}
|
||||
|
||||
// 消息运行间隔
|
||||
func (t *SimulationMapServer) getInterval() time.Duration {
|
||||
return 200 * time.Millisecond
|
||||
}
|
||||
|
||||
// 返回所有数据
|
||||
func (t *SimulationMapServer) allMsgData(params map[string]string) []byte {
|
||||
simId := params["SID"]
|
||||
if simId == "" {
|
||||
return nil
|
||||
}
|
||||
mId := params["MID"]
|
||||
if mId == "" {
|
||||
return nil
|
||||
}
|
||||
simulation := simulation.FindSimulation(simId)
|
||||
if simulation == nil {
|
||||
return nil
|
||||
}
|
||||
data, err := proto.Marshal(simulation.GetMapAllState(mId))
|
||||
if err != nil {
|
||||
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
// 定时发送数据
|
||||
func (t *SimulationMapServer) onTick() []TopicMsg {
|
||||
simArr := simulation.GetSimulationArr()
|
||||
var msgArr []TopicMsg
|
||||
for _, v := range simArr {
|
||||
for _, mapId := range v.MapIds {
|
||||
idStr := strconv.Itoa(int(mapId))
|
||||
channelName := handlerMapIdChannelName(v.SimulationId, idStr, t.getChannelName())
|
||||
b, err := proto.Marshal(v.GetMapAllState(idStr))
|
||||
if err != nil {
|
||||
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
|
||||
}
|
||||
msgArr = append(msgArr, TopicMsg{channalName: channelName, data: b})
|
||||
}
|
||||
}
|
||||
return msgArr
|
||||
}
|
||||
|
||||
// 处理订阅通道名称
|
||||
func handlerMapIdChannelName(sid, mapId string, format string) string {
|
||||
var channelName string
|
||||
channelName = strings.Replace(format, "{sid}", sid, 1)
|
||||
channelName = strings.Replace(channelName, "{mid}", mapId, 1)
|
||||
return channelName
|
||||
}
|
Loading…
Reference in New Issue
Block a user