Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
KSysGuard
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Plasma
KSysGuard
Commits
b6fa4756
Commit
b6fa4756
authored
Nov 12, 2020
by
Arjen Hiemstra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move SysFsSensor to libkstats and document it more properly
parent
fc74afb6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
114 additions
and
27 deletions
+114
-27
libkstats/CMakeLists.txt
libkstats/CMakeLists.txt
+2
-0
libkstats/SysFsSensor.cpp
libkstats/SysFsSensor.cpp
+56
-0
libkstats/SysFsSensor.h
libkstats/SysFsSensor.h
+56
-0
plugins/global/gpu/CMakeLists.txt
plugins/global/gpu/CMakeLists.txt
+0
-1
plugins/global/gpu/SysFsSensor.h
plugins/global/gpu/SysFsSensor.h
+0
-26
No files found.
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
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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