Clean up config
This commit is contained in:
parent
f8369b4bd0
commit
e5d5b6ca2f
1 changed files with 11 additions and 20 deletions
|
@ -14,28 +14,28 @@ func loadConfiguration() *controllers.ControllerConfig {
|
|||
hub := sentry.CurrentHub().Clone()
|
||||
defer hub.Flush(10 * time.Second)
|
||||
|
||||
viper.SetDefault("http.port", 8000)
|
||||
viper.SetDefault("main.data_path", "./data.txt")
|
||||
viper.SetDefault("nats.url", "nats.service.consul")
|
||||
viper.SetDefault("nats.stream", "FERMENTOR")
|
||||
viper.SetDefault("nats.subject.state", "FERMENTOR.state")
|
||||
viper.SetDefault("nats.subject.temp", "FERMENTOR.temp")
|
||||
viper.SetDefault("http.port", 8000)
|
||||
viper.SetDefault("pid.kp", 2.0)
|
||||
viper.SetDefault("pid.ki", 0.0001)
|
||||
viper.SetDefault("nats.url", "nats.service.consul")
|
||||
viper.SetDefault("pid.kd", 2.0)
|
||||
viper.SetDefault("limits.min_chamber_temp", 5)
|
||||
viper.SetDefault("pid.ki", 0.0001)
|
||||
viper.SetDefault("pid.kp", 2.0)
|
||||
viper.SetDefault("limits.heater_grace_time_secs", 1800)
|
||||
viper.SetDefault("limits.max_chamber_temp", 40)
|
||||
viper.SetDefault("limits.min_cooler_runtime_secs", 300)
|
||||
viper.SetDefault("limits.max_cooler_runtime_secs", 86400)
|
||||
viper.SetDefault("limits.min_chamber_temp", 5)
|
||||
viper.SetDefault("limits.min_cooler_cooldown_secs", 300)
|
||||
viper.SetDefault("liimts.heater_grace_time_secs", 1800)
|
||||
viper.SetDefault("limits.min_cooler_runtime_secs", 300)
|
||||
viper.SetDefault("sensors.weight", 0.8)
|
||||
|
||||
viper.AddConfigPath("/etc")
|
||||
viper.AddConfigPath("/usr/local/etc")
|
||||
viper.AddConfigPath(".")
|
||||
viper.SetConfigName("fermentord")
|
||||
viper.SetConfigType("toml")
|
||||
//viper.AutomaticEnv()
|
||||
|
||||
if err := viper.ReadInConfig(); err != nil {
|
||||
log.Printf("Error loading configuration: %v", err)
|
||||
|
@ -47,25 +47,16 @@ func loadConfiguration() *controllers.ControllerConfig {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
log.Printf("Min chamber temp : %v", config.Limits.MinChamberTemperature)
|
||||
log.Printf("Max chamber temp : %v", config.Limits.MaxChamberTemperature)
|
||||
log.Printf("Fermentation temp: %v", config.FermentationTemperature)
|
||||
log.Printf("Delta temp cool : %v", config.DeltaTemperatureCool)
|
||||
log.Printf("Delta temp heat : %v", config.DeltaTemperatureHeat)
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
func reloadConfiguration(config *controllers.ControllerConfig, ctrl *controllers.ChamberController) {
|
||||
log.Printf("Reloading configuration")
|
||||
log.Printf("Ambient sensor: %v", config.Sensor.Ambient)
|
||||
log.Printf("Chamber sensor: %v", config.Sensor.Chamber)
|
||||
log.Printf("Wort sensor : %v", config.Sensor.Wort)
|
||||
|
||||
temperature.ConfigUpdates <- []string{
|
||||
config.Sensor.Ambient,
|
||||
config.Sensor.Chamber,
|
||||
config.Sensor.Wort,
|
||||
config.Sensors.Ambient,
|
||||
config.Sensors.Chamber,
|
||||
config.Sensors.Wort,
|
||||
}
|
||||
|
||||
ctrl.ConfigUpdates <- *config
|
||||
|
|
Loading…
Reference in a new issue