From 073f5e3156b66343ff283ba3530b4d3d63ca4461 Mon Sep 17 00:00:00 2001 From: tiger_zhou Date: Thu, 17 Oct 2024 16:54:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=87/=E6=AC=A0=E6=A0=87=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- proto/src/model.proto | 2 +- repository/model/proto/model.pb.go | 8 ++++---- repository/repository_manager.go | 20 +++++++++----------- repository/transponder.go | 4 +++- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/proto/src/model.proto b/proto/src/model.proto index 0b16340..2aea39b 100644 --- a/proto/src/model.proto +++ b/proto/src/model.proto @@ -82,7 +82,7 @@ message Repository { repeated GasEnvironment gasEnvironments = 320; } message StopPosition{ - uint32 id = 1; + string id = 1; uint32 linkId = 2; uint32 linkOffset = 3; Kilometer km = 4; diff --git a/repository/model/proto/model.pb.go b/repository/model/proto/model.pb.go index 0857a1d..bacccb9 100644 --- a/repository/model/proto/model.pb.go +++ b/repository/model/proto/model.pb.go @@ -1781,7 +1781,7 @@ type StopPosition struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` LinkId uint32 `protobuf:"varint,2,opt,name=linkId,proto3" json:"linkId,omitempty"` LinkOffset uint32 `protobuf:"varint,3,opt,name=linkOffset,proto3" json:"linkOffset,omitempty"` Km *Kilometer `protobuf:"bytes,4,opt,name=km,proto3" json:"km,omitempty"` @@ -1822,11 +1822,11 @@ func (*StopPosition) Descriptor() ([]byte, []int) { return file_model_proto_rawDescGZIP(), []int{1} } -func (x *StopPosition) GetId() uint32 { +func (x *StopPosition) GetId() string { if x != nil { return x.Id } - return 0 + return "" } func (x *StopPosition) GetLinkId() uint32 { @@ -6334,7 +6334,7 @@ var file_model_proto_rawDesc = []byte{ 0x47, 0x61, 0x73, 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x0f, 0x67, 0x61, 0x73, 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0xe7, 0x01, 0x0a, 0x0c, 0x53, 0x74, 0x6f, 0x70, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, + 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x69, 0x6e, 0x6b, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x6c, 0x69, 0x6e, 0x6b, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x6c, 0x69, 0x6e, 0x6b, 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x6c, 0x69, diff --git a/repository/repository_manager.go b/repository/repository_manager.go index ba0b4ea..9947aff 100644 --- a/repository/repository_manager.go +++ b/repository/repository_manager.go @@ -67,16 +67,12 @@ func buildModels(source *proto.Repository, repository *Repository) error { } repository.stationMap[m.Id()] = m } - for _, sp := range source.StopPosition { - //calibrationKilometer(sp.Km, repository) - tid := strconv.Itoa(int(sp.Id)) - t := NewStopPosition(tid, sp.Km, sp.CoachNum) - repository.StopPosition[tid] = t - } + for _, protoData := range source.PhysicalSections { m := NewPhysicalSection(protoData.Id) repository.physicalSectionMap[m.Id()] = m } + for _, protoData := range source.AxleCountingSections { m := NewAxleCountingSection(protoData.Id, protoData.TurnoutAndPos) repository.axleCountingSectionMap[m.Id()] = m @@ -102,6 +98,11 @@ func buildModels(source *proto.Repository, repository *Repository) error { protoData.Type, protoData.LeuIndex, protoData.IndexInLeu) repository.responderMap[m.Id()] = m } + for _, sp := range source.StopPosition { + calibrationKilometer(sp.Km, repository) + t := NewStopPosition(sp.Id, sp.Km, sp.CoachNum) + repository.StopPosition[t.Id()] = t + } for _, protoData := range source.Slopes { for _, km := range protoData.Kms { calibrationKilometer(km, repository) @@ -634,8 +635,7 @@ func buildResponderRelationShip(source *proto.Repository, repository *Repository } func buildStopPositionRelationShip(source *proto.Repository, repository *Repository) error { for _, protoData := range source.StopPosition { - tid := strconv.Itoa(int(protoData.Id)) - responder := repository.StopPosition[tid] + responder := repository.StopPosition[protoData.Id] if protoData.SectionId != "" { repository.physicalSectionMap[protoData.SectionId].bindDevices(responder) } @@ -1024,6 +1024,7 @@ func getATurnoutPort(turnouts []*Turnout, visitedTurnoutMap map[string]bool) *Tu port: port, } key := buildTurnoutPortKey(tp) + fmt.Println(fmt.Sprintf("找到对应的道岔端点%v,id:%v %v", key, turnout.Id(), port)) if !visitedTurnoutMap[key] { visitedTurnoutMap[key] = true return tp @@ -1043,9 +1044,6 @@ func relateDevicesAndLink(repo *Repository, link *Link, startKm *proto.Kilometer if visitedModelMap[device.Id()] { continue } - if device.Id() == "508" { - fmt.Println("aaaaaaaaaaaaaaaaa") - } linkPositionDevice, ok := device.(LinkPositionDevice) if !ok { return fmt.Errorf("device [%s:%s] not implements LinkPositionDevice", device.Id(), device.Type().String()) diff --git a/repository/transponder.go b/repository/transponder.go index a429b4c..182ab06 100644 --- a/repository/transponder.go +++ b/repository/transponder.go @@ -1,6 +1,8 @@ package repository -import "joylink.club/rtsssimulation/repository/model/proto" +import ( + "joylink.club/rtsssimulation/repository/model/proto" +) type Transponder struct { Identity