Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
KSysGuard
Commits
b6fa4756
Commit
b6fa4756
authored
Nov 12, 2020
by
Arjen Hiemstra
Browse files
Move SysFsSensor to libkstats and document it more properly
parent
fc74afb6
Changes
5
Hide whitespace changes
Inline
Side-by-side
libkstats/CMakeLists.txt
View file @
b6fa4756
...
...
@@ -4,6 +4,8 @@ set(ksgrdbackend_LIB_SRCS
SensorContainer.cpp
SensorPlugin.cpp
SensorProperty.cpp
SysFsSensor.cpp
)
add_library
(
ksgrdbackend
${
ksgrdbackend_LIB_SRCS
}
)
...
...
plugins/global/gpu
/SysFsSensor.cpp
→
libkstats
/SysFsSensor.cpp
View file @
b6fa4756
/*
* SPDX-FileCopyrightText: 2020 Arjen Hiemstra <ahiemstra@heimr.nl>
*
* SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
Copyright (c) 2020 Arjen Hiemstra <ahiemstra@heimr.nl>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include
"SysFsSensor.h"
...
...
libkstats/SysFsSensor.h
0 → 100644
View file @
b6fa4756
/*
Copyright (c) 2020 Arjen Hiemstra <ahiemstra@heimr.nl>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#pragma once
#include
<QObject>
#include
"SensorProperty.h"
/**
* Convenience subclass of SensorProperty that reads a sysfs file and uses the result as value.
*/
class
Q_DECL_EXPORT
SysFsSensor
:
public
SensorProperty
{
Q_OBJECT
public:
SysFsSensor
(
const
QString
&
id
,
const
QString
&
path
,
SensorObject
*
parent
);
/**
* Set the function used to convert the data from sysfs to the value of this sensor.
*
* This accepts a function that takes a QByteArray and converts that to a QVariant.
* By default this is set to `std::atoll` or in other words, any numeric value
* should automatically be converted to a proper QVariant.
*/
void
setConvertFunction
(
const
std
::
function
<
QVariant
(
const
QByteArray
&
)
>
&
function
);
/**
* Update this sensor.
*
* This will cause the sensor to read sysfs and update the value from that.
* It should be called periodically so values are updated properly.
*/
void
update
();
private:
QString
m_path
;
std
::
function
<
QVariant
(
const
QByteArray
&
)
>
m_convertFunction
;
};
plugins/global/gpu/CMakeLists.txt
View file @
b6fa4756
...
...
@@ -5,7 +5,6 @@ set(KSYSGUARD_GPU_PLUGIN_SOURCES
LinuxAmdGpu.cpp
LinuxNvidiaGpu.cpp
LinuxBackend.cpp
SysFsSensor.cpp
NvidiaSmiProcess.cpp
AllGpus.cpp
)
...
...
plugins/global/gpu/SysFsSensor.h
deleted
100644 → 0
View file @
fc74afb6
/*
* SPDX-FileCopyrightText: 2020 Arjen Hiemstra <ahiemstra@heimr.nl>
*
* SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#pragma once
#include
<QObject>
#include
"SensorProperty.h"
class
SysFsSensor
:
public
SensorProperty
{
Q_OBJECT
public:
SysFsSensor
(
const
QString
&
id
,
const
QString
&
path
,
SensorObject
*
parent
);
void
setConvertFunction
(
const
std
::
function
<
QVariant
(
const
QByteArray
&
)
>
&
function
);
void
update
();
private:
QString
m_path
;
std
::
function
<
QVariant
(
const
QByteArray
&
)
>
m_convertFunction
;
};
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment