잘못된 변수명 수정
This commit is contained in:
parent
08e83afe52
commit
a3f4f54439
38
main.go
38
main.go
|
@ -15,6 +15,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"amuz.es/src/infra/cpu_ctrl/pid"
|
"amuz.es/src/infra/cpu_ctrl/pid"
|
||||||
|
|
||||||
"github.com/coreos/go-systemd/daemon"
|
"github.com/coreos/go-systemd/daemon"
|
||||||
|
@ -93,7 +94,7 @@ func ReadTempeture(path string, senseChan chan<- float64, errorChan chan<- error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func CpuTempetureMonitoring(info *Processor,sampleDuration time.Duration, notifier chan<- TempetureChange, errorChan chan<- error, ctx context.Context, waiter *sync.WaitGroup) {
|
func CpuTempetureMonitoring(info *Processor, sampleDuration time.Duration, notifier chan<- TempetureChange, errorChan chan<- error, ctx context.Context, waiter *sync.WaitGroup) {
|
||||||
defer waiter.Done()
|
defer waiter.Done()
|
||||||
tempeturePathGlob := path.Join(info.TempeturePath, "temp?_input")
|
tempeturePathGlob := path.Join(info.TempeturePath, "temp?_input")
|
||||||
ticker := time.Tick(sampleDuration)
|
ticker := time.Tick(sampleDuration)
|
||||||
|
@ -131,38 +132,37 @@ func CpuTempetureMonitoring(info *Processor,sampleDuration time.Duration, notifi
|
||||||
func CpuTempetureScraper(processorCount int, notifier <-chan TempetureChange, errorChan chan<- error, ctx context.Context, waiter *sync.WaitGroup) {
|
func CpuTempetureScraper(processorCount int, notifier <-chan TempetureChange, errorChan chan<- error, ctx context.Context, waiter *sync.WaitGroup) {
|
||||||
defer waiter.Done()
|
defer waiter.Done()
|
||||||
var (
|
var (
|
||||||
P,I,D=1.5, 0.4, 2.0
|
P, I, D = 1.5, 0.4, 2.0
|
||||||
SetPoint=40.0
|
SetPoint = 40.0
|
||||||
SampleTime=time.Second
|
SampleTime = time.Second
|
||||||
WindupGuard=96.0
|
WindupGuard = 96.0
|
||||||
maxNoob,minNoob=0x64,0x4
|
maxNoob, minNoob = 0x64, 0x4
|
||||||
)
|
)
|
||||||
noobs := make([]int,processorCount)
|
noobs := make([]int, processorCount)
|
||||||
controllers := make([]pid.Controller, 0,processorCount)
|
controllers := make([]pid.Controller, 0, processorCount)
|
||||||
for i:=0 ;i<processorCount;i++{
|
for i := 0; i < processorCount; i++ {
|
||||||
controller:=pid.New(PID)
|
controller := pid.New(P, I, D)
|
||||||
controller.SetSetPoint(SetPoint)
|
controller.SetSetPoint(SetPoint)
|
||||||
controller.SetSampleTime(SampleTime)
|
controller.SetSampleTime(SampleTime)
|
||||||
controller.SetWindupGuard(WindupGuard)
|
controller.SetWindupGuard(WindupGuard)
|
||||||
controllers := append(controllers,controller)
|
controllers := append(controllers, controller)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case change := <-notifier:
|
case change := <-notifier:
|
||||||
controller:=controllers[change.Id]
|
controller := controllers[change.Id]
|
||||||
resp:=controller.Update(change)
|
resp := controller.Update(change)
|
||||||
|
|
||||||
adj_noob := -resp + minNoob
|
adj_noob := -resp + minNoob
|
||||||
if adj_noob > maxNoob{
|
if adj_noob > maxNoob {
|
||||||
adj_noob=maxNoob
|
adj_noob = maxNoob
|
||||||
}
|
}
|
||||||
|
|
||||||
if noobs[change.Id]== adj_noob{
|
if noobs[change.Id] == adj_noob {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
noobs[change.Id]=adj_noob
|
noobs[change.Id] = adj_noob
|
||||||
fmt.Printf("cpu %d fan 0x%x\n", change.Id, adj_noob)
|
fmt.Printf("cpu %d fan 0x%x\n", change.Id, adj_noob)
|
||||||
|
|
||||||
args := make([]string, 0)
|
args := make([]string, 0)
|
||||||
|
@ -206,7 +206,7 @@ func main() {
|
||||||
errorChan <- err
|
errorChan <- err
|
||||||
} else {
|
} else {
|
||||||
waiter.Add(1)
|
waiter.Add(1)
|
||||||
go CpuTempetureMonitoring(info,sampleDuration, tempetureChange, errorChan, ctx, waiter)
|
go CpuTempetureMonitoring(info, sampleDuration, tempetureChange, errorChan, ctx, waiter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
waiter.Add(1)
|
waiter.Add(1)
|
||||||
|
|
Loading…
Reference in New Issue