File: cpuload.h

package info (click to toggle)
libqwt 4.2.0-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 9,856 kB
  • ctags: 5,512
  • sloc: cpp: 22,973; ansic: 244; makefile: 59
file content (111 lines) | stat: -rw-r--r-- 2,087 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include <qdialog.h>
#include <qwt_counter.h>

class QLabel;
class QPushButton;
class QMenuBar;
class QPopupMenu;
class QwtCounter;
class QwtThermo;

//
// A simple first-order lowpass used for averaging
//
class Lowpass
{
public:
    Lowpass();
    
    void setTConst(double t){tconst = t; recalc();}
    void setTSampl(double t){tsampl = t; recalc();}
    void reset(double v) { val = v; }
    double input(double v); 
    double value() {return val;}
    
private:
    void recalc();
    double val;
    double tsampl;
    double tconst;
    double c1;
    double c2;
};

//
//  A dialog for configuring the sampling rate and the lowpass constant
//
class ConfigDiag : public QDialog
{
    Q_OBJECT
public:
    ConfigDiag(QWidget *p = 0, const char *name = 0);
    ~ConfigDiag();

    double tSampl() {return ctSampl->value();}
    double tConst() {return ctConst->value();}

signals:
    void tSamplChg(double);
    void tConstChg(double);

public slots:
    void setTSampl(double);
    void setTConst(double);

protected slots:
    void chgTSampl(double t) { emit tSamplChg(t); }
    void chgTConst(double t) { emit tConstChg(t); }

private:
    QwtCounter *ctSampl;
    QwtCounter *ctConst;
    QLabel *lbSampl;
    QLabel *lbConst;
    QPushButton *btDismiss;
};

//
//  The main window
//
class MainWin : public QWidget 
{
    Q_OBJECT
   
public:
    MainWin(QApplication &a);
    ~MainWin();

    void start();
    void update();
    void read();
    void setTimer(int ms);

public slots:
    void setTSampl(double sec);
    void setTConst(double sec);
    void setFixedScale();
    void setDynScale() { dynscale = 1; }
    void showDialog();

protected:
    void timerEvent(QTimerEvent *e);

private:
    enum { CpuUser, CpuNice, CpuSystem, CpuIdle, ThermoCnt };
    QwtThermo *th[ThermoCnt];
    QLabel  *lb[ThermoCnt];
    ConfigDiag *cfg;
    QMenuBar *menu;
    QPopupMenu *puProg;
    QPopupMenu *puConf;
    QPopupMenu *puScale;

    Lowpass lp[ThermoCnt];

    unsigned long val[ThermoCnt];
    unsigned long old[ThermoCnt];
    
    int dynscale;
    int tmrID;
 };