Commit 4804bca2 authored by Guido Gunther's avatar Guido Gunther

Merge branch 'thermal-adaptive' into 'pureos/sloppy'

Add thermal view

See merge request !2
parents 3b326478 103e9551
Pipeline #53231 passed with stages
in 4 minutes and 54 seconds
include:
- 'https://source.puri.sm/Librem5/librem5-ci/raw/master/librem5-pipeline-definitions.yml'
stages:
- package
- test-package
package:deb-debian-buster:
extends: .l5-build-debian-package
package:deb-debian-buster:arm64:
tags:
- librem5:arm64
extends: .l5-build-debian-package
autopkgtest-debian-buster-package:
dependencies:
- package:deb-debian-buster
extends: .l5-autopkgtest-debian-package
...@@ -3,6 +3,7 @@ resource_data = files( ...@@ -3,6 +3,7 @@ resource_data = files(
'ui/primary-menu.ui', 'ui/primary-menu.ui',
'ui/header-bar.ui', 'ui/header-bar.ui',
'ui/memory-speedometer.ui', 'ui/memory-speedometer.ui',
'ui/no-gthd-view.ui',
'ui/no-results-found-view.ui', 'ui/no-results-found-view.ui',
'ui/performance-view.ui', 'ui/performance-view.ui',
'ui/process-row.ui', 'ui/process-row.ui',
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<file preprocess="xml-stripblanks">ui/primary-menu.ui</file> <file preprocess="xml-stripblanks">ui/primary-menu.ui</file>
<file preprocess="xml-stripblanks">ui/header-bar.ui</file> <file preprocess="xml-stripblanks">ui/header-bar.ui</file>
<file preprocess="xml-stripblanks">ui/memory-speedometer.ui</file> <file preprocess="xml-stripblanks">ui/memory-speedometer.ui</file>
<file preprocess="xml-stripblanks">ui/no-gthd-view.ui</file>
<file preprocess="xml-stripblanks">ui/no-results-found-view.ui</file> <file preprocess="xml-stripblanks">ui/no-results-found-view.ui</file>
<file preprocess="xml-stripblanks">ui/performance-view.ui</file> <file preprocess="xml-stripblanks">ui/performance-view.ui</file>
<file preprocess="xml-stripblanks">ui/quit-process-dialog.ui</file> <file preprocess="xml-stripblanks">ui/quit-process-dialog.ui</file>
...@@ -14,5 +15,7 @@ ...@@ -14,5 +15,7 @@
<file preprocess="xml-stripblanks">ui/storage-view.ui</file> <file preprocess="xml-stripblanks">ui/storage-view.ui</file>
<file preprocess="xml-stripblanks">ui/process-row.ui</file> <file preprocess="xml-stripblanks">ui/process-row.ui</file>
<file preprocess="xml-stripblanks">ui/swap-speedometer.ui</file> <file preprocess="xml-stripblanks">ui/swap-speedometer.ui</file>
<file preprocess="xml-stripblanks">ui/thermal-row.ui</file>
<file preprocess="xml-stripblanks">ui/thermal-view.ui</file>
</gresource> </gresource>
</gresources> </gresources>
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.9 -->
<template class="UsageNoGthdView" parent="UsageView">
<property name="visible">True</property>
<child>
<object class="GtkBox">
<property name="margin-top">40</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkImage">
<property name="margin">10</property>
<property name="icon-name">system-run-symbolic</property>
<property name="pixel-size">72</property>
</object>
</child>
<child>
<object class="GtkLabel">
<attributes>
<attribute name="font-desc" value="16"/>
<attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
</attributes>
<property name="label" translatable="yes">Thermal daemon is not running</property>
<property name="margin">10</property>
</object>
</child>
<child>
<object class="GtkLabel">
<attributes>
<attribute name="font-desc" value="12"/>
</attributes>
<property name="label" translatable="yes">Please start gthd</property>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
</object>
</child>
</template>
</interface>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.10"/>
<template class="UsageThermalZoneRow" parent="GtkListBoxRow">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="type_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">6</property>
<property name="wrap">True</property>
<property name="ellipsize">end</property>
<property name="max_width_chars">60</property>
<attributes>
<attribute name="scale" value="1"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="temp_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_right">10</property>
<property name="ellipsize">end</property>
<property name="max_width_chars">30</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
</template>
</interface>
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.9 -->
<template class="UsageThermalView" parent="UsageView">
<property name="visible">True</property>
<child>
<object class="HdyLeaflet" id="leaflet">
<property name="visible">True</property>
<property name="orientation">horizontal</property>
<property name="mode-transition-type">slide</property>
<property name="visible-child">content_box</property>
<child>
<object class="GtkBox" id="switcher_box">
<property name="hexpand">False</property>
<property name="hexpand-set">True</property>
<property name="width-request">200</property>
<style>
<class name="sidebar"/>
</style>
</object>
</child>
<child>
<object class="GtkBox" id="content_box">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="width-request">360</property>
<child>
<object class="UsageAnimatedScrolledWindow" id="scrolled_window">
<property name="visible">True</property>
<property name="vexpand">True</property>
<child>
<object class="HdyColumn">
<property name="visible">True</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<property name="expand">True</property>
<property name="maximum-width">600</property>
<property name="linear-growth-width">400</property>
<child>
<object class="GtkBox" id="thermal_content">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">30</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
</interface>
...@@ -11,10 +11,12 @@ Build-Depends: debhelper-compat (= 12), ...@@ -11,10 +11,12 @@ Build-Depends: debhelper-compat (= 12),
gnome-pkg-tools, gnome-pkg-tools,
libdazzle-1.0-dev (>= 3.30.0), libdazzle-1.0-dev (>= 3.30.0),
libglib2.0-dev (>= 2.38.0), libglib2.0-dev (>= 2.38.0),
libgtherm-dev,
libgtk-3-dev (>= 3.20.10), libgtk-3-dev (>= 3.20.10),
libgtop2-dev (>= 2.34.0), libgtop2-dev (>= 2.34.0),
libhandy-0.0-dev (>= 0.0.10), libhandy-0.0-dev (>= 0.0.10),
meson (>= 0.37), meson (>= 0.37),
libtracker-sparql-2.0-dev,
valac valac
Standards-Version: 4.3.0 Standards-Version: 4.3.0
Vcs-Browser: https://salsa.debian.org/gnome-team/gnome-usage Vcs-Browser: https://salsa.debian.org/gnome-team/gnome-usage
...@@ -25,6 +27,7 @@ Package: gnome-usage ...@@ -25,6 +27,7 @@ Package: gnome-usage
Architecture: any Architecture: any
Depends: ${misc:Depends}, Depends: ${misc:Depends},
${shlibs:Depends} ${shlibs:Depends}
Recommends: gthd
Description: simple system monitor app for GNOME Description: simple system monitor app for GNOME
Usage is an application for GNOME that allows monitoring of system resources Usage is an application for GNOME that allows monitoring of system resources
such as memory, CPU, and disk space. such as memory, CPU, and disk space.
...@@ -7,10 +7,12 @@ Build-Depends: debhelper-compat (= 12), ...@@ -7,10 +7,12 @@ Build-Depends: debhelper-compat (= 12),
gnome-pkg-tools, gnome-pkg-tools,
libdazzle-1.0-dev (>= 3.30.0), libdazzle-1.0-dev (>= 3.30.0),
libglib2.0-dev (>= 2.38.0), libglib2.0-dev (>= 2.38.0),
libgtherm-dev,
libgtk-3-dev (>= 3.20.10), libgtk-3-dev (>= 3.20.10),
libgtop2-dev (>= 2.34.0), libgtop2-dev (>= 2.34.0),
libhandy-0.0-dev (>= 0.0.10), libhandy-0.0-dev (>= 0.0.10),
meson (>= 0.37), meson (>= 0.37),
libtracker-sparql-2.0-dev,
valac valac
Standards-Version: 4.3.0 Standards-Version: 4.3.0
Vcs-Browser: https://salsa.debian.org/gnome-team/gnome-usage Vcs-Browser: https://salsa.debian.org/gnome-team/gnome-usage
...@@ -21,6 +23,7 @@ Package: gnome-usage ...@@ -21,6 +23,7 @@ Package: gnome-usage
Architecture: any Architecture: any
Depends: ${misc:Depends}, Depends: ${misc:Depends},
${shlibs:Depends} ${shlibs:Depends}
Recommends: gthd
Description: simple system monitor app for GNOME Description: simple system monitor app for GNOME
Usage is an application for GNOME that allows monitoring of system resources Usage is an application for GNOME that allows monitoring of system resources
such as memory, CPU, and disk space. such as memory, CPU, and disk space.
...@@ -14,6 +14,9 @@ gio_dep = dependency('gio-2.0') ...@@ -14,6 +14,9 @@ gio_dep = dependency('gio-2.0')
gtk_dep = dependency('gtk+-3.0', version : '>=3.20.10') gtk_dep = dependency('gtk+-3.0', version : '>=3.20.10')
libdazzle_dep = dependency('libdazzle-1.0', version : '>=3.30') libdazzle_dep = dependency('libdazzle-1.0', version : '>=3.30')
libhandy_dep = dependency('libhandy-0.0', version : '>=0.0.10') libhandy_dep = dependency('libhandy-0.0', version : '>=0.0.10')
libgtop_dep = dependency('libgtop-2.0', version : '>= 2.34.0')
tracker_dep = dependency('tracker-sparql-2.0')
gtherm_dep = dependency('libgtherm-0.0')
gnome = import('gnome') gnome = import('gnome')
i18n = import('i18n') i18n = import('i18n')
......
...@@ -36,6 +36,12 @@ namespace Usage ...@@ -36,6 +36,12 @@ namespace Usage
child = createContent(memory_graph, label); child = createContent(memory_graph, label);
} }
public GraphSwitcherButton.temperature(string label)
{
var thermal_graph = new ThermalGraph();
child = createContent(thermal_graph, label);
}
private Gtk.Box createContent(Dazzle.GraphView graph, string label_text) private Gtk.Box createContent(Dazzle.GraphView graph, string label_text)
{ {
graph.height_request = 80; graph.height_request = 80;
......
...@@ -19,6 +19,7 @@ vala_sources = [ ...@@ -19,6 +19,7 @@ vala_sources = [
'memory-speedometer.vala', 'memory-speedometer.vala',
'memory-sub-view.vala', 'memory-sub-view.vala',
'monitor.vala', 'monitor.vala',
'no-gthd-view.vala',
'no-results-found-view.vala', 'no-results-found-view.vala',
'performance-view.vala', 'performance-view.vala',
'pie-chart.vala', 'pie-chart.vala',
...@@ -39,6 +40,14 @@ vala_sources = [ ...@@ -39,6 +40,14 @@ vala_sources = [
'storage-worker.vala', 'storage-worker.vala',
'swap-speedometer.vala', 'swap-speedometer.vala',
'system-monitor.vala', 'system-monitor.vala',
'thermal-list-box.vala',
'thermal-row.vala',
'thermal-graph.vala',
'thermal-graph-stack-switcher.vala',
'thermal-graph-model.vala',
'thermal-monitor.vala',
'thermal-view.vala',
'thermal-sub-view.vala',
'utils.vala', 'utils.vala',
'view.vala', 'view.vala',
'window.vala' 'window.vala'
...@@ -48,6 +57,7 @@ deps = [ ...@@ -48,6 +57,7 @@ deps = [
gio_dep, gio_dep,
glib_dep, glib_dep,
gobject_dep, gobject_dep,
gtherm_dep,
gtk_dep, gtk_dep,
dependency('libgtop-2.0', version : '>= 2.34.0'), dependency('libgtop-2.0', version : '>= 2.34.0'),
libdazzle_dep, libdazzle_dep,
......
/* no-results-found-box.vala
*
* Copyright (C) 2020 Purism SPC
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Usage
{
[GtkTemplate (ui = "/org/gnome/Usage/ui/no-gthd-view.ui")]
public class NoGthdView : View { }
}
...@@ -23,6 +23,7 @@ namespace Usage ...@@ -23,6 +23,7 @@ namespace Usage
public class SystemMonitor : Object public class SystemMonitor : Object
{ {
public bool process_list_ready { get; private set; default = false; } public bool process_list_ready { get; private set; default = false; }
public bool thermal_list_ready { get; private set; default = false; }
public double cpu_load { get; private set; } public double cpu_load { get; private set; }
public double[] x_cpu_load { get; private set; } public double[] x_cpu_load { get; private set; }
public uint64 ram_usage { get; private set; } public uint64 ram_usage { get; private set; }
...@@ -30,9 +31,11 @@ namespace Usage ...@@ -30,9 +31,11 @@ namespace Usage
public uint64 swap_usage { get; private set; } public uint64 swap_usage { get; private set; }
public uint64 swap_total { get; private set; } public uint64 swap_total { get; private set; }
public bool group_system_apps { get; set; default = true; } public bool group_system_apps { get; set; default = true; }
public double[] x_temp { get; private set; }
private CpuMonitor cpu_monitor; private CpuMonitor cpu_monitor;
private MemoryMonitor memory_monitor; private MemoryMonitor memory_monitor;
private ThermalMonitor thermal_monitor;
private HashTable<string, AppItem> app_table; private HashTable<string, AppItem> app_table;
private int process_mode = GTop.KERN_PROC_ALL; private int process_mode = GTop.KERN_PROC_ALL;
...@@ -56,6 +59,12 @@ namespace Usage ...@@ -56,6 +59,12 @@ namespace Usage
return app_table.get(name); return app_table.get(name);
} }
public GLib.GenericArray<Gth.ThermalZone> get_thermal_zones()
{
return thermal_monitor.get_thermal_zones ();
}
public SystemMonitor() public SystemMonitor()
{ {
GTop.init(); GTop.init();
...@@ -63,6 +72,7 @@ namespace Usage ...@@ -63,6 +72,7 @@ namespace Usage
cpu_monitor = new CpuMonitor(); cpu_monitor = new CpuMonitor();
memory_monitor = new MemoryMonitor(); memory_monitor = new MemoryMonitor();
thermal_monitor = new ThermalMonitor();
app_table = new HashTable<string, AppItem>(str_hash, str_equal); app_table = new HashTable<string, AppItem>(str_hash, str_equal);
var settings = Settings.get_default(); var settings = Settings.get_default();
...@@ -80,6 +90,7 @@ namespace Usage ...@@ -80,6 +90,7 @@ namespace Usage
var settings = Settings.get_default(); var settings = Settings.get_default();
app_table.remove_all(); app_table.remove_all();
process_list_ready = false; process_list_ready = false;
thermal_list_ready = false;
if(group_system_apps) { if(group_system_apps) {
var system = new AppItem.system(); var system = new AppItem.system();
...@@ -90,6 +101,7 @@ namespace Usage ...@@ -90,6 +101,7 @@ namespace Usage
Timeout.add(settings.data_update_interval, () => Timeout.add(settings.data_update_interval, () =>
{ {
process_list_ready = true; process_list_ready = true;
thermal_list_ready = true;
return false; return false;
}); });
} }
...@@ -98,6 +110,7 @@ namespace Usage ...@@ -98,6 +110,7 @@ namespace Usage
{ {
cpu_monitor.update(); cpu_monitor.update();
memory_monitor.update(); memory_monitor.update();
thermal_monitor.update();
cpu_load = cpu_monitor.get_cpu_load(); cpu_load = cpu_monitor.get_cpu_load();
x_cpu_load = cpu_monitor.get_x_cpu_load(); x_cpu_load = cpu_monitor.get_x_cpu_load();
...@@ -105,6 +118,7 @@ namespace Usage ...@@ -105,6 +118,7 @@ namespace Usage
ram_total = memory_monitor.get_ram_total(); ram_total = memory_monitor.get_ram_total();
swap_usage = memory_monitor.get_swap_usage(); swap_usage = memory_monitor.get_swap_usage();
swap_total = memory_monitor.get_swap_total(); swap_total = memory_monitor.get_swap_total();
x_temp = thermal_monitor.get_x_temp();
GTop.Proclist proclist; GTop.Proclist proclist;
var pids = GTop.get_proclist (out proclist, process_mode); var pids = GTop.get_proclist (out proclist, process_mode);
......
/* thermal-graph-model.vala
*
* Copyright (C) 2019 Purism SPC
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Guido Guenther <agx@sigxcpu.org>
*/
using Dazzle;
namespace Usage {
public class ThermalGraphModel : GraphModel {
public int num_zones;
public ThermalGraphModel () {
var settings = Settings.get_default();
SystemMonitor monitor = SystemMonitor.get_default();
set_timespan (settings.graph_timespan * 1000);
set_max_samples (settings.graph_max_samples);
num_zones = monitor.x_temp.length;
for (int i = 0; i < num_zones; i++) {
/* TODO: use correct zone numbers */
var column_x_temp = new GraphColumn("ThermalZone: " + i.to_string(), Type.from_name("gdouble"));
add_column(column_x_temp);
}
Timeout.add(settings.graph_update_interval, update_data);
}
bool update_data() {
GraphModelIter iter;
push (out iter, get_monotonic_time ());
SystemMonitor monitor = SystemMonitor.get_default();
for (int i = 0; i < num_zones; i++) {
iter_set_value(iter, i, monitor.x_temp[i]);
}
return true;
}
}
}
/* graph-stack-switcher.vala
*
* Copyright (C) 2019 Purism SPC
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Guido Guenther <agx@sigxcpu.org>
*/
namespace Usage
{
public class ThermalGraphStackSwitcher : Gtk.Box
{
View[] sub_views;
AnimatedScrolledWindow scrolled_window;
GraphSwitcherButton[] buttons;
class construct
{
set_css_name("graph-stack-switcher");
}
public ThermalGraphStackSwitcher(AnimatedScrolledWindow scrolled_window, View[] sub_views)
{
Object(orientation: Gtk.Orientation.VERTICAL, spacing: 0);
this.sub_views = sub_views;
this.scrolled_window = scrolled_window;
scrolled_window.scroll_changed.connect(on_scroll_changed);
buttons = {
new GraphSwitcherButton.temperature(_("Temperature")),
};
foreach(GraphSwitcherButton button in buttons)
{
this.pack_start(button, false, true, 0);
button.button_release_event.connect(() => {
var button_number = get_button_number(button);
scroll_to_view(button_number);
return false;
});
}
}