2016-05-30 23:58:58 -04:00
|
|
|
#pragma once
|
2016-05-19 10:41:06 -04:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "modules/base.hpp"
|
|
|
|
#include "drawtypes/icon.hpp"
|
|
|
|
#include "drawtypes/label.hpp"
|
|
|
|
#include "drawtypes/ramp.hpp"
|
|
|
|
|
|
|
|
namespace modules
|
|
|
|
{
|
|
|
|
struct CpuTime
|
|
|
|
{
|
|
|
|
unsigned long long user;
|
|
|
|
unsigned long long nice;
|
|
|
|
unsigned long long system;
|
|
|
|
unsigned long long idle;
|
|
|
|
unsigned long long total;
|
|
|
|
};
|
|
|
|
|
|
|
|
DefineModule(CpuModule, TimerModule)
|
|
|
|
{
|
2016-05-30 23:58:58 -04:00
|
|
|
static constexpr auto TAG_LABEL = "<label>";
|
2016-05-25 20:14:56 -04:00
|
|
|
static constexpr auto TAG_BAR_LOAD = "<bar-load>";
|
|
|
|
static constexpr auto TAG_RAMP_LOAD = "<ramp-load>";
|
|
|
|
static constexpr auto TAG_RAMP_LOAD_PER_CORE = "<ramp-load_per_core>";
|
2016-05-19 10:41:06 -04:00
|
|
|
|
|
|
|
std::vector<std::unique_ptr<CpuTime>> cpu_times;
|
|
|
|
std::vector<std::unique_ptr<CpuTime>> prev_cpu_times;
|
|
|
|
|
|
|
|
std::unique_ptr<drawtypes::Bar> bar_load;
|
|
|
|
std::unique_ptr<drawtypes::Ramp> ramp_load;
|
|
|
|
std::unique_ptr<drawtypes::Ramp> ramp_load_per_core;
|
|
|
|
std::unique_ptr<drawtypes::Label> label;
|
|
|
|
std::unique_ptr<drawtypes::Label> label_tokenized;
|
|
|
|
|
2016-05-30 23:58:58 -04:00
|
|
|
float current_total_load = 0;
|
2016-05-19 10:41:06 -04:00
|
|
|
std::vector<float> current_load;
|
|
|
|
|
|
|
|
bool read_values();
|
|
|
|
float get_load(int core);
|
|
|
|
|
|
|
|
public:
|
2016-06-20 21:59:43 -04:00
|
|
|
explicit CpuModule(std::string name);
|
2016-05-19 10:41:06 -04:00
|
|
|
|
|
|
|
bool update();
|
2016-06-20 21:59:43 -04:00
|
|
|
bool build(Builder *builder, std::string tag);
|
2016-05-19 10:41:06 -04:00
|
|
|
};
|
|
|
|
}
|