停车点构建proto

This commit is contained in:
tiger_zhou 2024-09-25 11:19:18 +08:00
parent ef7ff5459c
commit 150aa24307
5 changed files with 1469 additions and 1264 deletions

View File

@ -35,6 +35,8 @@ message Repository {
repeated Spks spkss = 28; repeated Spks spkss = 28;
repeated AxleCountingSection axleCountingSections = 29; // repeated AxleCountingSection axleCountingSections = 29; //
repeated KilometerCalibration kilometerCalibrations = 30; // repeated KilometerCalibration kilometerCalibrations = 30; //
repeated StopPosition stopPosition = 31;
//ISCS [300,500] //ISCS [300,500]
//ISCS管线 //ISCS管线
repeated Pipe pipes = 300; repeated Pipe pipes = 300;
@ -79,7 +81,14 @@ message Repository {
//ISCS气体环境 //ISCS气体环境
repeated GasEnvironment gasEnvironments = 320; repeated GasEnvironment gasEnvironments = 320;
} }
message StopPosition{
uint32 id = 1;
uint32 linkId = 2;
uint32 linkOffset = 3;
Kilometer km = 4;
string sectionId = 5; //
DevicePort turnoutPort = 6; //
}
// //
message SignalLayout { message SignalLayout {
// //
@ -255,6 +264,7 @@ enum DeviceType {
DeviceType_Esb = 29; // DeviceType_Esb = 29; //
DeviceType_Spks = 30; // DeviceType_Spks = 30; //
DeviceTYpe_AxleCountingSection = 31; // DeviceTYpe_AxleCountingSection = 31; //
deviceType_Stop_position = 32;
//--------ISCS [300,500]------ //--------ISCS [300,500]------
//ISCS门磁 //ISCS门磁

File diff suppressed because it is too large Load Diff

View File

@ -38,6 +38,7 @@ type Repository struct {
esbMap map[string]*Esb esbMap map[string]*Esb
spksMap map[string]*Spks spksMap map[string]*Spks
kilometerCalibrationMap map[string][]*proto.KilometerCalibration //从大到小排序 kilometerCalibrationMap map[string][]*proto.KilometerCalibration //从大到小排序
StopPosition map[string]*StopPosition
PipeMap map[string]*Pipe //ISCS 管线 PipeMap map[string]*Pipe //ISCS 管线
PipeFittingMap map[string]*PipeFitting //ISCS 管件 PipeFittingMap map[string]*PipeFitting //ISCS 管件
@ -93,6 +94,7 @@ func newRepository(id string, version string) *Repository {
esbMap: make(map[string]*Esb), esbMap: make(map[string]*Esb),
spksMap: make(map[string]*Spks), spksMap: make(map[string]*Spks),
kilometerCalibrationMap: make(map[string][]*proto.KilometerCalibration), kilometerCalibrationMap: make(map[string][]*proto.KilometerCalibration),
StopPosition: make(map[string]*StopPosition),
PipeMap: make(map[string]*Pipe), //ISCS 管线 PipeMap: make(map[string]*Pipe), //ISCS 管线
PipeFittingMap: make(map[string]*PipeFitting), //ISCS 管件 PipeFittingMap: make(map[string]*PipeFitting), //ISCS 管件

View File

@ -67,6 +67,12 @@ func buildModels(source *proto.Repository, repository *Repository) error {
} }
repository.stationMap[m.Id()] = m 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)
repository.StopPosition[tid] = t
}
for _, protoData := range source.PhysicalSections { for _, protoData := range source.PhysicalSections {
m := NewPhysicalSection(protoData.Id) m := NewPhysicalSection(protoData.Id)
repository.physicalSectionMap[m.Id()] = m repository.physicalSectionMap[m.Id()] = m
@ -250,6 +256,7 @@ func buildModelRelationship(source *proto.Repository, repository *Repository) er
return err return err
} }
err = buildSpksRelationship(source, repository) err = buildSpksRelationship(source, repository)
buildStopPositionRelationShip(source, repository)
return err return err
} }
@ -625,7 +632,16 @@ func buildResponderRelationShip(source *proto.Repository, repository *Repository
} }
return nil return nil
} }
func buildStopPositionRelationShip(source *proto.Repository, repository *Repository) error {
for _, protoData := range source.StopPosition {
tid := strconv.Itoa(int(protoData.Id))
responder := repository.StopPosition[tid]
if protoData.SectionId != "" {
repository.physicalSectionMap[protoData.SectionId].bindDevices(responder)
}
}
return nil
}
func buildSignalRelationShip(source *proto.Repository, repository *Repository) error { func buildSignalRelationShip(source *proto.Repository, repository *Repository) error {
for _, protoData := range source.Signals { for _, protoData := range source.Signals {
signal := repository.signalMap[protoData.Id] signal := repository.signalMap[protoData.Id]
@ -862,6 +878,18 @@ func buildLinksAndRelate(repo *Repository) error {
return nil return nil
} }
/*func stopPositionRelateLink(repo *Repository) {
for _, curvature := range repo {
start, end, err := calculateLinkSegment(repo, curvature.kms[0], curvature.kms[1])
if err != nil {
return err
}
curvature.bindStartLinkPosition(start)
curvature.bindEndLinkPosition(end)
}
return nil
}*/
func buildLinks(repo *Repository) error { func buildLinks(repo *Repository) error {
visitedTurnoutPortMap := make(map[string]bool) visitedTurnoutPortMap := make(map[string]bool)
allTurnouts := repo.TurnoutList() allTurnouts := repo.TurnoutList()
@ -917,6 +945,7 @@ func findEndTurnoutPortOrEndKm(repo *Repository, link *Link, startTp *TurnoutPor
var currentDp DevicePort = startTp var currentDp DevicePort = startTp
devices := startTp.turnout.findDevicesByPort(startTp.port) devices := startTp.turnout.findDevicesByPort(startTp.port)
for { for {
//遍历设备并构建、关联其在Link上的位置 //遍历设备并构建、关联其在Link上的位置
err = relateDevicesAndLink(repo, link, baseKm, visitedModelMap, devices...) err = relateDevicesAndLink(repo, link, baseKm, visitedModelMap, devices...)
if err != nil { if err != nil {
@ -938,7 +967,10 @@ func findEndTurnoutPortOrEndKm(repo *Repository, link *Link, startTp *TurnoutPor
if nextDp == nil { if nextDp == nil {
endKm = turnout.findBoundaryKmByPort(currentDp.Port()) endKm = turnout.findBoundaryKmByPort(currentDp.Port())
} }
//case proto.DeviceType_deviceType_Stop_position:
// turnout := currentDp.Device().(*StopPosition)
} }
//根据下一个端口设备的信息决定是否结束循环 //根据下一个端口设备的信息决定是否结束循环
if nextDp == nil { if nextDp == nil {
break break
@ -1007,6 +1039,7 @@ func buildTurnoutPortKey(tp *TurnoutPort) string {
func relateDevicesAndLink(repo *Repository, link *Link, startKm *proto.Kilometer, visitedModelMap map[string]bool, devices ...Identity) error { func relateDevicesAndLink(repo *Repository, link *Link, startKm *proto.Kilometer, visitedModelMap map[string]bool, devices ...Identity) error {
for _, device := range devices { for _, device := range devices {
if visitedModelMap[device.Id()] { if visitedModelMap[device.Id()] {
continue continue
} }
@ -1078,7 +1111,10 @@ func findModelKm(model Identity) *proto.Kilometer {
return model.(*CheckPoint).km return model.(*CheckPoint).km
case proto.DeviceType_DeviceType_Turnout: case proto.DeviceType_DeviceType_Turnout:
return model.(*Turnout).km return model.(*Turnout).km
case proto.DeviceType_deviceType_Stop_position:
return model.(*StopPosition).km
} }
return nil return nil
} }

View File

@ -0,0 +1,25 @@
package repository
import (
"joylink.club/rtsssimulation/repository/model/proto"
)
type StopPosition struct {
Identity
dir proto.Platform_Direction
km *proto.Kilometer
linkPosition LinkPosition
}
func NewStopPosition(id string, km *proto.Kilometer) *StopPosition {
return &StopPosition{
Identity: identity{id, proto.DeviceType_deviceType_Stop_position},
km: km,
}
}
func (t *StopPosition) bindLinkPosition(position LinkPosition) {
t.linkPosition = position
}
func (t *StopPosition) LinkPosition() LinkPosition {
return t.linkPosition
}