1
0
Fork 0

잘못된 변수명 수정

This commit is contained in:
Sangbum Kim 2017-09-07 01:26:04 +09:00
parent 08e83afe52
commit a3f4f54439
1 changed files with 23 additions and 23 deletions

46
main.go
View File

@ -15,8 +15,9 @@ import (
"sync"
"syscall"
"time"
"amuz.es/src/infra/cpu_ctrl/pid"
"github.com/coreos/go-systemd/daemon"
"github.com/shirou/gopsutil/cpu"
)
@ -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)
@ -195,7 +195,7 @@ func main() {
exitSignal = make(chan os.Signal, 1)
errorChan = make(chan error, 1)
tempetureChange = make(chan TempetureChange)
sampleDuration = time.Second
sampleDuration = time.Second
)
if processorCount == 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)