|
|
@ -30,25 +30,74 @@ LMSensor::LMSensor(SensorsList *parent): Sensor(parent)
|
|
|
|
LMSensor::~LMSensor(){
|
|
|
|
LMSensor::~LMSensor(){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if SENSORS_API_VERSION < 0x400 /* libsensor 3 code */
|
|
|
|
bool LMSensor::init(const sensors_feature_data **data, int *nr1,int *nr2)
|
|
|
|
bool LMSensor::init(const sensors_feature_data **data, int *nr1,int *nr2)
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
bool LMSensor::init(const sensors_feature **data, int *nr1, int *nr2)
|
|
|
|
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
{
|
|
|
|
double min,max;
|
|
|
|
double min,max;
|
|
|
|
|
|
|
|
|
|
|
|
const sensors_chip_name *chip_name= getChipName();
|
|
|
|
const sensors_chip_name *chip_name= getChipName();
|
|
|
|
|
|
|
|
const char* main_name = (*data)->name;
|
|
|
|
|
|
|
|
feature= (*data)->number;
|
|
|
|
|
|
|
|
char *label = NULL;
|
|
|
|
|
|
|
|
QString uniqueSensorName;
|
|
|
|
|
|
|
|
|
|
|
|
if (strstr((*data)->name, "temp"))
|
|
|
|
#if SENSORS_API_VERSION < 0x400 /* libsensor 3 code */
|
|
|
|
|
|
|
|
uniqueSensorName.sprintf("%s_%d_%d.%s", chip_name->prefix, chip_name->bus, chip_name->addr, main_name);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
uniqueSensorName.sprintf("%s_%d_%d.%s", chip_name->prefix, chip_name->bus.nr, chip_name->addr, main_name);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
setName(uniqueSensorName.latin1());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if SENSORS_API_VERSION < 0x400 /* libsensor 3 code */
|
|
|
|
|
|
|
|
bool min_found=false;
|
|
|
|
|
|
|
|
bool max_found=false;
|
|
|
|
|
|
|
|
while( (*data= sensors_get_all_features(*chip_name, nr1, nr2)) && (*data)->mapping!=SENSORS_NO_MAPPING) {
|
|
|
|
|
|
|
|
int len = strlen((*data)->name);
|
|
|
|
|
|
|
|
const char *postfix = (*data)->name + len - 4;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (len < 5)
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if((!strcmp(postfix, "_min") || !strcmp(postfix, "_low")) &&
|
|
|
|
|
|
|
|
!sensors_get_feature(*chip_name, (*data)->number, &valMin))
|
|
|
|
|
|
|
|
min_found=true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!strcmp(postfix, "_max") &&
|
|
|
|
|
|
|
|
!sensors_get_feature(*chip_name, (*data)->number, &valMax)) {
|
|
|
|
|
|
|
|
max_found=true;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
postfix--;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if((!strcmp(postfix, "_over") || !strcmp(postfix, "_high")) &&
|
|
|
|
|
|
|
|
!sensors_get_feature(*chip_name, (*data)->number, &valMax))
|
|
|
|
|
|
|
|
max_found=true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double newVal;
|
|
|
|
|
|
|
|
if ((sensors_get_ignored(*chip_name, feature) != 1) || (sensors_get_feature(*chip_name, feature, &newVal) != 0)) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (strstr(main_name, "temp"))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
setType(lmTemp);
|
|
|
|
setType(lmTemp);
|
|
|
|
max= 65;
|
|
|
|
max= 65;
|
|
|
|
min= 0;
|
|
|
|
min= 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strstr((*data)->name, "fan"))
|
|
|
|
else if (strstr(main_name, "fan"))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
setType(lmFan);
|
|
|
|
setType(lmFan);
|
|
|
|
max= 10000;
|
|
|
|
max= 10000;
|
|
|
|
min= 3000;
|
|
|
|
min= 3000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (strstr(main_name, "alarm") || strstr(main_name, "sensor") || strstr(main_name, "vrm"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
setType(lmVoltage);
|
|
|
|
setType(lmVoltage);
|
|
|
@ -56,47 +105,129 @@ double min,max;
|
|
|
|
min= -16;
|
|
|
|
min= -16;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
feature= (*data)->number;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString str;
|
|
|
|
|
|
|
|
str.sprintf("%s.%s", chip_name->prefix, (*data)->name );
|
|
|
|
|
|
|
|
setName( str.latin1() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char *label;
|
|
|
|
|
|
|
|
sensors_get_label(*chip_name,feature,&label);
|
|
|
|
sensors_get_label(*chip_name,feature,&label);
|
|
|
|
|
|
|
|
if (label)
|
|
|
|
|
|
|
|
{
|
|
|
|
setDescription(QString(label));
|
|
|
|
setDescription(QString(label));
|
|
|
|
|
|
|
|
delete label;
|
|
|
|
|
|
|
|
label = NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
setDescription(uniqueSensorName.latin1());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool valid= false;
|
|
|
|
if(min_found)
|
|
|
|
while( (*data= sensors_get_all_features(*chip_name, nr1, nr2)) && (*data)->mapping!=SENSORS_NO_MAPPING) {
|
|
|
|
min = valMin;
|
|
|
|
str= (*data)->name;
|
|
|
|
|
|
|
|
if(str.find("_min")>=0 || str.find("_low")>=0) {
|
|
|
|
if(max_found)
|
|
|
|
sensors_get_feature(*chip_name, (*data)->number, &valMin);
|
|
|
|
max = valMax;
|
|
|
|
valid= true;
|
|
|
|
|
|
|
|
} else
|
|
|
|
#else /* libsensors4 code */
|
|
|
|
if(str.find("_max")>=0 || str.find("_over")>=0 || str.find("_high")>=0) {
|
|
|
|
|
|
|
|
sensors_get_feature(*chip_name, (*data)->number, &valMax);
|
|
|
|
const sensors_subfeature *sub_feature;
|
|
|
|
valid= true;
|
|
|
|
const sensors_feature *feature_data = *data;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Move to next feature for the loop in LMSensorsChip::createSensors() */
|
|
|
|
|
|
|
|
*data = sensors_get_features(chip_name, nr1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch(feature_data->type)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case SENSORS_FEATURE_IN:
|
|
|
|
|
|
|
|
sub_feature = sensors_get_subfeature(chip_name, feature_data,
|
|
|
|
|
|
|
|
SENSORS_SUBFEATURE_IN_INPUT);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!sub_feature)
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
feature = sub_feature->number;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!(sub_feature = sensors_get_subfeature(chip_name, feature_data,
|
|
|
|
|
|
|
|
SENSORS_SUBFEATURE_IN_MIN)) ||
|
|
|
|
|
|
|
|
sensors_get_value(chip_name, sub_feature->number, &min))
|
|
|
|
|
|
|
|
min = -16;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!(sub_feature = sensors_get_subfeature(chip_name, feature_data,
|
|
|
|
|
|
|
|
SENSORS_SUBFEATURE_IN_MAX)) ||
|
|
|
|
|
|
|
|
sensors_get_value(chip_name, sub_feature->number, &max))
|
|
|
|
|
|
|
|
max = 16;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setType(lmVoltage);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case SENSORS_FEATURE_FAN:
|
|
|
|
|
|
|
|
sub_feature = sensors_get_subfeature(chip_name, feature_data,
|
|
|
|
|
|
|
|
SENSORS_SUBFEATURE_FAN_INPUT);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!sub_feature)
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
feature = sub_feature->number;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!(sub_feature = sensors_get_subfeature(chip_name, feature_data,
|
|
|
|
|
|
|
|
SENSORS_SUBFEATURE_FAN_MIN)) ||
|
|
|
|
|
|
|
|
sensors_get_value(chip_name, sub_feature->number, &min))
|
|
|
|
|
|
|
|
min = 3000;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
max = 10000;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setType(lmFan);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case SENSORS_FEATURE_TEMP:
|
|
|
|
|
|
|
|
sub_feature = sensors_get_subfeature(chip_name, feature_data,
|
|
|
|
|
|
|
|
SENSORS_SUBFEATURE_TEMP_INPUT);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!sub_feature)
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
feature = sub_feature->number;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!(sub_feature = sensors_get_subfeature(chip_name, feature_data,
|
|
|
|
|
|
|
|
SENSORS_SUBFEATURE_TEMP_MIN)) ||
|
|
|
|
|
|
|
|
sensors_get_value(chip_name, sub_feature->number, &min))
|
|
|
|
|
|
|
|
min = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((!(sub_feature = sensors_get_subfeature(chip_name, feature_data,
|
|
|
|
|
|
|
|
SENSORS_SUBFEATURE_TEMP_MAX)) &&
|
|
|
|
|
|
|
|
!(sub_feature = sensors_get_subfeature(chip_name, feature_data,
|
|
|
|
|
|
|
|
SENSORS_SUBFEATURE_TEMP_CRIT))) ||
|
|
|
|
|
|
|
|
sensors_get_value(chip_name, sub_feature->number, &max))
|
|
|
|
|
|
|
|
max = 65;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setType(lmTemp);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
label = sensors_get_label(chip_name, feature_data);
|
|
|
|
|
|
|
|
if (label)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
setDescription(QString(label));
|
|
|
|
|
|
|
|
delete label;
|
|
|
|
|
|
|
|
label = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
setDescription( uniqueSensorName.latin1() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* libsensors3 / libsensors4 code */
|
|
|
|
|
|
|
|
|
|
|
|
if(valid) {
|
|
|
|
|
|
|
|
double newVal;
|
|
|
|
|
|
|
|
valid= (sensors_get_feature(*chip_name, feature, &newVal)==0);
|
|
|
|
|
|
|
|
if(valid) {
|
|
|
|
|
|
|
|
if(min>max) {
|
|
|
|
if(min>max) {
|
|
|
|
double pivot= valMin;
|
|
|
|
double pivot= min;
|
|
|
|
min= max;
|
|
|
|
min= max;
|
|
|
|
max= pivot;
|
|
|
|
max= pivot;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setValueMax(max,dgCelsius);
|
|
|
|
setValueMax(max,dgCelsius);
|
|
|
|
setValueMin(min,dgCelsius);
|
|
|
|
setValueMin(min,dgCelsius);
|
|
|
|
setValue((max+min)/2,dgCelsius);
|
|
|
|
|
|
|
|
readConfig();
|
|
|
|
readConfig();
|
|
|
|
updateValue();
|
|
|
|
updateValue();
|
|
|
|
setValueIdeal(getValue());
|
|
|
|
setValueIdeal(getValue());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
return valid;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LMSensor::updateValue()
|
|
|
|
void LMSensor::updateValue()
|
|
|
@ -108,7 +239,11 @@ double LMSensor::readSensorValue()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
double newVal;
|
|
|
|
double newVal;
|
|
|
|
const sensors_chip_name *chip_name= getChipName();
|
|
|
|
const sensors_chip_name *chip_name= getChipName();
|
|
|
|
|
|
|
|
#if SENSORS_API_VERSION < 0x400 /* libsensor 3 code */
|
|
|
|
sensors_get_feature(*chip_name, feature, &newVal);
|
|
|
|
sensors_get_feature(*chip_name, feature, &newVal);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
sensors_get_value(chip_name, feature, &newVal);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return newVal;
|
|
|
|
return newVal;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|