86 lines
1.5 KiB
Go
86 lines
1.5 KiB
Go
package model
|
|
|
|
// 区段
|
|
type Section interface {
|
|
RtssModel
|
|
}
|
|
|
|
// 物理区段(非道岔区段)
|
|
type PhysicalSection interface {
|
|
TwoPortsPipeElement
|
|
// 获取A端和B端的公里标
|
|
GetPaKm() *KilometerMark
|
|
GetPbKm() *KilometerMark
|
|
}
|
|
|
|
// 道岔区段
|
|
type TurnoutSection interface {
|
|
Section
|
|
// 获取关联的道岔列表
|
|
GetTurnouts() []Turnout
|
|
}
|
|
|
|
// 逻辑区段
|
|
type LogicalSection interface {
|
|
Section
|
|
// 获取A端和B端的公里标
|
|
GetPaKm() *KilometerMark
|
|
GetPbKm() *KilometerMark
|
|
}
|
|
|
|
type PhysicalSectionImpl struct {
|
|
*TwoPortsPipeElementImpl
|
|
PaKm *KilometerMark
|
|
PbKm *KilometerMark
|
|
}
|
|
|
|
var _ PhysicalSection = (*PhysicalSectionImpl)(nil)
|
|
|
|
func NewPhysicalSection(uid string) *PhysicalSectionImpl {
|
|
return &PhysicalSectionImpl{
|
|
TwoPortsPipeElementImpl: &TwoPortsPipeElementImpl{
|
|
uid: uid,
|
|
},
|
|
}
|
|
}
|
|
|
|
func (s *PhysicalSectionImpl) GetPaKm() *KilometerMark {
|
|
return s.PaKm
|
|
}
|
|
|
|
func (s *PhysicalSectionImpl) GetPbKm() *KilometerMark {
|
|
return s.PbKm
|
|
}
|
|
|
|
type SectionImpl struct {
|
|
uid string
|
|
}
|
|
|
|
func (s *SectionImpl) Uid() string {
|
|
return s.uid
|
|
}
|
|
|
|
var _ TurnoutSection = (*TurnoutSectionImpl)(nil)
|
|
|
|
type TurnoutSectionImpl struct {
|
|
*SectionImpl
|
|
Turnouts []Turnout
|
|
}
|
|
|
|
func NewTurnoutSection(uid string) *TurnoutSectionImpl {
|
|
return &TurnoutSectionImpl{
|
|
SectionImpl: &SectionImpl{
|
|
uid: uid,
|
|
},
|
|
Turnouts: make([]Turnout, 0),
|
|
}
|
|
}
|
|
|
|
func (t *TurnoutSectionImpl) AddTurnout(turnout Turnout) {
|
|
t.Turnouts = append(t.Turnouts, turnout)
|
|
}
|
|
|
|
func (t *TurnoutSectionImpl) GetTurnouts() []Turnout {
|
|
return t.Turnouts
|
|
}
|