rts-sim-module/modelrepo/model_impl/link.go

73 lines
1.5 KiB
Go
Raw Normal View History

2023-12-28 11:06:46 +08:00
package modelimpl
2023-12-27 09:15:26 +08:00
import (
"sync/atomic"
"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.
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.
func (l *Link) GetPbTurnout() model.Points {
2023-12-28 11:06:46 +08:00
return l.PbTurnout
}
// Next implements model.Link.
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 {
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
}