added device info in displaychannel

This commit is contained in:
louis 2014-10-25 20:10:00 +02:00
parent ce67dea08a
commit 1e20f0c893
14 changed files with 258 additions and 125 deletions

View File

@ -34,6 +34,7 @@ Version 0.0.2
- fixed a bug if displaydetailedtext is called without correct menucat (mailbox plugin)
- implemented function drawslope, see Wiki for documentation
- using default menu list in case an invalid MenuCategory is set
- added device info in displaychannel, example in metrixHD

View File

@ -90,6 +90,7 @@ OBJS = $(PLUGIN).o \
libtemplate/templateloopfunction.o \
libtemplate/xmlparser.o \
views/view.o \
views/viewhelpers.o \
views/displaychannelview.o \
views/displaymenurootview.o \
views/displaymenuview.o \

View File

@ -185,11 +185,13 @@ void cSDDisplayChannel::Flush(void) {
channelView->DrawScreenResolution();
channelView->DrawSignal();
channelView->DrawAudioInfo();
channelView->DrawDevices(initial);
} else {
channelView->ClearStatusIcons();
channelView->ClearScreenResolution();
channelView->ClearSignal();
channelView->ClearSignalBackground();
channelView->ClearDevices();
}
if (initial) {

View File

@ -4,7 +4,7 @@
<!ELEMENT displaychannel (background | channelinfo | epginfo | progressbar | progressbarback |
statusinfo | audioinfo | screenresolution | channelgroup |
signalquality | signalqualityback | scrapercontent |
signalquality | signalqualityback | devices | scrapercontent |
datetime | message | customtokens)* >
<!ATTLIST displaychannel
x CDATA #REQUIRED
@ -73,6 +73,11 @@
debug CDATA #IMPLIED
>
<!ELEMENT devices (area|areascroll)*>
<!ATTLIST devices
debug CDATA #IMPLIED
>
<!ELEMENT scrapercontent (area|areascroll)*>
<!ATTLIST scrapercontent
debug CDATA #IMPLIED

View File

@ -612,6 +612,7 @@ void cTemplateViewChannel::SetViewElements(void) {
viewElementsAllowed.insert("screenresolution");
viewElementsAllowed.insert("signalquality");
viewElementsAllowed.insert("signalqualityback");
viewElementsAllowed.insert("devices");
viewElementsAllowed.insert("scrapercontent");
viewElementsAllowed.insert("datetime");
viewElementsAllowed.insert("message");
@ -654,6 +655,9 @@ string cTemplateViewChannel::GetViewElementName(eViewElement ve) {
case veSignalQualityBack:
name = "Signal Quality Background";
break;
case veDevices:
name = "Devices";
break;
case veScraperContent:
name = "Scraper Content";
break;
@ -698,6 +702,8 @@ void cTemplateViewChannel::AddPixmap(string sViewElement, cTemplatePixmap *pix,
ve = veSignalQuality;
} else if (!sViewElement.compare("signalqualityback")) {
ve = veSignalQualityBack;
} else if (!sViewElement.compare("devices")) {
ve = veDevices;
} else if (!sViewElement.compare("scrapercontent")) {
ve = veScraperContent;
} else if (!sViewElement.compare("datetime")) {

View File

@ -24,6 +24,7 @@ enum eViewElement {
veBackground,
veDateTime,
veMessage,
veDevices,
veCustomTokens,
//DisplayChannel ViewElements
veChannelInfo,
@ -43,7 +44,6 @@ enum eViewElement {
veDiscUsage,
veSystemLoad,
veTimers,
veDevices,
veMenuItem,
veMenuCurrentItemDetail,
veScrollbar,

View File

@ -173,6 +173,41 @@
<signalqualityback>
</signalqualityback>
<!-- Available Variables devices:
{numdevices} number of available devices
{devices[]} array with available devices
{devices[num]} number of current device
{devices[type]} type of device (DVB-S, DVB-C, ...)
{devices[istuned]} true if device is currently tuned to a transponder
{devices[livetv]} true if device is currently playing livetv
{devices[recording]} true if device is currently recording
{devices[hascam]} true if device has a CAM
{devices[cam]} number of CAM
{devices[signalstrength]} signalstrength of devcie
{devices[signalquality]} signalstrength of devcie
{devices[channelnumber]} number of the currently tuned channel
{devices[channelname]} name of the currently tuned channel
{devices[channelid]} ID of the currently tuned channel
{devices[source]} source of the currently tuned channel
-->
<devices>
<area x="70%" y="15%" 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">
<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]})" />
<drawtext condition="{devices[recording]} ++ {devices[livetv]}" align="right" y="0" font="{light}" fontsize="{rowheight}*0.35" color="{clrRed}" text="LiveTV, Recording ({devices[channelname]}) " />
<drawtext condition="{devices[recording]} ++ not{devices[livetv]}" align="right" y="0" font="{light}" fontsize="{rowheight}*0.35" color="{clrRed}" text="Recording ({devices[channelname]}) " />
<drawtext condition="not{devices[recording]} ++ {devices[livetv]}" align="right" y="0" font="{light}" fontsize="{rowheight}*0.35" color="{clrWhite}" text="LiveTV ({devices[channelname]}) " />
<drawrectangle condition="{devices[istuned]}" x="5" y="{rowheight}/3 + 5" width="{areawidth} * {devices[signalstrength]} / 100 - 10 * {devices[signalstrength]} / 100" height="{rowheight}/3 - 10" color="{clrTransWhite}" />
<drawrectangle condition="{devices[istuned]}" x="5" y="2*{rowheight}/3 + 5" width="{areawidth} * {devices[signalquality]} / 100 - 10 * {devices[signalquality]} / 100" height="{rowheight}/3 - 10" color="{clrTransWhite}" />
<drawtext condition="not{devices[istuned]}" align="center" y="{rowheight}/2" font="{light}" fontsize="{rowheight}*0.40" color="{clrWhite}" text="not tuned" />
</loop>
</area>
</devices>
<!-- Available Variables scrapercontent:
{mediapath} Full Path of Poster or Banner to use in image path attribute
{mediawidth} width of image in pixel

View File

@ -105,6 +105,26 @@
<signalqualityback>
</signalqualityback>
<!-- Available Variables devices:
{numdevices} number of available devices
{devices[]} array with available devices
{devices[num]} number of current device
{devices[type]} type of device (DVB-S, DVB-C, ...)
{devices[istuned]} true if device is currently tuned to a transponder
{devices[livetv]} true if device is currently playing livetv
{devices[recording]} true if device is currently recording
{devices[hascam]} true if device has a CAM
{devices[cam]} number of CAM
{devices[signalstrength]} signalstrength of devcie
{devices[signalquality]} signalstrength of devcie
{devices[channelnumber]} number of the currently tuned channel
{devices[channelname]} name of the currently tuned channel
{devices[channelid]} ID of the currently tuned channel
{devices[source]} source of the currently tuned channel
-->
<devices>
</devices>
<!-- Available Variables scrapercontent:
{mediapath} Full Path of Poster or Banner to use in image path attribute
{mediawidth} width of image in pixel

View File

@ -17,6 +17,7 @@ cDisplayChannelView::cDisplayChannelView(cTemplateView *tmplView) : cView(tmplVi
lastAudioChannel = -1;
lastTracDesc = "";
lastTrackLang = "";
InitDevices();
DeleteOsdOnExit();
SetFadeTime(tmplView->GetNumericParameter(ptFadeTime));
}
@ -109,7 +110,8 @@ void cDisplayChannelView::DrawProgressBar(cString &start, cString &stop, int Cur
intTokens.insert(pair<string, int>("duration", Total));
intTokens.insert(pair<string, int>("elapsed", Current));
intTokens.insert(pair<string, int>("remaining", Total - Current));
ClearProgressBar();
DrawViewElement(veProgressBar, &stringTokens, &intTokens);
}
@ -399,6 +401,29 @@ void cDisplayChannelView::ClearSignalBackground(void) {
ClearViewElement(veSignalQualityBack);
}
void cDisplayChannelView::DrawDevices(bool initial) {
if (!ViewElementImplemented(veDevices)) {
return;
}
map < string, string > stringTokens;
map < string, int > intTokens;
map < string, vector< map< string, string > > > deviceLoopTokens;
vector< map< string, string > > devices;
bool changed = SetDevices(initial, &intTokens, &devices);
if (!changed)
return;
deviceLoopTokens.insert(pair< string, vector< map< string, string > > >("devices", devices));
ClearViewElement(veDevices);
DrawViewElement(veDevices, &stringTokens, &intTokens, &deviceLoopTokens);
}
void cDisplayChannelView::ClearDevices(void) {
ClearViewElement(veDevices);
}
void cDisplayChannelView::DrawChannelGroups(const cChannel *Channel, cString ChannelName) {
if (!ViewElementImplemented(veChannelGroup)) {
return;

View File

@ -3,8 +3,9 @@
#include "../libtemplate/template.h"
#include "view.h"
#include "viewhelpers.h"
class cDisplayChannelView : public cView {
class cDisplayChannelView : public cView, public cViewHelpers {
private:
cString lastDate;
int lastScreenWidth;
@ -44,6 +45,8 @@ public:
void DrawSignalBackground(void);
void ClearSignal(void);
void ClearSignalBackground(void);
void DrawDevices(bool initial);
void ClearDevices(void);
void DrawChannelGroups(const cChannel *Channel, cString ChannelName);
void ClearChannelGroups(void);
void DisplayMessage(eMessageType Type, const char *Text);

View File

@ -223,9 +223,6 @@ cDisplayMenuMainView::cDisplayMenuMainView(cTemplateView *tmplView, bool menuIni
cDisplayMenuMainView::~cDisplayMenuMainView() {
CancelSave();
FadeOut();
delete[] lastSignalStrength;
delete[] lastSignalQuality;
delete[] recDevices;
}
void cDisplayMenuMainView::DrawStaticViewElements(void) {
@ -360,18 +357,6 @@ void cDisplayMenuMainView::DrawDiscUsage(void) {
DrawViewElement(veDiscUsage, &stringTokens, &intTokens);
}
void cDisplayMenuMainView::InitDevices(void) {
int numDevices = cDevice::NumDevices();
lastSignalStrength = new int[numDevices];
lastSignalQuality = new int[numDevices];
recDevices = new bool[numDevices];
for (int i=0; i<numDevices; i++) {
lastSignalStrength[i] = 0;
lastSignalQuality[i] = 0;
recDevices[i] = false;
}
}
bool cDisplayMenuMainView::DrawLoad(void) {
if (!ViewElementImplemented(veSystemLoad)) {
return false;
@ -400,120 +385,22 @@ bool cDisplayMenuMainView::DrawDevices(void) {
if (!ViewElementImplemented(veDevices)) {
return false;
}
int numDevices = cDevice::NumDevices();
if (!initial) {
//check if drawing is necessary
bool changed = false;
for (int i = 0; i < numDevices; i++) {
const cDevice *device = cDevice::GetDevice(i);
if (!device || !device->NumProvidedSystems()) {
continue;
}
if ((device->SignalStrength() != lastSignalStrength[i]) || (device->SignalQuality() != lastSignalQuality[i])) {
changed = true;
break;
}
}
if (!changed) {
return false;
}
}
map < string, string > stringTokens;
map < string, int > intTokens;
map < string, vector< map< string, string > > > deviceLoopTokens;
vector< map< string, string > > devices;
//check device which currently displays live tv
int deviceLiveTV = -1;
cDevice *primaryDevice = cDevice::PrimaryDevice();
if (primaryDevice) {
if (!primaryDevice->Replaying() || primaryDevice->Transferring())
deviceLiveTV = cDevice::ActualDevice()->DeviceNumber();
else
deviceLiveTV = primaryDevice->DeviceNumber();
}
bool changed = SetDevices(initial, &intTokens, &devices);
if (!changed)
return false;
//check currently recording devices
for (cTimer *timer = Timers.First(); timer; timer = Timers.Next(timer)) {
if (!timer->Recording()) {
continue;
}
if (cRecordControl *RecordControl = cRecordControls::GetRecordControl(timer)) {
const cDevice *recDevice = RecordControl->Device();
if (recDevice) {
recDevices[recDevice->DeviceNumber()] = true;
}
}
}
int actualNumDevices = 0;
for (int i = 0; i < numDevices; i++) {
const cDevice *device = cDevice::GetDevice(i);
if (!device || !device->NumProvidedSystems()) {
continue;
}
actualNumDevices++;
map< string, string > deviceVals;
stringstream strNum;
strNum << actualNumDevices;
deviceVals.insert(pair< string, string >("devices[num]", strNum.str()));
deviceVals.insert(pair< string, string >("devices[type]", *(device->DeviceType())));
cCamSlot *camSlot = device->CamSlot();
int camNumber = -1;
if (camSlot) {
camNumber = camSlot->SlotNumber();
deviceVals.insert(pair< string, string >("devices[hascam]", "1"));
} else {
deviceVals.insert(pair< string, string >("devices[hascam]", "0"));
}
int signalStrength = device->SignalStrength();
int signalQuality = device->SignalQuality();
stringstream strCamNumber;
strCamNumber << camNumber;
deviceVals.insert(pair< string, string >("devices[cam]", strCamNumber.str()));
stringstream strStrength;
strStrength << signalStrength;
deviceVals.insert(pair< string, string >("devices[signalstrength]", strStrength.str()));
stringstream strQuality;
strQuality << signalQuality;
deviceVals.insert(pair< string, string >("devices[signalquality]", strQuality.str()));
deviceVals.insert(pair< string, string >("devices[livetv]", i == deviceLiveTV ? "1" : "0"));
deviceVals.insert(pair< string, string >("devices[recording]", recDevices[i] ? "1" : "0"));
const cChannel *channel = device->GetCurrentlyTunedTransponder();
const cSource *source = (channel) ? Sources.Get(channel->Source()) : NULL;
if (channel && channel->Number() > 0) {
stringstream strChanNum;
strChanNum << channel->Number();
deviceVals.insert(pair< string, string >("devices[channelnumber]", strChanNum.str()));
deviceVals.insert(pair< string, string >("devices[channelname]", channel->Name()));
deviceVals.insert(pair< string, string >("devices[channelid]", *(channel->GetChannelID().ToString())));
deviceVals.insert(pair< string, string >("devices[istuned]", "1"));
} else {
deviceVals.insert(pair< string, string >("devices[channelnumber]", "0"));
deviceVals.insert(pair< string, string >("devices[channelname]", ""));
deviceVals.insert(pair< string, string >("devices[channelid]", ""));
deviceVals.insert(pair< string, string >("devices[istuned]", "0"));
}
deviceVals.insert(pair< string, string >("devices[source]", source ? source->Description() : ""));
devices.push_back(deviceVals);
lastSignalStrength[i] = signalStrength;
lastSignalQuality[i] = signalQuality;
}
deviceLoopTokens.insert(pair< string, vector< map< string, string > > >("devices", devices));
intTokens.insert(pair<string, int>("numdevices", actualNumDevices));
ClearViewElement(veDevices);
DrawViewElement(veDevices, &stringTokens, &intTokens, &deviceLoopTokens);
return true;
}
/************************************************************************
* cDisplayMenuSchedulesView
************************************************************************/

View File

@ -2,6 +2,7 @@
#define __DISPLAYMENUVIEW_H
#include "../libtemplate/template.h"
#include "viewhelpers.h"
#include "displaymenulistview.h"
class cDisplayMenuView : public cView {
@ -28,17 +29,13 @@ public:
bool BackgroundImplemented(void);
};
class cDisplayMenuMainView : public cDisplayMenuView {
class cDisplayMenuMainView : public cDisplayMenuView, public cViewHelpers {
private:
bool initial;
int* lastSignalStrength;
int* lastSignalQuality;
double lastSystemLoad;
bool* recDevices;
void DrawTimers(void);
void DrawDiscUsage(void);
bool DrawLoad(void);
void InitDevices(void);
bool DrawDevices(void);
public:
cDisplayMenuMainView(cTemplateView *tmplView, bool menuInit);

133
views/viewhelpers.c Normal file
View File

@ -0,0 +1,133 @@
#include <vdr/menu.h>
#include "../config.h"
#include "viewhelpers.h"
cViewHelpers::cViewHelpers(void) {
devicesInit = false;
}
cViewHelpers::~cViewHelpers() {
if (devicesInit) {
delete[] lastSignalStrength;
delete[] lastSignalQuality;
delete[] recDevices;
}
}
void cViewHelpers::InitDevices(void) {
int numDevices = cDevice::NumDevices();
lastSignalStrength = new int[numDevices];
lastSignalQuality = new int[numDevices];
recDevices = new bool[numDevices];
for (int i=0; i<numDevices; i++) {
lastSignalStrength[i] = 0;
lastSignalQuality[i] = 0;
recDevices[i] = false;
}
devicesInit = true;
}
bool cViewHelpers::SetDevices(bool initial, map<string,int> *intTokens, vector<map<string,string> > *devices) {
int numDevices = cDevice::NumDevices();
if (!initial) {
//check if drawing is necessary
bool changed = false;
for (int i = 0; i < numDevices; i++) {
const cDevice *device = cDevice::GetDevice(i);
if (!device || !device->NumProvidedSystems()) {
continue;
}
if ((device->SignalStrength() != lastSignalStrength[i]) || (device->SignalQuality() != lastSignalQuality[i])) {
changed = true;
break;
}
}
if (!changed) {
return false;
}
}
//check device which currently displays live tv
int deviceLiveTV = -1;
cDevice *primaryDevice = cDevice::PrimaryDevice();
if (primaryDevice) {
if (!primaryDevice->Replaying() || primaryDevice->Transferring())
deviceLiveTV = cDevice::ActualDevice()->DeviceNumber();
else
deviceLiveTV = primaryDevice->DeviceNumber();
}
//check currently recording devices
for (cTimer *timer = Timers.First(); timer; timer = Timers.Next(timer)) {
if (!timer->Recording()) {
continue;
}
if (cRecordControl *RecordControl = cRecordControls::GetRecordControl(timer)) {
const cDevice *recDevice = RecordControl->Device();
if (recDevice) {
recDevices[recDevice->DeviceNumber()] = true;
}
}
}
int actualNumDevices = 0;
for (int i = 0; i < numDevices; i++) {
const cDevice *device = cDevice::GetDevice(i);
if (!device || !device->NumProvidedSystems()) {
continue;
}
actualNumDevices++;
map< string, string > deviceVals;
stringstream strNum;
strNum << actualNumDevices;
deviceVals.insert(pair< string, string >("devices[num]", strNum.str()));
deviceVals.insert(pair< string, string >("devices[type]", *(device->DeviceType())));
cCamSlot *camSlot = device->CamSlot();
int camNumber = -1;
if (camSlot) {
camNumber = camSlot->SlotNumber();
deviceVals.insert(pair< string, string >("devices[hascam]", "1"));
} else {
deviceVals.insert(pair< string, string >("devices[hascam]", "0"));
}
int signalStrength = device->SignalStrength();
int signalQuality = device->SignalQuality();
stringstream strCamNumber;
strCamNumber << camNumber;
deviceVals.insert(pair< string, string >("devices[cam]", strCamNumber.str()));
stringstream strStrength;
strStrength << signalStrength;
deviceVals.insert(pair< string, string >("devices[signalstrength]", strStrength.str()));
stringstream strQuality;
strQuality << signalQuality;
deviceVals.insert(pair< string, string >("devices[signalquality]", strQuality.str()));
deviceVals.insert(pair< string, string >("devices[livetv]", i == deviceLiveTV ? "1" : "0"));
deviceVals.insert(pair< string, string >("devices[recording]", recDevices[i] ? "1" : "0"));
const cChannel *channel = device->GetCurrentlyTunedTransponder();
const cSource *source = (channel) ? Sources.Get(channel->Source()) : NULL;
if (channel && channel->Number() > 0) {
stringstream strChanNum;
strChanNum << channel->Number();
deviceVals.insert(pair< string, string >("devices[channelnumber]", strChanNum.str()));
deviceVals.insert(pair< string, string >("devices[channelname]", channel->Name()));
deviceVals.insert(pair< string, string >("devices[channelid]", *(channel->GetChannelID().ToString())));
deviceVals.insert(pair< string, string >("devices[istuned]", "1"));
} else {
deviceVals.insert(pair< string, string >("devices[channelnumber]", "0"));
deviceVals.insert(pair< string, string >("devices[channelname]", ""));
deviceVals.insert(pair< string, string >("devices[channelid]", ""));
deviceVals.insert(pair< string, string >("devices[istuned]", "0"));
}
deviceVals.insert(pair< string, string >("devices[source]", source ? source->Description() : ""));
devices->push_back(deviceVals);
lastSignalStrength[i] = signalStrength;
lastSignalQuality[i] = signalQuality;
}
intTokens->insert(pair<string, int>("numdevices", actualNumDevices));
return true;
}

18
views/viewhelpers.h Normal file
View File

@ -0,0 +1,18 @@
#ifndef __VIEWHELPERS_H
#define __VIEWHELPERS_H
class cViewHelpers {
private:
bool devicesInit;
int* lastSignalStrength;
int* lastSignalQuality;
bool* recDevices;
protected:
public:
cViewHelpers(void);
virtual ~cViewHelpers(void);
void InitDevices(void);
bool SetDevices(bool initial, map<string,int> *intTokens, vector<map<string,string> > *devices);
};
#endif //__VIEWHELPERS_H