2014-05-24 17:58:57 -07:00
|
|
|
// Copyright 2014 Team 254. All Rights Reserved.
|
|
|
|
|
// Author: pat@patfairbank.com (Patrick Fairbank)
|
|
|
|
|
//
|
|
|
|
|
// Model and datastore read/write methods for event-level configuration.
|
|
|
|
|
|
2017-08-23 22:41:56 -07:00
|
|
|
package model
|
2014-05-24 17:58:57 -07:00
|
|
|
|
|
|
|
|
type EventSettings struct {
|
2018-09-03 19:24:50 -07:00
|
|
|
Id int
|
|
|
|
|
Name string
|
|
|
|
|
DisplayBackgroundColor string
|
|
|
|
|
NumElimAlliances int
|
|
|
|
|
SelectionRound2Order string
|
|
|
|
|
SelectionRound3Order string
|
|
|
|
|
TBADownloadEnabled bool
|
|
|
|
|
TbaPublishingEnabled bool
|
|
|
|
|
TbaEventCode string
|
|
|
|
|
TbaSecretId string
|
|
|
|
|
TbaSecret string
|
|
|
|
|
NetworkSecurityEnabled bool
|
|
|
|
|
ApAddress string
|
|
|
|
|
ApUsername string
|
|
|
|
|
ApPassword string
|
|
|
|
|
ApTeamChannel int
|
|
|
|
|
ApAdminChannel int
|
|
|
|
|
ApAdminWpaKey string
|
|
|
|
|
SwitchAddress string
|
|
|
|
|
SwitchPassword string
|
|
|
|
|
PlcAddress string
|
|
|
|
|
AdminPassword string
|
|
|
|
|
ReaderPassword string
|
|
|
|
|
StemTvPublishingEnabled bool
|
|
|
|
|
StemTvEventCode string
|
|
|
|
|
ScaleLedAddress string
|
|
|
|
|
RedSwitchLedAddress string
|
|
|
|
|
BlueSwitchLedAddress string
|
|
|
|
|
RedVaultLedAddress string
|
|
|
|
|
BlueVaultLedAddress string
|
2014-05-24 17:58:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const eventSettingsId = 0
|
|
|
|
|
|
|
|
|
|
func (database *Database) GetEventSettings() (*EventSettings, error) {
|
|
|
|
|
eventSettings := new(EventSettings)
|
|
|
|
|
err := database.eventSettingsMap.Get(eventSettings, eventSettingsId)
|
|
|
|
|
if err != nil {
|
|
|
|
|
// Database record doesn't exist yet; create it now.
|
2014-06-06 21:26:55 -07:00
|
|
|
eventSettings.Name = "Untitled Event"
|
|
|
|
|
eventSettings.DisplayBackgroundColor = "#00ff00"
|
|
|
|
|
eventSettings.NumElimAlliances = 8
|
|
|
|
|
eventSettings.SelectionRound2Order = "L"
|
|
|
|
|
eventSettings.SelectionRound3Order = ""
|
2015-04-01 14:19:14 -07:00
|
|
|
eventSettings.TBADownloadEnabled = true
|
2017-10-24 20:49:42 -07:00
|
|
|
eventSettings.ApTeamChannel = 157
|
|
|
|
|
eventSettings.ApAdminChannel = 11
|
|
|
|
|
eventSettings.ApAdminWpaKey = "1234Five"
|
2016-07-29 23:17:39 -07:00
|
|
|
|
2014-05-24 17:58:57 -07:00
|
|
|
err = database.eventSettingsMap.Insert(eventSettings)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return eventSettings, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (database *Database) SaveEventSettings(eventSettings *EventSettings) error {
|
|
|
|
|
eventSettings.Id = eventSettingsId
|
|
|
|
|
_, err := database.eventSettingsMap.Update(eventSettings)
|
|
|
|
|
return err
|
|
|
|
|
}
|