【修改link中节点的关联逻辑】

This commit is contained in:
weizhihong 2023-08-09 10:37:03 +08:00
parent 253d6f9889
commit 300232fda4

View File

@ -108,7 +108,7 @@ func calcGraphicLenBySection(section *buildCalcSectionStruct) int32 {
}
var length int64 // 两端公里标相减即可
for _, a := range section.axlePoints {
if a.KilometerSystem == nil || a.KilometerSystem.CoordinateSystem == "" {
if !judgeKilometerIsVaild(a.KilometerSystem) {
return 0
}
length = a.KilometerSystem.Kilometer - length
@ -119,11 +119,11 @@ func calcGraphicLenBySection(section *buildCalcSectionStruct) int32 {
// 计算道岔端长度
func calcGraphicLenByTurnout(turnout *buildCalcTurnoutStruct, p graphicData.RelatedRef_DevicePort) int32 {
endPoint := turnout.axlePoints[p]
if endPoint == nil || endPoint.KilometerSystem == nil || endPoint.KilometerSystem.CoordinateSystem == "" {
if endPoint == nil || !judgeKilometerIsVaild(endPoint.KilometerSystem) {
zap.S().Warnf("道岔【%s】对应端口【%s】数据无计轴", turnout.Data.Common.Id, p.String())
return 0
}
if turnout.CrossKilometerSystem == nil {
if !judgeKilometerIsVaild(turnout.CrossKilometerSystem) {
zap.S().Warnf("道岔【%s】数据错误,岔心公里标为空", turnout.Data.Common.Id)
return 0
}
@ -165,7 +165,7 @@ func getGraphicSectionRefDevices(deviceMap map[string]*graphicData.CalculateLink
spof := deviceMap[startPoint.Common.Id].Offset // 相对的起点offset
// 信号机信息
for _, s := range section.signals {
if s.KilometerSystem != nil && s.KilometerSystem.CoordinateSystem != "" && deviceMap[s.Common.Id] == nil {
if judgeKilometerIsVaild(s.KilometerSystem) && deviceMap[s.Common.Id] == nil {
deviceMap[s.Common.Id] = &graphicData.CalculateLink_DevicePosition{
DeviceId: s.Common.Id,
Offset: spof + int32(math.Abs(float64(s.KilometerSystem.Kilometer-sppk))),
@ -175,7 +175,7 @@ func getGraphicSectionRefDevices(deviceMap map[string]*graphicData.CalculateLink
}
// 停车标信息
for _, s := range section.stopPositions {
if s.KilometerSystem != nil && s.KilometerSystem.CoordinateSystem != "" && deviceMap[s.Common.Id] == nil {
if judgeKilometerIsVaild(s.KilometerSystem) && deviceMap[s.Common.Id] == nil {
deviceMap[s.Common.Id] = &graphicData.CalculateLink_DevicePosition{
DeviceId: s.Common.Id,
Offset: spof + int32(math.Abs(float64(s.KilometerSystem.Kilometer-sppk))),
@ -185,7 +185,7 @@ func getGraphicSectionRefDevices(deviceMap map[string]*graphicData.CalculateLink
}
// 应答器信息
for _, t := range section.transponders {
if t.KilometerSystem != nil && t.KilometerSystem.CoordinateSystem != "" && deviceMap[t.Common.Id] == nil {
if judgeKilometerIsVaild(t.KilometerSystem) && deviceMap[t.Common.Id] == nil {
deviceMap[t.Common.Id] = &graphicData.CalculateLink_DevicePosition{
DeviceId: t.Common.Id,
Offset: spof + int32(math.Abs(float64(t.KilometerSystem.Kilometer-sppk))),
@ -210,7 +210,7 @@ func getGraphicTurnoutRefDevices(refVal *graphicData.RelatedRef, deviceMap map[s
}
// 查看是否存在连接计轴
point := turnout.axlePoints[refVal.DevicePort]
if point != nil && point.KilometerSystem != nil && deviceMap[point.Common.Id] == nil {
if point != nil && judgeKilometerIsVaild(point.KilometerSystem) && deviceMap[point.Common.Id] == nil {
deviceMap[point.Common.Id] = &graphicData.CalculateLink_DevicePosition{
DeviceId: point.Common.Id,
Offset: offset + int32(math.Abs(float64(point.KilometerSystem.Kilometer-prevKm))),
@ -219,20 +219,18 @@ func getGraphicTurnoutRefDevices(refVal *graphicData.RelatedRef, deviceMap map[s
}
// 处理道岔上的信号机
signal := turnout.signals[refVal.DevicePort]
if signal != nil {
if signal.KilometerSystem != nil && signal.KilometerSystem.CoordinateSystem != "" && deviceMap[signal.Common.Id] == nil {
if signal != nil && judgeKilometerIsVaild(signal.KilometerSystem) && deviceMap[signal.Common.Id] == nil {
deviceMap[signal.Common.Id] = &graphicData.CalculateLink_DevicePosition{
DeviceId: signal.Common.Id,
Offset: offset + int32(math.Abs(float64(signal.KilometerSystem.Kilometer-prevKm))),
DeviceType: "Signal",
}
}
}
// 处理道岔上的应答器
transponders := turnout.transponders[refVal.DevicePort]
if transponders != nil {
for _, t := range transponders {
if t.KilometerSystem != nil && t.KilometerSystem.CoordinateSystem != "" && deviceMap[t.Common.Id] == nil {
if judgeKilometerIsVaild(t.KilometerSystem) && deviceMap[t.Common.Id] == nil {
deviceMap[t.Common.Id] = &graphicData.CalculateLink_DevicePosition{
DeviceId: t.Common.Id,
Offset: offset + int32(math.Abs(float64(t.KilometerSystem.Kilometer-prevKm))),
@ -253,10 +251,14 @@ func getGraphicSectionPointRef(section *buildCalcSectionStruct, b bool, defaultR
}
apoint := section.axlePoints[graphicData.RelatedRef_A]
bpoint := section.axlePoints[graphicData.RelatedRef_B]
if apoint == nil || bpoint == nil {
if apoint == nil && bpoint == nil {
return defaultRelateRef
} else if apoint != nil && bpoint == nil {
return &graphicData.RelatedRef{DeviceType: graphicData.RelatedRef_AxleCounting, Id: apoint.Common.Id}
} else if apoint == nil && bpoint != nil {
return &graphicData.RelatedRef{DeviceType: graphicData.RelatedRef_AxleCounting, Id: bpoint.Common.Id}
}
if apoint.KilometerSystem.Kilometer < bpoint.KilometerSystem.Kilometer && b {
if b {
return &graphicData.RelatedRef{DeviceType: graphicData.RelatedRef_AxleCounting, Id: apoint.Common.Id}
} else {
return &graphicData.RelatedRef{DeviceType: graphicData.RelatedRef_AxleCounting, Id: bpoint.Common.Id}
@ -276,7 +278,7 @@ func getGraphicDataDeviceMap(gd *graphicData.RtssGraphicStorage) (*buildCalcStru
for _, t := range gd.Turnouts {
var op *graphicData.KilometerSystem
for _, k := range t.KilometerSystem {
if k.CoordinateSystem == "MAIN_LINE" && k.Kilometer != 0 {
if judgeKilometerIsVaild(k) {
op = k
}
}
@ -317,6 +319,10 @@ func getGraphicDataDeviceMap(gd *graphicData.RtssGraphicStorage) (*buildCalcStru
}
// 信号机关联到对应区段或道岔上
for _, s := range gd.Signals {
// 过滤掉没有公里标数据的信号机
if !judgeKilometerIsVaild(s.KilometerSystem) {
continue
}
switch s.RefDev.DeviceType {
case graphicData.RelatedRef_Section:
gm.SectionMap[s.RefDev.Id].signals = append(gm.SectionMap[s.RefDev.Id].signals, s)
@ -326,6 +332,10 @@ func getGraphicDataDeviceMap(gd *graphicData.RtssGraphicStorage) (*buildCalcStru
}
// 应答器关联到对应区段或道岔
for _, t := range gd.Transponders {
// 过滤掉没有公里标数据的应答器
if !judgeKilometerIsVaild(t.KilometerSystem) {
continue
}
switch t.TransponderRef.DeviceType {
case graphicData.RelatedRef_Section:
gm.SectionMap[t.TransponderRef.Id].transponders = append(gm.SectionMap[t.TransponderRef.Id].transponders, t)
@ -335,6 +345,10 @@ func getGraphicDataDeviceMap(gd *graphicData.RtssGraphicStorage) (*buildCalcStru
}
// 停车标关联到对应区段或道岔
for _, s := range gd.StopPositions {
// 过滤掉没有公里标数据的停车标
if !judgeKilometerIsVaild(s.KilometerSystem) {
continue
}
switch s.RefDev.DeviceType {
case graphicData.RelatedRef_Section:
gm.SectionMap[s.RefDev.Id].stopPositions = append(gm.SectionMap[s.RefDev.Id].stopPositions, s)
@ -450,14 +464,14 @@ func handleFunc(gm *buildCalcStruct, ref *graphicData.RelatedRef) (int, bool) {
case graphicData.RelatedRef_Section:
section := gm.SectionMap[ref.Id]
point := section.axlePoints[ref.DevicePort]
if point == nil || point.KilometerSystem == nil {
if point == nil || !judgeKilometerIsVaild(point.KilometerSystem) {
zap.S().Warnf("区段【%s】【%s】端缺少关联计轴信息", ref.Id, ref.DevicePort.String())
} else {
return int(point.KilometerSystem.Kilometer), true
}
case graphicData.RelatedRef_Turnout:
turnout := gm.TurnoutMap[ref.Id]
if turnout.CrossKilometerSystem == nil {
if !judgeKilometerIsVaild(turnout.CrossKilometerSystem) {
zap.S().Warnf("道岔【%s】缺少岔心公里标数据", ref.Id)
} else {
return int(turnout.CrossKilometerSystem.Kilometer), true
@ -483,10 +497,15 @@ func getStartKilometer(gm *buildCalcStruct, ref *graphicData.RelatedRef) (int64,
return resultKilometer, 0
case graphicData.RelatedRef_Turnout:
turnout := gm.TurnoutMap[ref.Id]
if turnout.CrossKilometerSystem == nil {
if !judgeKilometerIsVaild(turnout.CrossKilometerSystem) {
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "道岔岔心无公里标"})
}
return turnout.CrossKilometerSystem.Kilometer, 0
}
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: "错误的设备类型类型"})
}
// 判断公里标是否有效
func judgeKilometerIsVaild(k *graphicData.KilometerSystem) bool {
return k != nil && k.CoordinateSystem == "MAIN_LINE" && k.Kilometer != 0
}