1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
/***************************************************************************
i8ksensorslist.cpp - description
-------------------
begin : jue jun 20 2002
copyright : (C) 2002 by Miguel Novas
email : migueln@users.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <tdelocale.h>
#include "i8ksensorslist.h"
#include "procinfo.h"
I8KSensorsList::I8KSensorsList(TQObject *parent, const char *name): SensorsList(parent,name)
{
setDescription(TQString(i18n("MainBoard")) );
setClass(Sensor::lmSensor);
readConfig();
if ( (i8kAvail = (I8KOnlyAvailable()==0)) )
{
cpuTemp= new Sensor(this);
cpuTemp->setType(Sensor::lmTemp);
cpuTemp->setName("cputemp");
cpuTemp->setDescription("CPU Temp");
cpuTemp->setValueMax (40 , Sensor::dgCelsius);
cpuTemp->setValueMin ( 0 , Sensor::dgCelsius);
cpuTemp->setValueIdeal(30 , Sensor::dgCelsius);
cpuTemp->setValue (30 , Sensor::dgCelsius);
cpuTemp->readConfig();
leftFan= new Sensor(this);
leftFan->setType(Sensor::lmFan);
leftFan->setName("fan1");
leftFan->setDescription("Left Fan");
leftFan->setValueMax (10000);
leftFan->setValueMin ( 0);
leftFan->setValueIdeal( 4500);
leftFan->setValue ( 4500);
leftFan->readConfig();
rightFan= new Sensor(this);
rightFan->setType(Sensor::lmFan);
rightFan->setName("fan2");
rightFan->setDescription("Right Fan");
rightFan->setValueMax (10000);
rightFan->setValueMin ( 0);
rightFan->setValueIdeal( 4500);
rightFan->setValue ( 4500);
rightFan->readConfig();
}
if ( (acpiAvail=(AcpiAvailable()==0)) )
{
cpuTempAcpi= new Sensor(this);
cpuTempAcpi->setType(Sensor::lmTemp);
cpuTempAcpi->setName("cputemp");
cpuTempAcpi->setDescription("CPU Temp");
cpuTempAcpi->setValueMax (40 , Sensor::dgCelsius);
cpuTempAcpi->setValueMin ( 0 , Sensor::dgCelsius);
cpuTempAcpi->setValueIdeal(30 , Sensor::dgCelsius);
cpuTempAcpi->setValue (30 , Sensor::dgCelsius);
cpuTempAcpi->readConfig();
}
updateSensors();
}
I8KSensorsList::~I8KSensorsList(){
}
void I8KSensorsList::updateSensors()
{
double t,f1,f2;
if(i8kAvail && !getI8KInfo(&t,&f1,&f2)) {
cpuTemp->setValue(t,Sensor::dgCelsius);
leftFan->setValue(f1);
rightFan->setValue(f2);
}
if(acpiAvail && !getAcpiTemperature(&t)) {
cpuTempAcpi->setValue(t,Sensor::dgCelsius);
}
}
int I8KSensorsList::AcpiAvailable()
{
double t;
return getAcpiTemperature(&t);
}
int I8KSensorsList::I8KOnlyAvailable()
{
double d1,d2,d3;
return getI8KInfo(&d1,&d2,&d3);
}
bool I8KSensorsList::I8KAvailable()
{
int result;
switch(result= I8KOnlyAvailable()) {
case -2: tqWarning("I18K Warning: /proc/i8k format not valid or not supported. Inform the author."); break;
case -3: tqWarning("I18K Warning: Only format version 1.0 is supported. Inform the author."); break;
}
return (result==0 || AcpiAvailable()==0);
}
#include "i8ksensorslist.moc"
|