summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Wieninger <cwieninger@gmx.de>2013-01-14 19:03:33 +0100
committerChristian Wieninger <cwieninger@gmx.de>2013-01-14 19:03:33 +0100
commitf897f4833fc1f4280ec71c5385210f6813ebf609 (patch)
tree8ffe94d3a99e84b23f37b290939e823ea07ac72d
parentb90d5defb67c0598ddb6009237e5ff4ccf999f9e (diff)
downloadvdr-plugin-epgsearch-f897f4833fc1f4280ec71c5385210f6813ebf609.tar.gz
vdr-plugin-epgsearch-f897f4833fc1f4280ec71c5385210f6813ebf609.tar.bz2
implement device bonding in timer conflict checker, thanks to Joachim Wilke for providing a patch
-rw-r--r--HISTORY3
-rw-r--r--HISTORY.DE1
-rw-r--r--conflictcheck.c25
-rw-r--r--conflictcheck.h63
4 files changed, 91 insertions, 1 deletions
diff --git a/HISTORY b/HISTORY
index 8e21079..742f42d 100644
--- a/HISTORY
+++ b/HISTORY
@@ -1,8 +1,9 @@
VDR Plugin 'epgsearch' Revision History
---------------------------------------
-2012-06-xx; Version 1.0.1 - maintenance release
+2013-01-xx; Version 1.0.1 - maintenance release
new:
+- implement device bonding in conflict checker, thanks to Joachim Wilke for providing a patch
- new service interface "Epgsearch-enablesearchtimers-v1.0" to switch the search timers
background update on/off. Updated the sample in source/vdr-epgsearchclient-0.0.2.tgz
to use the new service.
diff --git a/HISTORY.DE b/HISTORY.DE
index e4749b3..20be591 100644
--- a/HISTORY.DE
+++ b/HISTORY.DE
@@ -3,6 +3,7 @@ VDR Plugin 'epgsearch' Revision History
2012-05-xx: Version 1.0.1 - Maintenance Release
neu:
+- device bonding in der Timer-Konflikt-Prüfung implementiert, Danke an Joachim Wilke für den Path
- Neue Service-Schnittstelle "Epgsearch-enablesearchtimers-v1.0" zum Ein- und Ausschalten
des Suchtimer-Updates im Hintergrund. Das Beispiel in source/vdr-epgsearchclient-0.0.2.tgz
wurde aktualisiert und nutzt die neue Schnittstelle.
diff --git a/conflictcheck.c b/conflictcheck.c
index aa9c5e9..c8c1493 100644
--- a/conflictcheck.c
+++ b/conflictcheck.c
@@ -204,8 +204,33 @@ void cConflictCheck::InitDevicesInfo()
for(int i=0; i<numDevices; i++)
devices[i].device = cDevice::GetDevice(i);
#endif
+
+#if APIVERSNUM > 10721
+ BondDevices(Setup.DeviceBondings);
+#endif
+}
+
+void cConflictCheck::BondDevices(const char *Bondings)
+{
+#if APIVERSNUM > 10721
+ LogFile.Log(3, "Bond Devices");
+ if (Bondings) {
+ cSatCableNumbers SatCableNumbers(MAXDEVICES, Bondings);
+ int* array = SatCableNumbers.Array();
+ for (int i=0; i<SatCableNumbers.Size(); i++) {
+ for (int j=0; j<SatCableNumbers.Size(); j++) {
+ if (array[i] > 0 && array[i] == array[j] && i != j) {
+ LogFile.Log(3, "Bond devices %i and %i.", i+1, j+1);
+ devices[i].bondedDevices.push_back(&(devices[j]));
+ }
+ }
+ }
+ }
+ LogFile.Log(3, "Bond Devices done.");
+#endif
}
+
void cConflictCheck::Check()
{
if (evaltimeList)
diff --git a/conflictcheck.h b/conflictcheck.h
index 96ef5da..65eda2e 100644
--- a/conflictcheck.h
+++ b/conflictcheck.h
@@ -25,6 +25,7 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#define __EPGSEARCHCONFLCH_H
#include "epgsearchtools.h"
+#include <vdr/diseqc.h>
#include <vector>
#include <set>
#include <list>
@@ -99,6 +100,7 @@ class cConflictCheckDevice
std::set<cConflictCheckTimerObj*,TimerObjSort> recTimers;
cDevice* device;
int devicenr;
+ std::vector<cConflictCheckDevice*> bondedDevices;
cConflictCheckDevice() { device = NULL; devicenr = 0; }
int Priority() const
@@ -182,10 +184,70 @@ class cConflictCheckDevice
needsDetachReceivers = true;
}
}
+ if (result) {
+ if (!BondingOk(Channel)) {
+ // This device is bonded, so we need to check the priorities of the others:
+ for (size_t i=0; i<bondedDevices.size(); i++) {
+ if (bondedDevices[i]->Priority() >= Priority) {
+ LogFile.Log(3, "Attached receiver to bonded device %i has higher priority.", bondedDevices[i]->CardIndex()+1);
+ result = false;
+ break;
+ }
+ }
+ if (result)
+ LogFile.Log(3, "Bonding ok, but detaches receiver on device %i.", CardIndex());
+ else
+ LogFile.Log(3, "Bonding not okay on device %i.", CardIndex());
+ needsDetachReceivers = Receiving();
+ } else {
+ LogFile.Log(3, "Bonding ok on device %i.", CardIndex());
+ }
+ }
if (NeedsDetachReceivers)
*NeedsDetachReceivers = needsDetachReceivers;
return result;
}
+
+ bool BondingOk(const cChannel *Channel) const
+ {
+ if (bondedDevices.empty())
+ return true;
+
+ LogFile.Log(3, "Checking for bonding constraints on device %i", CardIndex()+1);
+
+ cString BondingParams = GetBondingParams(Channel);
+ for(size_t i=0; i< bondedDevices.size(); i++) {
+ // bonding not okay, if a bonded devices records on another polarization or freq. band
+ if (!bondedDevices[i]->recTimers.empty()) {
+ if (strcmp(BondingParams, GetBondingParams((*bondedDevices[i]->recTimers.begin())->timer->Channel())) != 0) {
+ LogFile.Log(3, "Bonded device %i has receiver attached. Not safe to use device.", bondedDevices[i]->CardIndex()+1);
+ return false;
+ } else {
+ LogFile.Log(3, "Bonded device %i has receiver attached but its safe.", bondedDevices[i]->CardIndex()+1);
+ }
+ } else {
+ LogFile.Log(3, "Bonded device %i has no receivers attached - ok.", bondedDevices[i]->CardIndex()+1);
+ }
+ }
+ return true;
+ }
+
+ cString GetBondingParams(const cChannel *Channel) const //copied from cDVBTuner
+ {
+#if APIVERSNUM > 10721
+ cDvbTransponderParameters dtp(Channel->Parameters());
+ if (Setup.DiSEqC) {
+ if (const cDiseqc *diseqc = Diseqcs.Get(device->CardIndex() + 1, Channel->Source(), Channel->Frequency(), dtp.Polarization(), NULL))
+ return diseqc->Commands();
+ }
+ else {
+ bool ToneOff = Channel->Frequency() < Setup.LnbSLOF;
+ bool VoltOff = dtp.Polarization() == 'V' || dtp.Polarization() == 'R';
+ return cString::sprintf("%c %c", ToneOff ? 't' : 'T', VoltOff ? 'v' : 'V');
+ }
+#endif
+ return "";
+ }
};
// --- cConflictCheck --------------------------------------------------------
@@ -209,6 +271,7 @@ class cConflictCheck
~cConflictCheck();
void InitDevicesInfo();
void Check();
+ void BondDevices(const char* bondings);
cList<cConflictCheckTimerObj>* CreateCurrentTimerList();
cList<cConflictCheckTime>* CreateEvaluationTimeList(cList<cConflictCheckTimerObj>*);
cList<cConflictCheckTime>* CreateConflictList(cList<cConflictCheckTime>*, cList<cConflictCheckTimerObj>* timerList);