From 1d55617d68eaf5b040f9eb2b934b6159f70f5b1f Mon Sep 17 00:00:00 2001 From: Sangbum Kim Date: Tue, 12 Sep 2017 23:17:04 +0900 Subject: [PATCH] =?UTF-8?q?=EC=8A=A4=ED=85=9F=EB=93=A4=20=EB=B0=94?= =?UTF-8?q?=EB=80=8C=EC=A7=80=20=EC=95=8A=EB=8D=94=EB=9D=BC=EB=8F=84=20?= =?UTF-8?q?=EB=85=B8=ED=8B=B0=ED=95=98=EA=B2=8C=20=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- consumer/speed_controller.go | 4 ++- processor/processor.go | 50 ++++++++++++++++++++---------------- 2 files changed, 31 insertions(+), 23 deletions(-) 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 }