应答器的Link位置作为组件存在;增加应答器移位接口
This commit is contained in:
parent
9b16941d2f
commit
a4c17218f7
@ -63,3 +63,5 @@ type Counter struct {
|
||||
}
|
||||
|
||||
var CounterType = ecs.NewComponentType[Counter]()
|
||||
|
||||
var LinkPositionType = ecs.NewComponentType[component_proto.LinkPosition]()
|
||||
|
@ -236,6 +236,64 @@ func (x *CounterDown) GetStep() int32 {
|
||||
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[4]
|
||||
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[4]
|
||||
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{4}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
var File_component_common_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_component_common_proto_rawDesc = []byte{
|
||||
@ -253,7 +311,11 @@ var file_component_common_proto_rawDesc = []byte{
|
||||
0x65, 0x70, 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, 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, 0x1d, 0x5a, 0x1b, 0x2e, 0x2f, 0x63, 0x6f, 0x6d,
|
||||
0x05, 0x52, 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, 0x42, 0x1d, 0x5a, 0x1b, 0x2e, 0x2f, 0x63, 0x6f, 0x6d,
|
||||
0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74,
|
||||
0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
@ -270,12 +332,13 @@ func file_component_common_proto_rawDescGZIP() []byte {
|
||||
return file_component_common_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_component_common_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||
var file_component_common_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
|
||||
var file_component_common_proto_goTypes = []interface{}{
|
||||
(*TwoPositionTransform)(nil), // 0: component.TwoPositionTransform
|
||||
(*BitState)(nil), // 1: component.BitState
|
||||
(*Counter)(nil), // 2: component.Counter
|
||||
(*CounterDown)(nil), // 3: component.CounterDown
|
||||
(*LinkPosition)(nil), // 4: component.LinkPosition
|
||||
}
|
||||
var file_component_common_proto_depIdxs = []int32{
|
||||
0, // [0:0] is the sub-list for method output_type
|
||||
@ -339,6 +402,18 @@ func file_component_common_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_component_common_proto_msgTypes[4].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
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
@ -346,7 +421,7 @@ func file_component_common_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_component_common_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 4,
|
||||
NumMessages: 5,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
@ -3,6 +3,7 @@ package entity
|
||||
import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
"joylink.club/rtsssimulation/component/component_proto"
|
||||
"joylink.club/rtsssimulation/repository"
|
||||
"joylink.club/rtsssimulation/repository/model/proto"
|
||||
)
|
||||
@ -10,9 +11,16 @@ import (
|
||||
// LoadBalises 加载应答器实体
|
||||
func LoadBalises(w ecs.World) error {
|
||||
data := GetWorldData(w)
|
||||
balises := data.Repo.ResponderList()
|
||||
balises := data.Repo.TransponderList()
|
||||
for _, b := range balises {
|
||||
be := newBaliseEntity(w, b, data)
|
||||
//应答器位置
|
||||
be.AddComponent(component.LinkPositionType)
|
||||
component.LinkPositionType.SetValue(be, component_proto.LinkPosition{
|
||||
LinkId: b.LinkPosition().Link().Id(),
|
||||
Offset: b.LinkPosition().Offset(),
|
||||
})
|
||||
//应答器类型
|
||||
switch b.TransponderType() {
|
||||
case proto.Transponder_FB:
|
||||
be.AddComponent(component.BaliseFB)
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit f25027e20535e0ae4940a34b80276c56597517fb
|
||||
Subproject commit 2757e2c4e06b03afab94727cee9d948dae6d1754
|
@ -51,6 +51,14 @@ message Counter {
|
||||
int32 step = 2;
|
||||
}
|
||||
|
||||
// Link位置
|
||||
message LinkPosition{
|
||||
//Link的ID
|
||||
string linkId = 1;
|
||||
//Link的偏移量
|
||||
int64 offset = 2;
|
||||
}
|
||||
|
||||
// 倒数/倒计时组件
|
||||
message CounterDown {
|
||||
int32 val = 1;
|
||||
|
3519
repository/message_proto/repo.pb.go
Normal file
3519
repository/message_proto/repo.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
@ -15,7 +15,7 @@ type Repository struct {
|
||||
checkPointMap map[string]*CheckPoint
|
||||
turnoutMap map[string]*Turnout
|
||||
signalMap map[string]*Signal
|
||||
responderMap map[string]*Transponder
|
||||
transponderMap map[string]*Transponder
|
||||
slopeMap map[string]*Slope
|
||||
sectionalCurvatureMap map[string]*SectionalCurvature
|
||||
kilometerConvertMap map[string]*proto.KilometerConvert
|
||||
@ -62,7 +62,7 @@ func newRepository(id string, version string) *Repository {
|
||||
checkPointMap: make(map[string]*CheckPoint),
|
||||
turnoutMap: make(map[string]*Turnout),
|
||||
signalMap: make(map[string]*Signal),
|
||||
responderMap: make(map[string]*Transponder),
|
||||
transponderMap: make(map[string]*Transponder),
|
||||
slopeMap: make(map[string]*Slope),
|
||||
sectionalCurvatureMap: make(map[string]*SectionalCurvature),
|
||||
kilometerConvertMap: make(map[string]*proto.KilometerConvert),
|
||||
@ -119,7 +119,7 @@ func (repo *Repository) FindById(id string) Identity {
|
||||
if md, ok := repo.checkPointMap[id]; ok {
|
||||
return md
|
||||
}
|
||||
if md, ok := repo.responderMap[id]; ok {
|
||||
if md, ok := repo.transponderMap[id]; ok {
|
||||
return md
|
||||
}
|
||||
if md, ok := repo.stationMap[id]; ok {
|
||||
@ -225,16 +225,16 @@ func (repo *Repository) SignalList() []*Signal {
|
||||
}
|
||||
return list
|
||||
}
|
||||
func (repo *Repository) ResponderList() []*Transponder {
|
||||
func (repo *Repository) TransponderList() []*Transponder {
|
||||
var list []*Transponder
|
||||
for _, model := range repo.responderMap {
|
||||
for _, model := range repo.transponderMap {
|
||||
list = append(list, model)
|
||||
}
|
||||
return list
|
||||
}
|
||||
func (repo *Repository) ResponderListByLink(linkId string) []*Transponder {
|
||||
var list []*Transponder
|
||||
for _, model := range repo.responderMap {
|
||||
for _, model := range repo.transponderMap {
|
||||
if model.linkPosition.link.Id() == linkId {
|
||||
list = append(list, model)
|
||||
}
|
||||
@ -336,7 +336,7 @@ func (repo *Repository) FindModel(deviceId string, deviceType proto.DeviceType)
|
||||
case proto.DeviceType_DeviceType_Signal:
|
||||
return repo.signalMap[deviceId], nil
|
||||
case proto.DeviceType_DeviceType_Transponder:
|
||||
return repo.responderMap[deviceId], nil
|
||||
return repo.transponderMap[deviceId], nil
|
||||
case proto.DeviceType_DeviceType_Slope:
|
||||
return repo.slopeMap[deviceId], nil
|
||||
case proto.DeviceType_DeviceType_SectionalCurvature:
|
||||
@ -396,7 +396,7 @@ func (repo *Repository) FindLink(id string) *Link {
|
||||
return repo.linkMap[id]
|
||||
}
|
||||
func (repo *Repository) FindTransponder(id string) *Transponder {
|
||||
return repo.responderMap[id]
|
||||
return repo.transponderMap[id]
|
||||
}
|
||||
func (repo *Repository) FindTurnout(id string) *Turnout {
|
||||
return repo.turnoutMap[id]
|
||||
@ -419,7 +419,7 @@ func (repo *Repository) FindPsd(id string) *Psd {
|
||||
return repo.psdMap[id]
|
||||
}
|
||||
|
||||
func (repo *Repository) FindPlatfrom(id string) *Platform {
|
||||
func (repo *Repository) FindPlatform(id string) *Platform {
|
||||
return repo.platformMap[id]
|
||||
}
|
||||
|
||||
@ -499,7 +499,7 @@ func (repo *Repository) generateCoordinateInfo(coordinateSystem string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (repo Repository) GetCoordinateInfo() *MapCoordinate {
|
||||
func (repo *Repository) GetCoordinateInfo() *MapCoordinate {
|
||||
return repo.coordinate
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ func buildModels(source *proto.Repository, repository *Repository) error {
|
||||
}
|
||||
for _, protoData := range source.Transponders {
|
||||
m := NewTransponder(protoData.Id, protoData.Km, protoData.FixedTelegram, protoData.Type)
|
||||
repository.responderMap[m.Id()] = m
|
||||
repository.transponderMap[m.Id()] = m
|
||||
}
|
||||
for _, protoData := range source.Slopes {
|
||||
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 {
|
||||
for _, protoData := range source.Transponders {
|
||||
responder := repository.responderMap[protoData.Id]
|
||||
responder := repository.transponderMap[protoData.Id]
|
||||
//应答器和区段相互关联
|
||||
if protoData.SectionId != "" {
|
||||
interrelateResponderAndPhysicalSection(responder, repository.physicalSectionMap[protoData.SectionId])
|
||||
@ -595,11 +595,7 @@ func buildLinks(repo *Repository) error {
|
||||
//以始端道岔的公里标作为Link零点的公里标
|
||||
linkZeroKm := startTp.turnout.km
|
||||
//创建基础Link
|
||||
link := &Link{
|
||||
Identity: identity{
|
||||
id: strconv.Itoa(linkIdGenerator), //由于发给动力学的link的id是数字,所以这里也用数字
|
||||
deviceType: proto.DeviceType_DeviceType_Link,
|
||||
}}
|
||||
link := NewLink(strconv.Itoa(linkIdGenerator)) //由于发给动力学的link的id是数字,所以这里也用数字
|
||||
linkIdGenerator++
|
||||
//以此道岔端口作为Link的A端节点
|
||||
interrelateLinkAndTurnout(repo, linkZeroKm, startTp, &LinkPort{link, proto.Port_A})
|
||||
|
@ -8,7 +8,7 @@ type Transponder struct {
|
||||
km *proto.Kilometer
|
||||
//section *PhysicalSection
|
||||
//turnoutPort TurnoutPort
|
||||
linkPosition *LinkPosition
|
||||
linkPosition *LinkPosition //此位置是应答器初始位置,当前位置需从应答器实体中获取
|
||||
fixedTelegram []byte //无源应答器固定报文
|
||||
baliseType proto.Transponder_Type //应答器类型
|
||||
}
|
||||
@ -31,13 +31,6 @@ func (t *Transponder) bindLinkPosition(position *LinkPosition) {
|
||||
t.linkPosition = position
|
||||
}
|
||||
|
||||
// func (r *Transponder) bindSection(section *PhysicalSection) {
|
||||
// r.section = section
|
||||
// }
|
||||
//
|
||||
// func (r *Transponder) bindTurnoutPort(turnoutPort TurnoutPort) {
|
||||
// r.turnoutPort = turnoutPort
|
||||
// }
|
||||
func (t *Transponder) LinkPosition() *LinkPosition {
|
||||
return t.linkPosition
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user