Skip to content

Commit

Permalink
Remove deprecated code which was used to convert very old diseqc sett…
Browse files Browse the repository at this point in the history
…ings.

Thank you Gary for noticing a problem with this code which prompted me
to look at it in more depth...
  • Loading branch information
Nicolas Riendeau committed Feb 7, 2016
1 parent a774469 commit b374632
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 300 deletions.
1 change: 0 additions & 1 deletion mythtv/libs/libmythtv/dbcheck.cpp
Expand Up @@ -12,7 +12,6 @@ using namespace std;
#include "schemawizard.h"
#include "mythdb.h"
#include "mythlogging.h"
#include "diseqcsettings.h" // for convert_diseqc_db()
#include "videodbcheck.h" // for 1267
#include "compat.h"
#include "recordingrule.h"
Expand Down
297 changes: 0 additions & 297 deletions mythtv/libs/libmythtv/diseqcsettings.cpp
Expand Up @@ -1518,300 +1518,3 @@ void DTVDeviceConfigGroup::AddChild(
else
group->addChild(setting);
}

//////////////////////////////////////// Database Upgrade

enum OLD_DISEQC_TYPES
{
DISEQC_SINGLE = 0,
DISEQC_MINI_2 = 1,
DISEQC_SWITCH_2_1_0 = 2,
DISEQC_SWITCH_2_1_1 = 3,
DISEQC_SWITCH_4_1_0 = 4,
DISEQC_SWITCH_4_1_1 = 5,
DISEQC_POSITIONER_1_2 = 6,
DISEQC_POSITIONER_X = 7,
DISEQC_POSITIONER_1_2_SWITCH_2 = 8,
DISEQC_POSITIONER_X_SWITCH_2 = 9,
DISEQC_SW21 = 10,
DISEQC_SW64 = 11,
DISEQC_SCR = 12,
};

// import old diseqc configuration into tree
bool convert_diseqc_db(void)
{
MSqlQuery cquery(MSqlQuery::InitCon());
cquery.prepare(
"SELECT cardid, dvb_diseqc_type "
"FROM capturecard"
"WHERE dvb_diseqc_type IS NOT NULL AND "
" diseqcid IS NULL");

// iterate through cards
if (!cquery.exec())
return false;

MSqlQuery iquery(MSqlQuery::InitCon());
iquery.prepare(
"SELECT cardid, diseqc_port, diseqc_pos, "
" lnb_lof_switch, lnb_lof_hi, lnb_lof_lo "
"FROM capturecard "
"WHERE capturecard.cardid = :CARDID");

while (cquery.next())
{
uint cardid = cquery.value(0).toUInt();
OLD_DISEQC_TYPES type = (OLD_DISEQC_TYPES) cquery.value(1).toUInt();

DiSEqCDevTree tree;
DiSEqCDevDevice *root = NULL;
uint add_lnbs = 0;
DiSEqCDevLNB::dvbdev_lnb_t lnb_type =
DiSEqCDevLNB::kTypeVoltageAndToneControl;

// create root of tree
switch (type)
{
case DISEQC_SINGLE:
{
// single LNB
root = DiSEqCDevDevice::CreateByType(
tree, DiSEqCDevDevice::kTypeLNB);
break;
}

case DISEQC_MINI_2:
{
// tone switch + 2 LNBs
root = DiSEqCDevDevice::CreateByType(
tree, DiSEqCDevDevice::kTypeSwitch);
DiSEqCDevSwitch *sw = dynamic_cast<DiSEqCDevSwitch*>(root);
if (sw)
{
sw->SetType(DiSEqCDevSwitch::kTypeTone);
sw->SetNumPorts(2);
add_lnbs = 2;
}
break;
}

case DISEQC_SWITCH_2_1_0:
case DISEQC_SWITCH_2_1_1:
{
// 2 port diseqc + 2 LNBs
root = DiSEqCDevDevice::CreateByType(
tree, DiSEqCDevDevice::kTypeSwitch);
DiSEqCDevSwitch *sw = dynamic_cast<DiSEqCDevSwitch*>(root);
if (sw)
{
sw->SetType(DiSEqCDevSwitch::kTypeDiSEqCCommitted);
sw->SetAddress(0x10);
sw->SetNumPorts(2);
add_lnbs = 2;
}
break;
}

case DISEQC_SWITCH_4_1_0:
case DISEQC_SWITCH_4_1_1:
{
// 4 port diseqc + 4 LNBs
root = DiSEqCDevDevice::CreateByType(
tree, DiSEqCDevDevice::kTypeSwitch);
DiSEqCDevSwitch *sw = dynamic_cast<DiSEqCDevSwitch*>(root);
if (sw)
{
sw->SetType(DiSEqCDevSwitch::kTypeDiSEqCCommitted);
sw->SetAddress(0x10);
sw->SetNumPorts(4);
add_lnbs = 4;
}
break;
}

case DISEQC_POSITIONER_1_2:
{
// non-usals positioner + LNB
root = DiSEqCDevDevice::CreateByType(
tree, DiSEqCDevDevice::kTypeRotor);
DiSEqCDevRotor *rotor = dynamic_cast<DiSEqCDevRotor*>(root);
if (rotor)
{
rotor->SetType(DiSEqCDevRotor::kTypeDiSEqC_1_2);
add_lnbs = 1;
}
break;
}

case DISEQC_POSITIONER_X:
{
// usals positioner + LNB (diseqc_pos)
root = DiSEqCDevDevice::CreateByType(
tree, DiSEqCDevDevice::kTypeRotor);
DiSEqCDevRotor *rotor = dynamic_cast<DiSEqCDevRotor*>(root);
if (rotor)
{
rotor->SetType(DiSEqCDevRotor::kTypeDiSEqC_1_3);
add_lnbs = 1;
}
break;
}

case DISEQC_POSITIONER_1_2_SWITCH_2:
{
// 10 port uncommitted switch + 10 LNBs
root = DiSEqCDevDevice::CreateByType(
tree, DiSEqCDevDevice::kTypeSwitch);
DiSEqCDevSwitch *sw = dynamic_cast<DiSEqCDevSwitch*>(root);
if (sw)
{
sw->SetType(DiSEqCDevSwitch::kTypeDiSEqCUncommitted);
sw->SetNumPorts(10);
add_lnbs = 10;
}
break;
}

case DISEQC_SW21:
{
// legacy SW21 + 2 fixed lnbs
root = DiSEqCDevDevice::CreateByType(
tree, DiSEqCDevDevice::kTypeSwitch);
DiSEqCDevSwitch *sw = dynamic_cast<DiSEqCDevSwitch*>(root);
if (sw)
{
sw->SetType(DiSEqCDevSwitch::kTypeLegacySW21);
sw->SetNumPorts(2);
add_lnbs = 2;
lnb_type = DiSEqCDevLNB::kTypeFixed;
}
break;
}

case DISEQC_SW64:
{
// legacy SW64 + 3 fixed lnbs
root = DiSEqCDevDevice::CreateByType(
tree, DiSEqCDevDevice::kTypeSwitch);
DiSEqCDevSwitch *sw = dynamic_cast<DiSEqCDevSwitch*>(root);
if (sw)
{
sw->SetType(DiSEqCDevSwitch::kTypeLegacySW64);
sw->SetNumPorts(3);
add_lnbs = 3;
lnb_type = DiSEqCDevLNB::kTypeFixed;
}
break;
}

case DISEQC_SCR:
{
// SCR + LNB
root = DiSEqCDevDevice::CreateByType(
tree, DiSEqCDevDevice::kTypeSCR);
DiSEqCDevSCR *scr = dynamic_cast<DiSEqCDevSCR*>(root);
if (scr)
{
add_lnbs = 1;
}
break;
}

default:
{
LOG(VB_GENERAL, LOG_ERR, "Unknown DiSEqC device type " +
QString("%1 ignoring card %2").arg(type).arg(cardid));
break;
}
}

if (!root)
continue;

tree.SetRoot(root);

// create LNBs
for (uint i = 0; i < add_lnbs; i++)
{
DiSEqCDevLNB *lnb = dynamic_cast<DiSEqCDevLNB*>
(DiSEqCDevDevice::CreateByType(
tree, DiSEqCDevDevice::kTypeLNB));
if (lnb)
{
lnb->SetType(lnb_type);
lnb->SetDescription(QString("LNB #%1").arg(i+1));
if (!root->SetChild(i, lnb))
delete lnb;
}
}

// save the tree to get real device ids
tree.Store(cardid);

// iterate inputs
DiSEqCDevSettings set;
iquery.bindValue(":CARDID", cardid);

if (!iquery.exec())
return false;

while (iquery.next())
{
uint inputid = iquery.value(0).toUInt();
uint port = iquery.value(1).toUInt();
double pos = iquery.value(2).toDouble();
DiSEqCDevLNB *lnb = NULL;

// configure LNB and settings
switch (type)
{
case DISEQC_SINGLE:
lnb = dynamic_cast<DiSEqCDevLNB*>(root);
break;

case DISEQC_MINI_2:
case DISEQC_SWITCH_2_1_0:
case DISEQC_SWITCH_2_1_1:
case DISEQC_SWITCH_4_1_0:
case DISEQC_SWITCH_4_1_1:
case DISEQC_SW21:
case DISEQC_SW64:
case DISEQC_POSITIONER_1_2_SWITCH_2:
lnb = dynamic_cast<DiSEqCDevLNB*>(root->GetChild(port));
set.SetValue(root->GetDeviceID(), port);
break;

case DISEQC_POSITIONER_1_2:
case DISEQC_POSITIONER_X:
case DISEQC_SCR:
lnb = dynamic_cast<DiSEqCDevLNB*>(root->GetChild(0));
set.SetValue(root->GetDeviceID(), pos);
break;

default:
break;
}

// configure lnb
if (lnb)
{
lnb->SetLOFSwitch(iquery.value(3).toUInt());
lnb->SetLOFHigh(iquery.value(4).toUInt());
lnb->SetLOFLow(iquery.value(5).toUInt());
}

// save settings
set.Store(inputid);
}

// save any LNB changes
tree.Store(cardid);

// invalidate cached devices
DiSEqCDev trees;
trees.InvalidateTrees();
}

return true;
}
2 changes: 0 additions & 2 deletions mythtv/libs/libmythtv/diseqcsettings.h
Expand Up @@ -16,8 +16,6 @@ class SwitchTypeSetting;
class SwitchPortsSetting;
class SwitchAddressSetting;

bool convert_diseqc_db(void);

class SwitchConfig : public QObject, public ConfigurationWizard
{
Q_OBJECT
Expand Down

0 comments on commit b374632

Please sign in to comment.