Go to the documentation of this file.
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 " +
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"));
SignalMonitorValue m_signalToNoise
void AddFlags(uint64_t _flags) override
double GetUncorrectedBlockCount(bool *ok=nullptr) const
Returns # of uncorrected blocks since last call. First call undefined.
volatile uint64_t m_flags
#define ENO
This can be appended to the LOG args with "+".
void RemoveFlags(uint64_t _flags) override
void SetRetuneAllowed(bool allow, DTVSignalMonitor *sigmon, DVBChannel *dvbchan)
std::chrono::milliseconds m_minimumUpdateRate
const DiSEqCDevRotor * GetRotor(void) const
Returns rotor object if it exists, nullptr otherwise.
void SetValue(int _value)
SignalMonitorValue m_bitErrorRate
void SetThreshold(int _threshold)
This table gives the current DVB stream time.
QString GetStatus() const
Returns a signal monitor value as one long string.
SignalMonitorValue m_uncorrectedBlocks
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...
static void usleep(std::chrono::microseconds time)
static const uint64_t kDTVSigMon_WaitForMGT
static const uint64_t kDVBSigMon_WaitForSNR
Wait for the Signal to Noise Ratio to rise above a threshold.
void HandleSTT(const SystemTimeTable *stt) override
void SendMessage(SignalMonitorMessageType type, const SignalMonitorValue &val)
void SetRotorTarget(float target) override
Sets rotor target pos from 0.0 to 1.0.
DVBStreamHandler * m_streamHandler
MPEGStreamData * GetStreamData()
Returns the MPEG stream data if it exists.
uint ProgramNumber(void) const
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
~DVBSignalMonitor() override
Stops signal monitoring and table monitoring threads.
QStringList GetStatusList(void) const override
Returns QStringList containing all signals and their current values.
void HandleTDT(const TimeDateTable *tdt) override
static const uint64_t kDVBSigMon_WaitForBER
Wait for the Bit Error Rate to fall below a threshold.
void HandleTDT(const TimeDateTable *tdt) override
double GetSignalStrength(bool *ok=nullptr) const
Returns signal strength in the range [0.0..1.0] (non-calibrated).
void SetPMT(const ProgramMapTable *pmt)
Tells the Conditional Access Module which streams we wish to decode.
QString GetName(void) const
Returns the long name of this value.
void EmitStatus(void) override
Emits signals for lock, signal strength, etc.
void UpdateValues(void) override
Fills in frontend stats and emits status Qt signals.
bool HasAnyFlag(uint64_t _flags) const
VERBOSE_PREAMBLE Most true
static const uint64_t kSigMon_WaitForSig
void GetRotorStatus(bool &was_moving, bool &is_moving) override
SignalMonitorValue m_rotorPosition
virtual void RemoveListener(MPEGStreamData *data)
QRecursiveMutex m_statusLock
void HandlePMT(uint program_num, const ProgramMapTable *pmt) override
double GetProgress(void) const
Returns an indication of rotor progress.
int GetValue() const
Returns the value.
static const uint64_t kDVBSigMon_WaitForUB
Wait for uncorrected FEC blocks to fall below a threshold.
void SetTimeout(std::chrono::milliseconds _timeout)
SignalMonitorValue m_signalStrength
static const uint64_t kDVBSigMon_WaitForPos
Wait for rotor to complete turning the antenna.
static void Return(DVBStreamHandler *&ref, int inputid)
static DVBStreamHandler * Get(const QString &devname, int inputid)
QString sm_flags_to_string(uint64_t flags)
bool IsRetuneAllowed(void) const
SignalMonitorValue m_signalLock
DVBChannel * GetDVBChannel(void)
void SendMessageAllGood(void)
static const uint64_t kDTVSigMon_WaitForPMT
void HandlePMT(uint program_num, const ProgramMapTable *pmt) override
static const uint64_t kDTVSigMon_WaitForPAT
static const uint64_t kDTVSigMon_WaitForNIT
virtual void EmitStatus(void)
static const uint64_t kDTVSigMon_WaitForSDT
double GetSNR(bool *ok=nullptr) const
Returns signal/noise in the range [0..1.0].
QStringList GetStatusList(void) const override
Returns QStringList containing all signals and their current values.
void HandleSTT(const SystemTimeTable *stt) override
@ kStatusUncorrectedBlocks
void SetRange(int _min, int _max)
Sets the minimum and maximum values.
static bool GetTimeouts(uint inputid, std::chrono::milliseconds &signal_timeout, std::chrono::milliseconds &channel_timeout)
bool IsGood() const
Returns true if the value is equal to the threshold, or on the right side of the threshold (depends o...
std::chrono::milliseconds GetMinSignalMonitorDelay(void) const
double GetBitErrorRate(bool *ok=nullptr) const
Returns # of corrected bits since last call. First call undefined.
Provides interface to the tuning hardware when using DVB drivers.
bool HasFlags(uint64_t _flags) const
void SetTimeOffset(double offset)
Tells the Conditional Access Module the offset from the computers utc time to dvb time.
bool HasLock(bool *ok=nullptr) const
Returns true iff we have a signal carrier lock.
This class is intended to detect the presence of needed tables.
virtual void AddListener(MPEGStreamData *data, bool allow_section_reader=false, bool needs_buffering=false, const QString &output_file=QString())
virtual void AddListeningPID(uint pid, PIDPriority priority=kPIDPriorityNormal)
void Stop(void) override
Stop signal monitoring and table monitoring threads.
bool IsRunning(void) const
virtual void Stop()
Stop signal monitoring thread.
bool IsAllGood(void) const override
QString GetCardNum(void) const
Returns DVB device number, used to construct filenames for DVB devices.
bool m_streamHandlerStarted
static const uint64_t kDTVSigMon_WaitForVCT