mirror of
https://projects.vdr-developer.org/git/vdr-plugin-skindesigner.git
synced 2023-10-19 17:58:31 +02:00
added <systemmemory> viewelement in main menu
This commit is contained in:
parent
a7d01384fc
commit
b6e6065b0f
1
HISTORY
1
HISTORY
@ -213,4 +213,5 @@ Version 0.3.0
|
||||
- fixed crash when opening and closing main menu consecutively
|
||||
- fixed bug detecting menu item numbers in main menu
|
||||
- fixed recording progress bar in nopacity
|
||||
- added <systemmemory> viewelement in main menu
|
||||
|
||||
|
@ -75,6 +75,12 @@
|
||||
condition CDATA #IMPLIED
|
||||
>
|
||||
|
||||
<!ELEMENT systemmemory (area|areascroll)*>
|
||||
<!ATTLIST systemmemory
|
||||
debug CDATA #IMPLIED
|
||||
condition CDATA #IMPLIED
|
||||
>
|
||||
|
||||
<!ELEMENT temperatures (area|areascroll)*>
|
||||
<!ATTLIST temperatures
|
||||
debug CDATA #IMPLIED
|
||||
@ -131,7 +137,8 @@
|
||||
>
|
||||
|
||||
<!ELEMENT menumain (background | header | datetime | time | colorbuttons | scrollbar | timers |
|
||||
discusage | devices | systemload | temperatures | currentschedule | currentweather | customtokens | menuitems)*>
|
||||
discusage | devices | systemload | systemmemory | temperatures | currentschedule |
|
||||
currentweather | customtokens | menuitems)*>
|
||||
<!ATTLIST menumain
|
||||
x CDATA #REQUIRED
|
||||
y CDATA #REQUIRED
|
||||
|
@ -1144,6 +1144,7 @@ void cTemplateViewMenu::SetViewElements(void) {
|
||||
viewElementsAllowed.insert("message");
|
||||
viewElementsAllowed.insert("discusage");
|
||||
viewElementsAllowed.insert("systemload");
|
||||
viewElementsAllowed.insert("systemmemory");
|
||||
viewElementsAllowed.insert("temperatures");
|
||||
viewElementsAllowed.insert("timers");
|
||||
viewElementsAllowed.insert("devices");
|
||||
@ -1227,6 +1228,9 @@ string cTemplateViewMenu::GetViewElementName(eViewElement ve) {
|
||||
case veSystemLoad:
|
||||
name = "System Load";
|
||||
break;
|
||||
case veSystemMemory:
|
||||
name = "System Memory";
|
||||
break;
|
||||
case veTemperatures:
|
||||
name = "Temperatures";
|
||||
break;
|
||||
@ -1348,6 +1352,8 @@ void cTemplateViewMenu::AddPixmap(string sViewElement, cTemplatePixmap *pix, vec
|
||||
ve = veDiscUsage;
|
||||
} else if (!sViewElement.compare("systemload")) {
|
||||
ve = veSystemLoad;
|
||||
} else if (!sViewElement.compare("systemmemory")) {
|
||||
ve = veSystemMemory;
|
||||
} else if (!sViewElement.compare("temperatures")) {
|
||||
ve = veTemperatures;
|
||||
} else if (!sViewElement.compare("timers")) {
|
||||
|
@ -45,6 +45,7 @@ enum eViewElement {
|
||||
veButtons,
|
||||
veDiscUsage,
|
||||
veSystemLoad,
|
||||
veSystemMemory,
|
||||
veTemperatures,
|
||||
veTimers,
|
||||
veCurrentSchedule,
|
||||
|
@ -57,6 +57,14 @@
|
||||
<systemload>
|
||||
</systemload>
|
||||
|
||||
<!-- Available Variables systemmemory:
|
||||
{totalmem} total system memory in MB
|
||||
{usedmem} currently used system memory in MB
|
||||
{usedmempercent} currently used system memory in Percent
|
||||
-->
|
||||
<systemmemory>
|
||||
</systemmemory>
|
||||
|
||||
<!-- Available Variables tempreatures:
|
||||
{cputemp} current cpu temperature in °C
|
||||
{gputemp} current gpu temperature in °C
|
||||
|
@ -1,6 +1,7 @@
|
||||
#define __STL_CONFIG_H
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sys/sysinfo.h>
|
||||
#include <vdr/menu.h>
|
||||
#include <vdr/videodir.h>
|
||||
#include "displaymenuview.h"
|
||||
@ -224,6 +225,7 @@ void cDisplayMenuView::Action(void) {
|
||||
cDisplayMenuMainView::cDisplayMenuMainView(cTemplateView *tmplView, bool menuInit) : cDisplayMenuView(tmplView, menuInit) {
|
||||
initial = true;
|
||||
lastSystemLoad = 0.0;
|
||||
lastMemUsage = -1;
|
||||
InitDevices();
|
||||
}
|
||||
|
||||
@ -243,9 +245,10 @@ void cDisplayMenuMainView::DrawStaticViewElements(void) {
|
||||
|
||||
bool cDisplayMenuMainView::DrawDynamicViewElements(void) {
|
||||
bool loadChanged = DrawLoad();
|
||||
bool memChanged = DrawMemory();
|
||||
bool devicesChanged = DrawDevices();
|
||||
initial = false;
|
||||
return loadChanged || devicesChanged;
|
||||
return loadChanged || memChanged || devicesChanged;
|
||||
|
||||
}
|
||||
|
||||
@ -415,6 +418,41 @@ bool cDisplayMenuMainView::DrawLoad(void) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cDisplayMenuMainView::DrawMemory(void) {
|
||||
if (!ExecuteViewElement(veSystemMemory)) {
|
||||
return false;
|
||||
}
|
||||
struct sysinfo memInfo;
|
||||
sysinfo (&memInfo);
|
||||
|
||||
long long totalMem = memInfo.totalram;
|
||||
totalMem += memInfo.totalswap;
|
||||
totalMem *= memInfo.mem_unit;
|
||||
int totalMemMB = totalMem / 1024 / 1024;
|
||||
|
||||
long long usedMem = memInfo.totalram - memInfo.freeram;
|
||||
usedMem += memInfo.totalswap - memInfo.freeswap;
|
||||
usedMem *= memInfo.mem_unit;
|
||||
int usedMemMB = usedMem / 1024 / 1024;
|
||||
|
||||
if (lastMemUsage == usedMemMB) {
|
||||
return false;
|
||||
}
|
||||
lastMemUsage = usedMemMB;
|
||||
|
||||
map < string, string > stringTokens;
|
||||
map < string, int > intTokens;
|
||||
intTokens.insert(pair<string,int>("totalmem", totalMemMB));
|
||||
intTokens.insert(pair<string,int>("usedmem", usedMemMB));
|
||||
if (totalMemMB > 0)
|
||||
intTokens.insert(pair<string,int>("usedmempercent", usedMemMB * 100 / totalMemMB));
|
||||
|
||||
ClearViewElement(veSystemMemory);
|
||||
DrawViewElement(veSystemMemory, &stringTokens, &intTokens);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void cDisplayMenuMainView::DrawTemperatures(void) {
|
||||
if (!ExecuteViewElement(veTemperatures)) {
|
||||
return;
|
||||
|
@ -38,9 +38,11 @@ class cDisplayMenuMainView : public cDisplayMenuView {
|
||||
private:
|
||||
bool initial;
|
||||
double lastSystemLoad;
|
||||
int lastMemUsage;
|
||||
void DrawTimers(void);
|
||||
void DrawDiscUsage(void);
|
||||
bool DrawLoad(void);
|
||||
bool DrawMemory(void);
|
||||
void DrawTemperatures(void);
|
||||
bool DrawDevices(void);
|
||||
void DrawCurrentSchedule(void);
|
||||
|
Loading…
Reference in New Issue
Block a user