mirror of
https://projects.vdr-developer.org/git/vdr-plugin-skindesigner.git
synced 2023-10-19 17:58:31 +02:00
introduced weather service interface
This commit is contained in:
parent
c59cc4e610
commit
4d8d1cc629
@ -169,6 +169,7 @@ void cSDDisplayChannel::Flush(void) {
|
||||
return;
|
||||
|
||||
if (initial) {
|
||||
channelView->DrawCurrentWeather();
|
||||
channelView->DrawCustomTokens();
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
<!ELEMENT displaychannel (background | channelinfo | epginfo | progressbar | progressbarback |
|
||||
statusinfo | audioinfo | screenresolution | channelgroup |
|
||||
signalquality | signalqualityback | devices | scrapercontent |
|
||||
signalquality | signalqualityback | devices | currentweather | scrapercontent |
|
||||
datetime | time | message | customtokens)* >
|
||||
<!ATTLIST displaychannel
|
||||
x CDATA #REQUIRED
|
||||
@ -78,6 +78,11 @@
|
||||
debug CDATA #IMPLIED
|
||||
>
|
||||
|
||||
<!ELEMENT currentweather (area|areascroll)*>
|
||||
<!ATTLIST currentweather
|
||||
debug CDATA #IMPLIED
|
||||
>
|
||||
|
||||
<!ELEMENT scrapercontent (area|areascroll)*>
|
||||
<!ATTLIST scrapercontent
|
||||
debug CDATA #IMPLIED
|
||||
|
@ -669,6 +669,7 @@ void cTemplateViewChannel::SetViewElements(void) {
|
||||
viewElementsAllowed.insert("signalquality");
|
||||
viewElementsAllowed.insert("signalqualityback");
|
||||
viewElementsAllowed.insert("devices");
|
||||
viewElementsAllowed.insert("currentweather");
|
||||
viewElementsAllowed.insert("scrapercontent");
|
||||
viewElementsAllowed.insert("datetime");
|
||||
viewElementsAllowed.insert("time");
|
||||
@ -715,6 +716,9 @@ string cTemplateViewChannel::GetViewElementName(eViewElement ve) {
|
||||
case veDevices:
|
||||
name = "Devices";
|
||||
break;
|
||||
case veCurrentWeather:
|
||||
name = "Current Weather";
|
||||
break;
|
||||
case veScraperContent:
|
||||
name = "Scraper Content";
|
||||
break;
|
||||
@ -764,6 +768,8 @@ void cTemplateViewChannel::AddPixmap(string sViewElement, cTemplatePixmap *pix,
|
||||
ve = veSignalQualityBack;
|
||||
} else if (!sViewElement.compare("devices")) {
|
||||
ve = veDevices;
|
||||
} else if (!sViewElement.compare("currentweather")) {
|
||||
ve = veCurrentWeather;
|
||||
} else if (!sViewElement.compare("scrapercontent")) {
|
||||
ve = veScraperContent;
|
||||
} else if (!sViewElement.compare("datetime")) {
|
||||
@ -1041,6 +1047,7 @@ void cTemplateViewMenu::SetViewElements(void) {
|
||||
viewElementsAllowed.insert("temperatures");
|
||||
viewElementsAllowed.insert("timers");
|
||||
viewElementsAllowed.insert("devices");
|
||||
viewElementsAllowed.insert("currentweather");
|
||||
viewElementsAllowed.insert("currentschedule");
|
||||
viewElementsAllowed.insert("customtokens");
|
||||
viewElementsAllowed.insert("scrollbar");
|
||||
@ -1252,6 +1259,8 @@ void cTemplateViewMenu::AddPixmap(string sViewElement, cTemplatePixmap *pix, vec
|
||||
ve = veCustomTokens;
|
||||
} else if (!sViewElement.compare("devices")) {
|
||||
ve = veDevices;
|
||||
} else if (!sViewElement.compare("currentweather")) {
|
||||
ve = veCurrentWeather;
|
||||
} else if (!sViewElement.compare("scrollbar")) {
|
||||
ve = veScrollbar;
|
||||
} else if (!sViewElement.compare("detailheader")) {
|
||||
|
@ -26,6 +26,7 @@ enum eViewElement {
|
||||
veTime,
|
||||
veMessage,
|
||||
veDevices,
|
||||
veCurrentWeather,
|
||||
veCustomTokens,
|
||||
//DisplayChannel ViewElements
|
||||
veChannelInfo,
|
||||
|
45
services/weatherforecast.h
Normal file
45
services/weatherforecast.h
Normal file
@ -0,0 +1,45 @@
|
||||
#ifndef __WEATHERFORECASTSERVICES_H
|
||||
#define __WEATHERFORECASTSERVICES_H
|
||||
|
||||
#include <string>
|
||||
|
||||
class cServiceCurrentWeather {
|
||||
public:
|
||||
cServiceCurrentWeather(void) {
|
||||
timeStamp = "";
|
||||
temperature = "";
|
||||
apparentTemperature = "";
|
||||
summary = "";
|
||||
icon = "";
|
||||
precipitationIntensity = "";
|
||||
precipitationProbability = 0;
|
||||
precipitationType = "";
|
||||
humidity = 0;
|
||||
windSpeed = "";
|
||||
windBearing = 0;
|
||||
windBearingString = "";
|
||||
visibility = "";
|
||||
cloudCover = 0;
|
||||
pressure = "";
|
||||
ozone = "";
|
||||
};
|
||||
std::string timeStamp;
|
||||
std::string temperature;
|
||||
std::string apparentTemperature;
|
||||
std::string summary;
|
||||
std::string icon;
|
||||
std::string precipitationIntensity;
|
||||
int precipitationProbability;
|
||||
std::string precipitationType;
|
||||
int humidity;
|
||||
std::string windSpeed;
|
||||
int windBearing;
|
||||
std::string windBearingString;
|
||||
std::string visibility;
|
||||
int cloudCover;
|
||||
std::string pressure;
|
||||
std::string ozone;
|
||||
};
|
||||
|
||||
#endif //__WEATHERFORECASTSERVICES_H
|
||||
|
@ -12,6 +12,11 @@
|
||||
<fill color="{clrTransBlack}" />
|
||||
<drawrectangle x="0" y="0" width="45%" height="100%" color="{clrTransBlueLight}" />
|
||||
</area>
|
||||
<!-- background weather -->
|
||||
<area x="70%" y="15%" width="30%" height="13%" layer="1">
|
||||
<fill color="{clrTransBlack}" />
|
||||
<drawrectangle x="0" y="0" width="45%" height="100%" color="{clrTransBlueLight}" />
|
||||
</area>
|
||||
<!-- background channellogo -->
|
||||
<area x="0" y="80%" width="20%" height="20%" layer="2">
|
||||
<fill color="{clrTransBlueLight}" />
|
||||
@ -192,10 +197,10 @@
|
||||
{devices[source]} source of the currently tuned channel
|
||||
-->
|
||||
<devices>
|
||||
<area x="70%" y="15%" width="30%" height="{areaheight}/12 * {numdevices}" layer="1">
|
||||
<area x="70%" y="30%" width="30%" height="{areaheight}/12 * {numdevices}" layer="1">
|
||||
<fill color="{clrTransBlack}"/>
|
||||
</area>
|
||||
<area x="70%" y="15%" width="30%" height="{areaheight}/12 * {numdevices}" layer="2">
|
||||
<area x="70%" y="30%" width="30%" 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.35" color="{clrWhite}" text="{devices[num]}: {devices[type]}" />
|
||||
<drawtext condition="{devices[hascam]}" x="{width(label)} + 15" y="0" font="{light}" fontsize="{rowheight}*0.35" color="{clrWhite}" text="(CAM {devices[cam]})" />
|
||||
@ -209,6 +214,33 @@
|
||||
</area>
|
||||
</devices>
|
||||
|
||||
<!-- 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="70%" y="15%" width="13%" height="13%" layer="1">
|
||||
<drawimage imagetype="icon" path="{icon}" align="center" valign="center" width="{areaheight}*0.8" height="{areaheight}*0.8"/>
|
||||
</area>
|
||||
<area x="85%" y="15%" width="13%" height="13%" layer="1">
|
||||
<drawtext align="center" valign="center" font="{light}" fontsize="90%" color="{clrWhite}" text="{temperature}°C" />
|
||||
</area>
|
||||
</currentweather>
|
||||
|
||||
<!-- Available Variables scrapercontent:
|
||||
{posterpath} Full Path of Poster to use in image path attribute
|
||||
{posterwidth} width of poster in pixel
|
||||
|
@ -127,6 +127,27 @@
|
||||
<devices>
|
||||
</devices>
|
||||
|
||||
<!-- 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 scrapercontent:
|
||||
{posterpath} Full Path of Poster to use in image path attribute
|
||||
{posterwidth} width of poster in pixel
|
||||
|
@ -539,6 +539,19 @@ void cDisplayChannelView::DrawCustomTokens(void) {
|
||||
DrawViewElement(veCustomTokens, &stringTokens, &intTokens);
|
||||
}
|
||||
|
||||
void cDisplayChannelView::DrawCurrentWeather(void) {
|
||||
if (!ViewElementImplemented(veCurrentWeather)) {
|
||||
return;
|
||||
}
|
||||
map < string, string > stringTokens;
|
||||
map < string, int > intTokens;
|
||||
SetCurrentWeatherTokens(stringTokens, intTokens);
|
||||
|
||||
ClearViewElement(veCurrentWeather);
|
||||
DrawViewElement(veCurrentWeather, &stringTokens, &intTokens);
|
||||
}
|
||||
|
||||
|
||||
void cDisplayChannelView::Action(void) {
|
||||
SetInitFinished();
|
||||
FadeIn();
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
void ClearChannelGroups(void);
|
||||
void DisplayMessage(eMessageType Type, const char *Text);
|
||||
void DrawCustomTokens(void);
|
||||
void DrawCurrentWeather(void);
|
||||
void DoStart(void) { Start(); };
|
||||
void Flush(void) { DoFlush(); };
|
||||
};
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <vdr/menu.h>
|
||||
#include "../services/scraper2vdr.h"
|
||||
#include "../services/weatherforecast.h"
|
||||
#include "../config.h"
|
||||
#include "../libcore/helpers.h"
|
||||
#include "viewhelpers.h"
|
||||
@ -425,3 +426,30 @@ bool cViewHelpers::SetDate(map < string, string > &stringTokens, map < string, i
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void cViewHelpers::SetCurrentWeatherTokens(map < string, string > &stringTokens, map < string, int > &intTokens) {
|
||||
static cPlugin *pWeatherForecast = cPluginManager::GetPlugin("weatherforecast");
|
||||
if (!pWeatherForecast)
|
||||
return;
|
||||
cServiceCurrentWeather currentWeather;
|
||||
if (!pWeatherForecast->Service("GetCurrentWeather", ¤tWeather)) {
|
||||
return;
|
||||
}
|
||||
esyslog("skindesigner: service call successfull");
|
||||
stringTokens.insert(pair<string,string>("timestamp", currentWeather.timeStamp));
|
||||
stringTokens.insert(pair<string,string>("temperature", currentWeather.temperature));
|
||||
stringTokens.insert(pair<string,string>("apparenttemperature", currentWeather.apparentTemperature));
|
||||
stringTokens.insert(pair<string,string>("summary", currentWeather.summary));
|
||||
stringTokens.insert(pair<string,string>("icon", currentWeather.icon));
|
||||
stringTokens.insert(pair<string,string>("precipitationintensity", currentWeather.precipitationIntensity));
|
||||
intTokens.insert(pair<string,int>("precipitationprobability", currentWeather.precipitationProbability));
|
||||
stringTokens.insert(pair<string,string>("precipitationtype", currentWeather.precipitationType));
|
||||
intTokens.insert(pair<string,int>("humidity", currentWeather.humidity));
|
||||
stringTokens.insert(pair<string,string>("windspeed", currentWeather.windSpeed));
|
||||
intTokens.insert(pair<string,int>("windbearing", currentWeather.windBearing));
|
||||
stringTokens.insert(pair<string,string>("windbearingstring", currentWeather.windBearingString));
|
||||
stringTokens.insert(pair<string,string>("visibility", currentWeather.visibility));
|
||||
intTokens.insert(pair<string,int>("cloudcover", currentWeather.cloudCover));
|
||||
stringTokens.insert(pair<string,string>("pressure", currentWeather.pressure));
|
||||
stringTokens.insert(pair<string,string>("ozone", currentWeather.ozone));
|
||||
}
|
||||
|
@ -16,6 +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);
|
||||
public:
|
||||
cViewHelpers(void);
|
||||
virtual ~cViewHelpers(void);
|
||||
|
Loading…
Reference in New Issue
Block a user