rts-sim-testing-service/ats/verify/simulation/wayside/model/section/axle_section_model.go

50 lines
1.5 KiB
Go
Raw Normal View History

2023-07-31 11:30:34 +08:00
package section
import (
2023-07-31 15:59:23 +08:00
"container/list"
"fmt"
"sort"
"strings"
2023-07-31 11:30:34 +08:00
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/face"
)
// 相邻计轴检测点(车档为特殊的计轴检测点)定义的计轴区段由LinkSection组成
type AxleSectionModel struct {
//计轴区段基本信息
face.DeviceModel
2023-07-31 15:59:23 +08:00
//计轴区段的A端的计轴检测点
AxlePointA face.AxlePointDeviceModeller
//计轴区段的B端的计轴检测点
AxlePointB face.AxlePointDeviceModeller
//如果该计轴区段经过岔区,则所经过的道岔应该所处的定反位
//ref.SwitchPositionRef
ViaSwitchPositions *list.List
//PathLayer中收集: 该计轴区段经过的轨道
//face.LinkSectionModeller
ViaLinks *list.List
//计轴区段的两侧计轴点的图形id形成的key
pointsKey string
}
// 计轴区段的两侧计轴点的图形id形成的key
func (asm *AxleSectionModel) GetPointsKey() string {
if len(strings.TrimSpace(asm.pointsKey)) == 0 {
var pointsKeySlice = make([]string, 0, 2)
pointsKeySlice = append(pointsKeySlice, asm.AxlePointA.GetGraphicId())
pointsKeySlice = append(pointsKeySlice, asm.AxlePointB.GetGraphicId())
sort.Strings(pointsKeySlice)
asm.pointsKey = fmt.Sprintf("%s_%s", pointsKeySlice[0], pointsKeySlice[1])
}
return asm.pointsKey
}
// 计轴区段中轨道个数,即计轴区段是由几个轨道组成
func (asm *AxleSectionModel) LinksCount() int {
if asm.ViaSwitchPositions == nil {
return 1
} else {
return 1 + asm.ViaSwitchPositions.Len()
}
2023-07-31 11:30:34 +08:00
}