From dd5ab35273c16f6833cd874571564d1d53f5cb2a Mon Sep 17 00:00:00 2001 From: Sangbum Kim Date: Mon, 11 Sep 2017 00:37:01 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A1=9C=EA=B7=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- consumer/speed_controller.go | 14 +++++++++++++- processor/processor.go | 3 ++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/consumer/speed_controller.go b/consumer/speed_controller.go index 6cbc7f8..a7d3ee8 100644 --- a/consumer/speed_controller.go +++ b/consumer/speed_controller.go @@ -6,6 +6,12 @@ import ( "amuz.es/src/infra/cpu_ctrl/util" "time" "amuz.es/src/infra/cpu_ctrl/processor" + "amuz.es/src/infra/cpu_ctrl/logger" + "bytes" +) + +var ( + log = logger.NewLogger("consumer") ) type fanControl struct { @@ -55,7 +61,7 @@ func (c *fanControl) StartControl() { return } } - if (compareFanSpeed(fanSpeedList, newFanSpeedList)) { + if (!compareFanSpeed(fanSpeedList, newFanSpeedList)) { fanSpeedList = newFanSpeedList args := make([]string, 0) args = append(args, @@ -73,6 +79,12 @@ func (c *fanControl) StartControl() { c.handler.NotifyError(err) return } + buf := bytes.NewBufferString("") + for _, item := range fanSpeedList { + buf.WriteString(fmt.Sprintf("0x%x", item)) + buf.WriteRune(' ') + } + log.Infof("Commit fan speed with %s", buf.String()) } } } diff --git a/processor/processor.go b/processor/processor.go index 98bf38c..92c6a37 100644 --- a/processor/processor.go +++ b/processor/processor.go @@ -147,6 +147,7 @@ func (p *processor) StartMonitoring() { } } p.tempeture = highestTemp + log.Infof("processor %d : tempeture changed %f", p.id, highestTemp) } fanspeed = p.normalizeFanspeed(p.fanController.Update(highestTemp)) @@ -159,10 +160,10 @@ func (p *processor) StartMonitoring() { }: default: } + log.Infof("processor %d : fan changed 0x%x", p.id, fanspeed) } p.fanSpeed = fanspeed } - case <-p.handler.Done(): return }