summaryrefslogtreecommitdiff
path: root/conflictcheck.h
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 /conflictcheck.h
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
Diffstat (limited to 'conflictcheck.h')
-rw-r--r--conflictcheck.h63
1 files changed, 63 insertions, 0 deletions
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);