package model import "strings" // 道岔 type Turnout interface { RtssModel PipeElement } var _ Turnout = (*TurnoutImpl)(nil) type TurnoutImpl struct { uid string paPipeLink *PipeLink pbPipeLink *PipeLink pcPipeLink *PipeLink } func NewTurnout(uid string) *TurnoutImpl { if strings.Trim(uid, " ") == "" { panic("Turnout uid is empty") } return &TurnoutImpl{ uid: uid, } } func (t *TurnoutImpl) Uid() string { return t.uid } func (t *TurnoutImpl) Ports() []PipePort { return threePorts } func (t *TurnoutImpl) GetLinkedElement(port PipePort) *PipeLink { if port == PipePortA { return t.paPipeLink } else if port == PipePortB { return t.pbPipeLink } else if port == PipePortC { return t.pcPipeLink } return nil }