[新增]设备公里表长短链校正

This commit is contained in:
thesai 2024-08-22 14:03:32 +08:00
parent 12df28cc37
commit 1f0a114c8d
4 changed files with 1317 additions and 1178 deletions

View File

@ -34,6 +34,7 @@ message Repository {
repeated Esb esbs = 27;
repeated Spks spkss = 28;
repeated AxleCountingSection axleCountingSections = 29; //
repeated KilometerCalibration kilometerCalibrations = 30; //
//ISCS [300,500]
//ISCS管线
repeated Pipe pipes = 300;
@ -419,6 +420,12 @@ message KilometerConvert {
bool sameTrend = 3; //
}
//
message KilometerCalibration {
Kilometer design = 1; //
Kilometer actual = 2; //
}
//
enum Direction {
LEFT = 0;

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -3,13 +3,13 @@ package repository
import (
"errors"
"fmt"
"log/slog"
"math"
"strconv"
"strings"
"joylink.club/rtsssimulation/repository/model/proto"
"joylink.club/rtsssimulation/util/number"
"log/slog"
"math"
"sort"
"strconv"
"strings"
)
var repositoryMap = make(map[string]*Repository)
@ -55,6 +55,10 @@ func buildModels(source *proto.Repository, repository *Repository) error {
for _, protoData := range source.KilometerConverts {
repository.addKilometerConvert(protoData)
}
err := buildKilometerCalibration(source, repository)
if err != nil {
return err
}
for _, protoData := range source.Stations {
m := NewStation(protoData.Id, protoData.Code)
_, ok := repository.stationMap[m.Id()]
@ -72,27 +76,37 @@ func buildModels(source *proto.Repository, repository *Repository) error {
repository.axleCountingSectionMap[m.Id()] = m
}
for _, protoData := range source.CheckPoints {
calibrationKilometer(protoData.Km, repository)
m := NewCheckPoint(protoData.Id, protoData.Km, protoData.Type)
repository.checkPointMap[m.Id()] = m
}
for _, protoData := range source.Turnouts {
calibrationKilometer(protoData.Km, repository)
m := NewTurnout(protoData.Id, protoData.Km, protoData.SwitchMachineType)
repository.turnoutMap[m.Id()] = m
}
for _, protoData := range source.Signals {
calibrationKilometer(protoData.Km, repository)
m := NewSignal(protoData.Id, protoData.Km, protoData.Code, protoData.Model)
repository.signalMap[m.Id()] = m
}
for _, protoData := range source.Transponders {
calibrationKilometer(protoData.Km, repository)
m := NewTransponder(protoData.Id, protoData.Km, protoData.FixedTelegram, protoData.FixedUserTelegram,
protoData.Type, protoData.LeuIndex, protoData.IndexInLeu)
repository.responderMap[m.Id()] = m
}
for _, protoData := range source.Slopes {
for _, km := range protoData.Kms {
calibrationKilometer(km, repository)
}
m := NewSlope(protoData.Id, protoData.Kms, protoData.Degree)
repository.slopeMap[m.Id()] = m
}
for _, protoData := range source.SectionalCurvatures {
for _, km := range protoData.Kms {
calibrationKilometer(km, repository)
}
m := NewSectionalCurvature(protoData.Id, protoData.Kms, protoData.Radius)
repository.sectionalCurvatureMap[m.Id()] = m
}
@ -151,7 +165,7 @@ func buildModels(source *proto.Repository, repository *Repository) error {
m := NewCkmPsl(protoData.Id)
repository.ckmPslMap[m.Id()] = m
}
err := repository.generateCoordinateInfo(source.MainCoordinateSystem)
err = repository.generateCoordinateInfo(source.MainCoordinateSystem)
if err != nil {
return err
}
@ -165,6 +179,7 @@ func buildModels(source *proto.Repository, repository *Repository) error {
repository.spksMap[protoData.Id] = &Spks{Identity: identity{id: protoData.Id, deviceType: proto.DeviceType_DeviceType_Spks}}
}
err = buildIscsModels(source, repository)
//
return err
}
@ -238,6 +253,29 @@ func buildModelRelationship(source *proto.Repository, repository *Repository) er
return err
}
func calibrationKilometer(km *proto.Kilometer, repository *Repository) {
params := repository.kilometerCalibrationMap[km.CoordinateSystem+km.Direction.String()]
for _, param := range params {
if param.Design.Value <= km.Value {
km.Value += param.Actual.Value - param.Design.Value
break
}
}
}
func buildKilometerCalibration(source *proto.Repository, repository *Repository) error {
for _, protoData := range source.KilometerCalibrations {
key := protoData.Design.CoordinateSystem + protoData.Design.Direction.String()
repository.kilometerCalibrationMap[key] = append(repository.kilometerCalibrationMap[key], protoData)
}
for _, calibrations := range repository.kilometerCalibrationMap {
sort.Slice(calibrations, func(i, j int) bool {
return calibrations[i].Design.Value > calibrations[j].Design.Value
})
}
return nil
}
func buildAxleCountingSectionRelationShip(source *proto.Repository, repository *Repository) error {
turnout_physicalSection_map := make(map[string]*PhysicalSection)
for _, physicalSection := range repository.physicalSectionMap {