53 lines
1.0 KiB
Go
53 lines
1.0 KiB
Go
|
package impl
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"sync/atomic"
|
||
|
|
||
|
"joylink.club/rtsssimulation/repo/dto"
|
||
|
"joylink.club/rtsssimulation/repo/model"
|
||
|
)
|
||
|
|
||
|
// link生成uid基础值
|
||
|
var link_uid_base = atomic.Uint32{}
|
||
|
|
||
|
// 轨道链路
|
||
|
type Link struct {
|
||
|
uid string
|
||
|
|
||
|
apTurnout *Turnout // A端关联道岔,可能为nil
|
||
|
bpTurnout *Turnout // B端关联道岔,可能为nil
|
||
|
apGlb dto.GLB // A端公里标
|
||
|
bpGlb dto.GLB // B端公里标
|
||
|
length int64 // 长度
|
||
|
models []model.Model // 关联的模型,从A到B排序
|
||
|
physicalSections []*PhysicalSection // 关联的物理区段(包含道岔物理区段),从A到B排序
|
||
|
}
|
||
|
|
||
|
func NewLink() *Link {
|
||
|
return &Link{
|
||
|
uid: fmt.Sprintf("%d", link_uid_base.Add(1)),
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (l *Link) Uid() string {
|
||
|
return l.uid
|
||
|
}
|
||
|
|
||
|
func (l *Link) Type() model.ModelType {
|
||
|
return model.MT_Link
|
||
|
}
|
||
|
|
||
|
// link偏移
|
||
|
type LinkOffset struct {
|
||
|
link *Link
|
||
|
offset int64
|
||
|
}
|
||
|
|
||
|
// link偏移范围
|
||
|
type LinkRange struct {
|
||
|
link *Link
|
||
|
start int64
|
||
|
end int64
|
||
|
}
|