Dear root-community,
I am trying to program a little status frame within the user can see the cpu load, used ram etc.
Getting the values and also the SetPosition and ShowPosition Members are running in an own thread.
The Frame does most of the time as it should.
But sometimes there seems to be an graphical error and also I have seen several times that the “Usr-Load” text appears in the status bar of the “CPU-Load”. When I want to show also the percentage within the status bar then I get strange hieroglyphs when the error occurs.
This is the actual code of the class method which runs in its own thread:
void *StatusDisplay :: Refresh(void *Ptr)
{
StatusDisplay *p = (StatusDisplay *)Ptr;
MemInfo_t memInfo;
CpuInfo_t cpuInfo;
while(p -> fOpen)
{
//std :: cout << Hist -> GetEntries() - nEntries << std :: endl;
Double_t CountRate = (p -> Hist -> GetEntries() - p -> nEntries) * 2;
p -> tCountRate -> Form("%.0lf 1/s", CountRate);
p -> lCountRate -> SetText(p -> tCountRate -> Data());
p -> nEntries = p -> Hist -> GetEntries();
gSystem -> GetCpuInfo(&cpuInfo, 400);
gSystem -> GetMemInfo(&memInfo);
if(cpuInfo.fTotal >= 0 && cpuInfo.fTotal <= 100)
{
p -> pbCPU -> SetPosition(cpuInfo.fTotal);
p -> pbCPU -> ShowPosition(kTRUE, kFALSE, "CPU-Load");
}
if(cpuInfo.fSys >= 0 && cpuInfo.fSys <= 100)
{
p -> pbCPUSys -> SetPosition(cpuInfo.fSys);
p -> pbCPUSys -> ShowPosition(kTRUE, kFALSE, "Sys-Load");
}
if(cpuInfo.fUser >= 0 && cpuInfo.fUser <= 100)
{
p -> pbCPUUser -> SetPosition(cpuInfo.fUser);
p -> pbCPUUser -> ShowPosition(kTRUE, kFALSE, "Usr-Load");
}
p -> pbRAM -> SetPosition((Float_t)memInfo.fMemUsed);
p -> pbRAM -> ShowPosition(kTRUE, kFALSE, "Used RAM: %.0f MB");
gSystem -> Sleep(500);
}
return 0;
}
Could it be that I have done something messy within my thread?
Is there maybe a better way to get such an status frame?
Thanks in advance
Cheers
Johannes