23 TGShapedMain(
const TGWindow *p,
int w,
int h);
24 virtual ~TGShapedMain();
27 TGSpeedo *GetSpeedo()
const {
return fSpeedo; }
28 Int_t GetActInfo()
const {
return fActInfo; }
36 TGShapedMain *gMainWindow;
42 TGShapedMain::TGShapedMain(
const TGWindow *p,
int w,
int h) :
49 fSpeedo =
new TGSpeedo(
this, 0.0, 100.0,
"CPU",
"[%]");
50 fSpeedo->Connect(
"OdoClicked()",
"TGShapedMain",
this,
"ToggleInfos()");
51 fSpeedo->Connect(
"LedClicked()",
"TGShapedMain",
this,
"CloseWindow()");
52 Connect(
"CloseWindow()",
"TGShapedMain",
this,
"CloseWindow()");
54 fSpeedo->SetDisplayText(
"Used RAM",
"[MB]");
56 fTimer->SetCommand(
"Update()");
58 fBgnd = fSpeedo->GetPicture();
59 gVirtualX->ShapeCombineMask(GetId(), 0, 0, fBgnd->GetMask());
60 SetBackgroundPixmap(fBgnd->GetPicture());
61 SetWMSizeHints(fBgnd->GetWidth(), fBgnd->GetHeight(), fBgnd->GetWidth(),
62 fBgnd->GetHeight(), 1, 1);
69 Resize(GetDefaultSize());
71 SetWMSizeHints(GetDefaultWidth(), GetDefaultHeight(), GetDefaultWidth(),
72 GetDefaultHeight(), 1, 1);
73 SetWindowName(
"ROOT CPU Load Meter");
78 void TGShapedMain::ToggleInfos()
87 fSpeedo->SetDisplayText(
"Total RAM",
"[MB]");
88 else if (fActInfo == 1)
89 fSpeedo->SetDisplayText(
"Used RAM",
"[MB]");
90 else if (fActInfo == 2)
91 fSpeedo->SetDisplayText(
"Free RAM",
"[MB]");
95 TGShapedMain::~TGShapedMain()
104 void TGShapedMain::CloseWindow()
119 prev_load = act_load;
120 old_memUsage = memUsage;
125 act_load = cpuInfo.
fTotal;
129 if (gMainWindow->GetActInfo() == 0)
131 else if (gMainWindow->GetActInfo() == 1)
133 else if (gMainWindow->GetActInfo() == 2)
136 if (
fabs(act_load-prev_load) > 0.9) {
138 prev_load = act_load;
141 if (memUsage != old_memUsage) {
143 old_memUsage = memUsage;
152 gMainWindow =
new TGShapedMain(
gClient->GetRoot(), 500, 200);
153 gSpeedo = gMainWindow->GetSpeedo();
156 gSpeedo->SetThresholds(12.5, 50.0, 87.5);
161 gSpeedo->EnableThreshold();
162 gSpeedo->SetScaleValue(0.0, 5);
164 gSpeedo->EnablePeakMark();
virtual int GetCpuInfo(CpuInfo_t *info, Int_t sampleTime=1000) const
Returns cpu load average and load info into the CpuInfo_t structure.
virtual int GetMemInfo(MemInfo_t *info) const
Returns ram and swap memory usage info into the MemInfo_t structure.
#define ClassDef(name, id)
void SetOdoValue(Int_t val)
Set actual value of odo meter.
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
void SetScaleValue(Float_t val)
Set actual scale (needle position) value.
R__EXTERN TSystem * gSystem
virtual void CloseWindow()
Close and delete main frame.
Handles synchronous and a-synchronous timer events.