2006-03-04 18:16:49 +00:00
|
|
|
/*
|
|
|
|
htop - CPUMeter.c
|
2011-05-26 16:35:07 +00:00
|
|
|
(C) 2004-2011 Hisham H. Muhammad
|
2020-10-05 07:51:32 +00:00
|
|
|
Released under the GNU GPLv2, see the COPYING file
|
2006-03-04 18:16:49 +00:00
|
|
|
in the source distribution for its full text.
|
|
|
|
*/
|
|
|
|
|
2020-11-18 14:12:18 +00:00
|
|
|
#include "config.h" // IWYU pragma: keep
|
2020-11-18 13:26:30 +00:00
|
|
|
|
2006-03-04 18:16:49 +00:00
|
|
|
#include "CPUMeter.h"
|
|
|
|
|
2020-09-19 11:55:23 +00:00
|
|
|
#include <math.h>
|
2020-11-18 13:26:30 +00:00
|
|
|
#include <stdint.h>
|
2020-09-19 11:55:23 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2011-12-26 21:35:57 +00:00
|
|
|
#include "CRT.h"
|
2020-09-19 11:55:23 +00:00
|
|
|
#include "Object.h"
|
2015-01-22 01:27:31 +00:00
|
|
|
#include "Platform.h"
|
2020-09-19 11:55:23 +00:00
|
|
|
#include "ProcessList.h"
|
|
|
|
#include "RichString.h"
|
|
|
|
#include "Settings.h"
|
2020-10-14 18:21:09 +00:00
|
|
|
#include "XUtils.h"
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
|
2020-09-28 10:23:07 +00:00
|
|
|
static const int CPUMeter_attributes[] = {
|
|
|
|
CPU_NICE,
|
|
|
|
CPU_NORMAL,
|
|
|
|
CPU_SYSTEM,
|
|
|
|
CPU_IRQ,
|
|
|
|
CPU_SOFTIRQ,
|
|
|
|
CPU_STEAL,
|
|
|
|
CPU_GUEST,
|
|
|
|
CPU_IOWAIT
|
2006-06-06 20:41:01 +00:00
|
|
|
};
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2020-09-23 09:58:11 +00:00
|
|
|
typedef struct CPUMeterData_ {
|
|
|
|
int cpus;
|
|
|
|
Meter** meters;
|
|
|
|
} CPUMeterData;
|
|
|
|
|
2008-03-09 08:58:38 +00:00
|
|
|
static void CPUMeter_init(Meter* this) {
|
2010-08-24 23:20:38 +00:00
|
|
|
int cpu = this->param;
|
|
|
|
if (this->pl->cpuCount > 1) {
|
2006-04-10 20:40:38 +00:00
|
|
|
char caption[10];
|
2020-09-01 11:50:25 +00:00
|
|
|
xSnprintf(caption, sizeof(caption), "%3d", Settings_cpuId(this->pl->settings, cpu - 1));
|
2006-04-10 20:40:38 +00:00
|
|
|
Meter_setCaption(this, caption);
|
2006-03-04 18:16:49 +00:00
|
|
|
}
|
2006-04-10 20:40:38 +00:00
|
|
|
if (this->param == 0)
|
|
|
|
Meter_setCaption(this, "Avg");
|
2006-03-04 18:16:49 +00:00
|
|
|
}
|
|
|
|
|
2020-11-24 17:31:03 +00:00
|
|
|
static void CPUMeter_updateValues(Meter* this, char* buffer, size_t size) {
|
2010-08-24 23:20:38 +00:00
|
|
|
int cpu = this->param;
|
|
|
|
if (cpu > this->pl->cpuCount) {
|
2017-07-27 19:07:50 +00:00
|
|
|
xSnprintf(buffer, size, "absent");
|
2020-10-29 22:17:12 +00:00
|
|
|
for (uint8_t i = 0; i < this->curItems; i++)
|
2020-09-23 09:58:11 +00:00
|
|
|
this->values[i] = 0;
|
2009-06-02 04:51:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2015-10-23 15:46:21 +00:00
|
|
|
memset(this->values, 0, sizeof(double) * CPU_METER_ITEMCOUNT);
|
2020-09-10 17:56:33 +00:00
|
|
|
|
|
|
|
char cpuUsageBuffer[8] = { 0 };
|
|
|
|
char cpuFrequencyBuffer[16] = { 0 };
|
|
|
|
char cpuTemperatureBuffer[16] = { 0 };
|
|
|
|
|
2015-01-22 01:27:31 +00:00
|
|
|
double percent = Platform_setCPUValues(this, cpu);
|
2020-09-10 17:56:33 +00:00
|
|
|
|
|
|
|
if (this->pl->settings->showCPUUsage) {
|
2020-12-19 22:52:03 +00:00
|
|
|
xSnprintf(cpuUsageBuffer, sizeof(cpuUsageBuffer), "%.1f%%", percent);
|
2020-09-10 17:56:33 +00:00
|
|
|
}
|
|
|
|
|
2019-08-11 05:19:32 +00:00
|
|
|
if (this->pl->settings->showCPUFrequency) {
|
2019-08-10 04:34:48 +00:00
|
|
|
double cpuFrequency = this->values[CPU_METER_FREQUENCY];
|
2020-09-07 10:24:32 +00:00
|
|
|
if (isnan(cpuFrequency)) {
|
2019-08-10 18:37:35 +00:00
|
|
|
xSnprintf(cpuFrequencyBuffer, sizeof(cpuFrequencyBuffer), "N/A");
|
|
|
|
} else {
|
2020-09-22 12:50:50 +00:00
|
|
|
xSnprintf(cpuFrequencyBuffer, sizeof(cpuFrequencyBuffer), "%4uMHz", (unsigned)cpuFrequency);
|
2019-08-10 04:34:48 +00:00
|
|
|
}
|
|
|
|
}
|
2020-09-10 17:56:33 +00:00
|
|
|
|
2020-12-01 12:59:19 +00:00
|
|
|
#ifdef HAVE_SENSORS_SENSORS_H
|
2020-09-10 17:56:33 +00:00
|
|
|
if (this->pl->settings->showCPUTemperature) {
|
|
|
|
double cpuTemperature = this->values[CPU_METER_TEMPERATURE];
|
|
|
|
if (isnan(cpuTemperature))
|
|
|
|
xSnprintf(cpuTemperatureBuffer, sizeof(cpuTemperatureBuffer), "N/A");
|
|
|
|
else if (this->pl->settings->degreeFahrenheit)
|
|
|
|
xSnprintf(cpuTemperatureBuffer, sizeof(cpuTemperatureBuffer), "%3d%sF", (int)(cpuTemperature * 9 / 5 + 32), CRT_degreeSign);
|
|
|
|
else
|
|
|
|
xSnprintf(cpuTemperatureBuffer, sizeof(cpuTemperatureBuffer), "%d%sC", (int)cpuTemperature, CRT_degreeSign);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
xSnprintf(buffer, size, "%s%s%s%s%s",
|
|
|
|
cpuUsageBuffer,
|
|
|
|
(cpuUsageBuffer[0] && (cpuFrequencyBuffer[0] || cpuTemperatureBuffer[0])) ? " " : "",
|
|
|
|
cpuFrequencyBuffer,
|
|
|
|
(cpuFrequencyBuffer[0] && cpuTemperatureBuffer[0]) ? " " : "",
|
|
|
|
cpuTemperatureBuffer);
|
2006-03-04 18:16:49 +00:00
|
|
|
}
|
|
|
|
|
2020-10-06 10:28:11 +00:00
|
|
|
static void CPUMeter_display(const Object* cast, RichString* out) {
|
2006-03-04 18:16:49 +00:00
|
|
|
char buffer[50];
|
2020-10-06 10:28:11 +00:00
|
|
|
const Meter* this = (const Meter*)cast;
|
2010-11-22 12:40:20 +00:00
|
|
|
RichString_prune(out);
|
2010-08-24 23:20:38 +00:00
|
|
|
if (this->param > this->pl->cpuCount) {
|
2020-12-04 13:44:57 +00:00
|
|
|
RichString_appendAscii(out, CRT_colors[METER_TEXT], "absent");
|
2009-06-02 04:51:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-07-27 19:07:50 +00:00
|
|
|
xSnprintf(buffer, sizeof(buffer), "%5.1f%% ", this->values[CPU_METER_NORMAL]);
|
2020-12-04 13:44:57 +00:00
|
|
|
RichString_appendAscii(out, CRT_colors[METER_TEXT], ":");
|
|
|
|
RichString_appendAscii(out, CRT_colors[CPU_NORMAL], buffer);
|
2015-01-22 01:27:31 +00:00
|
|
|
if (this->pl->settings->detailedCPUTime) {
|
2017-07-27 19:07:50 +00:00
|
|
|
xSnprintf(buffer, sizeof(buffer), "%5.1f%% ", this->values[CPU_METER_KERNEL]);
|
2020-12-04 13:44:57 +00:00
|
|
|
RichString_appendAscii(out, CRT_colors[METER_TEXT], "sy:");
|
|
|
|
RichString_appendAscii(out, CRT_colors[CPU_SYSTEM], buffer);
|
2017-07-27 19:07:50 +00:00
|
|
|
xSnprintf(buffer, sizeof(buffer), "%5.1f%% ", this->values[CPU_METER_NICE]);
|
2020-12-04 13:44:57 +00:00
|
|
|
RichString_appendAscii(out, CRT_colors[METER_TEXT], "ni:");
|
|
|
|
RichString_appendAscii(out, CRT_colors[CPU_NICE_TEXT], buffer);
|
2017-07-27 19:07:50 +00:00
|
|
|
xSnprintf(buffer, sizeof(buffer), "%5.1f%% ", this->values[CPU_METER_IRQ]);
|
2020-12-04 13:44:57 +00:00
|
|
|
RichString_appendAscii(out, CRT_colors[METER_TEXT], "hi:");
|
|
|
|
RichString_appendAscii(out, CRT_colors[CPU_IRQ], buffer);
|
2017-07-27 19:07:50 +00:00
|
|
|
xSnprintf(buffer, sizeof(buffer), "%5.1f%% ", this->values[CPU_METER_SOFTIRQ]);
|
2020-12-04 13:44:57 +00:00
|
|
|
RichString_appendAscii(out, CRT_colors[METER_TEXT], "si:");
|
|
|
|
RichString_appendAscii(out, CRT_colors[CPU_SOFTIRQ], buffer);
|
2020-09-07 10:07:08 +00:00
|
|
|
if (!isnan(this->values[CPU_METER_STEAL])) {
|
2017-07-27 19:07:50 +00:00
|
|
|
xSnprintf(buffer, sizeof(buffer), "%5.1f%% ", this->values[CPU_METER_STEAL]);
|
2020-12-04 13:44:57 +00:00
|
|
|
RichString_appendAscii(out, CRT_colors[METER_TEXT], "st:");
|
|
|
|
RichString_appendAscii(out, CRT_colors[CPU_STEAL], buffer);
|
2013-12-18 02:58:34 +00:00
|
|
|
}
|
2020-09-07 10:07:08 +00:00
|
|
|
if (!isnan(this->values[CPU_METER_GUEST])) {
|
2017-07-27 19:07:50 +00:00
|
|
|
xSnprintf(buffer, sizeof(buffer), "%5.1f%% ", this->values[CPU_METER_GUEST]);
|
2020-12-04 13:44:57 +00:00
|
|
|
RichString_appendAscii(out, CRT_colors[METER_TEXT], "gu:");
|
|
|
|
RichString_appendAscii(out, CRT_colors[CPU_GUEST], buffer);
|
2010-08-24 23:20:38 +00:00
|
|
|
}
|
2017-07-27 19:07:50 +00:00
|
|
|
xSnprintf(buffer, sizeof(buffer), "%5.1f%% ", this->values[CPU_METER_IOWAIT]);
|
2020-12-04 13:44:57 +00:00
|
|
|
RichString_appendAscii(out, CRT_colors[METER_TEXT], "wa:");
|
|
|
|
RichString_appendAscii(out, CRT_colors[CPU_IOWAIT], buffer);
|
2006-10-04 14:21:27 +00:00
|
|
|
} else {
|
2017-07-27 19:07:50 +00:00
|
|
|
xSnprintf(buffer, sizeof(buffer), "%5.1f%% ", this->values[CPU_METER_KERNEL]);
|
2020-12-04 13:44:57 +00:00
|
|
|
RichString_appendAscii(out, CRT_colors[METER_TEXT], "sys:");
|
|
|
|
RichString_appendAscii(out, CRT_colors[CPU_SYSTEM], buffer);
|
2017-07-27 19:07:50 +00:00
|
|
|
xSnprintf(buffer, sizeof(buffer), "%5.1f%% ", this->values[CPU_METER_NICE]);
|
2020-12-04 13:44:57 +00:00
|
|
|
RichString_appendAscii(out, CRT_colors[METER_TEXT], "low:");
|
|
|
|
RichString_appendAscii(out, CRT_colors[CPU_NICE_TEXT], buffer);
|
2020-09-07 10:07:08 +00:00
|
|
|
if (!isnan(this->values[CPU_METER_IRQ])) {
|
2017-07-27 19:07:50 +00:00
|
|
|
xSnprintf(buffer, sizeof(buffer), "%5.1f%% ", this->values[CPU_METER_IRQ]);
|
2020-12-04 13:44:57 +00:00
|
|
|
RichString_appendAscii(out, CRT_colors[METER_TEXT], "vir:");
|
|
|
|
RichString_appendAscii(out, CRT_colors[CPU_GUEST], buffer);
|
2010-08-24 23:20:38 +00:00
|
|
|
}
|
2006-10-04 14:21:27 +00:00
|
|
|
}
|
2020-09-10 17:56:33 +00:00
|
|
|
|
2020-12-01 12:59:19 +00:00
|
|
|
#ifdef HAVE_SENSORS_SENSORS_H
|
2020-09-10 17:56:33 +00:00
|
|
|
if (this->pl->settings->showCPUTemperature) {
|
|
|
|
char cpuTemperatureBuffer[10];
|
|
|
|
double cpuTemperature = this->values[CPU_METER_TEMPERATURE];
|
|
|
|
if (isnan(cpuTemperature)) {
|
|
|
|
xSnprintf(cpuTemperatureBuffer, sizeof(cpuTemperatureBuffer), "N/A");
|
|
|
|
} else if (this->pl->settings->degreeFahrenheit) {
|
|
|
|
xSnprintf(cpuTemperatureBuffer, sizeof(cpuTemperatureBuffer), "%5.1f%sF", cpuTemperature * 9 / 5 + 32, CRT_degreeSign);
|
|
|
|
} else {
|
|
|
|
xSnprintf(cpuTemperatureBuffer, sizeof(cpuTemperatureBuffer), "%5.1f%sC", cpuTemperature, CRT_degreeSign);
|
|
|
|
}
|
2020-12-04 13:44:57 +00:00
|
|
|
RichString_appendAscii(out, CRT_colors[METER_TEXT], "temp:");
|
|
|
|
RichString_appendWide(out, CRT_colors[METER_VALUE], cpuTemperatureBuffer);
|
2020-09-10 17:56:33 +00:00
|
|
|
}
|
|
|
|
#endif
|
2006-03-04 18:16:49 +00:00
|
|
|
}
|
2006-04-10 20:40:38 +00:00
|
|
|
|
2011-11-18 06:08:56 +00:00
|
|
|
static void AllCPUsMeter_getRange(Meter* this, int* start, int* count) {
|
2020-09-23 09:58:11 +00:00
|
|
|
CPUMeterData* data = this->meterData;
|
|
|
|
int cpus = data->cpus;
|
2012-12-05 15:12:20 +00:00
|
|
|
switch(Meter_name(this)[0]) {
|
2011-11-18 06:08:56 +00:00
|
|
|
default:
|
|
|
|
case 'A': // All
|
|
|
|
*start = 0;
|
|
|
|
*count = cpus;
|
|
|
|
break;
|
|
|
|
case 'L': // First Half
|
|
|
|
*start = 0;
|
|
|
|
*count = (cpus+1) / 2;
|
|
|
|
break;
|
|
|
|
case 'R': // Second Half
|
|
|
|
*start = (cpus+1) / 2;
|
|
|
|
*count = cpus / 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-31 22:28:02 +00:00
|
|
|
static void CPUMeterCommonInit(Meter* this, int ncol) {
|
2010-08-24 23:20:38 +00:00
|
|
|
int cpus = this->pl->cpuCount;
|
2020-09-23 09:58:11 +00:00
|
|
|
CPUMeterData* data = this->meterData;
|
|
|
|
if (!data) {
|
|
|
|
data = this->meterData = xMalloc(sizeof(CPUMeterData));
|
|
|
|
data->cpus = cpus;
|
|
|
|
data->meters = xCalloc(cpus, sizeof(Meter*));
|
|
|
|
}
|
|
|
|
Meter** meters = data->meters;
|
2011-11-18 06:08:56 +00:00
|
|
|
int start, count;
|
|
|
|
AllCPUsMeter_getRange(this, &start, &count);
|
|
|
|
for (int i = 0; i < count; i++) {
|
2011-03-31 20:24:59 +00:00
|
|
|
if (!meters[i])
|
2020-10-31 22:28:02 +00:00
|
|
|
meters[i] = Meter_new(this->pl, start + i + 1, (const MeterClass*) Class(CPUMeter));
|
2020-11-01 00:09:51 +00:00
|
|
|
|
2012-12-05 15:12:20 +00:00
|
|
|
Meter_init(meters[i]);
|
2011-03-31 20:24:59 +00:00
|
|
|
}
|
2020-11-01 00:09:51 +00:00
|
|
|
|
2011-11-18 06:08:56 +00:00
|
|
|
if (this->mode == 0)
|
|
|
|
this->mode = BAR_METERMODE;
|
2020-11-01 00:09:51 +00:00
|
|
|
|
2011-11-18 06:08:56 +00:00
|
|
|
int h = Meter_modes[this->mode]->h;
|
2020-10-31 22:28:02 +00:00
|
|
|
this->h = h * ((count + ncol - 1) / ncol);
|
2006-04-10 20:40:38 +00:00
|
|
|
}
|
|
|
|
|
2020-09-24 19:17:51 +00:00
|
|
|
static void CPUMeterCommonUpdateMode(Meter* this, int mode, int ncol) {
|
2020-09-23 09:58:11 +00:00
|
|
|
CPUMeterData* data = this->meterData;
|
|
|
|
Meter** meters = data->meters;
|
2006-05-09 18:35:51 +00:00
|
|
|
this->mode = mode;
|
2011-11-18 06:08:56 +00:00
|
|
|
int h = Meter_modes[mode]->h;
|
|
|
|
int start, count;
|
|
|
|
AllCPUsMeter_getRange(this, &start, &count);
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
Meter_setMode(meters[i], mode);
|
|
|
|
}
|
2020-10-31 22:28:02 +00:00
|
|
|
this->h = h * ((count + ncol - 1) / ncol);
|
2006-05-09 18:35:51 +00:00
|
|
|
}
|
|
|
|
|
2020-09-24 19:17:51 +00:00
|
|
|
static void AllCPUsMeter_done(Meter* this) {
|
2020-09-23 09:58:11 +00:00
|
|
|
CPUMeterData* data = this->meterData;
|
|
|
|
Meter** meters = data->meters;
|
2011-11-18 06:08:56 +00:00
|
|
|
int start, count;
|
|
|
|
AllCPUsMeter_getRange(this, &start, &count);
|
2020-09-24 19:17:51 +00:00
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
Meter_delete((Object*)meters[i]);
|
2020-09-23 09:58:11 +00:00
|
|
|
free(data->meters);
|
|
|
|
free(data);
|
2011-11-18 06:08:56 +00:00
|
|
|
}
|
|
|
|
|
2020-09-24 19:17:51 +00:00
|
|
|
static void SingleColCPUsMeter_init(Meter* this) {
|
|
|
|
CPUMeterCommonInit(this, 1);
|
2006-04-10 20:40:38 +00:00
|
|
|
}
|
2008-03-09 08:58:38 +00:00
|
|
|
|
2020-09-24 19:17:51 +00:00
|
|
|
static void SingleColCPUsMeter_updateMode(Meter* this, int mode) {
|
|
|
|
CPUMeterCommonUpdateMode(this, mode, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void DualColCPUsMeter_init(Meter* this) {
|
|
|
|
CPUMeterCommonInit(this, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void DualColCPUsMeter_updateMode(Meter* this, int mode) {
|
|
|
|
CPUMeterCommonUpdateMode(this, mode, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void QuadColCPUsMeter_init(Meter* this) {
|
|
|
|
CPUMeterCommonInit(this, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void QuadColCPUsMeter_updateMode(Meter* this, int mode) {
|
|
|
|
CPUMeterCommonUpdateMode(this, mode, 4);
|
|
|
|
}
|
|
|
|
|
2020-09-24 19:56:40 +00:00
|
|
|
static void OctoColCPUsMeter_init(Meter* this) {
|
|
|
|
CPUMeterCommonInit(this, 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void OctoColCPUsMeter_updateMode(Meter* this, int mode) {
|
|
|
|
CPUMeterCommonUpdateMode(this, mode, 8);
|
|
|
|
}
|
|
|
|
|
2020-09-24 19:17:51 +00:00
|
|
|
static void CPUMeterCommonDraw(Meter* this, int x, int y, int w, int ncol) {
|
2020-09-23 09:58:11 +00:00
|
|
|
CPUMeterData* data = this->meterData;
|
|
|
|
Meter** meters = data->meters;
|
|
|
|
int start, count;
|
|
|
|
AllCPUsMeter_getRange(this, &start, &count);
|
2020-10-31 22:28:02 +00:00
|
|
|
int colwidth = (w - ncol) / ncol + 1;
|
2020-09-23 09:58:11 +00:00
|
|
|
int diff = (w - (colwidth * ncol));
|
|
|
|
int nrows = (count + ncol - 1) / ncol;
|
2020-10-31 22:28:02 +00:00
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
int d = (i / nrows) > diff ? diff : (i / nrows); // dynamic spacer
|
2020-09-23 09:58:11 +00:00
|
|
|
int xpos = x + ((i / nrows) * colwidth) + d;
|
|
|
|
int ypos = y + ((i % nrows) * meters[0]->h);
|
|
|
|
meters[i]->draw(meters[i], xpos, ypos, colwidth);
|
|
|
|
}
|
2020-06-11 21:21:52 +00:00
|
|
|
}
|
|
|
|
|
2020-09-24 19:17:51 +00:00
|
|
|
static void DualColCPUsMeter_draw(Meter* this, int x, int y, int w) {
|
|
|
|
CPUMeterCommonDraw(this, x, y, w, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void QuadColCPUsMeter_draw(Meter* this, int x, int y, int w) {
|
|
|
|
CPUMeterCommonDraw(this, x, y, w, 4);
|
|
|
|
}
|
|
|
|
|
2020-09-24 19:56:40 +00:00
|
|
|
static void OctoColCPUsMeter_draw(Meter* this, int x, int y, int w) {
|
|
|
|
CPUMeterCommonDraw(this, x, y, w, 8);
|
|
|
|
}
|
|
|
|
|
2020-09-24 19:17:51 +00:00
|
|
|
|
|
|
|
static void SingleColCPUsMeter_draw(Meter* this, int x, int y, int w) {
|
2020-09-23 09:58:11 +00:00
|
|
|
CPUMeterData* data = this->meterData;
|
|
|
|
Meter** meters = data->meters;
|
2020-09-24 19:17:51 +00:00
|
|
|
int start, count;
|
|
|
|
AllCPUsMeter_getRange(this, &start, &count);
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
meters[i]->draw(meters[i], x, y, w);
|
|
|
|
y += meters[i]->h;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-05 11:19:50 +00:00
|
|
|
const MeterClass CPUMeter_class = {
|
2012-12-05 15:12:20 +00:00
|
|
|
.super = {
|
|
|
|
.extends = Class(Meter),
|
|
|
|
.delete = Meter_delete,
|
|
|
|
.display = CPUMeter_display
|
|
|
|
},
|
2016-05-04 05:39:26 +00:00
|
|
|
.updateValues = CPUMeter_updateValues,
|
2012-12-05 15:12:20 +00:00
|
|
|
.defaultMode = BAR_METERMODE,
|
2015-10-23 15:46:21 +00:00
|
|
|
.maxItems = CPU_METER_ITEMCOUNT,
|
2008-03-09 08:58:38 +00:00
|
|
|
.total = 100.0,
|
2019-10-31 16:39:12 +00:00
|
|
|
.attributes = CPUMeter_attributes,
|
2008-03-09 08:58:38 +00:00
|
|
|
.name = "CPU",
|
|
|
|
.uiName = "CPU",
|
|
|
|
.caption = "CPU",
|
|
|
|
.init = CPUMeter_init
|
|
|
|
};
|
|
|
|
|
2020-10-05 11:19:50 +00:00
|
|
|
const MeterClass AllCPUsMeter_class = {
|
2012-12-05 15:12:20 +00:00
|
|
|
.super = {
|
|
|
|
.extends = Class(Meter),
|
|
|
|
.delete = Meter_delete,
|
|
|
|
.display = CPUMeter_display
|
|
|
|
},
|
|
|
|
.defaultMode = CUSTOM_METERMODE,
|
2008-03-09 08:58:38 +00:00
|
|
|
.total = 100.0,
|
2019-10-31 16:39:12 +00:00
|
|
|
.attributes = CPUMeter_attributes,
|
2008-03-09 08:58:38 +00:00
|
|
|
.name = "AllCPUs",
|
2011-11-18 06:08:56 +00:00
|
|
|
.uiName = "CPUs (1/1)",
|
2015-02-03 21:31:44 +00:00
|
|
|
.description = "CPUs (1/1): all CPUs",
|
2008-03-09 08:58:38 +00:00
|
|
|
.caption = "CPU",
|
2011-11-18 06:08:56 +00:00
|
|
|
.draw = SingleColCPUsMeter_draw,
|
2020-09-24 19:17:51 +00:00
|
|
|
.init = SingleColCPUsMeter_init,
|
|
|
|
.updateMode = SingleColCPUsMeter_updateMode,
|
2008-03-09 08:58:38 +00:00
|
|
|
.done = AllCPUsMeter_done
|
|
|
|
};
|
2011-11-18 06:08:56 +00:00
|
|
|
|
2020-10-05 11:19:50 +00:00
|
|
|
const MeterClass AllCPUs2Meter_class = {
|
2012-12-05 15:12:20 +00:00
|
|
|
.super = {
|
|
|
|
.extends = Class(Meter),
|
|
|
|
.delete = Meter_delete,
|
|
|
|
.display = CPUMeter_display
|
|
|
|
},
|
|
|
|
.defaultMode = CUSTOM_METERMODE,
|
2011-11-18 06:08:56 +00:00
|
|
|
.total = 100.0,
|
2019-10-31 16:39:12 +00:00
|
|
|
.attributes = CPUMeter_attributes,
|
2011-11-18 06:08:56 +00:00
|
|
|
.name = "AllCPUs2",
|
|
|
|
.uiName = "CPUs (1&2/2)",
|
2015-02-03 21:31:44 +00:00
|
|
|
.description = "CPUs (1&2/2): all CPUs in 2 shorter columns",
|
2011-11-18 06:08:56 +00:00
|
|
|
.caption = "CPU",
|
|
|
|
.draw = DualColCPUsMeter_draw,
|
2020-09-24 19:17:51 +00:00
|
|
|
.init = DualColCPUsMeter_init,
|
|
|
|
.updateMode = DualColCPUsMeter_updateMode,
|
2011-11-18 06:08:56 +00:00
|
|
|
.done = AllCPUsMeter_done
|
|
|
|
};
|
|
|
|
|
2020-10-05 11:19:50 +00:00
|
|
|
const MeterClass LeftCPUsMeter_class = {
|
2012-12-05 15:12:20 +00:00
|
|
|
.super = {
|
|
|
|
.extends = Class(Meter),
|
|
|
|
.delete = Meter_delete,
|
|
|
|
.display = CPUMeter_display
|
|
|
|
},
|
|
|
|
.defaultMode = CUSTOM_METERMODE,
|
2011-11-18 06:08:56 +00:00
|
|
|
.total = 100.0,
|
2019-10-31 16:39:12 +00:00
|
|
|
.attributes = CPUMeter_attributes,
|
2011-11-18 06:08:56 +00:00
|
|
|
.name = "LeftCPUs",
|
|
|
|
.uiName = "CPUs (1/2)",
|
2015-02-03 21:31:44 +00:00
|
|
|
.description = "CPUs (1/2): first half of list",
|
2011-11-18 06:08:56 +00:00
|
|
|
.caption = "CPU",
|
|
|
|
.draw = SingleColCPUsMeter_draw,
|
2020-09-24 19:17:51 +00:00
|
|
|
.init = SingleColCPUsMeter_init,
|
|
|
|
.updateMode = SingleColCPUsMeter_updateMode,
|
2011-11-18 06:08:56 +00:00
|
|
|
.done = AllCPUsMeter_done
|
|
|
|
};
|
|
|
|
|
2020-10-05 11:19:50 +00:00
|
|
|
const MeterClass RightCPUsMeter_class = {
|
2012-12-05 15:12:20 +00:00
|
|
|
.super = {
|
|
|
|
.extends = Class(Meter),
|
|
|
|
.delete = Meter_delete,
|
|
|
|
.display = CPUMeter_display
|
|
|
|
},
|
|
|
|
.defaultMode = CUSTOM_METERMODE,
|
2011-11-18 06:08:56 +00:00
|
|
|
.total = 100.0,
|
2019-10-31 16:39:12 +00:00
|
|
|
.attributes = CPUMeter_attributes,
|
2011-11-18 06:08:56 +00:00
|
|
|
.name = "RightCPUs",
|
|
|
|
.uiName = "CPUs (2/2)",
|
2015-02-03 21:31:44 +00:00
|
|
|
.description = "CPUs (2/2): second half of list",
|
2011-11-18 06:08:56 +00:00
|
|
|
.caption = "CPU",
|
|
|
|
.draw = SingleColCPUsMeter_draw,
|
2020-09-24 19:17:51 +00:00
|
|
|
.init = SingleColCPUsMeter_init,
|
|
|
|
.updateMode = SingleColCPUsMeter_updateMode,
|
2011-11-18 06:08:56 +00:00
|
|
|
.done = AllCPUsMeter_done
|
|
|
|
};
|
|
|
|
|
2020-10-05 11:19:50 +00:00
|
|
|
const MeterClass LeftCPUs2Meter_class = {
|
2012-12-05 15:12:20 +00:00
|
|
|
.super = {
|
|
|
|
.extends = Class(Meter),
|
|
|
|
.delete = Meter_delete,
|
|
|
|
.display = CPUMeter_display
|
|
|
|
},
|
|
|
|
.defaultMode = CUSTOM_METERMODE,
|
2011-11-18 06:08:56 +00:00
|
|
|
.total = 100.0,
|
2019-10-31 16:39:12 +00:00
|
|
|
.attributes = CPUMeter_attributes,
|
2011-11-18 06:08:56 +00:00
|
|
|
.name = "LeftCPUs2",
|
|
|
|
.uiName = "CPUs (1&2/4)",
|
2016-03-11 02:54:34 +00:00
|
|
|
.description = "CPUs (1&2/4): first half in 2 shorter columns",
|
2011-11-18 06:08:56 +00:00
|
|
|
.caption = "CPU",
|
|
|
|
.draw = DualColCPUsMeter_draw,
|
2020-09-24 19:17:51 +00:00
|
|
|
.init = DualColCPUsMeter_init,
|
|
|
|
.updateMode = DualColCPUsMeter_updateMode,
|
2011-11-18 06:08:56 +00:00
|
|
|
.done = AllCPUsMeter_done
|
|
|
|
};
|
|
|
|
|
2020-10-05 11:19:50 +00:00
|
|
|
const MeterClass RightCPUs2Meter_class = {
|
2012-12-05 15:12:20 +00:00
|
|
|
.super = {
|
|
|
|
.extends = Class(Meter),
|
|
|
|
.delete = Meter_delete,
|
|
|
|
.display = CPUMeter_display
|
|
|
|
},
|
|
|
|
.defaultMode = CUSTOM_METERMODE,
|
2011-11-18 06:08:56 +00:00
|
|
|
.total = 100.0,
|
2019-10-31 16:39:12 +00:00
|
|
|
.attributes = CPUMeter_attributes,
|
2011-11-18 06:08:56 +00:00
|
|
|
.name = "RightCPUs2",
|
|
|
|
.uiName = "CPUs (3&4/4)",
|
2015-02-03 21:31:44 +00:00
|
|
|
.description = "CPUs (3&4/4): second half in 2 shorter columns",
|
2011-11-18 06:08:56 +00:00
|
|
|
.caption = "CPU",
|
|
|
|
.draw = DualColCPUsMeter_draw,
|
2020-09-24 19:17:51 +00:00
|
|
|
.init = DualColCPUsMeter_init,
|
|
|
|
.updateMode = DualColCPUsMeter_updateMode,
|
2011-11-18 06:08:56 +00:00
|
|
|
.done = AllCPUsMeter_done
|
|
|
|
};
|
|
|
|
|
2020-10-05 11:19:50 +00:00
|
|
|
const MeterClass AllCPUs4Meter_class = {
|
2020-06-11 21:21:52 +00:00
|
|
|
.super = {
|
|
|
|
.extends = Class(Meter),
|
|
|
|
.delete = Meter_delete,
|
|
|
|
.display = CPUMeter_display
|
|
|
|
},
|
|
|
|
.defaultMode = CUSTOM_METERMODE,
|
|
|
|
.total = 100.0,
|
|
|
|
.attributes = CPUMeter_attributes,
|
|
|
|
.name = "AllCPUs4",
|
|
|
|
.uiName = "CPUs (1&2&3&4/4)",
|
|
|
|
.description = "CPUs (1&2&3&4/4): all CPUs in 4 shorter columns",
|
|
|
|
.caption = "CPU",
|
2020-09-24 19:17:51 +00:00
|
|
|
.draw = QuadColCPUsMeter_draw,
|
|
|
|
.init = QuadColCPUsMeter_init,
|
|
|
|
.updateMode = QuadColCPUsMeter_updateMode,
|
2020-06-11 21:21:52 +00:00
|
|
|
.done = AllCPUsMeter_done
|
|
|
|
};
|
|
|
|
|
2020-10-05 11:19:50 +00:00
|
|
|
const MeterClass LeftCPUs4Meter_class = {
|
2020-06-11 21:21:52 +00:00
|
|
|
.super = {
|
|
|
|
.extends = Class(Meter),
|
|
|
|
.delete = Meter_delete,
|
|
|
|
.display = CPUMeter_display
|
|
|
|
},
|
|
|
|
.defaultMode = CUSTOM_METERMODE,
|
|
|
|
.total = 100.0,
|
|
|
|
.attributes = CPUMeter_attributes,
|
|
|
|
.name = "LeftCPUs4",
|
|
|
|
.uiName = "CPUs (1-4/8)",
|
|
|
|
.description = "CPUs (1-4/8): first half in 4 shorter columns",
|
|
|
|
.caption = "CPU",
|
2020-09-24 19:17:51 +00:00
|
|
|
.draw = QuadColCPUsMeter_draw,
|
|
|
|
.init = QuadColCPUsMeter_init,
|
|
|
|
.updateMode = QuadColCPUsMeter_updateMode,
|
2020-06-11 21:21:52 +00:00
|
|
|
.done = AllCPUsMeter_done
|
|
|
|
};
|
|
|
|
|
2020-10-05 11:19:50 +00:00
|
|
|
const MeterClass RightCPUs4Meter_class = {
|
2020-06-11 21:21:52 +00:00
|
|
|
.super = {
|
|
|
|
.extends = Class(Meter),
|
|
|
|
.delete = Meter_delete,
|
|
|
|
.display = CPUMeter_display
|
|
|
|
},
|
|
|
|
.defaultMode = CUSTOM_METERMODE,
|
|
|
|
.total = 100.0,
|
|
|
|
.attributes = CPUMeter_attributes,
|
|
|
|
.name = "RightCPUs4",
|
|
|
|
.uiName = "CPUs (5-8/8)",
|
|
|
|
.description = "CPUs (5-8/8): second half in 4 shorter columns",
|
|
|
|
.caption = "CPU",
|
2020-09-24 19:17:51 +00:00
|
|
|
.draw = QuadColCPUsMeter_draw,
|
|
|
|
.init = QuadColCPUsMeter_init,
|
|
|
|
.updateMode = QuadColCPUsMeter_updateMode,
|
2020-06-11 21:21:52 +00:00
|
|
|
.done = AllCPUsMeter_done
|
|
|
|
};
|
2020-09-24 19:56:40 +00:00
|
|
|
|
2020-10-05 11:19:50 +00:00
|
|
|
const MeterClass AllCPUs8Meter_class = {
|
2020-09-24 19:56:40 +00:00
|
|
|
.super = {
|
|
|
|
.extends = Class(Meter),
|
|
|
|
.delete = Meter_delete,
|
|
|
|
.display = CPUMeter_display
|
|
|
|
},
|
|
|
|
.defaultMode = CUSTOM_METERMODE,
|
|
|
|
.total = 100.0,
|
|
|
|
.attributes = CPUMeter_attributes,
|
|
|
|
.name = "AllCPUs8",
|
|
|
|
.uiName = "CPUs (1-8/8)",
|
|
|
|
.description = "CPUs (1-8/8): all CPUs in 8 shorter columns",
|
|
|
|
.caption = "CPU",
|
|
|
|
.draw = OctoColCPUsMeter_draw,
|
|
|
|
.init = OctoColCPUsMeter_init,
|
|
|
|
.updateMode = OctoColCPUsMeter_updateMode,
|
|
|
|
.done = AllCPUsMeter_done
|
|
|
|
};
|
|
|
|
|
2020-10-05 11:19:50 +00:00
|
|
|
const MeterClass LeftCPUs8Meter_class = {
|
2020-09-24 19:56:40 +00:00
|
|
|
.super = {
|
|
|
|
.extends = Class(Meter),
|
|
|
|
.delete = Meter_delete,
|
|
|
|
.display = CPUMeter_display
|
|
|
|
},
|
|
|
|
.defaultMode = CUSTOM_METERMODE,
|
|
|
|
.total = 100.0,
|
|
|
|
.attributes = CPUMeter_attributes,
|
|
|
|
.name = "LeftCPUs8",
|
|
|
|
.uiName = "CPUs (1-8/16)",
|
|
|
|
.description = "CPUs (1-8/16): first half in 8 shorter columns",
|
|
|
|
.caption = "CPU",
|
|
|
|
.draw = OctoColCPUsMeter_draw,
|
|
|
|
.init = OctoColCPUsMeter_init,
|
|
|
|
.updateMode = OctoColCPUsMeter_updateMode,
|
|
|
|
.done = AllCPUsMeter_done
|
|
|
|
};
|
|
|
|
|
2020-10-05 11:19:50 +00:00
|
|
|
const MeterClass RightCPUs8Meter_class = {
|
2020-09-24 19:56:40 +00:00
|
|
|
.super = {
|
|
|
|
.extends = Class(Meter),
|
|
|
|
.delete = Meter_delete,
|
|
|
|
.display = CPUMeter_display
|
|
|
|
},
|
|
|
|
.defaultMode = CUSTOM_METERMODE,
|
|
|
|
.total = 100.0,
|
|
|
|
.attributes = CPUMeter_attributes,
|
|
|
|
.name = "RightCPUs8",
|
|
|
|
.uiName = "CPUs (9-16/16)",
|
|
|
|
.description = "CPUs (9-16/16): second half in 8 shorter columns",
|
|
|
|
.caption = "CPU",
|
|
|
|
.draw = OctoColCPUsMeter_draw,
|
|
|
|
.init = OctoColCPUsMeter_init,
|
|
|
|
.updateMode = OctoColCPUsMeter_updateMode,
|
|
|
|
.done = AllCPUsMeter_done
|
|
|
|
};
|