【修改检验逻辑】
This commit is contained in:
parent
82367536da
commit
339ba7295c
@ -287,9 +287,10 @@ func (repo *Repository) ConvertKilometer(km *proto.Kilometer, cs string) (*proto
|
|||||||
targetCsKm = kc.KmA
|
targetCsKm = kc.KmA
|
||||||
}
|
}
|
||||||
value := targetCsKm.Value + (km.Value - sourceCsKm.Value)
|
value := targetCsKm.Value + (km.Value - sourceCsKm.Value)
|
||||||
if value < 0 {
|
// 20231205 注释
|
||||||
panic(fmt.Sprintf("公里标[%v]转换为坐标系[%s]的公里标的值[%d]小于0", km, cs, value))
|
// if value < 0 {
|
||||||
}
|
// panic(fmt.Sprintf("公里标[%v]转换为坐标系[%s]的公里标的值[%d]小于0", km, cs, value))
|
||||||
|
// }
|
||||||
return &proto.Kilometer{Value: value, CoordinateSystem: cs}, nil
|
return &proto.Kilometer{Value: value, CoordinateSystem: cs}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package repository
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"joylink.club/rtsssimulation/repository/model/proto"
|
"joylink.club/rtsssimulation/repository/model/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -23,7 +24,8 @@ func baseCheck(source *proto.Repository) []string {
|
|||||||
if turnout.Km == nil {
|
if turnout.Km == nil {
|
||||||
errMsg = append(errMsg, fmt.Sprintf("道岔[%s]缺少公里标", turnout.Id))
|
errMsg = append(errMsg, fmt.Sprintf("道岔[%s]缺少公里标", turnout.Id))
|
||||||
}
|
}
|
||||||
if turnout.ADevicePort == nil || turnout.BDevicePort == nil || turnout.CDevicePort == nil {
|
// 如果缺少所有关联设备则报错
|
||||||
|
if turnout.ADevicePort == nil && turnout.BDevicePort == nil && turnout.CDevicePort == nil {
|
||||||
errMsg = append(errMsg, fmt.Sprintf("道岔[%s]缺少端口关联数据", turnout.Id))
|
errMsg = append(errMsg, fmt.Sprintf("道岔[%s]缺少端口关联数据", turnout.Id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -386,6 +386,9 @@ func buildSignalRelationShip(source *proto.Repository, repository *Repository) e
|
|||||||
func buildTurnoutRelationShip(source *proto.Repository, repo *Repository) error {
|
func buildTurnoutRelationShip(source *proto.Repository, repo *Repository) error {
|
||||||
for _, protoData := range source.Turnouts {
|
for _, protoData := range source.Turnouts {
|
||||||
turnout := repo.turnoutMap[protoData.Id]
|
turnout := repo.turnoutMap[protoData.Id]
|
||||||
|
if protoData.ADevicePort == nil && protoData.BDevicePort == nil && protoData.CDevicePort == nil {
|
||||||
|
return fmt.Errorf("道岔[%s]无连接设备", protoData.Id)
|
||||||
|
}
|
||||||
err := buildTurnoutPortRelation(repo, turnout, proto.Port_A, protoData.ADevicePort)
|
err := buildTurnoutPortRelation(repo, turnout, proto.Port_A, protoData.ADevicePort)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -418,6 +421,9 @@ func buildTurnoutRelationShip(source *proto.Repository, repo *Repository) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
func buildTurnoutPortRelation(repo *Repository, turnout *Turnout, port proto.Port, protoDp *proto.DevicePort) error {
|
func buildTurnoutPortRelation(repo *Repository, turnout *Turnout, port proto.Port, protoDp *proto.DevicePort) error {
|
||||||
|
if protoDp == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
model, err := repo.FindModel(protoDp.DeviceId, protoDp.DeviceType)
|
model, err := repo.FindModel(protoDp.DeviceId, protoDp.DeviceType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user