added weather viewelement to metrix main menu

This commit is contained in:
louis 2015-01-14 14:20:22 +01:00
parent 645f625d79
commit 3de7f8f13d
14 changed files with 138 additions and 40 deletions

View File

@ -75,6 +75,11 @@
debug CDATA #IMPLIED
>
<!ELEMENT currentweather (area|areascroll)*>
<!ATTLIST currentweather
debug CDATA #IMPLIED
>
<!ELEMENT customtokens (area|areascroll)*>
<!ATTLIST customtokens
debug CDATA #IMPLIED
@ -109,7 +114,7 @@
>
<!ELEMENT menumain (background | header | datetime | time | colorbuttons | scrollbar | timers |
discusage | devices | systemload | temperatures | currentschedule | customtokens | menuitems)*>
discusage | devices | systemload | temperatures | currentschedule | currentweather | customtokens | menuitems)*>
<!ATTLIST menumain
x CDATA #REQUIRED
y CDATA #REQUIRED

View File

@ -381,10 +381,8 @@ void cTemplateView::Translate(void) {
//Translate Plugin Views
for (map < string, map< int, cTemplateView*> >::iterator it = pluginViews.begin(); it != pluginViews.end(); it++) {
esyslog("skindesigner: translating plugin %s", (it->first).c_str());
map< int, cTemplateView*> plugViews = it->second;
for (map< int, cTemplateView*>::iterator it2 = plugViews.begin(); it2 != plugViews.end(); it2++) {
esyslog("skindesigner: translating view %d", (int)it2->first);
cTemplateView *pluginView = it2->second;
pluginView->Translate();
}
@ -1178,6 +1176,9 @@ string cTemplateViewMenu::GetViewElementName(eViewElement ve) {
case veCurrentSchedule:
name = "Current Schedule";
break;
case veCurrentWeather:
name = "Current Weather";
break;
case veCustomTokens:
name = "Custom Tokens";
break;

View File

@ -270,6 +270,10 @@
<trans lang="en_EN">max</trans>
<trans lang="de_DE">max</trans>
</token>
<token name="tr(for)">
<trans lang="en_EN">for</trans>
<trans lang="de_DE">für</trans>
</token>
</translations>
<!--
The three Fonts FontOSD, FontFix and FontSml configured in VDR

View File

@ -175,17 +175,52 @@
{vdrusagestring} localized VDR internal usage string
-->
<discusage>
<area x="75%" y="15%" width="25%" height="10%" layer="1">
<area x="75%" y="26%" width="25%" height="10%" layer="1">
<fill condition="not{discalert}" color="{clrTransBlack}"/>
<fill condition="{discalert}" color="{clrRed}"/>
</area>
<area x="75%" y="15%" width="25%" height="10%" layer="2">
<area x="75%" y="26%" width="25%" height="10%" layer="2">
<drawimage imagetype="icon" path="ico_discusage" x="1%" valign="center" width="{areaheight}*0.9" height="{areaheight}*0.9"/>
<drawtext x="{areaheight}+10" y="0" font="{light}" fontsize="55%" color="{clrWhite}" text="{tr(disc)}: {freepercent}% {tr(free)}" />
<drawtext x="{areaheight}+10" y="45%" font="{light}" fontsize="55%" color="{clrWhite}" text="{freetime} {tr(hours)}" />
</area>
</discusage>
<!-- Available Variables currentweather:
{timestamp} timestamp of forecast in dd.mm hh:mm
{temperature} current temperature in °C
{apparenttemperature} apparent (feeled) temperature
{summary} short weather summary
{icon} weather icon
{precipitationintensity} precipitation intensity in l/m2
{precipitationprobability} precipitation probability in %
{precipitationtype} precipitation type
{humidity} humidity in %
{windspeed} windspeed in km/h
{windbearing} wind bearing in °
{windbearingstring} wind bearing (N, NE, ...)
{visibility} visibility in km
{cloudcover} cloud cover in %
{pressure} pressure in HPo
{ozone} ozone value in DU
-->
<currentweather>
<area x="75%" y="13%" width="25%" height="10%" layer="2">
<drawrectangle x="0" y="0" width="53%" height="100%" color="{clrTransBlueLight}" />
<drawrectangle x="53%" y="0" width="47%" height="100%" color="{clrTransBlack}" />
</area>
<area x="75%" y="13%" width="12%" height="10%" layer="2">
<drawimage imagetype="icon" path="{icon}" align="center" valign="center" width="{areaheight}*0.9" height="{areaheight}*0.9"/>
</area>
<area x="89%" y="13%" width="10%" height="10%" layer="2">
<drawtext x="0" y="0" font="{light}" fontsize="25%" color="{clrWhite}" text="{mintemperature}°C" />
<drawtext x="0" y="75%" font="{light}" fontsize="25%" color="{clrWhite}" text="{maxtemperature}°C" />
</area>
<area x="89%" y="13%" width="10%" height="10%" layer="3">
<drawtext align="right" valign="center" font="{light}" fontsize="60%" color="{clrWhite}" text="{temperature}°C" />
</area>
</currentweather>
<!-- Available Variables devices:
{numdevices} number of available devices
{devices[]} array with available devices
@ -204,10 +239,10 @@
{devices[source]} source of the currently tuned channel
-->
<devices>
<area x="75%" y="40%" width="25%" height="{areaheight}/12 * {numdevices}" layer="1">
<area x="75%" y="48%" width="25%" height="{areaheight}/12 * {numdevices}" layer="1">
<fill color="{clrTransBlack}"/>
</area>
<area x="75%" y="40%" width="25%" height="{areaheight}/12 * {numdevices}" layer="2">
<area x="75%" y="48%" width="25%" height="{areaheight}/12 * {numdevices}" layer="2">
<loop name="devices" x="0" y="0" orientation="vertical" columnwidth="{areawidth}" rowheight="{areaheight} / {numdevices}" overflow="cut">
<drawtext name="label" x="5" y="0" font="{light}" fontsize="{rowheight}*0.4" color="{clrWhite}" text="{devices[num]}: {devices[type]}" />
<drawtext condition="{devices[hascam]}" x="{width(label)} + 15" y="0" font="{light}" fontsize="{rowheight}*0.40" color="{clrWhite}" text="(CAM {devices[cam]})" />
@ -225,10 +260,10 @@
{load} current system load
-->
<systemload>
<area x="75%" y="30%" width="25%" height="5%" layer="1">
<area x="75%" y="40%" width="25%" height="5%" layer="1">
<fill color="{clrTransBlack}"/>
</area>
<area x="75%" y="30%" width="25%" height="5%" layer="2">
<area x="75%" y="40%" width="25%" height="5%" layer="2">
<drawtext x="5" valign="center" font="{light}" fontsize="100%" color="{clrWhite}" text="System Load: {load}" />
</area>
</systemload>

View File

@ -45,6 +45,9 @@
{iscurrent} true if item is "Current Weather"
{ishourly} true if item is "Next 48 hours"
{isdaily} true if item is "Next 7 days"
{city} configured city to display weather for
{latitude} latitude
{longitude} longitude
If {iscurrent} is true, the following tokens are set:
{timestamp} timestamp in hh:mm dd.mm of current forecast
@ -125,20 +128,18 @@
<!-- All Tokens from listelement are available -->
<currentelement delay="100" fadetime="0">
<area condition="{iscurrent}" x="51%" y="0" width="48%" height="100%" layer="3">
<drawimage name="weathericon" imagetype="icon" path="{icon}" x="2%" y="0" width="{areawidth}*0.3" height="{areawidth}*0.3"/>
<drawtext align="right" y="0" font="{light}" fontsize="8%" color="{clrWhite}" text="{timestamp}" />
<drawtext align="right" y="6%" font="{light}" fontsize="16%" color="{clrWhite}" text="{temperature}°C" />
<drawtext align="right" y="20%" font="{light}" fontsize="8%" color="{clrWhite}" text="{summary}" />
<drawtext x="0" y="34%" font="{light}" fontsize="6%" color="{clrWhite}" text="{tr(apparenttemp)}: {apparenttemperature} °C" />
<drawtext x="0" y="40%" font="{light}" fontsize="6%" color="{clrWhite}" text="{tr(precipitationprobability)}: {precipitationprobability} %" />
<drawtext x="0" y="46%" font="{light}" fontsize="6%" color="{clrWhite}" text="{tr(precipitationintensity)}: {precipitationintensity} l/qm" />
<drawtext x="0" y="52%" font="{light}" fontsize="6%" color="{clrWhite}" text="{tr(humidity)}: {humidity} %" />
<drawtext x="0" y="58%" font="{light}" fontsize="6%" color="{clrWhite}" text="{tr(apparenttemp)}: {windspeed} km/h" />
<drawtext x="0" y="64%" font="{light}" fontsize="6%" color="{clrWhite}" text="{tr(windbearing)}: {windbearingstring} ({windbearing} °)" />
<drawtext x="0" y="70%" font="{light}" fontsize="6%" color="{clrWhite}" text="{tr(cloudcover)}: {cloudcover} %" />
<drawtext x="0" y="76%" font="{light}" fontsize="6%" color="{clrWhite}" text="{tr(pressure)}: {pressure} HPa" />
<drawtext x="0" y="82%" font="{light}" fontsize="6%" color="{clrWhite}" text="{tr(ozone)}: {ozone} DU" />
<drawtext x="0" y="88%" font="{light}" fontsize="6%" color="{clrWhite}" text="{tr(visibility)}: {visibility} km" />
<drawimage name="weathericon" imagetype="icon" path="{icon}" x="2%" y="0" width="{areawidth}*0.4" height="{areawidth}*0.4"/>
<drawtext align="right" y="0" font="{semibold}" fontsize="8%" color="{clrWhite}" text="{city}" />
<drawtext align="right" y="7%" font="{light}" fontsize="8%" color="{clrWhite}" text="{timestamp}" />
<drawtext align="right" y="13%" font="{light}" fontsize="18%" color="{clrWhite}" text="{temperature}°C" />
<drawtext align="right" y="28%" font="{light}" fontsize="8%" color="{clrWhite}" text="{summary}" />
<drawtext x="0" y="40%" font="{light}" fontsize="6%" color="{clrWhite}" text="{tr(apparenttemp)}: {apparenttemperature} °C" />
<drawtext x="0" y="46%" font="{light}" fontsize="6%" color="{clrWhite}" text="{tr(precipitationprobability)}: {precipitationprobability} %" />
<drawtext x="0" y="52%" font="{light}" fontsize="6%" color="{clrWhite}" text="{tr(precipitationintensity)}: {precipitationintensity} l/qm" />
<drawtext x="0" y="58%" font="{light}" fontsize="6%" color="{clrWhite}" text="{tr(humidity)}: {humidity} %" />
<drawtext x="0" y="64%" font="{light}" fontsize="6%" color="{clrWhite}" text="{tr(windspeed)}: {windspeed} km/h" />
<drawtext x="0" y="70%" font="{light}" fontsize="6%" color="{clrWhite}" text="{tr(windbearing)}: {windbearingstring} ({windbearing} °)" />
<drawtext x="0" y="76%" font="{light}" fontsize="6%" color="{clrWhite}" text="{tr(cloudcover)}: {cloudcover} %" />
</area>
<area condition="{ishourly}" x="51%" y="0" width="48%" height="100%" layer="3">
<loop name="hourly" x="0" y="0" orientation="vertical" columnwidth="{areawidth}" rowheight="{areaheight}/12" overflow="cut">

View File

@ -35,6 +35,9 @@
</scrollbar>
<!-- Available Variables in detailheader and tab:
{menuheader} "Current Weather"
{city} configured city to display weather for
{latitude} latitude
{longitude} longitude
{timestamp} timestamp in hh:mm dd.mm of current forecast
{temperature} current temperature in °C
{apparenttemperature} apparent (felt) temperature in °C
@ -70,17 +73,18 @@
</detailheader>
<tab name="current" x="2%" y="20%" width="94%" height="65%" layer="2" scrollheight="{areaheight}/4">
<drawtext x="0" y="0" font="{semibold}" fontsize="10%" color="{clrWhite}" text="{tr(conditions)}: {summary}" />
<drawtext x="0" y="10%" font="{light}" fontsize="10%" color="{clrWhite}" text="{tr(temp)}: {temperature}°C" />
<drawtext x="0" y="20%" font="{light}" fontsize="10%" color="{clrWhite}" text="{tr(apparenttemp)}: {apparenttemperature}°C" />
<drawtext x="0" y="30%" font="{light}" fontsize="10%" color="{clrWhite}" text="{tr(todaymin)}: {mintemperature}°C, {tr(todaymax)}: {maxtemperature}°C" />
<drawtext x="0" y="40%" font="{light}" fontsize="10%" color="{clrWhite}" text="{tr(precipitationprobability)}: {precipitationprobability} %" />
<drawtext x="0" y="50%" font="{light}" fontsize="10%" color="{clrWhite}" text="{tr(precipitationintensity)}: {precipitationintensity} l/qm" />
<drawtext x="0" y="60%" font="{light}" fontsize="10%" color="{clrWhite}" text="{tr(humidity)}: {humidity} %" />
<drawtext x="0" y="70%" font="{light}" fontsize="10%" color="{clrWhite}" text="{tr(windspeed)}: {windspeed} km/h aus {windbearingstring}" />
<drawtext x="0" y="80%" font="{light}" fontsize="10%" color="{clrWhite}" text="{tr(visibility)}: {visibility} km" />
<drawtext x="0" y="90%" font="{light}" fontsize="10%" color="{clrWhite}" text="{tr(cloudcover)}: {cloudcover} %" />
<drawtext x="0" y="100%" font="{light}" fontsize="10%" color="{clrWhite}" text="{tr(pressure)}: {pressure} HPa" />
<drawtext x="0" y="110%" font="{light}" fontsize="10%" color="{clrWhite}" text="{tr(ozone)}: {ozone} DU" />
<drawtext x="0" y="0" font="{semibold}" fontsize="10%" color="{clrWhite}" text="{tr(conditions)} {tr(for)} {city} ({latitude}, {longitude}):" />
<drawtext x="0" y="10%" font="{semibold}" fontsize="10%" color="{clrWhite}" text="{summary}" />
<drawtext x="0" y="25%" font="{light}" fontsize="10%" color="{clrWhite}" text="{tr(temp)}: {temperature}°C" />
<drawtext x="0" y="35%" font="{light}" fontsize="10%" color="{clrWhite}" text="{tr(apparenttemp)}: {apparenttemperature}°C" />
<drawtext x="0" y="45%" font="{light}" fontsize="10%" color="{clrWhite}" text="{tr(todaymin)}: {mintemperature}°C, {tr(todaymax)}: {maxtemperature}°C" />
<drawtext x="0" y="55%" font="{light}" fontsize="10%" color="{clrWhite}" text="{tr(precipitationprobability)}: {precipitationprobability} %" />
<drawtext x="0" y="65%" font="{light}" fontsize="10%" color="{clrWhite}" text="{tr(precipitationintensity)}: {precipitationintensity} l/qm" />
<drawtext x="0" y="75%" font="{light}" fontsize="10%" color="{clrWhite}" text="{tr(humidity)}: {humidity} %" />
<drawtext x="0" y="85%" font="{light}" fontsize="10%" color="{clrWhite}" text="{tr(windspeed)}: {windspeed} km/h aus {windbearingstring}" />
<drawtext x="0" y="95%" font="{light}" fontsize="10%" color="{clrWhite}" text="{tr(visibility)}: {visibility} km" />
<drawtext x="0" y="105%" font="{light}" fontsize="10%" color="{clrWhite}" text="{tr(cloudcover)}: {cloudcover} %" />
<drawtext x="0" y="115%" font="{light}" fontsize="10%" color="{clrWhite}" text="{tr(pressure)}: {pressure} HPa" />
<drawtext x="0" y="125%" font="{light}" fontsize="10%" color="{clrWhite}" text="{tr(ozone)}: {ozone} DU" />
</tab>
</menuplugin>

View File

@ -37,6 +37,9 @@
<!-- Available Variables in detailheader and tab:
{summary} short summary of weather
{icon} path to use in <drawimage> to display appropriate weather icon
{city} configured city to display weather for
{latitude} latitude
{longitude} longitude
{daily[day]} day of forecast in dd.mm
{daily[dayname]} three letter abbrivated day name

View File

@ -37,6 +37,9 @@
<!-- Available Variables in detailheader and tab:
{summary} short summary of weather
{icon} path to use in <drawimage> to display appropriate weather icon
{city} configured city to display weather for
{latitude} latitude
{longitude} longitude
{hourly[]} array with up to 48 hourly forecasts
{hourly[num]} number of forecast, starting at 1

View File

@ -86,6 +86,27 @@
<currentschedule>
</currentschedule>
<!-- Available Variables currentweather:
{timestamp} timestamp of forecast in dd.mm hh:mm
{temperature} current temperature in °C
{apparenttemperature} apparent (feeled) temperature
{summary} short weather summary
{icon} weather icon
{precipitationintensity} precipitation intensity in l/m2
{precipitationprobability} precipitation probability in %
{precipitationtype} precipitation type
{humidity} humidity in %
{windspeed} windspeed in km/h
{windbearing} wind bearing in °
{windbearingstring} wind bearing (N, NE, ...)
{visibility} visibility in km
{cloudcover} cloud cover in %
{pressure} pressure in HPo
{ozone} ozone value in DU
-->
<currentweather>
</currentweather>
<!-- Available Variables customtokens:
all custom tokens set by the svdrp command SCTK are available in this viewelement
For instance, use an appropriate script which runs periodically as cronjob and

View File

@ -545,7 +545,10 @@ void cDisplayChannelView::DrawCurrentWeather(void) {
}
map < string, string > stringTokens;
map < string, int > intTokens;
SetCurrentWeatherTokens(stringTokens, intTokens);
if (!SetCurrentWeatherTokens(stringTokens, intTokens)){
ClearViewElement(veCurrentWeather);
return;
}
ClearViewElement(veCurrentWeather);
DrawViewElement(veCurrentWeather, &stringTokens, &intTokens);

View File

@ -237,6 +237,7 @@ void cDisplayMenuMainView::DrawStaticViewElements(void) {
DrawDiscUsage();
DrawTemperatures();
DrawCurrentSchedule();
DrawCurrentWeather();
DrawCustomTokens();
}
@ -581,6 +582,21 @@ void cDisplayMenuMainView::DrawCurrentSchedule(void) {
DrawViewElement(veCurrentSchedule, &stringTokens, &intTokens);
}
void cDisplayMenuMainView::DrawCurrentWeather(void) {
if (!ViewElementImplemented(veCurrentWeather)) {
return;
}
map < string, string > stringTokens;
map < string, int > intTokens;
if (!SetCurrentWeatherTokens(stringTokens, intTokens)){
ClearViewElement(veCurrentWeather);
return;
}
ClearViewElement(veCurrentWeather);
DrawViewElement(veCurrentWeather, &stringTokens, &intTokens);
}
void cDisplayMenuMainView::DrawCustomTokens(void) {
if (!ViewElementImplemented(veCustomTokens)) {
return;

View File

@ -44,6 +44,7 @@ private:
void DrawTemperatures(void);
bool DrawDevices(void);
void DrawCurrentSchedule(void);
void DrawCurrentWeather(void);
void DrawCustomTokens(void);
public:
cDisplayMenuMainView(cTemplateView *tmplView, bool menuInit);

View File

@ -427,13 +427,13 @@ bool cViewHelpers::SetDate(map < string, string > &stringTokens, map < string, i
return true;
}
void cViewHelpers::SetCurrentWeatherTokens(map < string, string > &stringTokens, map < string, int > &intTokens) {
bool cViewHelpers::SetCurrentWeatherTokens(map < string, string > &stringTokens, map < string, int > &intTokens) {
static cPlugin *pWeatherForecast = cPluginManager::GetPlugin("weatherforecast");
if (!pWeatherForecast)
return;
return false;
cServiceCurrentWeather currentWeather;
if (!pWeatherForecast->Service("GetCurrentWeather", &currentWeather)) {
return;
return false;
}
stringTokens.insert(pair<string,string>("timestamp", currentWeather.timeStamp));
stringTokens.insert(pair<string,string>("temperature", currentWeather.temperature));
@ -453,4 +453,5 @@ void cViewHelpers::SetCurrentWeatherTokens(map < string, string > &stringTokens,
intTokens.insert(pair<string,int>("cloudcover", currentWeather.cloudCover));
stringTokens.insert(pair<string,string>("pressure", currentWeather.pressure));
stringTokens.insert(pair<string,string>("ozone", currentWeather.ozone));
return true;
}

View File

@ -16,7 +16,7 @@ protected:
void SetScraperTokens(const cEvent *event, const cRecording *recording, map < string, string > &stringTokens, map < string, int > &intTokens, map < string, vector< map< string, string > > > &loopTokens);
bool SetTime(map < string, string > &stringTokens, map < string, int > &intTokens);
bool SetDate(map < string, string > &stringTokens, map < string, int > &intTokens);
void SetCurrentWeatherTokens(map < string, string > &stringTokens, map < string, int > &intTokens);
bool SetCurrentWeatherTokens(map < string, string > &stringTokens, map < string, int > &intTokens);
public:
cViewHelpers(void);
virtual ~cViewHelpers(void);