56 lines
1.1 KiB
Go
56 lines
1.1 KiB
Go
|
package repository
|
||
|
|
||
|
import "joylink.club/rtsssimulation/repository/model/proto"
|
||
|
|
||
|
type Route struct {
|
||
|
Identity
|
||
|
name string
|
||
|
routeType proto.Route_RouteType
|
||
|
start *Signal
|
||
|
destination *Signal
|
||
|
sections []*PhysicalSection
|
||
|
conflictingRoutes []*Route
|
||
|
turnoutPositions []*TurnoutPosition
|
||
|
}
|
||
|
|
||
|
func NewRoute(id string, name string, routeType proto.Route_RouteType) *Route {
|
||
|
return &Route{
|
||
|
Identity: identity{id, proto.DeviceType_DeviceType_Route},
|
||
|
name: name,
|
||
|
routeType: routeType,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (s *Route) StartSignal() *Signal {
|
||
|
return s.start
|
||
|
}
|
||
|
|
||
|
func (s *Route) DestinationSignal() *Signal {
|
||
|
return s.destination
|
||
|
}
|
||
|
|
||
|
func (s *Route) Sections() []*PhysicalSection {
|
||
|
return s.sections
|
||
|
}
|
||
|
|
||
|
func (s *Route) ConflictingRoutes() []*Route {
|
||
|
return s.conflictingRoutes
|
||
|
}
|
||
|
|
||
|
func (s *Route) TurnoutPositions() []*TurnoutPosition {
|
||
|
return s.turnoutPositions
|
||
|
}
|
||
|
|
||
|
type TurnoutPosition struct {
|
||
|
turnout *Turnout
|
||
|
normal bool
|
||
|
}
|
||
|
|
||
|
func (s *TurnoutPosition) Turnout() *Turnout {
|
||
|
return s.turnout
|
||
|
}
|
||
|
|
||
|
func (s *TurnoutPosition) Position() bool {
|
||
|
return s.normal
|
||
|
}
|