Documentation
¶
Index ¶
Constants ¶
const (
ScheduleFilename = "schedule.json"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ActualClock ¶
type ActualClock struct{}
ActualClock uses the standard go time.
func (*ActualClock) Now ¶
func (t *ActualClock) Now() time.Time
func (*ActualClock) Wait ¶
func (t *ActualClock) Wait(duration time.Duration)
type Clock ¶
type Clock interface { // Now gets the current time Now() time.Time // Wait does a synchronous wait for the given time duration. Wait(time.Duration) }
Clock models a clock. That has been abstracted for unit testing.
type Schedule ¶
type Schedule struct { Description string ControlNights int PlayNights int StartDay int Combos []Combo AllSounds []int }
func GetScheduleFromAPI ¶
func LoadScheduleFromDisk ¶
func (*Schedule) CycleLength ¶
CycleLength calculates how many days the play-control cycle is.
func (*Schedule) GetReferencedSounds ¶
GetReferencedSounds finds the sound file ids that required for playing this schedule.
type SchedulePlayer ¶
type SchedulePlayer struct {
// contains filtered or unexported fields
}
SchedulePlayer takes a schedule and a bunch of audio files and plays them at the times specified on the schedule.
func NewPlayer ¶
func NewPlayer(allSoundsMap map[int]string, filesDirectory string) *SchedulePlayer
NewPlayer creates a new schedule player.
func (SchedulePlayer) IsSoundPlayingDay ¶
func (sp SchedulePlayer) IsSoundPlayingDay(schedule Schedule) bool
IsSoundPlayingDay works out whether sounds should be played today. Having control days when we play no sound, helps to make sure that we canaccurately determine whether sounds are attracting more animals or not. They may also help stop animals getting attuned to hearing the sounds.
func (SchedulePlayer) PlayTodaysSchedule ¶
func (sp SchedulePlayer) PlayTodaysSchedule(schedule Schedule)
PlayTodaysSchedule plays todays schedule or if it is a control day it waits until the start of the next day
func (*SchedulePlayer) SetRecorder ¶
func (sp *SchedulePlayer) SetRecorder(recorder SoundPlayedRecorder)
SetRecorder sets the call back that records when a sound has successfully played
func (SchedulePlayer) TimeUntilNextCombo ¶
func (sp SchedulePlayer) TimeUntilNextCombo(schedule Schedule) time.Duration
type SoundChooser ¶
type SoundChooser struct {
// contains filtered or unexported fields
}
func NewSoundChooser ¶
func NewSoundChooser(allSoundsMap map[int]string) *SoundChooser
func NewSoundChooserWithRandom ¶
func NewSoundChooserWithRandom(allSoundsMap map[int]string, seed int64) *SoundChooser
func (*SoundChooser) ChooseSound ¶
func (chooser *SoundChooser) ChooseSound(choice string) (int, string)
type SoundPlayedRecorder ¶
type SoundPlayedRecorder interface { // OnBaitPlayed is called when the device believes audiobait has been played OnAudioBaitPlayed(ts time.Time, fileId int, volume int) }
SoundPlayedRecorder gets a notification when a sound has been played.