73 lines
1.5 KiB
Go
73 lines
1.5 KiB
Go
package modelimpl
|
|
|
|
import (
|
|
"sync/atomic"
|
|
|
|
"joylink.club/rtsssimulation/modelrepo/dto"
|
|
"joylink.club/rtsssimulation/modelrepo/model"
|
|
)
|
|
|
|
// link生成uid基础值
|
|
var link_uid_base = atomic.Uint32{}
|
|
|
|
var _link model.Link = (*Link)(nil)
|
|
|
|
// 轨道链路
|
|
type Link struct {
|
|
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排序
|
|
}
|
|
|
|
// GetLength implements model.Link.
|
|
func (l *Link) GetLength() int64 {
|
|
return l.Length
|
|
}
|
|
|
|
// GetPaTurnout implements model.Link.
|
|
func (l *Link) GetPaTurnout() model.Points {
|
|
return l.PaTurnout
|
|
}
|
|
|
|
// GetPbTurnout implements model.Link.
|
|
func (l *Link) GetPbTurnout() model.Points {
|
|
return l.PbTurnout
|
|
}
|
|
|
|
// Next implements model.Link.
|
|
func (*Link) Next(port model.Link_Port, tpos model.PointsPosition) *model.LinkPort {
|
|
panic("unimplemented")
|
|
}
|
|
|
|
// Type implements model.Link.
|
|
func (l *Link) Type() model.ModelType {
|
|
return model.ModelType_Link
|
|
}
|
|
|
|
// Uid implements model.Link.
|
|
func (l *Link) Uid() model.Uid {
|
|
return l.uid
|
|
}
|
|
|
|
func NewLink() *Link {
|
|
return &Link{}
|
|
}
|
|
|
|
// link偏移
|
|
type LinkOffset struct {
|
|
link *Link
|
|
offset int64
|
|
}
|
|
|
|
// link偏移范围
|
|
type LinkRange struct {
|
|
link *Link
|
|
start int64
|
|
end int64
|
|
}
|