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 const QEvent::Type ScannerEvent::kScanComplete =
39  (QEvent::Type) QEvent::registerEventType();
40 const QEvent::Type ScannerEvent::kScanShutdown =
41  (QEvent::Type) QEvent::registerEventType();
42 const QEvent::Type ScannerEvent::kScanErrored =
43  (QEvent::Type) QEvent::registerEventType();
44 const QEvent::Type ScannerEvent::kAppendTextToLog =
45  (QEvent::Type) QEvent::registerEventType();
46 const QEvent::Type ScannerEvent::kSetStatusText =
47  (QEvent::Type) QEvent::registerEventType();
48 const QEvent::Type ScannerEvent::kSetStatusTitleText =
49  (QEvent::Type) QEvent::registerEventType();
50 const QEvent::Type ScannerEvent::kSetPercentComplete =
51  (QEvent::Type) QEvent::registerEventType();
52 const QEvent::Type ScannerEvent::kSetStatusRotorPosition =
53  (QEvent::Type) QEvent::registerEventType();
54 const QEvent::Type ScannerEvent::kSetStatusSignalToNoise =
55  (QEvent::Type) QEvent::registerEventType();
56 const QEvent::Type ScannerEvent::kSetStatusSignalStrength =
57  (QEvent::Type) QEvent::registerEventType();
58 const QEvent::Type ScannerEvent::kSetStatusSignalLock =
59  (QEvent::Type) QEvent::registerEventType();
60 const QEvent::Type ScannerEvent::kSetStatusChannelTuned =
61  (QEvent::Type) QEvent::registerEventType();
62 
64 static constexpr int8_t TRANSPORT_PCT { 6 };
66 //static constexpr int8_t 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, 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 }
ChannelScanner::HandleEvent
virtual void HandleEvent(const ScannerEvent *)=0
build_compdb.dest
dest
Definition: build_compdb.py:9
TRANSPORT_PCT
static constexpr int8_t TRANSPORT_PCT
Percentage to set to after the transports have been scanned.
Definition: scanmonitor.cpp:64
error
static void error(const char *str,...)
Definition: vbi.cpp:36
ScanMonitor::StatusSignalStrength
void StatusSignalStrength(const SignalMonitorValue &val) override
Signal to be sent with an actual signal value.
Definition: scanmonitor.cpp:155
SignalMonitorValue::GetNormalizedValue
int GetNormalizedValue(int newmin, int newmax) const
Returns the value normalized to the [newmin, newmax] range.
Definition: signalmonitorvalue.h:63
ScanMonitor::ScanPercentComplete
void ScanPercentComplete(int pct)
Definition: scanmonitor.cpp:103
signalmonitorvalue.h
ScannerEvent::kAppendTextToLog
static const Type kAppendTextToLog
Definition: scanmonitor.h:109
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
ScannerEvent::kSetStatusText
static const Type kSetStatusText
Definition: scanmonitor.h:110
tmp
static guint32 * tmp
Definition: goom_core.cpp:26
channelscanner.h
ScannerEvent::kScanShutdown
static const Type kScanShutdown
Definition: scanmonitor.h:107
ScanMonitor::ScanErrored
void ScanErrored(const QString &error)
Definition: scanmonitor.cpp:128
ScannerEvent::kScanComplete
static const Type kScanComplete
Definition: scanmonitor.h:106
scanmonitor.h
SignalMonitorValue::GetValue
int GetValue() const
Returns the value.
Definition: signalmonitorvalue.h:40
ScannerEvent::kSetStatusRotorPosition
static const Type kSetStatusRotorPosition
Definition: scanmonitor.h:113
ScannerEvent::kSetStatusChannelTuned
static const Type kSetStatusChannelTuned
Definition: scanmonitor.h:117
ScannerEvent::kSetStatusSignalToNoise
static const Type kSetStatusSignalToNoise
Definition: scanmonitor.h:114
ScanMonitor::StatusRotorPosition
void StatusRotorPosition(const SignalMonitorValue &val) override
Definition: scanmonitor.cpp:133
ScannerEvent::kSetStatusSignalLock
static const Type kSetStatusSignalLock
Definition: scanmonitor.h:116
SignalMonitorValue
Definition: signalmonitorvalue.h:13
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::kSetStatusSignalStrength
static const Type kSetStatusSignalStrength
Definition: scanmonitor.h:115
ScanMonitor::ScanAppendTextToLog
void ScanAppendTextToLog(const QString &status)
Definition: scanmonitor.cpp:109
ScannerEvent
Definition: scanmonitor.h:86
ScanMonitor::StatusChannelTuned
void StatusChannelTuned(const SignalMonitorValue &val) override
Signal to be sent with change change status.
Definition: scanmonitor.cpp:144
ScannerEvent::kSetStatusTitleText
static const Type kSetStatusTitleText
Definition: scanmonitor.h:111
ScanMonitor::ScanComplete
void ScanComplete(void)
Definition: scanmonitor.cpp:98
ScannerEvent::kSetPercentComplete
static const Type kSetPercentComplete
Definition: scanmonitor.h:112
ScannerEvent::kScanErrored
static const Type kScanErrored
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
post_event
void post_event(QObject *dest, QEvent::Type type, int val)
Percentage to set to after the first tune.
Definition: scanmonitor.cpp:68
ScanMonitor::ScanUpdateStatusTitleText
void ScanUpdateStatusTitleText(const QString &status)
Definition: scanmonitor.cpp:123