잘못된 코드 수정2
This commit is contained in:
parent
bca37ebec0
commit
fa3950cd85
|
@ -53,21 +53,21 @@ func (c *fanControl) StartControl() {
|
|||
for {
|
||||
select {
|
||||
case <-ticker:
|
||||
go c.applyFanspeed(pastFanSpeedList, newFanSpeedList)
|
||||
pastFanSpeedList, newFanSpeedList = newFanSpeedList, make([]int, c.processorCount)
|
||||
copy(newFanSpeedList, pastFanSpeedList)
|
||||
if !compareFanSpeed(pastFanSpeedList, newFanSpeedList) {
|
||||
copy(pastFanSpeedList, newFanSpeedList)
|
||||
newFanSpeedList = make([]int, c.processorCount)
|
||||
go c.applyFanspeed(pastFanSpeedList)
|
||||
}
|
||||
case changedSpeed := <-c.fanSpeedConsumer:
|
||||
if changedSpeed.Changed {
|
||||
newFanSpeedList[changedSpeed.Id] = changedSpeed.FanSpeed
|
||||
}
|
||||
case <-c.handler.Done():
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
func (c *fanControl) applyFanspeed(pastFanSpeedList, newFanSpeedList []int) {
|
||||
if !compareFanSpeed(pastFanSpeedList, newFanSpeedList) {
|
||||
return
|
||||
}
|
||||
|
||||
func (c *fanControl) applyFanspeed(newFanSpeedList []int) {
|
||||
args := make([]string, 0)
|
||||
args = append(args, "raw", "0x3a", "0x01", )
|
||||
for _, item := range newFanSpeedList {
|
||||
|
|
|
@ -33,12 +33,14 @@ type processor struct {
|
|||
type TempetureInfo struct {
|
||||
Id int
|
||||
Tempeture float64
|
||||
Changed bool
|
||||
At time.Time
|
||||
}
|
||||
|
||||
type FanspeedInfo struct {
|
||||
Id int
|
||||
FanSpeed int
|
||||
Changed bool
|
||||
At time.Time
|
||||
}
|
||||
|
||||
|
@ -147,6 +149,7 @@ func (p *processor) StartMonitoring() {
|
|||
case p.tempetureChanged <- TempetureInfo{
|
||||
Id: p.id,
|
||||
Tempeture: highestTemp,
|
||||
Changed: highestTemp != p.tempeture,
|
||||
At: now,
|
||||
}:
|
||||
default:
|
||||
|
@ -164,6 +167,7 @@ func (p *processor) StartMonitoring() {
|
|||
case p.fanSpeedChanged <- FanspeedInfo{
|
||||
Id: p.id,
|
||||
FanSpeed: fanspeed,
|
||||
Changed: fanspeed != p.fanSpeed,
|
||||
At: now,
|
||||
}:
|
||||
default:
|
||||
|
|
Loading…
Reference in New Issue