10#include <QCoreApplication>
27#define LOC QString("DVBSigMon[%1](%2): ") \
28 .arg(m_inputid).arg(m_channel->GetDevice())
52 m_signalToNoise (QCoreApplication::translate(
"(Common)",
53 "Signal To Noise"),
"snr",
54 0,
true, 0, 65535, 0ms),
55 m_bitErrorRate (tr(
"Bit Error Rate"),
"ber",
56 65535,
false, 0, 65535, 0ms),
57 m_uncorrectedBlocks(tr(
"Uncorrected Blocks"),
"ucb",
58 65535,
false, 0, 65535, 0ms),
59 m_rotorPosition (tr(
"Rotor Progress"),
"pos",
60 100,
true, 0, 100, 0ms),
61 m_streamHandlerStarted(
false),
62 m_streamHandler(nullptr)
68 std::chrono::milliseconds
wait = 3s;
69 std::chrono::milliseconds signal_timeout = 0ms;
70 std::chrono::milliseconds tuning_timeout = 0ms;
72 if (tuning_timeout <
wait)
74 LOG(VB_CHANNEL, LOG_DEBUG,
LOC +
75 QString(
"Tuning timeout from database: %1 ms is too small, using %2 ms")
76 .arg(tuning_timeout.count()).arg(
wait.count()));
80 wait = tuning_timeout;
81 LOG(VB_CHANNEL, LOG_DEBUG,
LOC +
82 QString(
"Tuning timeout: %1 ms").arg(
wait.count()));
98 auto log_message = [&mok](
const QString& loc,
const QString& msg)
101 LOG(VB_CHANNEL, LOG_INFO, loc +
"Can " + msg);
103 LOG(VB_GENERAL, LOG_WARNING, loc +
"Cannot " + msg +
ENO);
106 auto log_message_channel = [&mok](
const QString& loc,
const QString& msg)
109 LOG(VB_CHANNEL, LOG_INFO, loc +
"Can " + msg);
111 LOG(VB_CHANNEL, LOG_WARNING, loc +
"Cannot " + msg +
ENO);
114 auto update_rmflags = [&mok, &rmflags](uint64_t flag)
125 update_rmflags(flag);
126 log_message(
LOC,
"measure Signal Strength");
134 update_rmflags(flag);
135 log_message(
LOC,
"measure S/N");
143 update_rmflags(flag);
144 log_message_channel(
LOC,
"measure Bit Error Rate");
152 update_rmflags(flag);
153 log_message_channel(
LOC,
"count Uncorrected Blocks");
158 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"DVBSignalMonitor::ctor " +
196 int pos = (int)std::trunc(rotor->
GetProgress() * 100);
206 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"Stop() -- begin");
212 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"Stop() -- end");
279 m_error = tr(
"Error: stream handler died");
335 bool wasLocked =
false;
336 bool isLocked =
false;
343 bool has_lock = dvbchannel->
HasLock();
379 if (wasLocked != isLocked)
381 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"UpdateValues -- Signal " +
382 (isLocked ?
"Locked" :
"Lost"));
static bool GetTimeouts(uint inputid, std::chrono::milliseconds &signal_timeout, std::chrono::milliseconds &channel_timeout)
This class is intended to detect the presence of needed tables.
bool IsAllGood(void) const override
void HandlePMT(uint program_num, const ProgramMapTable *pmt) override
void AddFlags(uint64_t _flags) override
void HandleTDT(const TimeDateTable *tdt) override
QStringList GetStatusList(void) const override
Returns QStringList containing all signals and their current values.
void HandleSTT(const SystemTimeTable *stt) override
void RemoveFlags(uint64_t _flags) override
MPEGStreamData * GetStreamData()
Returns the MPEG stream data if it exists.
Provides interface to the tuning hardware when using DVB drivers.
const DiSEqCDevRotor * GetRotor(void) const
Returns rotor object if it exists, nullptr otherwise.
void SetPMT(const ProgramMapTable *pmt)
Tells the Conditional Access Module which streams we wish to decode.
void SetTimeOffset(double offset)
Tells the Conditional Access Module the offset from the computers utc time to dvb time.
double GetUncorrectedBlockCount(bool *ok=nullptr) const
Returns # of uncorrected blocks since last call. First call undefined.
std::chrono::milliseconds GetMinSignalMonitorDelay(void) const
bool HasLock(bool *ok=nullptr) const
Returns true iff we have a signal carrier lock.
double GetBitErrorRate(bool *ok=nullptr) const
Returns # of corrected bits since last call. First call undefined.
double GetSNR(bool *ok=nullptr) const
Returns signal/noise in the range [0..1.0].
double GetSignalStrength(bool *ok=nullptr) const
Returns signal strength in the range [0.0..1.0] (non-calibrated).
QString GetCardNum(void) const
Returns DVB device number, used to construct filenames for DVB devices.
void HandleTDT(const TimeDateTable *tdt) override
void EmitStatus(void) override
Emits signals for lock, signal strength, etc.
void UpdateValues(void) override
Fills in frontend stats and emits status Qt signals.
SignalMonitorValue m_uncorrectedBlocks
~DVBSignalMonitor() override
Stops signal monitoring and table monitoring threads.
DVBChannel * GetDVBChannel(void)
SignalMonitorValue m_bitErrorRate
void Stop(void) override
Stop signal monitoring and table monitoring threads.
void SetRotorTarget(float target) override
Sets rotor target pos from 0.0 to 1.0.
void HandlePMT(uint program_num, const ProgramMapTable *pmt) override
SignalMonitorValue m_rotorPosition
QStringList GetStatusList(void) const override
Returns QStringList containing all signals and their current values.
bool m_streamHandlerStarted
void HandleSTT(const SystemTimeTable *stt) override
DVBStreamHandler * m_streamHandler
void GetRotorStatus(bool &was_moving, bool &is_moving) override
SignalMonitorValue m_signalToNoise
bool IsRetuneAllowed(void) const
void SetRetuneAllowed(bool allow, DTVSignalMonitor *sigmon, DVBChannel *dvbchan)
static void Return(DVBStreamHandler *&ref, int inputid)
static DVBStreamHandler * Get(const QString &devname, int inputid)
double GetProgress(void) const
Returns an indication of rotor progress.
virtual void AddListeningPID(uint pid, PIDPriority priority=kPIDPriorityNormal)
static void usleep(std::chrono::microseconds time)
bool wait(std::chrono::milliseconds time=std::chrono::milliseconds::max())
Wait for the MThread to exit, with a maximum timeout.
A PMT table maps a program described in the ProgramAssociationTable to various PID's which describe t...
uint ProgramNumber(void) const
void SetTimeout(std::chrono::milliseconds _timeout)
void SetThreshold(int _threshold)
void SetRange(int _min, int _max)
Sets the minimum and maximum values.
int GetValue() const
Returns the value.
bool IsGood() const
Returns true if the value is equal to the threshold, or on the right side of the threshold (depends o...
QString GetName(void) const
Returns the long name of this value.
void SetValue(int _value)
QString GetStatus() const
Returns a signal monitor value as one long string.
static const uint64_t kDTVSigMon_WaitForVCT
QRecursiveMutex m_statusLock
void SendMessageAllGood(void)
SignalMonitorValue m_signalLock
static const uint64_t kDTVSigMon_WaitForNIT
void SendMessage(SignalMonitorMessageType type, const SignalMonitorValue &val)
static const uint64_t kDVBSigMon_WaitForPos
Wait for rotor to complete turning the antenna.
bool HasFlags(uint64_t _flags) const
static const uint64_t kDTVSigMon_WaitForSDT
virtual void Stop()
Stop signal monitoring thread.
static const uint64_t kDTVSigMon_WaitForPMT
virtual void EmitStatus(void)
static const uint64_t kSigMon_WaitForSig
static const uint64_t kDTVSigMon_WaitForPAT
static const uint64_t kDTVSigMon_WaitForMGT
static const uint64_t kDVBSigMon_WaitForUB
Wait for uncorrected FEC blocks to fall below a threshold.
SignalMonitorValue m_signalStrength
std::chrono::milliseconds m_minimumUpdateRate
static const uint64_t kDVBSigMon_WaitForSNR
Wait for the Signal to Noise Ratio to rise above a threshold.
static const uint64_t kDVBSigMon_WaitForBER
Wait for the Bit Error Rate to fall below a threshold.
volatile uint64_t m_flags
bool HasAnyFlag(uint64_t _flags) const
bool IsRunning(void) const
virtual void RemoveListener(MPEGStreamData *data)
virtual void AddListener(MPEGStreamData *data, bool allow_section_reader=false, bool needs_buffering=false, const QString &output_file=QString())
This table gives the current DVB stream time.
#define ENO
This can be appended to the LOG args with "+".
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
QString sm_flags_to_string(uint64_t flags)
@ kStatusUncorrectedBlocks
VERBOSE_PREAMBLE Most true