ldb

package
v0.0.0-...-fd78167 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2024 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Overview

LDB - Live Departure Boards

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteSchedule

func DeleteSchedule(tx *bolt.Tx, rid []byte)

func GetSchedule

func GetSchedule(tx *bolt.Tx, rid string) *darwind3.Schedule

func PutSchedule

func PutSchedule(tx *bolt.Tx, sched *darwind3.Schedule) bool

func RemoveSchedule

func RemoveSchedule(tx *bolt.Tx, rid []byte)

Types

type LDB

type LDB struct {
	Darwin       string
	Reference    string
	EventManager *darwind3.DarwinEventManager
	// contains filtered or unexported fields
}

func (*LDB) DBStatus

func (d *LDB) DBStatus()

func (*LDB) GetSchedule

func (d *LDB) GetSchedule(rid string) *darwind3.Schedule

func (*LDB) GetServices

func (d *LDB) GetServices(s *Station, from *util.WorkingTime, to *util.WorkingTime) []ServiceEntry

GetServices returns all Services that have not yet departed that are within the specified time range. If from is before to then it's resumed the time range crosses midnight.

func (*LDB) GetStationCrs

func (d *LDB) GetStationCrs(crs string) *Station

GetStationCrs returns the Station instance by CRS or nil if not found Unlike GetStationTiploc this will not create a station if it's not found

func (*LDB) GetStationTiploc

func (d *LDB) GetStationTiploc(tiploc string) *Station

GetStationTiploc returns the Station instance by Tiploc or nil if not found. Note: If we don't have an entry then this will create one

func (*LDB) Init

func (d *LDB) Init(dbFile string) error

func (*LDB) PurgeOrphans

func (d *LDB) PurgeOrphans()

func (*LDB) PurgeSchedules

func (d *LDB) PurgeSchedules()

func (*LDB) PurgeServices

func (d *LDB) PurgeServices()

PurgeServices looks for any services who's schedule has been deleted

func (*LDB) PutSchedule

func (d *LDB) PutSchedule(s *darwind3.Schedule) error

func (*LDB) PutStation

func (d *LDB) PutStation(s *Station)

func (*LDB) RefreshStations

func (d *LDB) RefreshStations()

RefreshStations ensures we have all Public stations defined on startup. Not doing so incurs a performance hit when a train references it for the first time.

func (*LDB) RemoveSchedule

func (d *LDB) RemoveSchedule(rid string)

func (*LDB) RequestStationMessages

func (d *LDB) RequestStationMessages()

func (*LDB) Update

func (d *LDB) Update(f func(tx *bolt.Tx) error) error

func (*LDB) View

func (d *LDB) View(f func(tx *bolt.Tx) error) error

type Service

type Service struct {
	// The RID of this service
	RID string `json:"rid"`
	// The destination - use this and not Dest.Tiploc as this can be overridden
	// if Location.FalseDestination is set
	Destination string `json:"destination"`
	// Origin Location of this service
	Origin darwind3.Location `json:"origin"`
	// Destination Location of this service
	Dest darwind3.Location `json:"dest"`
	// Where this train terminates
	Terminates darwind3.Location `json:"terminates"`
	// Service Start Date
	SSD util.SSD `json:"ssd"`
	// The trainId (headcode)
	TrainId string `json:"trainId"`
	// The operator of this service
	Toc string `json:"toc"`
	// Is a passenger service
	PassengerService bool `json:"passengerService,omitempty"`
	// Is a charter service
	Charter bool `json:"charter,omitempty"`
	// Cancel running reason for this service. The reason applies to all locations
	// of this service which are marked as cancelled
	CancelReason darwind3.DisruptionReason `json:"cancelReason"`
	// Late running reason for this service. The reason applies to all locations
	// of this service which are not marked as cancelled
	LateReason darwind3.DisruptionReason `json:"lateReason"`
	// The "time" for this service
	Location darwind3.Location `json:"location"`
	// The calling points from this location
	CallingPoints []darwind3.CallingPoint `json:"calling"`
	// The last report
	LastReport darwind3.CallingPoint `json:"lastReport,omitempty"`
	// The associations
	Associations []*darwind3.Association `json:"association"`
	// Formation data
	Formation darwind3.ScheduleFormation `json:"formation"`

	// The index within the schedule of this location
	LocationIndex int `json:"locind"`
	// The time this entry was set
	Date time.Time `json:"date,omitempty" xml:"date,attr,omitempty"`
	// contains filtered or unexported fields
}

A representation of a service at a location

func (*Service) Clone

func (a *Service) Clone() *Service

Clone returns a copy of this Service

func (*Service) Timestamp

func (s *Service) Timestamp() time.Time

Timestamp returns the time.Time of this service based on the SSD and Location's Time. TODO this does not currently handle midnight correctly

func (*Service) Update

func (s *Service) Update(sched *darwind3.Schedule, idx int) bool

type ServiceEntry

type ServiceEntry struct {
	RID           string
	LocationIndex int
	Departed      bool
	Date          time.Time
}

Entry in the DB, just the essential data

func ServiceEntryFromBytes

func ServiceEntryFromBytes(b []byte) ServiceEntry

ScheduleFromBytes returns a schedule based on a slice or nil if none

func (*ServiceEntry) Bytes

func (s *ServiceEntry) Bytes() ([]byte, error)

Bytes returns the message as an encoded byte slice

type Station

type Station struct {
	// The location details for this station
	Locations []*darwinref.Location
	Crs       string
	// This station is Public - i.e. has a CRS so can have departures
	Public bool
	// The Station message id's applicable to this station
	Messages []int64
}

The holder for a station's departure boards

func StationFromBytes

func StationFromBytes(b []byte) *Station

ScheduleFromBytes returns a schedule based on a slice or nil if none

func (*Station) Bytes

func (s *Station) Bytes() ([]byte, error)

Bytes returns the message as an encoded byte slice

func (*Station) GetMessages

func (s *Station) GetMessages(client *d3client.DarwinD3Client) []*darwind3.StationMessage

GetMessages returns all station Messages for this Station.

type Task

type Task struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL