2023-12-28 11:06:46 +08:00
|
|
|
package modelimpl
|
2023-12-27 09:15:26 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"sync/atomic"
|
|
|
|
|
2023-12-28 16:49:28 +08:00
|
|
|
"joylink.club/rtsssimulation/modelrepo/dto"
|
|
|
|
"joylink.club/rtsssimulation/modelrepo/model"
|
2023-12-27 09:15:26 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
// link生成uid基础值
|
|
|
|
var link_uid_base = atomic.Uint32{}
|
|
|
|
|
2023-12-28 11:06:46 +08:00
|
|
|
var _link model.Link = (*Link)(nil)
|
|
|
|
|
2023-12-27 09:15:26 +08:00
|
|
|
// 轨道链路
|
|
|
|
type Link struct {
|
2023-12-28 11:06:46 +08:00
|
|
|
uid model.Uid
|
|
|
|
PaTurnout *Turnout // A端关联道岔,可能为nil
|
|
|
|
PbTurnout *Turnout // B端关联道岔,可能为nil
|
|
|
|
PaGlb dto.GLB // A端公里标
|
|
|
|
PbGlb dto.GLB // B端公里标
|
|
|
|
Length int64 // 长度
|
|
|
|
Models []model.Model // 关联的模型,从A到B排序
|
|
|
|
Sections []*PhysicalSection // 关联的物理区段(包含道岔物理区段),从A到B排序
|
|
|
|
}
|
2023-12-27 09:15:26 +08:00
|
|
|
|
2023-12-28 11:06:46 +08:00
|
|
|
// GetLength implements model.Link.
|
|
|
|
func (l *Link) GetLength() int64 {
|
|
|
|
return l.Length
|
2023-12-27 09:15:26 +08:00
|
|
|
}
|
|
|
|
|
2023-12-28 11:06:46 +08:00
|
|
|
// GetPaTurnout implements model.Link.
|
2024-01-02 18:22:28 +08:00
|
|
|
func (l *Link) GetPaTurnout() model.Points {
|
2023-12-28 11:06:46 +08:00
|
|
|
return l.PaTurnout
|
2023-12-27 09:15:26 +08:00
|
|
|
}
|
|
|
|
|
2023-12-28 11:06:46 +08:00
|
|
|
// GetPbTurnout implements model.Link.
|
2024-01-02 18:22:28 +08:00
|
|
|
func (l *Link) GetPbTurnout() model.Points {
|
2023-12-28 11:06:46 +08:00
|
|
|
return l.PbTurnout
|
|
|
|
}
|
|
|
|
|
|
|
|
// Next implements model.Link.
|
2024-01-02 18:22:28 +08:00
|
|
|
func (*Link) Next(port model.Link_Port, tpos model.PointsPosition) *model.LinkPort {
|
2023-12-28 11:06:46 +08:00
|
|
|
panic("unimplemented")
|
2023-12-27 09:15:26 +08:00
|
|
|
}
|
|
|
|
|
2023-12-28 11:06:46 +08:00
|
|
|
// Type implements model.Link.
|
2023-12-27 09:15:26 +08:00
|
|
|
func (l *Link) Type() model.ModelType {
|
2023-12-27 15:51:28 +08:00
|
|
|
return model.ModelType_Link
|
2023-12-27 09:15:26 +08:00
|
|
|
}
|
|
|
|
|
2023-12-28 11:06:46 +08:00
|
|
|
// Uid implements model.Link.
|
|
|
|
func (l *Link) Uid() model.Uid {
|
|
|
|
return l.uid
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewLink() *Link {
|
|
|
|
return &Link{}
|
|
|
|
}
|
|
|
|
|
2023-12-27 09:15:26 +08:00
|
|
|
// link偏移
|
|
|
|
type LinkOffset struct {
|
|
|
|
link *Link
|
|
|
|
offset int64
|
|
|
|
}
|
|
|
|
|
|
|
|
// link偏移范围
|
|
|
|
type LinkRange struct {
|
|
|
|
link *Link
|
|
|
|
start int64
|
|
|
|
end int64
|
|
|
|
}
|