merge处理
This commit is contained in:
parent
3f5b459460
commit
972bac0561
@ -63,4 +63,4 @@ type Counter struct {
|
|||||||
|
|
||||||
var CounterType = ecs.NewComponentType[Counter]()
|
var CounterType = ecs.NewComponentType[Counter]()
|
||||||
|
|
||||||
var LinkPositionType = ecs.NewComponentType[component_proto.LinkPosition]()
|
var LinkPositionType = ecs.NewComponentType[component_data.LinkPosition]()
|
||||||
|
@ -360,6 +360,64 @@ func (x *Counter) GetStep() int32 {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Link位置
|
||||||
|
type LinkPosition struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
// Link的ID
|
||||||
|
LinkId string `protobuf:"bytes,1,opt,name=linkId,proto3" json:"linkId,omitempty"`
|
||||||
|
// Link的偏移量
|
||||||
|
Offset int64 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *LinkPosition) Reset() {
|
||||||
|
*x = LinkPosition{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_component_common_proto_msgTypes[6]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *LinkPosition) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*LinkPosition) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *LinkPosition) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_component_common_proto_msgTypes[6]
|
||||||
|
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 LinkPosition.ProtoReflect.Descriptor instead.
|
||||||
|
func (*LinkPosition) Descriptor() ([]byte, []int) {
|
||||||
|
return file_component_common_proto_rawDescGZIP(), []int{6}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *LinkPosition) GetLinkId() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.LinkId
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *LinkPosition) GetOffset() int64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Offset
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
// 倒数/倒计时组件
|
// 倒数/倒计时组件
|
||||||
type CounterDown struct {
|
type CounterDown struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
@ -373,7 +431,7 @@ type CounterDown struct {
|
|||||||
func (x *CounterDown) Reset() {
|
func (x *CounterDown) Reset() {
|
||||||
*x = CounterDown{}
|
*x = CounterDown{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_component_common_proto_msgTypes[6]
|
mi := &file_component_common_proto_msgTypes[7]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@ -386,7 +444,7 @@ func (x *CounterDown) String() string {
|
|||||||
func (*CounterDown) ProtoMessage() {}
|
func (*CounterDown) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *CounterDown) ProtoReflect() protoreflect.Message {
|
func (x *CounterDown) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_component_common_proto_msgTypes[6]
|
mi := &file_component_common_proto_msgTypes[7]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@ -399,7 +457,7 @@ func (x *CounterDown) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use CounterDown.ProtoReflect.Descriptor instead.
|
// Deprecated: Use CounterDown.ProtoReflect.Descriptor instead.
|
||||||
func (*CounterDown) Descriptor() ([]byte, []int) {
|
func (*CounterDown) Descriptor() ([]byte, []int) {
|
||||||
return file_component_common_proto_rawDescGZIP(), []int{6}
|
return file_component_common_proto_rawDescGZIP(), []int{7}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *CounterDown) GetVal() int32 {
|
func (x *CounterDown) GetVal() int32 {
|
||||||
@ -441,7 +499,11 @@ var file_component_common_proto_rawDesc = []byte{
|
|||||||
0x03, 0x76, 0x61, 0x6c, 0x22, 0x2f, 0x0a, 0x07, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x12,
|
0x03, 0x76, 0x61, 0x6c, 0x22, 0x2f, 0x0a, 0x07, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x12,
|
||||||
0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x76, 0x61,
|
0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x76, 0x61,
|
||||||
0x6c, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x74, 0x65, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52,
|
0x6c, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x74, 0x65, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52,
|
||||||
0x04, 0x73, 0x74, 0x65, 0x70, 0x22, 0x33, 0x0a, 0x0b, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72,
|
0x04, 0x73, 0x74, 0x65, 0x70, 0x22, 0x3e, 0x0a, 0x0c, 0x4c, 0x69, 0x6e, 0x6b, 0x50, 0x6f, 0x73,
|
||||||
|
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x69, 0x6e, 0x6b, 0x49, 0x64, 0x18,
|
||||||
|
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6c, 0x69, 0x6e, 0x6b, 0x49, 0x64, 0x12, 0x16, 0x0a,
|
||||||
|
0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6f,
|
||||||
|
0x66, 0x66, 0x73, 0x65, 0x74, 0x22, 0x33, 0x0a, 0x0b, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72,
|
||||||
0x44, 0x6f, 0x77, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28,
|
0x44, 0x6f, 0x77, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||||
0x05, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x74, 0x65, 0x70, 0x18, 0x02,
|
0x05, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x74, 0x65, 0x70, 0x18, 0x02,
|
||||||
0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, 0x74, 0x65, 0x70, 0x42, 0x1c, 0x5a, 0x1a, 0x2e, 0x2f,
|
0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, 0x74, 0x65, 0x70, 0x42, 0x1c, 0x5a, 0x1a, 0x2e, 0x2f,
|
||||||
@ -461,7 +523,7 @@ func file_component_common_proto_rawDescGZIP() []byte {
|
|||||||
return file_component_common_proto_rawDescData
|
return file_component_common_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_component_common_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
|
var file_component_common_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
|
||||||
var file_component_common_proto_goTypes = []interface{}{
|
var file_component_common_proto_goTypes = []interface{}{
|
||||||
(*MotorState)(nil), // 0: component.MotorState
|
(*MotorState)(nil), // 0: component.MotorState
|
||||||
(*RelayState)(nil), // 1: component.RelayState
|
(*RelayState)(nil), // 1: component.RelayState
|
||||||
@ -469,7 +531,8 @@ var file_component_common_proto_goTypes = []interface{}{
|
|||||||
(*FixedPositionTransform)(nil), // 3: component.FixedPositionTransform
|
(*FixedPositionTransform)(nil), // 3: component.FixedPositionTransform
|
||||||
(*BitState)(nil), // 4: component.BitState
|
(*BitState)(nil), // 4: component.BitState
|
||||||
(*Counter)(nil), // 5: component.Counter
|
(*Counter)(nil), // 5: component.Counter
|
||||||
(*CounterDown)(nil), // 6: component.CounterDown
|
(*LinkPosition)(nil), // 6: component.LinkPosition
|
||||||
|
(*CounterDown)(nil), // 7: component.CounterDown
|
||||||
}
|
}
|
||||||
var file_component_common_proto_depIdxs = []int32{
|
var file_component_common_proto_depIdxs = []int32{
|
||||||
0, // [0:0] is the sub-list for method output_type
|
0, // [0:0] is the sub-list for method output_type
|
||||||
@ -558,6 +621,18 @@ func file_component_common_proto_init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_component_common_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
file_component_common_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*LinkPosition); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_component_common_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*CounterDown); i {
|
switch v := v.(*CounterDown); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@ -576,7 +651,7 @@ func file_component_common_proto_init() {
|
|||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: file_component_common_proto_rawDesc,
|
RawDescriptor: file_component_common_proto_rawDesc,
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 7,
|
NumMessages: 8,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 0,
|
NumServices: 0,
|
||||||
},
|
},
|
||||||
|
@ -3,7 +3,7 @@ package entity
|
|||||||
import (
|
import (
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
"joylink.club/rtsssimulation/component"
|
"joylink.club/rtsssimulation/component"
|
||||||
"joylink.club/rtsssimulation/component/component_proto"
|
"joylink.club/rtsssimulation/component/component_data"
|
||||||
"joylink.club/rtsssimulation/repository"
|
"joylink.club/rtsssimulation/repository"
|
||||||
"joylink.club/rtsssimulation/repository/model/proto"
|
"joylink.club/rtsssimulation/repository/model/proto"
|
||||||
)
|
)
|
||||||
@ -11,12 +11,12 @@ import (
|
|||||||
// LoadBalises 加载应答器实体
|
// LoadBalises 加载应答器实体
|
||||||
func LoadBalises(w ecs.World) error {
|
func LoadBalises(w ecs.World) error {
|
||||||
data := GetWorldData(w)
|
data := GetWorldData(w)
|
||||||
balises := data.Repo.TransponderList()
|
balises := data.Repo.ResponderList()
|
||||||
for _, b := range balises {
|
for _, b := range balises {
|
||||||
be := newBaliseEntity(w, b, data)
|
be := newBaliseEntity(w, b, data)
|
||||||
//应答器位置
|
//应答器位置
|
||||||
be.AddComponent(component.LinkPositionType)
|
be.AddComponent(component.LinkPositionType)
|
||||||
component.LinkPositionType.SetValue(be, component_proto.LinkPosition{
|
component.LinkPositionType.SetValue(be, component_data.LinkPosition{
|
||||||
LinkId: b.LinkPosition().Link().Id(),
|
LinkId: b.LinkPosition().Link().Id(),
|
||||||
Offset: b.LinkPosition().Offset(),
|
Offset: b.LinkPosition().Offset(),
|
||||||
})
|
})
|
||||||
|
@ -15,7 +15,7 @@ type Repository struct {
|
|||||||
checkPointMap map[string]*CheckPoint
|
checkPointMap map[string]*CheckPoint
|
||||||
turnoutMap map[string]*Turnout
|
turnoutMap map[string]*Turnout
|
||||||
signalMap map[string]*Signal
|
signalMap map[string]*Signal
|
||||||
transponderMap map[string]*Transponder
|
responderMap map[string]*Transponder
|
||||||
slopeMap map[string]*Slope
|
slopeMap map[string]*Slope
|
||||||
sectionalCurvatureMap map[string]*SectionalCurvature
|
sectionalCurvatureMap map[string]*SectionalCurvature
|
||||||
kilometerConvertMap map[string]*proto.KilometerConvert
|
kilometerConvertMap map[string]*proto.KilometerConvert
|
||||||
@ -62,7 +62,7 @@ func newRepository(id string, version string) *Repository {
|
|||||||
checkPointMap: make(map[string]*CheckPoint),
|
checkPointMap: make(map[string]*CheckPoint),
|
||||||
turnoutMap: make(map[string]*Turnout),
|
turnoutMap: make(map[string]*Turnout),
|
||||||
signalMap: make(map[string]*Signal),
|
signalMap: make(map[string]*Signal),
|
||||||
transponderMap: make(map[string]*Transponder),
|
responderMap: make(map[string]*Transponder),
|
||||||
slopeMap: make(map[string]*Slope),
|
slopeMap: make(map[string]*Slope),
|
||||||
sectionalCurvatureMap: make(map[string]*SectionalCurvature),
|
sectionalCurvatureMap: make(map[string]*SectionalCurvature),
|
||||||
kilometerConvertMap: make(map[string]*proto.KilometerConvert),
|
kilometerConvertMap: make(map[string]*proto.KilometerConvert),
|
||||||
@ -119,7 +119,7 @@ func (repo *Repository) FindById(id string) Identity {
|
|||||||
if md, ok := repo.checkPointMap[id]; ok {
|
if md, ok := repo.checkPointMap[id]; ok {
|
||||||
return md
|
return md
|
||||||
}
|
}
|
||||||
if md, ok := repo.transponderMap[id]; ok {
|
if md, ok := repo.responderMap[id]; ok {
|
||||||
return md
|
return md
|
||||||
}
|
}
|
||||||
if md, ok := repo.stationMap[id]; ok {
|
if md, ok := repo.stationMap[id]; ok {
|
||||||
@ -225,16 +225,16 @@ func (repo *Repository) SignalList() []*Signal {
|
|||||||
}
|
}
|
||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
func (repo *Repository) TransponderList() []*Transponder {
|
func (repo *Repository) ResponderList() []*Transponder {
|
||||||
var list []*Transponder
|
var list []*Transponder
|
||||||
for _, model := range repo.transponderMap {
|
for _, model := range repo.responderMap {
|
||||||
list = append(list, model)
|
list = append(list, model)
|
||||||
}
|
}
|
||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
func (repo *Repository) ResponderListByLink(linkId string) []*Transponder {
|
func (repo *Repository) ResponderListByLink(linkId string) []*Transponder {
|
||||||
var list []*Transponder
|
var list []*Transponder
|
||||||
for _, model := range repo.transponderMap {
|
for _, model := range repo.responderMap {
|
||||||
if model.linkPosition.link.Id() == linkId {
|
if model.linkPosition.link.Id() == linkId {
|
||||||
list = append(list, model)
|
list = append(list, model)
|
||||||
}
|
}
|
||||||
@ -336,7 +336,7 @@ func (repo *Repository) FindModel(deviceId string, deviceType proto.DeviceType)
|
|||||||
case proto.DeviceType_DeviceType_Signal:
|
case proto.DeviceType_DeviceType_Signal:
|
||||||
return repo.signalMap[deviceId], nil
|
return repo.signalMap[deviceId], nil
|
||||||
case proto.DeviceType_DeviceType_Transponder:
|
case proto.DeviceType_DeviceType_Transponder:
|
||||||
return repo.transponderMap[deviceId], nil
|
return repo.responderMap[deviceId], nil
|
||||||
case proto.DeviceType_DeviceType_Slope:
|
case proto.DeviceType_DeviceType_Slope:
|
||||||
return repo.slopeMap[deviceId], nil
|
return repo.slopeMap[deviceId], nil
|
||||||
case proto.DeviceType_DeviceType_SectionalCurvature:
|
case proto.DeviceType_DeviceType_SectionalCurvature:
|
||||||
@ -396,7 +396,7 @@ func (repo *Repository) FindLink(id string) *Link {
|
|||||||
return repo.linkMap[id]
|
return repo.linkMap[id]
|
||||||
}
|
}
|
||||||
func (repo *Repository) FindTransponder(id string) *Transponder {
|
func (repo *Repository) FindTransponder(id string) *Transponder {
|
||||||
return repo.transponderMap[id]
|
return repo.responderMap[id]
|
||||||
}
|
}
|
||||||
func (repo *Repository) FindTurnout(id string) *Turnout {
|
func (repo *Repository) FindTurnout(id string) *Turnout {
|
||||||
return repo.turnoutMap[id]
|
return repo.turnoutMap[id]
|
||||||
@ -419,7 +419,7 @@ func (repo *Repository) FindPsd(id string) *Psd {
|
|||||||
return repo.psdMap[id]
|
return repo.psdMap[id]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repository) FindPlatform(id string) *Platform {
|
func (repo *Repository) FindPlatfrom(id string) *Platform {
|
||||||
return repo.platformMap[id]
|
return repo.platformMap[id]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -499,7 +499,7 @@ func (repo *Repository) generateCoordinateInfo(coordinateSystem string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repository) GetCoordinateInfo() *MapCoordinate {
|
func (repo Repository) GetCoordinateInfo() *MapCoordinate {
|
||||||
return repo.coordinate
|
return repo.coordinate
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ func buildModels(source *proto.Repository, repository *Repository) error {
|
|||||||
}
|
}
|
||||||
for _, protoData := range source.Transponders {
|
for _, protoData := range source.Transponders {
|
||||||
m := NewTransponder(protoData.Id, protoData.Km, protoData.FixedTelegram, protoData.Type)
|
m := NewTransponder(protoData.Id, protoData.Km, protoData.FixedTelegram, protoData.Type)
|
||||||
repository.transponderMap[m.Id()] = m
|
repository.responderMap[m.Id()] = m
|
||||||
}
|
}
|
||||||
for _, protoData := range source.Slopes {
|
for _, protoData := range source.Slopes {
|
||||||
m := NewSlope(protoData.Id, protoData.Kms, protoData.Degree)
|
m := NewSlope(protoData.Id, protoData.Kms, protoData.Degree)
|
||||||
@ -346,7 +346,7 @@ func buildCheckPointRelationShip(source *proto.Repository, repo *Repository) err
|
|||||||
|
|
||||||
func buildResponderRelationShip(source *proto.Repository, repository *Repository) error {
|
func buildResponderRelationShip(source *proto.Repository, repository *Repository) error {
|
||||||
for _, protoData := range source.Transponders {
|
for _, protoData := range source.Transponders {
|
||||||
responder := repository.transponderMap[protoData.Id]
|
responder := repository.responderMap[protoData.Id]
|
||||||
//应答器和区段相互关联
|
//应答器和区段相互关联
|
||||||
if protoData.SectionId != "" {
|
if protoData.SectionId != "" {
|
||||||
interrelateResponderAndPhysicalSection(responder, repository.physicalSectionMap[protoData.SectionId])
|
interrelateResponderAndPhysicalSection(responder, repository.physicalSectionMap[protoData.SectionId])
|
||||||
|
Loading…
Reference in New Issue
Block a user