区段道岔公里标模型数据构建
This commit is contained in:
parent
5a18ea69fe
commit
b3271b497a
@ -11,7 +11,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
slog.SetLogLoggerLevel(slog.LevelDebug)
|
// slog.SetLogLoggerLevel(slog.LevelDebug)
|
||||||
|
slog.SetLogLoggerLevel(slog.LevelInfo)
|
||||||
repo1 := repository.NewRepository("test1")
|
repo1 := repository.NewRepository("test1")
|
||||||
rtssGraphicStorage := data_proto.GetXian6STYG()
|
rtssGraphicStorage := data_proto.GetXian6STYG()
|
||||||
dataMapping := repository.NewDataMapping("1", rtssGraphicStorage)
|
dataMapping := repository.NewDataMapping("1", rtssGraphicStorage)
|
||||||
@ -67,6 +68,8 @@ func main() {
|
|||||||
} else {
|
} else {
|
||||||
slog.Info("区段、道岔连接关系检查通过")
|
slog.Info("区段、道岔连接关系检查通过")
|
||||||
}
|
}
|
||||||
|
// 构建区段、道岔公里标
|
||||||
|
buildKilometerMark(dataMapping, repo1)
|
||||||
// 构建link/linknode
|
// 构建link/linknode
|
||||||
repo1.BuildLinks()
|
repo1.BuildLinks()
|
||||||
// 检查link/linknode
|
// 检查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) {
|
func buildTurnoutRelationships(dataMapping *repository.DataMapping, repo1 *repository.Repository) {
|
||||||
for _, turnout := range dataMapping.TurnoutDataMap {
|
for _, turnout := range dataMapping.TurnoutDataMap {
|
||||||
idmapping := dataMapping.IdMappingMap[turnout.Common.Id]
|
idmapping := dataMapping.IdMappingMap[turnout.Common.Id]
|
||||||
|
@ -4,14 +4,14 @@ package model
|
|||||||
type Section interface {
|
type Section interface {
|
||||||
TwoPortsPipeElement
|
TwoPortsPipeElement
|
||||||
// 获取A端和B端的公里标
|
// 获取A端和B端的公里标
|
||||||
GetPaKm() KilometerMark
|
GetPaKm() *KilometerMark
|
||||||
GetPbKm() KilometerMark
|
GetPbKm() *KilometerMark
|
||||||
}
|
}
|
||||||
|
|
||||||
type SectionImpl struct {
|
type SectionImpl struct {
|
||||||
*TwoPortsPipeElementImpl
|
*TwoPortsPipeElementImpl
|
||||||
PaKm KilometerMark
|
PaKm *KilometerMark
|
||||||
PbKm KilometerMark
|
PbKm *KilometerMark
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ Section = (*SectionImpl)(nil)
|
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
|
return s.PaKm
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SectionImpl) GetPbKm() KilometerMark {
|
func (s *SectionImpl) GetPbKm() *KilometerMark {
|
||||||
return s.PbKm
|
return s.PbKm
|
||||||
}
|
}
|
||||||
|
@ -8,23 +8,23 @@ import (
|
|||||||
type Turnout interface {
|
type Turnout interface {
|
||||||
ThreePortsPipeElement
|
ThreePortsPipeElement
|
||||||
// 获取道岔岔心公里标
|
// 获取道岔岔心公里标
|
||||||
GetKm() KilometerMark
|
GetKm() *KilometerMark
|
||||||
// 获取道岔A端公里标
|
// 获取道岔A端公里标
|
||||||
GetPaKm() KilometerMark
|
GetPaKm() *KilometerMark
|
||||||
// 获取道岔B端公里标
|
// 获取道岔B端公里标
|
||||||
GetPbKm() KilometerMark
|
GetPbKm() *KilometerMark
|
||||||
// 获取道岔C端公里标
|
// 获取道岔C端公里标
|
||||||
GetPcKm() KilometerMark
|
GetPcKm() *KilometerMark
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ Turnout = (*TurnoutImpl)(nil)
|
var _ Turnout = (*TurnoutImpl)(nil)
|
||||||
|
|
||||||
type TurnoutImpl struct {
|
type TurnoutImpl struct {
|
||||||
*ThreePortsPipeElementImpl
|
*ThreePortsPipeElementImpl
|
||||||
Km KilometerMark
|
Km *KilometerMark
|
||||||
PaKm KilometerMark
|
PaKm *KilometerMark
|
||||||
PbKm KilometerMark
|
PbKm *KilometerMark
|
||||||
PcKm KilometerMark
|
PcKm *KilometerMark
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTurnout(uid string) *TurnoutImpl {
|
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
|
return t.Km
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TurnoutImpl) GetPaKm() KilometerMark {
|
func (t *TurnoutImpl) GetPaKm() *KilometerMark {
|
||||||
return t.PaKm
|
return t.PaKm
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TurnoutImpl) GetPbKm() KilometerMark {
|
func (t *TurnoutImpl) GetPbKm() *KilometerMark {
|
||||||
return t.PbKm
|
return t.PbKm
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TurnoutImpl) GetPcKm() KilometerMark {
|
func (t *TurnoutImpl) GetPcKm() *KilometerMark {
|
||||||
return t.PcKm
|
return t.PcKm
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user