blob: a03cd333c99c189c5e12cdb7f6e1c05a0cd848e8 (
plain)
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
|
/***************************************************************************
lmsensorschip.cpp - description
-------------------
begin : Wed Feb 20 2002
copyright : (C) 2002 by Miguel Novas
email : michaell@teleline.es
***************************************************************************/
/***************************************************************************
* *
* 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 <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <sensors/sensors.h>
#include "lmsensorschip.h"
//****************************************************************************
// Public methods
//****************************************************************************
LMSensorsChip::LMSensorsChip(const sensors_chip_name *chip, TQObject *parent, const char * name)
: SensorsList(parent,name)
{
setClass(Sensor::lmSensor);
chip_name= chip;
setName( chip_name->prefix );
setDescription( chip_name->prefix );
readConfig();
createSensors();
}
LMSensorsChip::~LMSensorsChip()
{
}
const sensors_chip_name *LMSensorsChip::getChipName()
{
return chip_name;
}
void LMSensorsChip::createSensors()
{
if(!chip_name) return;
int nr1= 0;
int nr2= 0;
#if SENSORS_API_VERSION < 0x400 /* libsensor 3 code */
const sensors_feature_data *data;
data= sensors_get_all_features(*chip_name, &nr1, &nr2);
#else
const sensors_feature *data;
data= sensors_get_features(chip_name, &nr1);
#endif
while(data) {
LMSensor *sensor= new LMSensor(this);
if( !sensor->init(&data,&nr1,&nr2) )
delete sensor;
}
}
void LMSensorsChip::updateSensors()
{
TQObjectList *sensors= (TQObjectList *)children();
if(sensors)
for(LMSensor *sensor= (LMSensor *)sensors->first(); sensor!=0; sensor= (LMSensor *)sensors->next())
if(sensor->monitorized()) sensor->updateValue();
}
|