added viewelement <vdrstatistics> in main menu

This commit is contained in:
louis 2015-05-14 16:55:56 +02:00
parent af59c465aa
commit 5a0155d1e9
12 changed files with 140 additions and 18 deletions

View File

@ -329,5 +329,6 @@ Version 0.4.5
Version 0.4.6
- added token {startsin} in displaymenuschedules
- added viewelement <vdrstatistics> in main menu

View File

@ -175,6 +175,20 @@
condition CDATA #IMPLIED
>
<!ELEMENT vdrstatistics (area|areascroll)*>
<!ATTLIST vdrstatistics
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
shifttype CDATA #IMPLIED
shiftmode CDATA #IMPLIED
startx CDATA #IMPLIED
starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT currentschedule (area|areascroll)*>
<!ATTLIST currentschedule
detached CDATA #IMPLIED
@ -264,7 +278,7 @@
>
<!ELEMENT menumain (background | header | datetime | time | colorbuttons | scrollbar | sortmode | timers |
discusage | devices | systemload | systemmemory | temperatures | currentschedule |
discusage | devices | systemload | systemmemory | vdrstatistics | temperatures | currentschedule |
currentweather | lastrecordings | customtokens | menuitems)*>
<!ATTLIST menumain
x CDATA #REQUIRED

View File

@ -1293,6 +1293,7 @@ void cTemplateViewMenu::SetViewElements(void) {
viewElementsAllowed.insert("discusage");
viewElementsAllowed.insert("systemload");
viewElementsAllowed.insert("systemmemory");
viewElementsAllowed.insert("vdrstatistics");
viewElementsAllowed.insert("temperatures");
viewElementsAllowed.insert("timers");
viewElementsAllowed.insert("lastrecordings");
@ -1383,6 +1384,9 @@ string cTemplateViewMenu::GetViewElementName(eViewElement ve) {
case veSystemMemory:
name = "System Memory";
break;
case veVDRStats:
name = "VDR Statistics";
break;
case veTemperatures:
name = "Temperatures";
break;
@ -1511,6 +1515,8 @@ void cTemplateViewMenu::AddPixmap(string sViewElement, cTemplatePixmap *pix, vec
ve = veSystemLoad;
} else if (!sViewElement.compare("systemmemory")) {
ve = veSystemMemory;
} else if (!sViewElement.compare("vdrstatistics")) {
ve = veVDRStats;
} else if (!sViewElement.compare("temperatures")) {
ve = veTemperatures;
} else if (!sViewElement.compare("timers")) {

View File

@ -48,6 +48,7 @@ enum eViewElement {
veDiscUsage,
veSystemLoad,
veSystemMemory,
veVDRStats,
veTemperatures,
veTimers,
veLastRecordings,

View File

@ -1,10 +1,11 @@
This Widget provide information about the system temperatures.
Scripts for:
- system temperatures - "temperatures" is called
- vdr statistics (vdr cpu load and memory usage) "vdrstats" is called
You must manually create a link to the corresponding script, for example:
You must manually create a link for each script to the script you want to use, for example:
ln -s temperatures.default temperatures
ln -s vdrstats.default vdrstats
The command "temperatures" will be executed every time the widget is drawn, so please keep it short and fast.
The command can provide three temperatures: cpu, pc case and gpu temperature
The command can also be called from system information widget. So the output files must also begin with 01_ - 99_ for sort/position.
The scripts will be executed every time the according viewelement is displayed, so please keep it short and fast.
Please install lm-sensors and configure it for your system. See the default script for an example.
Please install lm-sensors and configure it for your system.

0
scripts/temperatures.g2v Normal file → Executable file
View File

17
scripts/vdrstats.default Normal file
View File

@ -0,0 +1,17 @@
#!/bin/bash
# please update this script to fit your needs
# this script is call every time the according viewelement will be drawn, so keep it short and fast ;)
OUTPUTFLDR="/tmp/skindesigner/"
mkdir -p ${OUTPUTFLDR}
# there can be 2 files, vdrcpu and vdrmem
rm -f ${OUTPUTFLDR}/vdrcpu ${OUTPUTFLDR}/vdrmem
# vdr cpu usage, is 10th element in "top" list
top -n 1 | grep " vdr " | awk -F " " '{ print $10;}' > ${OUTPUTFLDR}/vdrcpu
# vdr memory usage, is 11th element in "top" list
top -n 1 | grep " vdr " | awk -F " " '{ print $11;}' > ${OUTPUTFLDR}/vdrmem

View File

@ -17,7 +17,7 @@
{timers[channellogoexists]} true if channel logo exists
{timers[isremotetimer]} true if timer is a remote timer from remotetimers plugin
-->
<timers>
<timers detached="false">
</timers>
<!-- Available Variables lastrecordings: 5 newest recordings
@ -33,7 +33,7 @@
{recordings[posterwidth]} width of poster
{recordings[posterheight]} height of poster
-->
<lastrecordings>
<lastrecordings detached="false">
</lastrecordings>
<!-- Available Variables discusage:
@ -44,11 +44,12 @@
{discalert} true if disc usage is > 95%
{vdrusagestring} localized VDR internal usage string
-->
<discusage>
<discusage detached="false">
</discusage>
<!-- Available Variables devices:
signalstrength and -quality are only set if not mode="light" is used in <devices>
execution slow, should be detached
{numdevices} number of available devices
{devices[]} array with available devices
{devices[num]} number of current device
@ -66,13 +67,13 @@
{devices[channelid]} ID of the currently tuned channel
{devices[source]} source of the currently tuned channel
-->
<devices mode="full|light">
<devices mode="full|light" detached="false">
</devices>
<!-- Available Variables systemload:
{load} current system load
-->
<systemload>
<systemload detached="false">
</systemload>
<!-- Available Variables systemmemory:
@ -80,14 +81,23 @@
{usedmem} currently used system memory in MB
{usedmempercent} currently used system memory in Percent
-->
<systemmemory>
<systemmemory detached="false">
</systemmemory>
<!-- Available Variables vdrstatistics:
execution slow, should be detached
{vdrcpu} current cpu usage of vdr process in percent
{vdrmem} current mem usage of vdr process in percent
-->
<vdrstatistics detached="false">
</vdrstatistics>
<!-- Available Variables tempreatures:
execution slow, should be detached
{cputemp} current cpu temperature in °C
{gputemp} current gpu temperature in °C
-->
<temperatures>
<temperatures detached="false">
</temperatures>
<!-- Available Variables currentschedule:
@ -111,7 +121,7 @@
{bannerwidth} width of banner in pixel
{bannerheight} height of banner in pixel
-->
<currentschedule>
<currentschedule detached="false">
</currentschedule>
<!-- Available Variables currentweather:
@ -134,7 +144,7 @@
{pressure} pressure in HPo
{ozone} ozone value in DU
-->
<currentweather>
<currentweather detached="false">
</currentweather>
<!-- Available Variables customtokens:
@ -142,7 +152,7 @@
For instance, use an appropriate script which runs periodically as cronjob and
sets these custom tokens with svdrpsend or dbus2vdr
-->
<customtokens>
<customtokens detached="false">
</customtokens>
<menuitems x="0" y="0" orientation="vertical" width="100%" height="100%" align="center" numlistelements="8">

View File

@ -299,9 +299,10 @@ void cDisplayMenuMainView::DrawStaticViewElements(void) {
bool cDisplayMenuMainView::DrawDynamicViewElements(void) {
bool loadChanged = DrawLoad();
bool memChanged = DrawMemory();
bool vdrChanged = DrawVdrStats();
bool devicesChanged = DrawDevices();
initial = false;
return loadChanged || memChanged || devicesChanged;
return loadChanged || memChanged || vdrChanged || devicesChanged;
}
@ -445,6 +446,35 @@ bool cDisplayMenuMainView::DrawMemory(void) {
return changed;
}
bool cDisplayMenuMainView::DrawVdrStats(void) {
if (!ExecuteViewElement(veVDRStats)) {
return false;
}
bool changed = false;
if (DetachViewElement(veVDRStats)) {
cViewElement *viewElement = GetViewElement(veVDRStats);
if (!viewElement) {
viewElement = new cViewElement(tmplView->GetViewElement(veVDRStats), this);
viewElement->SetCallback(veVDRStats, &cDisplayMenuMainView::SetVDRStats);
AddViewElement(veVDRStats, viewElement);
viewElement->Start();
changed = true;
} else {
if (!viewElement->Starting())
changed = viewElement->Render();
}
} else {
map < string, string > stringTokens;
map < string, int > intTokens;
changed = SetVDRStats(false, stringTokens, intTokens);
if (changed) {
ClearViewElement(veVDRStats);
DrawViewElement(veVDRStats, &stringTokens, &intTokens);
}
}
return changed;
}
void cDisplayMenuMainView::DrawTemperatures(void) {
if (!ExecuteViewElement(veTemperatures)) {
return;

View File

@ -57,6 +57,7 @@ private:
void DrawDiscUsage(void);
bool DrawLoad(void);
bool DrawMemory(void);
bool DrawVdrStats(void);
void DrawTemperatures(void);
bool DrawDevices(void);
void DrawCurrentSchedule(void);

View File

@ -26,6 +26,8 @@ cViewHelpers::cViewHelpers(void) {
lastEcmInfo.caid = -1;
lastEcmInfo.pid = -1;
lastEcmInfo.prid = -1;
lastVdrCPU = "undefined";
lastVdrMEM = "undefined";
}
cViewHelpers::~cViewHelpers() {
@ -257,6 +259,42 @@ bool cViewHelpers::SetSystemTemperatures(bool forced, stringmap &stringTokens, i
return true;
}
bool cViewHelpers::SetVDRStats(bool forced, stringmap &stringTokens, intmap &intTokens) {
cString execCommand = cString::sprintf("cd \"%s/\"; \"%s/vdrstats\"", SCRIPTFOLDER, SCRIPTFOLDER);
system(*execCommand);
string vdrCPU = "";
string vdrMEM = "";
cString itemFilename = cString::sprintf("%s/vdrcpu", SCRIPTOUTPUTPATH );
ifstream file(*itemFilename, ifstream::in);
if( file.is_open() ) {
std::getline(file, vdrCPU);
file.close();
}
itemFilename = cString::sprintf("%s/vdrmem", SCRIPTOUTPUTPATH );
ifstream file2(*itemFilename, ifstream::in);
if( file2.is_open() ) {
std::getline(file2, vdrMEM);
file2.close();
}
if (vdrCPU.size() == 0 || vdrMEM.size() == 0)
return false;
if (!lastVdrCPU.compare(vdrCPU) && !lastVdrMEM.compare(vdrMEM)) {
return false;
}
lastVdrCPU = vdrCPU;
lastVdrMEM = vdrMEM;
stringTokens.insert(pair<string,string>("vdrcpu", vdrCPU));
stringTokens.insert(pair<string,string>("vdrmem", vdrMEM));
return true;
}
bool cViewHelpers::SetDummy(bool forced, stringmap &stringTokens, intmap &intTokens) {
return true;
}

View File

@ -20,6 +20,8 @@ private:
int lastMinute;
double lastSystemLoad;
int lastMemUsage;
string lastVdrCPU;
string lastVdrMEM;
sDVBAPIEcmInfo lastEcmInfo;
void RecName(string &path, string &name, string &folder);
void RecPoster(const cRecording *rec, int &posterWidth, int &posterHeight, string &path, bool &hasPoster);
@ -49,6 +51,7 @@ public:
bool SetSystemLoad (bool forced, stringmap &stringTokens, intmap &intTokens);
bool SetSystemMemory (bool forced, stringmap &stringTokens, intmap &intTokens);
bool SetSystemTemperatures (bool forced, stringmap &stringTokens, intmap &intTokens);
bool SetVDRStats (bool forced, stringmap &stringTokens, intmap &intTokens);
bool SetDummy (bool forced, stringmap &stringTokens, intmap &intTokens);
};