• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeutils API Reference
  • KDE Home
  • Contact Us
 

superkaramba

  • sources
  • kde-4.12
  • kdeutils
  • superkaramba
  • src
  • sensors
lmsensor.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2003 by Hans Karlsson *
3  * karlsson.h@home.se *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  ***************************************************************************/
10 
11 #include "lmsensor.h"
12 
13 SensorSensor::SensorSensor(int interval, char tempUnit) : Sensor(interval)
14 {
15 #if defined __FreeBSD__ || defined(Q_OS_NETBSD)
16  sensorMapBSD["VCore 1"] = "VC0";
17  sensorMapBSD["VCore 2"] = "VC1";
18  sensorMapBSD["+3.3V"] = "V33";
19  sensorMapBSD["+5V"] = "V50P";
20  sensorMapBSD["+12V"] = "V12P";
21  sensorMapBSD["-12V"] = "V12N";
22  sensorMapBSD["-5V"] = "V50N";
23  sensorMapBSD["fan1"] = "FAN0";
24  sensorMapBSD["fan2"] = "FAN1";
25  sensorMapBSD["fan3"] = "FAN2";
26  sensorMapBSD["temp1"] = "TEMP0";
27  sensorMapBSD["temp2"] = "TEMP1";
28  sensorMapBSD["temp3"] = "TEMP2";
29 #endif
30  if (tempUnit == 'F')
31  extraParams = " -f";
32  connect(&ksp, SIGNAL(receivedStdout(K3Process*,char*,int)),
33  this, SLOT(receivedStdout(K3Process*,char*,int)));
34  connect(&ksp, SIGNAL(processExited(K3Process*)),
35  this, SLOT(processExited(K3Process*)));
36 
37  // readValues();
38 }
39 
40 
41 SensorSensor::~SensorSensor()
42 {}
43 
44 void SensorSensor::receivedStdout(K3Process *, char *buffer, int len)
45 {
46  buffer[len] = 0;
47  sensorResult += QString(buffer);
48 }
49 
50 void SensorSensor::processExited(K3Process *)
51 {
52  QStringList stringList = sensorResult.split('\n');
53  sensorResult = "";
54  QStringList::Iterator it = stringList.begin();
55 #if defined __FreeBSD__ || defined(Q_OS_NETBSD)
56  QRegExp rx("^(\\S+)\\s+:\\s+[\\+\\-]?(\\d+\\.?\\d*)");
57 #else
58  QRegExp rx("^(.+):\\s+[\\+\\-]?(\\d+\\.?\\d*)");
59 #endif
60  while (it != stringList.end()) {
61  rx.indexIn(*it);
62 
63  if (!rx.cap(0).isEmpty()) {
64  sensorMap[rx.cap(1)] = rx.cap(2);
65  }
66  it++;
67  }
68 
69  QString format;
70  QString type;
71  SensorParams *sp;
72  Meter *meter;
73 
74  QObject *lobject;
75  foreach(lobject, *objList) {
76  sp = (SensorParams*)(lobject);
77  meter = sp->getMeter();
78  format = sp->getParam("FORMAT");
79  type = sp->getParam("TYPE");
80 
81  if (type.length() == 0)
82  type = "temp2";
83 
84  if (format.length() == 0) {
85  format = "%v";
86  }
87 
88 #if defined __FreeBSD__ || defined(Q_OS_NETBSD)
89  format.replace(QRegExp("%v", Qt::CaseInsensitive),
90  sensorMap[sensorMapBSD[type]]);
91 #else
92  format.replace(QRegExp("%v", Qt::CaseInsensitive),
93  sensorMap[type]);
94 #endif
95  meter->setValue(format);
96  }
97 }
98 
99 void SensorSensor::update()
100 {
101  ksp.clearArguments();
102 #if defined __FreeBSD__ || defined(Q_OS_NETBSD)
103  ksp << "mbmon -r -c 1" << extraParams;
104 #else
105  ksp << "sensors" << extraParams;
106 #endif
107  ksp.start(K3Process::NotifyOnExit, K3ProcIO::Stdout);
108 }
109 
110 
111 #include "lmsensor.moc"
lmsensor.h
SensorParams::getMeter
Meter * getMeter() const
Definition: sensorparams.cpp:31
QObject
Sensor
Definition: sensor.h:17
SensorParams
Hans Karlsson.
Definition: sensorparams.h:30
SensorParams::getParam
QString getParam(const QString &) const
Definition: sensorparams.cpp:26
SensorSensor::~SensorSensor
~SensorSensor()
Definition: lmsensor.cpp:41
Meter
Definition: meters/meter.h:23
Meter::setValue
virtual void setValue(int)
Definition: meters/meter.cpp:136
SensorSensor::update
void update()
Definition: lmsensor.cpp:99
SensorSensor::SensorSensor
SensorSensor(int interval, char tempUnit)
Definition: lmsensor.cpp:13
Sensor::objList
QList< QObject * > * objList
Definition: sensor.h:39
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:07:20 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

superkaramba

Skip menu "superkaramba"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • kremotecontrol
  • ktimer
  • kwallet
  • superkaramba
  • sweeper

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal