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