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 
38 QEvent::Type ScannerEvent::ScanComplete =
39  (QEvent::Type) QEvent::registerEventType();
40 QEvent::Type ScannerEvent::ScanShutdown =
41  (QEvent::Type) QEvent::registerEventType();
42 QEvent::Type ScannerEvent::ScanErrored =
43  (QEvent::Type) QEvent::registerEventType();
44 QEvent::Type ScannerEvent::AppendTextToLog =
45  (QEvent::Type) QEvent::registerEventType();
46 QEvent::Type ScannerEvent::SetStatusText =
47  (QEvent::Type) QEvent::registerEventType();
49  (QEvent::Type) QEvent::registerEventType();
51  (QEvent::Type) QEvent::registerEventType();
53  (QEvent::Type) QEvent::registerEventType();
55  (QEvent::Type) QEvent::registerEventType();
57  (QEvent::Type) QEvent::registerEventType();
59  (QEvent::Type) QEvent::registerEventType();
61  (QEvent::Type) QEvent::registerEventType();
62 
64 #define TRANSPORT_PCT 6
65 #define TUNED_PCT 3
67 
68 void 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 
75 void 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 
82 void 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 
109 void ScanMonitor::ScanAppendTextToLog(const QString &status)
110 {
112 }
113 
114 void ScanMonitor::ScanUpdateStatusText(const QString &status)
115 {
116  QString msg = tr("Scanning");
117  if (!status.isEmpty())
118  msg = QString("%1 %2").arg(msg).arg(status);
119 
121 }
122 
123 void ScanMonitor::ScanUpdateStatusTitleText(const QString &status)
124 {
126 }
127 
128 void 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 {
163  if (m_channelScanner)
164  {
165  auto *scanEvent = dynamic_cast<ScannerEvent*>(e);
166  if (scanEvent != nullptr)
167  m_channelScanner->HandleEvent(scanEvent);
168  }
169 }
e
QDomElement e
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:1417
ScannerEvent::SetPercentComplete
static Type SetPercentComplete
Definition: scanmonitor.h:112
ChannelScanner::HandleEvent
virtual void HandleEvent(const ScannerEvent *)=0
build_compdb.dest
dest
Definition: build_compdb.py:9
error
static void error(const char *str,...)
Definition: vbi.cpp:42
ScanMonitor::StatusSignalStrength
void StatusSignalStrength(const SignalMonitorValue &val) override
Signal to be sent with an actual signal value.
Definition: scanmonitor.cpp:155
ScannerEvent::ScanComplete
static Type ScanComplete
Definition: scanmonitor.h:106
ScannerEvent::ScanShutdown
static Type ScanShutdown
Definition: scanmonitor.h:107
SignalMonitorValue::GetNormalizedValue
int GetNormalizedValue(int newmin, int newmax) const
Returns the value normalized to the [newmin, newmax] range.
Definition: signalmonitorvalue.h:64
ScanMonitor::ScanPercentComplete
void ScanPercentComplete(int pct)
Definition: scanmonitor.cpp:103
signalmonitorvalue.h
ScannerEvent::SetStatusText
static Type SetStatusText
Definition: scanmonitor.h:110
ScanMonitor::customEvent
void customEvent(QEvent *event) override
Definition: scanmonitor.cpp:161
ScanMonitor::StatusSignalToNoise
void StatusSignalToNoise(const SignalMonitorValue &val) override
Definition: scanmonitor.cpp:149
ScanMonitor::deleteLater
virtual void deleteLater(void)
Definition: scanmonitor.cpp:91
tmp
static guint32 * tmp
Definition: goom_core.cpp:30
channelscanner.h
ScanMonitor::ScanErrored
void ScanErrored(const QString &error)
Definition: scanmonitor.cpp:128
scanmonitor.h
SignalMonitorValue::GetValue
int GetValue() const
Returns the value.
Definition: signalmonitorvalue.h:41
TRANSPORT_PCT
#define TRANSPORT_PCT
Percentage to set to after the transports have been scanned.
Definition: scanmonitor.cpp:64
ScannerEvent::AppendTextToLog
static Type AppendTextToLog
Definition: scanmonitor.h:109
ScannerEvent::SetStatusSignalToNoise
static Type SetStatusSignalToNoise
Definition: scanmonitor.h:114
ScanMonitor::StatusRotorPosition
void StatusRotorPosition(const SignalMonitorValue &val) override
Definition: scanmonitor.cpp:133
SignalMonitorValue
Definition: signalmonitorvalue.h:15
ScanMonitor::StatusSignalLock
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 ...
Definition: scanmonitor.cpp:139
ScannerEvent::SetStatusSignalLock
static Type SetStatusSignalLock
Definition: scanmonitor.h:116
ScanMonitor::ScanAppendTextToLog
void ScanAppendTextToLog(const QString &status)
Definition: scanmonitor.cpp:109
ScannerEvent
Definition: scanmonitor.h:87
ScannerEvent::SetStatusChannelTuned
static Type SetStatusChannelTuned
Definition: scanmonitor.h:117
ScanMonitor::StatusChannelTuned
void StatusChannelTuned(const SignalMonitorValue &val) override
Signal to be sent with change change status.
Definition: scanmonitor.cpp:144
ScannerEvent::SetStatusRotorPosition
static Type SetStatusRotorPosition
Definition: scanmonitor.h:113
ScanMonitor::ScanComplete
void ScanComplete(void)
Definition: scanmonitor.cpp:98
ScannerEvent::ScanErrored
static Type ScanErrored
Definition: scanmonitor.h:108
ScanMonitor::m_channelScanner
ChannelScanner * m_channelScanner
Definition: scanmonitor.h:81
ScanMonitor::ScanUpdateStatusText
void ScanUpdateStatusText(const QString &status)
Definition: scanmonitor.cpp:114
ScannerEvent::SetStatusSignalStrength
static Type SetStatusSignalStrength
Definition: scanmonitor.h:115
post_event
void post_event(QObject *dest, QEvent::Type type, int val)
Definition: scanmonitor.cpp:68
ScannerEvent::SetStatusTitleText
static Type SetStatusTitleText
Definition: scanmonitor.h:111
ScanMonitor::ScanUpdateStatusTitleText
void ScanUpdateStatusTitleText(const QString &status)
Definition: scanmonitor.cpp:123