MythTV master
scanmonitor.cpp
Go to the documentation of this file.
1/* -*- Mode: c++ -*-
2 * vim: set expandtab tabstop=4 shiftwidth=4:
3 *
4 * Original Project
5 * MythTV http://www.mythtv.org
6 *
7 * Copyright (c) 2004, 2005 John Pullan <john@pullan.org>
8 * Copyright (c) 2005 - 2007 Daniel Kristjansson
9 *
10 * Description:
11 * Collection of classes to provide channel scanning functionallity
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
27 *
28 */
29
30// MythTV headers
31#include "scanmonitor.h"
32#include "signalmonitorvalue.h"
33#include "channelscanner.h"
34
35// Qt headers
36#include <QCoreApplication>
37
38const QEvent::Type ScannerEvent::kScanComplete =
39 (QEvent::Type) QEvent::registerEventType();
40const QEvent::Type ScannerEvent::kScanShutdown =
41 (QEvent::Type) QEvent::registerEventType();
42const QEvent::Type ScannerEvent::kScanErrored =
43 (QEvent::Type) QEvent::registerEventType();
44const QEvent::Type ScannerEvent::kAppendTextToLog =
45 (QEvent::Type) QEvent::registerEventType();
46const QEvent::Type ScannerEvent::kSetStatusText =
47 (QEvent::Type) QEvent::registerEventType();
48const QEvent::Type ScannerEvent::kSetStatusTitleText =
49 (QEvent::Type) QEvent::registerEventType();
50const QEvent::Type ScannerEvent::kSetPercentComplete =
51 (QEvent::Type) QEvent::registerEventType();
53 (QEvent::Type) QEvent::registerEventType();
55 (QEvent::Type) QEvent::registerEventType();
57 (QEvent::Type) QEvent::registerEventType();
58const QEvent::Type ScannerEvent::kSetStatusSignalLock =
59 (QEvent::Type) QEvent::registerEventType();
60const QEvent::Type ScannerEvent::kSetStatusChannelTuned =
61 (QEvent::Type) QEvent::registerEventType();
62
64static constexpr int8_t TRANSPORT_PCT { 6 };
66//static constexpr int8_t TUNED_PCT { 3 };
67
68void post_event(QObject *dest, QEvent::Type type, int val)
69{
70 auto *e = new ScannerEvent(type);
71 e->intValue(val);
72 QCoreApplication::postEvent(dest, e);
73}
74
75void post_event(QObject *dest, QEvent::Type type, const QString &val)
76{
77 auto *e = new ScannerEvent(type);
78 e->strValue(val);
79 QCoreApplication::postEvent(dest, e);
80}
81
82void post_event(QObject *dest, QEvent::Type type, int val,
83 Configurable *spp)
84{
85 auto *e = new ScannerEvent(type);
86 e->intValue(val);
87 e->ConfigurableValue(spp);
88 QCoreApplication::postEvent(dest, e);
89}
90
92{
93 m_channelScanner = nullptr;
94
95 QObject::deleteLater();
96}
97
99{
101}
102
104{
105 int tmp = TRANSPORT_PCT + (((100 - TRANSPORT_PCT) * pct)/100);
107}
108
109void ScanMonitor::ScanAppendTextToLog(const QString &status)
110{
112}
113
114void ScanMonitor::ScanUpdateStatusText(const QString &status)
115{
116 QString msg = tr("Scanning");
117 if (!status.isEmpty())
118 msg = QString("%1 %2").arg(msg, status);
119
121}
122
123void ScanMonitor::ScanUpdateStatusTitleText(const QString &status)
124{
126}
127
128void ScanMonitor::ScanErrored(const QString &error)
129{
131}
132
134{
136 val.GetNormalizedValue(0, 65535));
137}
138
140{
142}
143
145{
147}
148
150{
152 val.GetNormalizedValue(0, 65535));
153}
154
156{
158 val.GetNormalizedValue(0, 65535));
159}
160
162{
164 {
165 auto *scanEvent = dynamic_cast<ScannerEvent*>(e);
166 if (scanEvent != nullptr)
167 m_channelScanner->HandleEvent(scanEvent);
168 }
169}
virtual void HandleEvent(const ScannerEvent *)=0
void StatusSignalToNoise(const SignalMonitorValue &val) override
void ScanPercentComplete(int pct)
void ScanComplete(void)
Definition: scanmonitor.cpp:98
void ScanAppendTextToLog(const QString &status)
void StatusRotorPosition(const SignalMonitorValue &val) override
void StatusChannelTuned(const SignalMonitorValue &val) override
Signal to be sent with change change status.
void StatusSignalLock(const SignalMonitorValue &val) override
Signal to be sent as true when it is safe to begin or continue recording, and false if it may not be ...
void ScanUpdateStatusTitleText(const QString &status)
ChannelScanner * m_channelScanner
Definition: scanmonitor.h:81
void StatusSignalStrength(const SignalMonitorValue &val) override
Signal to be sent with an actual signal value.
virtual void deleteLater(void)
Definition: scanmonitor.cpp:91
void ScanErrored(const QString &error)
void ScanUpdateStatusText(const QString &status)
void customEvent(QEvent *event) override
static const Type kSetStatusSignalLock
Definition: scanmonitor.h:116
static const Type kScanShutdown
Definition: scanmonitor.h:107
static const Type kSetStatusTitleText
Definition: scanmonitor.h:111
static const Type kSetStatusSignalToNoise
Definition: scanmonitor.h:114
static const Type kSetStatusText
Definition: scanmonitor.h:110
static const Type kAppendTextToLog
Definition: scanmonitor.h:109
static const Type kSetStatusRotorPosition
Definition: scanmonitor.h:113
static const Type kSetStatusChannelTuned
Definition: scanmonitor.h:117
static const Type kScanComplete
Definition: scanmonitor.h:106
static const Type kSetPercentComplete
Definition: scanmonitor.h:112
static const Type kSetStatusSignalStrength
Definition: scanmonitor.h:115
static const Type kScanErrored
Definition: scanmonitor.h:108
int GetValue() const
Returns the value.
int GetNormalizedValue(int newmin, int newmax) const
Returns the value normalized to the [newmin, newmax] range.
static guint32 * tmp
Definition: goom_core.cpp:26
def error(message)
Definition: smolt.py:409
static constexpr int8_t TRANSPORT_PCT
Percentage to set to after the transports have been scanned.
Definition: scanmonitor.cpp:64
void post_event(QObject *dest, QEvent::Type type, int val)
Percentage to set to after the first tune.
Definition: scanmonitor.cpp:68