区段道岔公里标模型数据构建

This commit is contained in:
walker-sheng” 2024-07-05 13:22:01 +08:00
parent 5a18ea69fe
commit b3271b497a
3 changed files with 56 additions and 19 deletions

View File

@ -11,7 +11,8 @@ import (
)
func main() {
slog.SetLogLoggerLevel(slog.LevelDebug)
// slog.SetLogLoggerLevel(slog.LevelDebug)
slog.SetLogLoggerLevel(slog.LevelInfo)
repo1 := repository.NewRepository("test1")
rtssGraphicStorage := data_proto.GetXian6STYG()
dataMapping := repository.NewDataMapping("1", rtssGraphicStorage)
@ -67,6 +68,8 @@ func main() {
} else {
slog.Info("区段、道岔连接关系检查通过")
}
// 构建区段、道岔公里标
buildKilometerMark(dataMapping, repo1)
// 构建link/linknode
repo1.BuildLinks()
// 检查link/linknode
@ -79,6 +82,40 @@ func main() {
}
}
// 构建区段、道岔公里标
func buildKilometerMark(dataMapping *repository.DataMapping, repo1 *repository.Repository) {
for _, checkpoint := range dataMapping.AxleCountings {
if checkpoint.AxleCountingRef == nil || len(checkpoint.AxleCountingRef) == 0 {
repo1.BuildErrorInfos = append(repo1.BuildErrorInfos, fmt.Errorf("构建区段、道岔公里标错误:检测点[id=%d]未关联任何区段、道岔", checkpoint.Common.Id))
}
for _, linkship := range checkpoint.AxleCountingRef {
slog.Info("区段检测点关联数据", "code", checkpoint.Code, "linkship", fmt.Sprintf("{type=%s, id=%d, port=%s}", linkship.DeviceType, linkship.Id, linkship.DevicePort))
idmapping := dataMapping.IdMappingMap[linkship.Id]
if idmapping == nil {
repo1.BuildErrorInfos = append(repo1.BuildErrorInfos, fmt.Errorf("构建区段、道岔公里标错误:检测点[id=%d]关联的{type=%s,id=%d}不存在", checkpoint.Common.Id, linkship.DeviceType, linkship.Id))
continue
}
if linkship.DeviceType == data_proto.RelatedRef_Section {
sectionModel := repo1.SectionMap[idmapping.Uid]
if sectionModel == nil {
panic(fmt.Errorf("构建区段、道岔公里标错误:检测点[id=%d]关联的区段模型[uid=%s]不存在", checkpoint.Common.Id, idmapping.Uid))
}
sectionModel.(*modelimpl.Section).PaKm = model.NewKilometerMark(checkpoint.KilometerSystem.CoordinateSystem, convertKmDirection(checkpoint.KilometerSystem.Direction), checkpoint.KilometerSystem.Kilometer)
}
}
}
}
func convertKmDirection(kddata data_proto.KilometerSystem_Direction) model.OperationDirection {
if kddata == data_proto.KilometerSystem_LEFT {
return model.OperationDirectionDown
}
if kddata == data_proto.KilometerSystem_RIGHT {
return model.OperationDirectionUp
}
panic(fmt.Errorf("未知的公里标方向类型: %v", kddata))
}
func buildTurnoutRelationships(dataMapping *repository.DataMapping, repo1 *repository.Repository) {
for _, turnout := range dataMapping.TurnoutDataMap {
idmapping := dataMapping.IdMappingMap[turnout.Common.Id]

View File

@ -4,14 +4,14 @@ package model
type Section interface {
TwoPortsPipeElement
// 获取A端和B端的公里标
GetPaKm() KilometerMark
GetPbKm() KilometerMark
GetPaKm() *KilometerMark
GetPbKm() *KilometerMark
}
type SectionImpl struct {
*TwoPortsPipeElementImpl
PaKm KilometerMark
PbKm KilometerMark
PaKm *KilometerMark
PbKm *KilometerMark
}
var _ Section = (*SectionImpl)(nil)
@ -24,10 +24,10 @@ func NewSection(uid string) *SectionImpl {
}
}
func (s *SectionImpl) GetPaKm() KilometerMark {
func (s *SectionImpl) GetPaKm() *KilometerMark {
return s.PaKm
}
func (s *SectionImpl) GetPbKm() KilometerMark {
func (s *SectionImpl) GetPbKm() *KilometerMark {
return s.PbKm
}

View File

@ -8,23 +8,23 @@ import (
type Turnout interface {
ThreePortsPipeElement
// 获取道岔岔心公里标
GetKm() KilometerMark
GetKm() *KilometerMark
// 获取道岔A端公里标
GetPaKm() KilometerMark
GetPaKm() *KilometerMark
// 获取道岔B端公里标
GetPbKm() KilometerMark
GetPbKm() *KilometerMark
// 获取道岔C端公里标
GetPcKm() KilometerMark
GetPcKm() *KilometerMark
}
var _ Turnout = (*TurnoutImpl)(nil)
type TurnoutImpl struct {
*ThreePortsPipeElementImpl
Km KilometerMark
PaKm KilometerMark
PbKm KilometerMark
PcKm KilometerMark
Km *KilometerMark
PaKm *KilometerMark
PbKm *KilometerMark
PcKm *KilometerMark
}
func NewTurnout(uid string) *TurnoutImpl {
@ -38,18 +38,18 @@ func NewTurnout(uid string) *TurnoutImpl {
}
}
func (t *TurnoutImpl) GetKm() KilometerMark {
func (t *TurnoutImpl) GetKm() *KilometerMark {
return t.Km
}
func (t *TurnoutImpl) GetPaKm() KilometerMark {
func (t *TurnoutImpl) GetPaKm() *KilometerMark {
return t.PaKm
}
func (t *TurnoutImpl) GetPbKm() KilometerMark {
func (t *TurnoutImpl) GetPbKm() *KilometerMark {
return t.PbKm
}
func (t *TurnoutImpl) GetPcKm() KilometerMark {
func (t *TurnoutImpl) GetPcKm() *KilometerMark {
return t.PcKm
}