Go to the documentation of this file.
30 static constexpr uint8_t SEC_VOLTAGE_13 { 0 };
31 static constexpr uint8_t SEC_VOLTAGE_18 { 1 };
32 static constexpr uint8_t SEC_VOLTAGE_OFF { 2 };
91 static constexpr
double EPS { 1E-4 };
93 #define LOC QString("DiSEqCDevTree: ")
99 for (
const auto &item : table)
100 if (
type == item.value)
108 for (
const auto &item : table)
109 if (
type == item.name)
111 return table[0].value;
138 "SELECT diseqcid, value "
139 "FROM diseqc_config "
140 "WHERE cardinputid = :INPUTID");
142 query.
bindValue(
":INPUTID", card_input_id);
168 "DELETE from diseqc_config "
169 "WHERE cardinputid = :INPUTID");
170 query.
bindValue(
":INPUTID", card_input_id);
180 "INSERT INTO diseqc_config "
181 " ( cardinputid, diseqcid, value) "
182 "VALUES (:INPUTID, :DEVID, :VALUE) ");
186 query.
bindValue(
":INPUTID", card_input_id);
206 uint_to_dbl_t::const_iterator it =
m_config.find(devid);
269 cardid_to_diseqc_tree_t::iterator it =
m_trees.find(cardid);
318 "WHERE hostname = :HOSTNAME AND "
319 " videodevice = :VIDEODEVICE "
330 else if (query.
next())
332 cardid = query.
value(0).toUInt();
358 "SELECT diseqcid, cardtype, inputname "
360 "WHERE cardid = :CARDID");
367 else if (!query.
next())
372 if (query.
value(0).toBool())
375 *
this, query.
value(0).toUInt());
377 else if ((query.
value(1).toString().toUpper() ==
"DVB") &&
378 ((query.
value(2).toString().toUpper() ==
"DVB-S" ) ||
379 (query.
value(2).toString().toUpper() ==
"DVB-S2") ))
381 LOG(VB_GENERAL, LOG_WARNING,
LOC +
382 QString(
"No device tree for cardid %1").arg(cardid));
400 "WHERE cardid = :CARDID");
407 else if (query.
next())
409 if (query.
value(0).toUInt() > 0)
432 "DELETE FROM diseqc_tree "
433 "WHERE diseqcid = :DEVID");
435 "DELETE FROM diseqc_config "
436 "WHERE diseqcid = :DEVID");
458 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to save DiSEqC tree.");
464 "UPDATE capturecard "
465 "SET diseqcid = :DEVID "
466 "WHERE (hostname = :HOSTNAME AND "
467 " videodevice = :VIDEODEVICE) "
468 " OR cardid = :CARDID");
471 query0.
bindValue(
":VIDEODEVICE", device);
484 bool success =
false;
490 on ? SEC_TONE_ON : SEC_TONE_OFF) == 0)
498 LOG(VB_GENERAL, LOG_ERR,
LOC +
"FE_SET_TONE failed" +
ENO);
514 LOG(VB_GENERAL, LOG_ERR,
LOC +
"No root device tree node!");
555 for (
uint count = 0; node;)
559 if (rotor && (++count > index))
644 bool success =
false;
648 if (ioctl(fd, FE_DISEQC_SEND_MASTER_CMD, &cmd) == 0)
656 LOG(VB_GENERAL, LOG_ERR,
LOC +
657 "send_diseqc FE_DISEQC_SEND_MASTER_CMD failed" +
ENO);
673 [[maybe_unused]]
uint cmd,
674 [[maybe_unused]]
uint repeats,
680 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Bad DiSEqC command");
688 #else // if USING_DVB
690 bool resend_cmd =
false;
693 dvb_diseqc_master_cmd mcmd = {};
697 mcmd.msg_len = data.size() + 3;
700 std::copy(data.cbegin(), data.cend(), mcmd.msg + 3);
704 for (
uint byte = 0;
byte < mcmd.msg_len;
byte++)
705 cmdstr += QString(
"%1 ").arg(mcmd.msg[
byte], 2, 16);
707 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"Sending DiSEqC Command: " + cmdstr);
711 repeats = repeats - 10;
716 for (
uint i = 0; i <= repeats; i++)
720 LOG(VB_GENERAL, LOG_ERR,
LOC +
"DiSEqC command failed" +
ENO);
749 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"Power-cycling DiSEqC Bus");
765 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"Resetting DiSEqC Bus");
768 LOG(VB_GENERAL, LOG_ERR,
LOC +
"DiSEqC reset failed" +
ENO);
777 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"Skipping reset: already done for this SCR bus");
803 int volts = ((voltage == SEC_VOLTAGE_18) ? 18 :
804 ((voltage == SEC_VOLTAGE_13) ? 13 : 0));
806 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"Changing LNB voltage to " +
807 QString(
"%1V").arg(volts));
809 bool success =
false;
823 LOG(VB_GENERAL, LOG_ERR,
LOC +
"FE_SET_VOLTAGE failed" +
ENO);
842 uint voltage = SEC_VOLTAGE_18;
858 {
"switch", kTypeSwitch },
859 {
"rotor", kTypeRotor },
862 { QString(), kTypeLNB },
881 for (
uint ch = 0; !dev && ch < num_children; ch++)
901 "SELECT type, description "
903 "WHERE diseqcid = :DEVID");
913 LOG(VB_GENERAL, LOG_ERR,
LOC +
"CreateById failed to find dtv dev " +
914 QString(
"%1").arg(devid));
920 QString desc = query.
value(1).toString();
1049 {
"legacy_sw21", kTypeLegacySW21 },
1050 {
"legacy_sw42", kTypeLegacySW42 },
1051 {
"legacy_sw64", kTypeLegacySW64 },
1052 {
"tone", kTypeTone },
1053 {
"diseqc", kTypeDiSEqCCommitted },
1054 {
"diseqc_uncom", kTypeDiSEqCUncommitted },
1055 {
"voltage", kTypeVoltage },
1056 {
"mini_diseqc", kTypeMiniDiSEqC },
1057 { QString(), kTypeTone },
1080 bool success =
true;
1112 LOG(VB_GENERAL, LOG_ERR,
LOC +
1113 QString(
"Unknown switch type (%1)").arg((
uint)
m_type));
1120 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"Waiting for switch");
1129 success =
m_children[pos]->Execute(settings, tuning);
1201 uint voltage = SEC_VOLTAGE_18;
1205 voltage = child->
GetVoltage(settings, tuning);
1221 "SELECT subtype, address, switch_ports, cmd_repeat "
1223 "WHERE diseqcid = :DEVID");
1244 "SELECT diseqcid, ordinal "
1246 "WHERE parentid = :DEVID");
1254 while (query.
next())
1256 uint child_dev_id = query.
value(0).toUInt();
1259 if (child && !
SetChild(ordinal, child))
1261 LOG(VB_GENERAL, LOG_ERR,
LOC +
1262 QString(
"Switch port out of range (%1 > %2)")
1280 "UPDATE diseqc_tree "
1281 "SET parentid = :PARENT, "
1282 " ordinal = :ORDINAL, "
1283 " type = 'switch', "
1284 " description = :DESC, "
1285 " subtype = :TYPE, "
1286 " address = :ADDRESS, "
1287 " switch_ports = :PORTS, "
1288 " cmd_repeat = :REPEAT "
1289 "WHERE diseqcid = :DEVID");
1295 "INSERT INTO diseqc_tree"
1296 " ( parentid, ordinal, type, "
1297 " description, address, subtype, "
1298 " switch_ports, cmd_repeat ) "
1300 " (:PARENT, :ORDINAL, 'switch', "
1301 " :DESC, :ADDRESS, :TYPE, "
1302 " :PORTS, :REPEAT )");
1326 bool success =
true;
1330 success &= child->Store();
1340 if (old_num > num_ports)
1342 for (
uint ch = num_ports; ch < old_num; ch++)
1349 else if (old_num < num_ports)
1352 for (
uint ch = old_num; ch < num_ports; ch++)
1361 [[maybe_unused]]
uint pos)
1363 #if defined(USING_DVB) && defined(FE_DISHNETWORK_SEND_LEGACY_CMD)
1364 static const cmd_vec_t kSw21Cmds { 0x34, 0x65, };
1365 static const cmd_vec_t kSw42Cmds { 0x46, 0x17, };
1366 static const cmd_vec_t kSw64VCmds { 0x39, 0x4b, 0x0d, };
1367 static const cmd_vec_t kSw64HCmds { 0x1a, 0x5c, 0x2e, };
1370 unsigned char horizcmd = 0x00;
1373 bool horizontal =
false;
1400 LOG(VB_CHANNEL, LOG_INFO,
LOC +
1401 QString(
"Changing to Legacy switch port %1/%2")
1402 .arg(pos + 1).arg(cmds.size()));
1405 if (ioctl(
m_tree.
GetFD(), FE_DISHNETWORK_SEND_LEGACY_CMD,
1406 cmds[pos] | horizcmd) == -1)
1408 LOG(VB_GENERAL, LOG_ERR,
LOC +
1409 "FE_DISHNETWORK_SEND_LEGACY_CMD failed" +
ENO);
1416 #else // !FE_DISHNETWORK_SEND_LEGACY_CMD
1418 LOG(VB_GENERAL, LOG_ERR,
LOC +
"You must compile with a newer "
1419 "version of the linux headers for DishNet Legacy switch support.");
1422 #endif // !FE_DISHNETWORK_SEND_LEGACY_CMD
1428 bool success =
false;
1432 if (ioctl(fd, FE_SET_TONE, tone) == 0)
1440 LOG(VB_GENERAL, LOG_ERR,
LOC +
"set_tone failed" +
ENO);
1450 bool success =
false;
1454 if (0 == ioctl(fd, FE_SET_VOLTAGE, volt))
1462 LOG(VB_GENERAL, LOG_ERR,
LOC +
"FE_SET_VOLTAGE failed" +
ENO);
1472 bool success =
false;
1476 if (ioctl(fd, FE_DISEQC_SEND_BURST, cmd) == 0)
1484 LOG(VB_GENERAL, LOG_ERR,
LOC +
1485 "mini_diseqc FE_DISEQC_SEND_BURST failed" +
ENO);
1496 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"Changing to Tone switch port " +
1497 QString(
"%1/2").arg(pos + 1));
1504 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Setting Tone Switch failed." +
ENO);
1512 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"Changing to Voltage Switch port " +
1513 QString(
"%1/2").arg(pos + 1));
1517 (0 == pos) ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18))
1523 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Setting Voltage Switch failed." +
ENO);
1532 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"Changing to MiniDiSEqC Switch port " +
1533 QString(
"%1/2").arg(pos + 1));
1540 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Setting Mini DiSEqC Switch failed." +
ENO);
1556 bool high_band =
false;
1557 bool horizontal =
false;
1573 bool horizontal =
false;
1592 auto pos =
static_cast<uint8_t
>(pos32);
1594 bool high_band =
false;
1595 bool horizontal =
false;
1607 LOG(VB_GENERAL, LOG_ERR,
LOC +
1608 QString(
"Invalid number of ports for DiSEqC 1.x Switch (%1)")
1619 data[0] = ((pos << 2) | (horizontal ? 2 : 0) | (high_band ? 1 : 0));
1623 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"Changing to DiSEqC switch port " +
1624 QString(
"%1/%2").arg(pos + 1).arg(
m_numPorts));
1641 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Port %1 ").arg(pos + 1) +
1642 QString(
"is not in range [0..%1)").arg(
m_numPorts));
1649 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Port %1 ").arg(pos + 1) +
1650 "has no connected devices configured.");
1662 struct timeval curtime {};
1663 gettimeofday(&curtime,
nullptr);
1664 return (
double)curtime.tv_sec + (((double)curtime.tv_usec) / 1000000);
1673 {
"diseqc_1_2", kTypeDiSEqC_1_2 },
1674 {
"diseqc_1_3", kTypeDiSEqC_1_3 },
1675 {
nullptr, kTypeDiSEqC_1_3 }
1686 bool success =
true;
1701 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Unknown rotor type " +
1780 LOG(VB_CHANNEL, LOG_INFO,
LOC +
1781 "Overriding voltage to 18V for faster rotor movement");
1788 return SEC_VOLTAGE_18;
1796 "SELECT subtype, rotor_positions, "
1797 " rotor_hi_speed, rotor_lo_speed, "
1800 "WHERE diseqcid = :DEVID");
1816 QString positions = query.
value(1).toString();
1817 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
1818 QStringList pos = positions.split(
":", QString::SkipEmptyParts);
1820 QStringList pos = positions.split(
":", Qt::SkipEmptyParts);
1822 for (
const auto & kv : qAsConst(pos))
1824 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
1825 const QStringList eq = kv.split(
"=", QString::SkipEmptyParts);
1827 const QStringList eq = kv.split(
"=", Qt::SkipEmptyParts);
1830 m_posmap[eq[0].toFloat()] = eq[1].toUInt();
1844 "WHERE parentid = :DEVID");
1854 uint child_dev_id = query.
value(0).toUInt();
1863 QString posmap =
"";
1870 dbl_to_uint_t::const_iterator it =
m_posmap.begin();
1872 pos.push_back(QString(
"%1=%2").arg(it.key()).arg(*it));
1874 posmap = pos.join(
":");
1883 "UPDATE diseqc_tree "
1884 "SET parentid = :PARENT, "
1885 " ordinal = :ORDINAL, "
1887 " description = :DESC, "
1888 " subtype = :TYPE, "
1889 " rotor_hi_speed = :HISPEED, "
1890 " rotor_lo_speed = :LOSPEED, "
1891 " rotor_positions = :POSMAP, "
1892 " cmd_repeat = :REPEAT "
1893 "WHERE diseqcid = :DEVID");
1899 "INSERT INTO diseqc_tree "
1900 " ( parentid, ordinal, type, "
1901 " description, subtype, rotor_hi_speed, "
1902 " rotor_lo_speed, rotor_positions, cmd_repeat ) "
1904 " (:PARENT, :ORDINAL, 'rotor', "
1905 " :DESC, :TYPE, :HISPEED, "
1906 " :LOSPEED, :POSMAP, :REPEAT )");
1951 double duration = change / speed;
1955 double completed = time_since_move / duration;
1980 dbl_to_uint_t::const_iterator it;
1982 inv_posmap[*it] = it.key();
1991 uint_to_dbl_t::const_iterator it;
1992 for (it = inv_posmap.begin(); it != inv_posmap.end(); ++it)
2001 dbl_to_uint_t::const_iterator it =
2003 cmd_vec_t index {
static_cast<uint8_t
>(angle) };
2010 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"Rotor - " +
2011 QString(
"Goto Stored Position %1").arg(index[0]));
2024 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"USALS Rotor - " +
2025 QString(
"Goto %1 (Azimuth %2)").arg(angle).arg(azimuth));
2027 uint az16 = (
uint) (abs(azimuth) * 16.0);
2029 static_cast<uint8_t
>(((azimuth > 0.0) ? 0xE0 : 0xD0) | ((az16 >> 8) & 0x0f)),
2030 static_cast<uint8_t
>(az16 & 0xff) };
2049 return TO_DEC * atan( tan(Us - Ue) / sin(P) );
2090 {
"A", kTypeScrPosA },
2091 {
"B", kTypeScrPosB },
2092 { QString(), kTypeScrPosA },
2112 LOG(VB_GENERAL, LOG_ERR,
LOC +
"SCR: No LNB for this configuration!");
2127 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"SCR: Userband ID=%1 is out of range (0-7)!")
2134 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"SCR: T=%1 is out of range!").arg(
t));
2138 LOG(VB_GENERAL, LOG_INFO, QString(
"SCR: Tuning to %1kHz, %2, %3 using UB=%4, FREQ=%5MHz, POS=%6%7")
2140 .arg(high_band ?
"HiBand" :
"LoBand",
2141 horizontal ?
"H" :
"V")
2144 .arg((scr_position) ?
"B" :
"A",
2146 QString(
", PIN=%1").arg(
m_scrPin) : QString(
"")));
2151 static_cast<uint8_t
>(
t & 0x00FF) };
2154 data[0] |= (1 << 2);
2157 data[0] |= (1 << 3);
2160 data[0] |= (1 << 4);
2173 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"SCR: Userband ID=%1 is out of range (0-7)!")
2178 LOG(VB_CHANNEL, LOG_INFO,
LOC + QString(
"SCR: Power off UB=%1%7")
2181 ? QString(
", PIN=%1").arg(
m_scrPin)
2195 [[maybe_unused]]
uint repeats,
2216 return SEC_VOLTAGE_13;
2222 return ((
t + 350) * 4) * 1000 - frequency;
2230 "SELECT scr_userband, scr_frequency, "
2231 " scr_pin, cmd_repeat "
2233 "WHERE diseqcid = :DEVID");
2259 "WHERE parentid = :DEVID");
2269 uint child_dev_id = query.
value(0).toUInt();
2284 "UPDATE diseqc_tree "
2285 "SET parentid = :PARENT, "
2286 " ordinal = :ORDINAL, "
2288 " description = :DESC, "
2289 " scr_userband = :USERBAND, "
2290 " scr_frequency = :FREQUENCY, "
2292 " cmd_repeat = :REPEAT "
2293 "WHERE diseqcid = :DEVID");
2299 "INSERT INTO diseqc_tree"
2300 " ( parentid, ordinal, type, "
2301 " description, scr_userband, scr_frequency, "
2302 " scr_pin, cmd_repeat) "
2304 " (:PARENT, :ORDINAL, 'scr', "
2305 " :DESC, :USERBAND, :FREQUENCY,"
2306 " :PIN, :REPEAT) ");
2364 {
"fixed", kTypeFixed },
2365 {
"voltage", kTypeVoltageControl },
2366 {
"voltage_tone", kTypeVoltageAndToneControl },
2367 {
"bandstacked", kTypeBandstacked },
2368 { QString(), kTypeVoltageAndToneControl },
2383 uint voltage = SEC_VOLTAGE_18;
2388 voltage = (
IsHorizontal(tuning) ? SEC_VOLTAGE_18 : SEC_VOLTAGE_13);
2399 "SELECT subtype, lnb_lof_switch, "
2400 " lnb_lof_hi, lnb_lof_lo, "
2401 " lnb_pol_inv, cmd_repeat "
2403 "WHERE diseqcid = :DEVID");
2433 "UPDATE diseqc_tree "
2434 "SET parentid = :PARENT, "
2435 " ordinal = :ORDINAL, "
2437 " description = :DESC, "
2438 " subtype = :TYPE, "
2439 " lnb_lof_switch = :LOFSW, "
2440 " lnb_lof_lo = :LOFLO, "
2441 " lnb_lof_hi = :LOFHI, "
2442 " lnb_pol_inv = :POLINV, "
2443 " cmd_repeat = :REPEAT "
2444 "WHERE diseqcid = :DEVID");
2450 "INSERT INTO diseqc_tree"
2451 " ( parentid, ordinal, type, "
2452 " description, subtype, lnb_lof_switch, "
2453 " lnb_lof_lo, lnb_lof_hi, lnb_pol_inv, "
2456 " (:PARENT, :ORDINAL, 'lnb', "
2457 " :DESC, :TYPE, :LOFSW, "
2458 " :LOFLO, :LOFHI, :POLINV, "
2532 return (lof > abs_freq) ? (lof - abs_freq) : (abs_freq - lof);
static QString SwitchTypeToString(dvbdev_switch_t type)
bool isActive(void) 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 next(void)
Wrap QSqlQuery::next() so we can display the query results.
QSqlQuery wrapper that fetches a DB connection from the connection pool.
virtual uint GetChildCount(void) const
Retrieves the proper number of children for this node.
bool Store(void) const override
bool IsInNeedOfConf(void) const
#define ENO
This can be appended to the LOG args with "+".
static dvbdev_switch_t SwitchTypeFromString(const QString &type)
DiSEqCDevDevice * FindDevice(uint dev_id)
uint32_t GetIntermediateFrequency(uint32_t frequency) const
static const TypeTableVec kSwitchTypeTable
static constexpr useconds_t DISEQC_LONG_WAIT
double GetValue(uint devid) const
Retrieves a value from this configuration chain by device id.
~DiSEqCDevRotor() override
static dvbdev_lnb_t LNBTypeFromString(const QString &type)
void SetDeviceID(uint devid) const
uint GetVoltage(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning) const override
Retrives the desired voltage for this config.
static bool set_tone(int fd, fe_sec_tone_mode tone)
std::vector< uint > m_delete
bool SetChild(uint ordinal, DiSEqCDevDevice *device) override
Changes the nth child of this node.
static constexpr uint8_t DISEQC_FRM_REPEAT
static const TypeTableVec kLNBTypeTable
bool SendCommand(uint adr, uint cmd, uint repeats, cmd_vec_t &data) const
void SetValue(uint devid, double value)
Sets a value for this configuration chain by device id.
QString GetDescription(void) const
QVariant lastInsertId()
Return the id of the last inserted row.
bool SendCommand(uint cmd, uint repeats, cmd_vec_t &data) const
bool Execute(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning)
Applies settings to the entire tree.
QVariant value(int i) const
static QString RotorTypeToString(dvbdev_rotor_t type)
DiSEqCDevDevice * GetChild(uint ordinal) override
Retrieves the nth child of this node.
void SetPosMap(const uint_to_dbl_t &posmap)
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
bool SetTone(bool on) const
bool Execute(const DiSEqCDevSettings &, const DTVMultiplex &) override
Applies DiSEqC settings to this node and any children.
DiSEqCDevDevice * m_child
Static-scoped locked tree list class.
static const TypeTableVec kRotorTypeTable
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Represents a node in a DVB-S device network.
virtual uint GetVoltage(const DiSEqCDevSettings &, const DTVMultiplex &) const =0
Retrives the desired voltage for this config.
static constexpr uint8_t DISEQC_FRM
bool Load(uint card_input_id)
Loads configuration chain from DB for specified card input id.
void Reset(void) override
Resets to the last known settings for this device.
bool Store(void) const override
int GetPosition(const DiSEqCDevSettings &settings) const
static constexpr useconds_t TIMEOUT_WAIT
static bool Exists(int cardid)
Check if a Diseqc device tree exists.
bool SetChild(uint ordinal, DiSEqCDevDevice *device) override
Changes the nth child of this node.
void Open(int fd_frontend, bool is_SCR)
Retrieve device tree.
uint m_inputId
current input id
virtual void Reset(void)
Resets to the last known settings for this device.
bool ExecuteTone(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning, uint pos)
static constexpr double TO_DEC
bool ExecuteRotor(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning, double angle)
DVB-S device settings class.
static const uint kFirstFakeDiSEqCID
dvbdev_t GetDeviceType(void) const
double GetProgress(void) const
Returns an indication of rotor progress.
std::vector< uint8_t > cmd_vec_t
static double CalculateAzimuth(double angle)
uint GetChildCount(void) const override
Retrieves the proper number of children for this node.
static QString TableToString(uint type, const TypeTableVec &table)
bool IsPolarityInverted(void) const
bool Store(void) const override
static const TypeTableVec kSCRPositionTable
static double GetCurTimeFloating(void)
bool ApplyVoltage(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning)
bool m_polInv
If a signal is circularly polarized the polarity will flip on each reflection, so antenna systems wit...
bool ExecuteMiniDiSEqC(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning, uint pos)
bool Store(void) const override
MBASE_PUBLIC long long copy(QFile &dst, QFile &src, uint block_size=0)
Copies src file to dst file.
static uint TableFromString(const QString &type, const TypeTableVec &table)
bool SetVoltage(uint voltage)
void SetDeviceType(dvbdev_t type)
bool Load(void) override
Loads this device from the database.
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
std::vector< TypeTable > TypeTableVec
virtual bool Load(void)=0
Loads this device from the database.
static void DBError(const QString &where, const MSqlQuery &query)
bool IsPositionKnown(void) const
Returns true if there is reasonable confidence in the value returned by GetProgress().
static bool send_diseqc(int fd, const dvb_diseqc_master_cmd cmd)
uint CreateFakeDiSEqCID(void)
QMap< uint, double > uint_to_dbl_t
void SetOrdinal(uint ordinal)
bool Execute(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning) override
Applies DiSEqC settings to this node and any children.
static dvbdev_rotor_t RotorTypeFromString(const QString &type)
void RotationComplete(void) const
bool Load(const QString &device)
Loads the device tree from the database.
void SetParent(DiSEqCDevDevice *parent)
bool ExecuteLegacy(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning, uint pos)
void SetRoot(DiSEqCDevDevice *root)
Changes the root node of the tree.
static constexpr useconds_t DISEQC_POWER_ON_WAIT
DiSEqCDevDevice * GetSelectedChild(const DiSEqCDevSettings &setting) const override
Retrieves the selected child for this configuration, if any.
virtual DiSEqCDevDevice * GetChild(uint)
Retrieves the nth child of this node.
bool Load(void) override
Loads this device from 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.
DiSEqCDevDevice * GetSelectedChild(const DiSEqCDevSettings &settings) const override
Retrieves the selected child for this configuration, if any.
bool IsHorizontal(const DTVMultiplex &tuning) const
Determine if horizontal polarity is active (for switchable LNBs).
bool Execute(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning) override
Applies DiSEqC settings to this node and any children.
DiSEqCDevDevice * m_parent
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
uint_to_dbl_t GetPosMap(void) const
bool ExecuteVoltage(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning, uint pos)
bool Execute(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning) override
Applies DiSEqC settings to this node and any children.
static DiSEqCDevTree * FindTree(uint cardid)
Retrieve device tree.
static constexpr double TO_RADS
static DiSEqCDevTrees s_trees
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 DiSEqCDevDevice * CreateByType(DiSEqCDevTree &tree, dvbdev_t type, uint dev_id=0)
bool SetChild(uint ordinal, DiSEqCDevDevice *device) override
Changes the nth child of this node.
DiSEqCDevDevice * FindDevice(uint dev_id)
Returns a device by ID.
bool PowerOff(void) const
bool Load(void) override
Loads this device from the database.
DiSEqCDevLNB * FindLNB(const DiSEqCDevSettings &settings)
Returns the LNB device object selected by the configuration chain.
static QString LNBTypeToString(dvbdev_lnb_t type)
void StartRotorPositionTracking(double azimuth)
bool ExecuteUSALS(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning, double angle)
static bool set_voltage(int fd, fe_sec_voltage volt)
bool diseqc_bus_already_reset
void SetNumPorts(uint num_ports)
bool Store(uint card_input_id) const
Stores configuration chain to DB for specified card input id.
static void InvalidateTrees(void)
Invalidate cached trees.
bool ResetDiseqc(bool hard_reset, bool is_SCR)
Resets the DiSEqC bus.
virtual ~DiSEqCDevDevice()
static const TypeTableVec kDvbdevLookup
DiSEqCDevRotor * FindRotor(const DiSEqCDevSettings &settings, uint index=0)
Returns the nth rotor device object in the tree.
uint GetVoltage(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning) const override
Retrives the desired voltage for this config.
static constexpr useconds_t DISEQC_SHORT_WAIT
static DiSEqCDevDevice * CreateById(DiSEqCDevTree &tree, uint devid)
DiSEqCDevDevice * m_child
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
static dvbdev_t DevTypeFromString(const QString &type)
~DiSEqCDevSwitch() override
DiSEqCDevSCR * FindSCR(const DiSEqCDevSettings &settings)
Returns the SCR device object selected by the configuration chain.
bool IsRealDeviceID(void) const
bool ExecuteDiseqc(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning, uint pos)
void Reset(void) override
Resets to the last known settings for this device.
double GetApproxAzimuth(void) const
static bool mini_diseqc(int fd, fe_sec_mini_cmd cmd)
bool IsMoving(const DiSEqCDevSettings &settings) const
bool Load(void) override
Loads this device from the database.
DVB-S device tree class. Represents a tree of DVB-S devices.
virtual bool Store(void) const =0
void SetDescription(const QString &desc)
bool IsHighBand(const DTVMultiplex &tuning) const
Determine if the high frequency band is active (for switchable LNBs).
QString GetHostName(void)
bool Store(uint cardid, const QString &device="")
Stores the device tree to the database.
DiSEqCDevTree * FindTree(uint cardid)
Retrieve device tree.
uint GetDeviceID(void) const
@ kTypeVoltageAndToneControl
DiSEqCDevSwitch(DiSEqCDevTree &tree, uint devid)
void Reset(void) override
Resets to the last known settings for this device.
uint GetVoltage(void) const
static constexpr useconds_t DISEQC_POWER_OFF_WAIT
static constexpr uint8_t TIMEOUT_RETRIES
virtual DiSEqCDevDevice * GetSelectedChild(const DiSEqCDevSettings &) const
Retrieves the selected child for this configuration, if any.
virtual bool Execute(const DiSEqCDevSettings &, const DTVMultiplex &)=0
Applies DiSEqC settings to this node and any children.
cardid_to_diseqc_tree_t m_trees
static constexpr double EPS
void InvalidateTrees(void)
Invalidate cached trees.
uint GetVoltage(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning) const override
Retrives the desired voltage for this config.
uint GetVoltage(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning) const override
Retrives the desired voltage for this config.
void Reset(void)
Reset state of nodes in tree, forcing updates on the next Execute command.
QString GetSetting(const QString &key, const QString &defaultval="")
uint32_t GetIntermediateFrequency(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning) const
Calculate proper intermediate frequency for the given settings and tuning parameters.
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
void AddDeferredDelete(uint dev_id)
Switch class, including tone, legacy and DiSEqC switches.
bool ShouldSwitch(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning) const