20#include "libmythbase/mythconfig.h"
46static constexpr uint8_t TIMEOUT_RETRIES { 10 };
47static constexpr std::chrono::milliseconds TIMEOUT_WAIT { 250ms };
50static constexpr uint8_t DISEQC_FRM { 0xe0 };
51static constexpr uint8_t DISEQC_FRM_REPEAT {1 << 0};
94static constexpr double EPS { 1E-4 };
96#define LOC QString("DiSEqCDevTree: ")
102 for (
const auto &item : table)
103 if (
type == item.value)
111 for (
const auto &item : table)
112 if (
type == item.name)
114 return table[0].value;
141 "SELECT diseqcid, value "
142 "FROM diseqc_config "
143 "WHERE cardinputid = :INPUTID");
145 query.
bindValue(
":INPUTID", card_input_id);
171 "DELETE from diseqc_config "
172 "WHERE cardinputid = :INPUTID");
173 query.
bindValue(
":INPUTID", card_input_id);
183 "INSERT INTO diseqc_config "
184 " ( cardinputid, diseqcid, value) "
185 "VALUES (:INPUTID, :DEVID, :VALUE) ");
189 query.
bindValue(
":INPUTID", card_input_id);
209 uint_to_dbl_t::const_iterator it =
m_config.find(devid);
272 cardid_to_diseqc_tree_t::iterator it =
m_trees.find(cardid);
321 "WHERE hostname = :HOSTNAME AND "
322 " videodevice = :VIDEODEVICE "
333 else if (query.
next())
335 cardid = query.
value(0).toUInt();
361 "SELECT diseqcid, cardtype, inputname "
363 "WHERE cardid = :CARDID");
370 else if (!query.
next())
375 if (query.
value(0).toBool())
378 *
this, query.
value(0).toUInt());
380 else if ((query.
value(1).toString().toUpper() ==
"DVB") &&
381 ((query.
value(2).toString().toUpper() ==
"DVB-S" ) ||
382 (query.
value(2).toString().toUpper() ==
"DVB-S2") ))
384 LOG(VB_GENERAL, LOG_WARNING,
LOC +
385 QString(
"No device tree for cardid %1").arg(cardid));
403 "WHERE cardid = :CARDID");
410 else if (query.
next())
412 if (query.
value(0).toUInt() > 0)
435 "DELETE FROM diseqc_tree "
436 "WHERE diseqcid = :DEVID");
438 "DELETE FROM diseqc_config "
439 "WHERE diseqcid = :DEVID");
463 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to save DiSEqC tree.");
469 "UPDATE capturecard "
470 "SET diseqcid = :DEVID "
471 "WHERE (hostname = :HOSTNAME AND "
472 " videodevice = :VIDEODEVICE) "
473 " OR cardid = :CARDID");
476 query0.
bindValue(
":VIDEODEVICE", device);
490 bool success =
false;
493 for (
uint retry = 0; !success && (retry < TIMEOUT_RETRIES); retry++)
496 on ? SEC_TONE_ON : SEC_TONE_OFF) == 0)
499 std::this_thread::sleep_for(TIMEOUT_WAIT);
504 LOG(VB_GENERAL, LOG_ERR,
LOC +
"FE_SET_TONE failed" +
ENO);
520 LOG(VB_GENERAL, LOG_ERR,
LOC +
"No root device tree node!");
561 for (
uint count = 0; node;)
565 if (rotor && (++count > index))
648static bool send_diseqc(
int fd,
const dvb_diseqc_master_cmd cmd)
650 bool success =
false;
652 for (
uint retry = 0; !success && (retry < TIMEOUT_RETRIES); retry++)
654 if (ioctl(fd, FE_DISEQC_SEND_MASTER_CMD, &cmd) == 0)
657 std::this_thread::sleep_for(TIMEOUT_WAIT);
662 LOG(VB_GENERAL, LOG_ERR,
LOC +
663 "send_diseqc FE_DISEQC_SEND_MASTER_CMD failed" +
ENO);
680 [[maybe_unused]]
uint cmd,
681 [[maybe_unused]]
uint repeats,
687 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Bad DiSEqC command");
697 bool resend_cmd =
false;
700 dvb_diseqc_master_cmd mcmd = {};
701 mcmd.msg[0] = DISEQC_FRM;
704 mcmd.msg_len = data.size() + 3;
711 for (
uint byte = 0;
byte < mcmd.msg_len;
byte++)
712 cmdstr += QString(
"%1 ").arg(mcmd.msg[
byte], 2, 16);
714 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"Sending DiSEqC Command: " + cmdstr);
718 repeats = repeats - 10;
723 for (
uint i = 0; i <= repeats; i++)
725 if (!send_diseqc(
GetFD(), mcmd))
727 LOG(VB_GENERAL, LOG_ERR,
LOC +
"DiSEqC command failed" +
ENO);
732 mcmd.msg[0] |= DISEQC_FRM_REPEAT;
756 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"Power-cycling DiSEqC Bus");
772 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"Resetting DiSEqC Bus");
775 LOG(VB_GENERAL, LOG_ERR,
LOC +
"DiSEqC reset failed" +
ENO);
784 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"Skipping reset: already done for this SCR bus");
816 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"Changing LNB voltage to " +
817 QString(
"%1V").arg(volts));
819 bool success =
false;
822 for (
uint retry = 0; !success && retry < TIMEOUT_RETRIES; retry++)
827 std::this_thread::sleep_for(TIMEOUT_WAIT);
833 LOG(VB_GENERAL, LOG_ERR,
LOC +
"FE_SET_VOLTAGE failed" +
ENO);
868 {
"switch", kTypeSwitch },
869 {
"rotor", kTypeRotor },
872 { QString(), kTypeLNB },
891 for (
uint ch = 0; !dev && ch < num_children; ch++)
911 "SELECT type, description "
913 "WHERE diseqcid = :DEVID");
923 LOG(VB_GENERAL, LOG_ERR,
LOC +
"CreateById failed to find dtv dev " +
924 QString(
"%1").arg(devid));
930 QString desc = query.
value(1).toString();
1059 {
"legacy_sw21", kTypeLegacySW21 },
1060 {
"legacy_sw42", kTypeLegacySW42 },
1061 {
"legacy_sw64", kTypeLegacySW64 },
1062 {
"tone", kTypeTone },
1063 {
"diseqc", kTypeDiSEqCCommitted },
1064 {
"diseqc_uncom", kTypeDiSEqCUncommitted },
1065 {
"voltage", kTypeVoltage },
1066 {
"mini_diseqc", kTypeMiniDiSEqC },
1067 { QString(), kTypeTone },
1090 bool success =
true;
1122 LOG(VB_GENERAL, LOG_ERR,
LOC +
1123 QString(
"Unknown switch type (%1)").arg((
uint)
m_type));
1130 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"Waiting for switch");
1139 success =
m_children[pos]->Execute(settings, tuning);
1215 voltage = child->
GetVoltage(settings, tuning);
1231 "SELECT subtype, address, switch_ports, cmd_repeat "
1233 "WHERE diseqcid = :DEVID");
1254 "SELECT diseqcid, ordinal "
1256 "WHERE parentid = :DEVID");
1264 while (query.
next())
1266 uint child_dev_id = query.
value(0).toUInt();
1269 if (child && !
SetChild(ordinal, child))
1271 LOG(VB_GENERAL, LOG_ERR,
LOC +
1272 QString(
"Switch port out of range (%1 > %2)")
1290 "UPDATE diseqc_tree "
1291 "SET parentid = :PARENT, "
1292 " ordinal = :ORDINAL, "
1293 " type = 'switch', "
1294 " description = :DESC, "
1295 " subtype = :TYPE, "
1296 " address = :ADDRESS, "
1297 " switch_ports = :PORTS, "
1298 " cmd_repeat = :REPEAT "
1299 "WHERE diseqcid = :DEVID");
1305 "INSERT INTO diseqc_tree"
1306 " ( parentid, ordinal, type, "
1307 " description, address, subtype, "
1308 " switch_ports, cmd_repeat ) "
1310 " (:PARENT, :ORDINAL, 'switch', "
1311 " :DESC, :ADDRESS, :TYPE, "
1312 " :PORTS, :REPEAT )");
1336 bool success =
true;
1340 success &= child->Store();
1350 if (old_num > num_ports)
1352 for (
uint ch = num_ports; ch < old_num; ch++)
1359 else if (old_num < num_ports)
1362 for (
uint ch = old_num; ch < num_ports; ch++)
1372 [[maybe_unused]]
uint pos)
1374#if CONFIG_DVB && defined(FE_DISHNETWORK_SEND_LEGACY_CMD)
1375 static const cmd_vec_t kSw21Cmds { 0x34, 0x65, };
1376 static const cmd_vec_t kSw42Cmds { 0x46, 0x17, };
1377 static const cmd_vec_t kSw64VCmds { 0x39, 0x4b, 0x0d, };
1378 static const cmd_vec_t kSw64HCmds { 0x1a, 0x5c, 0x2e, };
1381 unsigned char horizcmd = 0x00;
1384 bool horizontal =
false;
1411 LOG(VB_CHANNEL, LOG_INFO,
LOC +
1412 QString(
"Changing to Legacy switch port %1/%2")
1413 .arg(pos + 1).arg(cmds.size()));
1416 if (ioctl(
m_tree.
GetFD(), FE_DISHNETWORK_SEND_LEGACY_CMD,
1417 cmds[pos] | horizcmd) == -1)
1419 LOG(VB_GENERAL, LOG_ERR,
LOC +
1420 "FE_DISHNETWORK_SEND_LEGACY_CMD failed" +
ENO);
1429 LOG(VB_GENERAL, LOG_ERR,
LOC +
"You must compile with a newer "
1430 "version of the linux headers for DishNet Legacy switch support.");
1437static bool set_tone(
int fd, fe_sec_tone_mode tone)
1439 bool success =
false;
1441 for (
uint retry = 0; !success && (retry < TIMEOUT_RETRIES); retry++)
1443 if (ioctl(fd, FE_SET_TONE, tone) == 0)
1446 std::this_thread::sleep_for(TIMEOUT_WAIT);
1451 LOG(VB_GENERAL, LOG_ERR,
LOC +
"set_tone failed" +
ENO);
1459static bool set_voltage(
int fd, fe_sec_voltage volt)
1461 bool success =
false;
1463 for (
uint retry = 0; !success && (retry < TIMEOUT_RETRIES); retry++)
1465 if (0 == ioctl(fd, FE_SET_VOLTAGE, volt))
1468 std::this_thread::sleep_for(TIMEOUT_WAIT);
1473 LOG(VB_GENERAL, LOG_ERR,
LOC +
"FE_SET_VOLTAGE failed" +
ENO);
1481static bool mini_diseqc(
int fd, fe_sec_mini_cmd cmd)
1483 bool success =
false;
1485 for (
uint retry = 0; !success && (retry < TIMEOUT_RETRIES); retry++)
1487 if (ioctl(fd, FE_DISEQC_SEND_BURST, cmd) == 0)
1490 std::this_thread::sleep_for(TIMEOUT_WAIT);
1495 LOG(VB_GENERAL, LOG_ERR,
LOC +
1496 "mini_diseqc FE_DISEQC_SEND_BURST failed" +
ENO);
1508 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"Changing to Tone switch port " +
1509 QString(
"%1/2").arg(pos + 1));
1512 if (set_tone(
m_tree.
GetFD(), (0 == pos) ? SEC_TONE_OFF : SEC_TONE_ON))
1516 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Setting Tone Switch failed." +
ENO);
1525 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"Changing to Voltage Switch port " +
1526 QString(
"%1/2").arg(pos + 1));
1536 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Setting Voltage Switch failed." +
ENO);
1546 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"Changing to MiniDiSEqC Switch port " +
1547 QString(
"%1/2").arg(pos + 1));
1550 if (mini_diseqc(
m_tree.
GetFD(), (0 == pos) ? SEC_MINI_A : SEC_MINI_B))
1554 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Setting Mini DiSEqC Switch failed." +
ENO);
1570 bool high_band =
false;
1571 bool horizontal =
false;
1587 bool horizontal =
false;
1608 auto pos =
static_cast<uint8_t
>(pos32);
1610 bool high_band =
false;
1611 bool horizontal =
false;
1623 LOG(VB_GENERAL, LOG_ERR,
LOC +
1624 QString(
"Invalid number of ports for DiSEqC 1.x Switch (%1)")
1635 data[0] = ((pos << 2) | (horizontal ? 2 : 0) | (high_band ? 1 : 0));
1639 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"Changing to DiSEqC switch port " +
1640 QString(
"%1/%2").arg(pos + 1).arg(
m_numPorts));
1657 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Port %1 ").arg(pos + 1) +
1658 QString(
"is not in range [0..%1)").arg(
m_numPorts));
1665 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Port %1 ").arg(pos + 1) +
1666 "has no connected devices configured.");
1678 struct timeval curtime {};
1679 gettimeofday(&curtime,
nullptr);
1680 return (
double)curtime.tv_sec + (((double)curtime.tv_usec) / 1000000);
1689 {
"diseqc_1_2", kTypeDiSEqC_1_2 },
1690 {
"diseqc_1_3", kTypeDiSEqC_1_3 },
1691 {
nullptr, kTypeDiSEqC_1_3 }
1702 bool success =
true;
1717 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Unknown rotor type " +
1796 LOG(VB_CHANNEL, LOG_INFO,
LOC +
1797 "Overriding voltage to 18V for faster rotor movement");
1812 "SELECT subtype, rotor_positions, "
1813 " rotor_hi_speed, rotor_lo_speed, "
1816 "WHERE diseqcid = :DEVID");
1832 QString positions = query.
value(1).toString();
1833 QStringList pos = positions.split(
":", Qt::SkipEmptyParts);
1834 for (
const auto & kv : std::as_const(pos))
1836 const QStringList eq = kv.split(
"=", Qt::SkipEmptyParts);
1838 m_posmap[eq[0].toFloat()] = eq[1].toUInt();
1852 "WHERE parentid = :DEVID");
1862 uint child_dev_id = query.
value(0).toUInt();
1871 QString posmap =
"";
1878 dbl_to_uint_t::const_iterator it =
m_posmap.begin();
1880 pos.push_back(QString(
"%1=%2").arg(it.key()).arg(*it));
1882 posmap = pos.join(
":");
1891 "UPDATE diseqc_tree "
1892 "SET parentid = :PARENT, "
1893 " ordinal = :ORDINAL, "
1895 " description = :DESC, "
1896 " subtype = :TYPE, "
1897 " rotor_hi_speed = :HISPEED, "
1898 " rotor_lo_speed = :LOSPEED, "
1899 " rotor_positions = :POSMAP, "
1900 " cmd_repeat = :REPEAT "
1901 "WHERE diseqcid = :DEVID");
1907 "INSERT INTO diseqc_tree "
1908 " ( parentid, ordinal, type, "
1909 " description, subtype, rotor_hi_speed, "
1910 " rotor_lo_speed, rotor_positions, cmd_repeat ) "
1912 " (:PARENT, :ORDINAL, 'rotor', "
1913 " :DESC, :TYPE, :HISPEED, "
1914 " :LOSPEED, :POSMAP, :REPEAT )");
1959 double duration = change / speed;
1963 double completed = time_since_move / duration;
1988 dbl_to_uint_t::const_iterator it;
1990 inv_posmap[*it] = it.key();
1999 uint_to_dbl_t::const_iterator it;
2000 for (it = inv_posmap.begin(); it != inv_posmap.end(); ++it)
2009 dbl_to_uint_t::const_iterator it =
2011 cmd_vec_t index {
static_cast<uint8_t
>(angle) };
2018 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"Rotor - " +
2019 QString(
"Goto Stored Position %1").arg(index[0]));
2032 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"USALS Rotor - " +
2033 QString(
"Goto %1 (Azimuth %2)").arg(angle).arg(azimuth));
2035 uint az16 = (
uint) (abs(azimuth) * 16.0);
2037 static_cast<uint8_t
>(((azimuth > 0.0) ? 0xE0 : 0xD0) | ((az16 >> 8) & 0x0f)),
2038 static_cast<uint8_t
>(az16 & 0xff) };
2057 return TO_DEC * atan( tan(Us - Ue) / sin(P) );
2098 {
"A", kTypeScrPosA },
2099 {
"B", kTypeScrPosB },
2100 { QString(), kTypeScrPosA },
2120 LOG(VB_GENERAL, LOG_ERR,
LOC +
"SCR: No LNB for this configuration!");
2135 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"SCR: Userband ID=%1 is out of range (0-7)!")
2142 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"SCR: T=%1 is out of range!").arg(
t));
2146 LOG(VB_GENERAL, LOG_INFO, QString(
"SCR: Tuning to %1kHz, %2, %3 using UB=%4, FREQ=%5MHz, POS=%6%7")
2148 .arg(high_band ?
"HiBand" :
"LoBand",
2149 horizontal ?
"H" :
"V")
2152 .arg((scr_position) ?
"B" :
"A",
2154 QString(
", PIN=%1").arg(
m_scrPin) : QString(
"")));
2159 static_cast<uint8_t
>(
t & 0x00FF) };
2162 data[0] |= (1 << 2);
2165 data[0] |= (1 << 3);
2168 data[0] |= (1 << 4);
2181 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"SCR: Userband ID=%1 is out of range (0-7)!")
2186 LOG(VB_CHANNEL, LOG_INFO,
LOC + QString(
"SCR: Power off UB=%1%7")
2189 ? QString(
", PIN=%1").arg(
m_scrPin)
2203 [[maybe_unused]]
uint repeats,
2230 return (((
t + 350) * 4) * 1000) - frequency;
2238 "SELECT scr_userband, scr_frequency, "
2239 " scr_pin, cmd_repeat "
2241 "WHERE diseqcid = :DEVID");
2267 "WHERE parentid = :DEVID");
2277 uint child_dev_id = query.
value(0).toUInt();
2292 "UPDATE diseqc_tree "
2293 "SET parentid = :PARENT, "
2294 " ordinal = :ORDINAL, "
2296 " description = :DESC, "
2297 " scr_userband = :USERBAND, "
2298 " scr_frequency = :FREQUENCY, "
2300 " cmd_repeat = :REPEAT "
2301 "WHERE diseqcid = :DEVID");
2307 "INSERT INTO diseqc_tree"
2308 " ( parentid, ordinal, type, "
2309 " description, scr_userband, scr_frequency, "
2310 " scr_pin, cmd_repeat) "
2312 " (:PARENT, :ORDINAL, 'scr', "
2313 " :DESC, :USERBAND, :FREQUENCY,"
2314 " :PIN, :REPEAT) ");
2372 {
"fixed", kTypeFixed },
2373 {
"voltage", kTypeVoltageControl },
2374 {
"voltage_tone", kTypeVoltageAndToneControl },
2375 {
"bandstacked", kTypeBandstacked },
2376 { QString(), kTypeVoltageAndToneControl },
2407 "SELECT subtype, lnb_lof_switch, "
2408 " lnb_lof_hi, lnb_lof_lo, "
2409 " lnb_pol_inv, cmd_repeat "
2411 "WHERE diseqcid = :DEVID");
2441 "UPDATE diseqc_tree "
2442 "SET parentid = :PARENT, "
2443 " ordinal = :ORDINAL, "
2445 " description = :DESC, "
2446 " subtype = :TYPE, "
2447 " lnb_lof_switch = :LOFSW, "
2448 " lnb_lof_lo = :LOFLO, "
2449 " lnb_lof_hi = :LOFHI, "
2450 " lnb_pol_inv = :POLINV, "
2451 " cmd_repeat = :REPEAT "
2452 "WHERE diseqcid = :DEVID");
2458 "INSERT INTO diseqc_tree"
2459 " ( parentid, ordinal, type, "
2460 " description, subtype, lnb_lof_switch, "
2461 " lnb_lof_lo, lnb_lof_hi, lnb_pol_inv, "
2464 " (:PARENT, :ORDINAL, 'lnb', "
2465 " :DESC, :TYPE, :LOFSW, "
2466 " :LOFLO, :LOFHI, :POLINV, "
2540 return (lof > abs_freq) ? (lof - abs_freq) : (abs_freq - lof);
Represents a node in a DVB-S device network.
uint GetDeviceID(void) const
std::vector< TypeTable > TypeTableVec
virtual void Reset(void)
Resets to the last known settings for this device.
bool IsRealDeviceID(void) const
virtual bool Store(void) const =0
Stores this device to the database.
virtual uint GetChildCount(void) const
Retrieves the proper number of children for this node.
virtual DiSEqCDevDevice * GetSelectedChild(const DiSEqCDevSettings &) const
Retrieves the selected child for this configuration, if any.
virtual DiSEqCDevDevice * GetChild(uint)
Retrieves the nth child of this node.
static DiSEqCDevDevice * CreateById(DiSEqCDevTree &tree, uint devid)
virtual bool Execute(const DiSEqCDevSettings &, const DTVMultiplex &)=0
Applies DiSEqC settings to this node and any children.
QString GetDescription(void) const
void SetDescription(const QString &desc)
void SetParent(DiSEqCDevDevice *parent)
virtual uint GetVoltage(const DiSEqCDevSettings &, const DTVMultiplex &) const =0
Retrives the desired voltage for this config.
void SetOrdinal(uint ordinal)
static QString TableToString(uint type, const TypeTableVec &table)
void SetDeviceID(uint devid) const
virtual ~DiSEqCDevDevice()
static DiSEqCDevDevice * CreateByType(DiSEqCDevTree &tree, dvbdev_t type, uint dev_id=0)
DiSEqCDevDevice * FindDevice(uint dev_id)
Returns a device by ID.
virtual bool Load(void)=0
Loads this device from the database.
void SetDeviceType(dvbdev_t type)
static const TypeTableVec kDvbdevLookup
static uint TableFromString(const QString &type, const TypeTableVec &table)
DiSEqCDevDevice * m_parent
dvbdev_t GetDeviceType(void) const
virtual bool IsCommandNeeded(const DiSEqCDevSettings &, const DTVMultiplex &) const
Determines if this device or any child will be sending a command for the given configuration chain.
static dvbdev_t DevTypeFromString(const QString &type)
static dvbdev_lnb_t LNBTypeFromString(const QString &type)
bool IsHighBand(const DTVMultiplex &tuning) const
Determine if the high frequency band is active (for switchable LNBs).
bool IsPolarityInverted(void) const
uint32_t GetIntermediateFrequency(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning) const
Calculate proper intermediate frequency for the given settings and tuning parameters.
bool Store(void) const override
Stores this device to the database.
@ kTypeVoltageAndToneControl
static QString LNBTypeToString(dvbdev_lnb_t type)
bool Execute(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning) override
Applies DiSEqC settings to this node and any children.
bool Load(void) override
Loads this device from the database.
static const TypeTableVec kLNBTypeTable
bool m_polInv
If a signal is circularly polarized the polarity will flip on each reflection, so antenna systems wit...
bool IsHorizontal(const DTVMultiplex &tuning) const
Determine if horizontal polarity is active (for switchable LNBs).
uint GetVoltage(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning) const override
Retrives the desired voltage for this config.
void StartRotorPositionTracking(double azimuth)
bool ExecuteUSALS(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning, double angle)
static dvbdev_rotor_t RotorTypeFromString(const QString &type)
uint_to_dbl_t GetPosMap(void) const
double GetProgress(void) const
Returns an indication of rotor progress.
uint GetVoltage(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning) const override
Retrives the desired voltage for this config.
bool SetChild(uint ordinal, DiSEqCDevDevice *device) override
Changes the nth child of this node.
bool ExecuteRotor(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning, double angle)
~DiSEqCDevRotor() override
bool IsMoving(const DiSEqCDevSettings &settings) const
static const TypeTableVec kRotorTypeTable
static double CalculateAzimuth(double angle)
bool Store(void) const override
Stores this device to the database.
bool IsCommandNeeded(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning) const override
Determines if this device or any child will be sending a command for the given configuration chain.
bool Execute(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning) override
Applies DiSEqC settings to this node and any children.
void SetPosMap(const uint_to_dbl_t &posmap)
void RotationComplete(void) const
bool IsPositionKnown(void) const
Returns true if there is reasonable confidence in the value returned by GetProgress().
DiSEqCDevDevice * m_child
static QString RotorTypeToString(dvbdev_rotor_t type)
bool Load(void) override
Loads this device from the database.
double GetApproxAzimuth(void) const
void Reset(void) override
Resets to the last known settings for this device.
DiSEqCDevDevice * GetSelectedChild(const DiSEqCDevSettings &setting) const override
Retrieves the selected child for this configuration, if any.
bool SendCommand(uint cmd, uint repeats, cmd_vec_t &data) const
uint32_t GetIntermediateFrequency(uint32_t frequency) const
uint GetVoltage(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning) const override
Retrives the desired voltage for this config.
bool PowerOff(void) const
DiSEqCDevDevice * m_child
void Reset(void) override
Resets to the last known settings for this device.
bool Store(void) const override
Stores this device to the database.
bool SetChild(uint ordinal, DiSEqCDevDevice *device) override
Changes the nth child of this node.
bool Load(void) override
Loads this device from the database.
static const TypeTableVec kSCRPositionTable
bool Execute(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning) override
Applies DiSEqC settings to this node and any children.
DVB-S device settings class.
double GetValue(uint devid) const
Retrieves a value from this configuration chain by device id.
void SetValue(uint devid, double value)
Sets a value for this configuration chain by device id.
bool Store(uint card_input_id) const
Stores configuration chain to DB for specified card input id.
bool Load(uint card_input_id)
Loads configuration chain from DB for specified card input id.
uint m_inputId
current input id
Switch class, including tone, legacy and DiSEqC switches.
static QString SwitchTypeToString(dvbdev_switch_t type)
DiSEqCDevDevice * GetChild(uint ordinal) override
Retrieves the nth child of this node.
DiSEqCDevSwitch(DiSEqCDevTree &tree, uint devid)
DiSEqCDevDevice * GetSelectedChild(const DiSEqCDevSettings &settings) const override
Retrieves the selected child for this configuration, if any.
bool SetChild(uint ordinal, DiSEqCDevDevice *device) override
Changes the nth child of this node.
bool ShouldSwitch(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning) const
bool IsCommandNeeded(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning) const override
Determines if this device or any child will be sending a command for the given configuration chain.
bool Execute(const DiSEqCDevSettings &, const DTVMultiplex &) override
Applies DiSEqC settings to this node and any children.
int GetPosition(const DiSEqCDevSettings &settings) const
static const TypeTableVec kSwitchTypeTable
uint GetChildCount(void) const override
Retrieves the proper number of children for this node.
bool ExecuteTone(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning, uint pos)
bool ExecuteLegacy(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning, uint pos)
void SetNumPorts(uint num_ports)
bool Store(void) const override
Stores this device to the database.
static dvbdev_switch_t SwitchTypeFromString(const QString &type)
~DiSEqCDevSwitch() override
bool Load(void) override
Loads this device from the database.
bool ExecuteMiniDiSEqC(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning, uint pos)
void Reset(void) override
Resets to the last known settings for this device.
bool ExecuteDiseqc(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning, uint pos)
bool ExecuteVoltage(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning, uint pos)
uint GetVoltage(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning) const override
Retrives the desired voltage for this config.
uint GetVoltage(void) const
bool Execute(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning)
Applies settings to the entire tree.
bool Load(const QString &device)
Loads the device tree from the database.
void AddDeferredDelete(uint dev_id)
void SetRoot(DiSEqCDevDevice *root)
Changes the root node of the tree.
DiSEqCDevDevice * FindDevice(uint dev_id)
Returns a device by ID.
uint CreateFakeDiSEqCID(void)
void Reset(void)
Reset state of nodes in tree, forcing updates on the next Execute command.
static const uint kFirstFakeDiSEqCID
bool Store(uint cardid, const QString &device="")
Stores the device tree to the database.
bool ResetDiseqc(bool hard_reset, bool is_SCR)
Resets the DiSEqC bus.
DiSEqCDevSCR * FindSCR(const DiSEqCDevSettings &settings)
Returns the SCR device object selected by the configuration chain.
DiSEqCDevLNB * FindLNB(const DiSEqCDevSettings &settings)
Returns the LNB device object selected by the configuration chain.
DiSEqCDevRotor * FindRotor(const DiSEqCDevSettings &settings, uint index=0)
Returns the nth rotor device object in the tree.
bool SendCommand(uint adr, uint cmd, uint repeats, cmd_vec_t &data) const
static bool Exists(int cardid)
Check if a Diseqc device tree exists.
bool SetVoltage(uint voltage)
bool SetTone(bool on) const
bool ApplyVoltage(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning)
std::vector< uint > m_delete
bool IsInNeedOfConf(void) const
void Open(int fd_frontend, bool is_SCR)
Retrieve device tree.
Static-scoped locked tree list class.
DiSEqCDevTree * FindTree(uint cardid)
Retrieve device tree.
void InvalidateTrees(void)
Invalidate cached trees.
cardid_to_diseqc_tree_t m_trees
static DiSEqCDevTree * FindTree(uint cardid)
Retrieve device tree.
static void InvalidateTrees(void)
Invalidate cached trees.
static DiSEqCDevTrees s_trees
QSqlQuery wrapper that fetches a DB connection from the connection pool.
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
QVariant value(int i) const
bool isActive(void) const
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
QVariant lastInsertId()
Return the id of the last inserted row.
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
QString GetHostName(void)
QString GetSetting(const QString &key, const QString &defaultval="")
static void DBError(const QString &where, const MSqlQuery &query)
static constexpr std::chrono::milliseconds DISEQC_POWER_ON_WAIT
static constexpr std::chrono::milliseconds DISEQC_SHORT_WAIT
static constexpr double EPS
bool diseqc_bus_already_reset
static constexpr uint8_t SEC_VOLTAGE_18
static constexpr uint8_t SEC_VOLTAGE_OFF
static constexpr uint8_t SEC_VOLTAGE_13
static constexpr double TO_DEC
static double GetCurTimeFloating(void)
static constexpr std::chrono::milliseconds DISEQC_LONG_WAIT
static constexpr std::chrono::milliseconds DISEQC_POWER_OFF_WAIT
static constexpr double TO_RADS
std::vector< uint8_t > cmd_vec_t
QMap< uint, double > uint_to_dbl_t
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
#define ENO
This can be appended to the LOG args with "+".
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
MBASE_PUBLIC long long copy(QFile &dst, QFile &src, uint block_size=0)
Copies src file to dst file.