Permalink
Browse files

EPG 'interval timer' related changes

  • Loading branch information...
owlsroost committed Oct 2, 2018
1 parent d97a29e commit c6d0b39db8e991149b37a77bd0e41785ada51bff
@@ -507,9 +507,12 @@ private bool TuneEPGgrabber(Channel channel, IChannel tuning, Card card, TvResul
if (!_isRunning || false == _tvController.GrabEpg(this, Card.IdCard))
{
if (!_isRunning)
Log.Epg("Tuning finished but EpgGrabber no longer enabled");
{
Log.Epg("EpgCard:TuneEPGgrabber: Tuning finished but EpgGrabber no longer enabled");
}
CardReservationHelper.CancelCardReservation(cardHandler, ticket);
Stop();
Log.Epg("Epg: card:{0} could not start dvbt grabbing", Card.IdCard);
Log.Epg("EpgCard:TuneEPGgrabber: card:{0} could not start dvbt grabbing", Card.IdCard);
return false;
}
_user.CardId = Card.IdCard;
@@ -525,7 +528,7 @@ private bool TuneEPGgrabber(Channel channel, IChannel tuning, Card card, TvResul

}
_user.CardId = -1;
Log.Epg("Epg: card:{0} could not tune to channel:{1}", Card.IdCard, result.ToString());
Log.Epg("EpgCard:TuneEPGgrabber: card:{0} could not tune to channel:{1}", Card.IdCard, result.ToString());
return false;
}
catch (Exception ex)
@@ -97,6 +97,14 @@ public bool IsRunning
/// Starts the epg grabber
/// </summary>
public void Start()
{
Start(1000);
}

/// <summary>
/// Starts the epg grabber with a specified timer interval
/// </summary>
public void Start(double timerInterval)
{
TvBusinessLayer layer = new TvBusinessLayer();
if (layer.GetSetting("idleEPGGrabberEnabled", "yes").Value != "yes")
@@ -119,8 +127,8 @@ public void Start()
{
return;
}
Log.Epg("EPG: EpgGrabber initialized for {0} transponders..", TransponderList.Instance.Count);
// _isRunning = true;
Log.Epg("EPG: EpgGrabber initialized for {0} transponders, timerInterval {1}s", TransponderList.Instance.Count, timerInterval/1000);
_isRunning = true;
IList<Card> cards = Card.ListAll();

if (_epgCards != null)
@@ -157,8 +165,7 @@ public void Start()
_epgCards.Add(epgCard);
}
_epgCards.Sort(new EpgCardPriorityComparer());
_epgTimer.Interval = 1000;
_isRunning = true;
_epgTimer.Interval = timerInterval;
_epgTimer.Enabled = true;
}

@@ -215,8 +222,12 @@ private void _epgTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
//security check, dont allow re-entrancy here
if (_reEntrant)
return;
if (_epgTimer.Interval == 1000)
if (_epgTimer.Interval != 30000)
{
double oldTimInt = _epgTimer.Interval;
_epgTimer.Interval = 30000;
Log.Debug("EpgGrabber:_epgTimer_Elapsed: timerInterval changed from {0}s to {1}s", oldTimInt/1000, _epgTimer.Interval/1000);
}
try
{
_reEntrant = true;
@@ -590,22 +590,23 @@ private bool InitController()
if (_isMaster)
{
_epgGrabber = new EpgGrabber(this);
_epgGrabber.Start();
//Initial EPG timer interval is 30s to allow other things to initialise
StartEPGgrabber(30000);
_scheduler = new Scheduler(this);
_scheduler.Start();
}

_thumbProcessor = new ThumbProcessor();
_thumbProcessor.Start();

SetupHeartbeatThread();
ExecutePendingDeletions();

// Re-evaluate program states
Log.Info("Controller: recalculating program states");
TvDatabase.Program.ResetAllStates();
Schedule.SynchProgramStatesForAll();
}

_thumbProcessor = new ThumbProcessor();
_thumbProcessor.Start();
}
catch (Exception ex)
{
Log.Write("TvControllerException: {0}\r\n{1}", ex.ToString(), ex.StackTrace);
@@ -2925,6 +2926,15 @@ private void StartEPGgrabber()
}
}

private void StartEPGgrabber(double timerInterval)
{
if (_epgGrabber != null && AllCardsIdle)
{
Log.Write("Controller: epg start, timerInterval {0}s", timerInterval/1000);
_epgGrabber.Start(timerInterval);
}
}

private int GetMaxCards(ICollection<CardDetail> freeCards)
{
int maxCards;

0 comments on commit c6d0b39

Please sign in to comment.