diff --git a/consumer/speed_controller.go b/consumer/speed_controller.go index 0f10c0f..ce9face 100644 --- a/consumer/speed_controller.go +++ b/consumer/speed_controller.go @@ -58,7 +58,9 @@ func (c *fanControl) StartControl() { case <-ticker: break checker case changedSpeed := <-c.fanSpeedConsumer: - newFanSpeedList[changedSpeed.Id] = changedSpeed.FanSpeed + if changedSpeed.Changed { + newFanSpeedList[changedSpeed.Id] = changedSpeed.FanSpeed + } case <-c.handler.Done(): return } diff --git a/processor/processor.go b/processor/processor.go index b12cca6..407bc56 100644 --- a/processor/processor.go +++ b/processor/processor.go @@ -33,11 +33,13 @@ type processor struct { type TempetureInfo struct { Id int Tempeture float64 + Changed bool } type FanspeedInfo struct { Id int FanSpeed int + Changed bool } type Processor interface { @@ -136,35 +138,39 @@ func (p *processor) StartMonitoring() { fanspeed int ) + /* + CREATE CONTINUOUS QUERY "processor_tempeture_5s" ON "core" BEGIN SELECT mean("tempeture") AS "mean_tempeture" INTO "12 weeks"."processor_tempeture_5s" FROM "processor_tempeture" GROUP BY processor, time(5s) fill(previous) END + */ highestTemp = p.getMaxTempetureOnProcessor(tempeturePathGlob) - if highestTemp != p.tempeture { - if p.tempetureChanged != nil { - select { - case p.tempetureChanged <- TempetureInfo{ - Id: p.id, - Tempeture: highestTemp, - }: - default: - } + if p.tempetureChanged != nil { + select { + case p.tempetureChanged <- TempetureInfo{ + Id: p.id, + Tempeture: highestTemp, + Changed: highestTemp != p.tempeture, + }: + default: } - p.tempeture = highestTemp - log.Debugf("processor %d : tempeture changed %f", p.id, highestTemp) } + p.tempeture = highestTemp + log.Debugf("processor %d : tempeture changed %f", p.id, highestTemp) + /* + CREATE CONTINUOUS QUERY "processor_cooling_fanspeed_5s" ON "core" BEGIN SELECT mean("noob") AS "mean_noob" INTO "12 weeks"."processor_cooling_fanspeed_5s" FROM "processor_cooling_fanspeed" GROUP BY processor, time(5s) fill(previous) END + */ fanspeed = p.normalizeFanspeed(p.fanController.Update(highestTemp)) - if fanspeed != p.fanSpeed { - if p.fanSpeedChanged != nil { - select { - case p.fanSpeedChanged <- FanspeedInfo{ - Id: p.id, - FanSpeed: fanspeed, - }: - default: - } + if p.fanSpeedChanged != nil { + select { + case p.fanSpeedChanged <- FanspeedInfo{ + Id: p.id, + FanSpeed: fanspeed, + Changed: fanspeed != p.fanSpeed, + }: + default: } - p.fanSpeed = fanspeed - log.Debugf("processor %d : fan changed 0x%x", p.id, fanspeed) } + p.fanSpeed = fanspeed + log.Debugf("processor %d : fan changed 0x%x", p.id, fanspeed) case <-p.handler.Done(): return }