コード例 #1
0
        /// <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")
            {
                Log.Epg("EPG: grabber disabled");
                return;
            }
            if (_isRunning)
            {
                return;
            }

            Setting s = layer.GetSetting("timeoutEPGRefresh", "240");

            if (Int32.TryParse(s.Value, out _epgReGrabAfter) == false)
            {
                _epgReGrabAfter = 240;
            }
            TransponderList.Instance.RefreshTransponders();
            if (TransponderList.Instance.Count == 0)
            {
                return;
            }
            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)
            {
                foreach (EpgCard epgCard in _epgCards)
                {
                    epgCard.Dispose();
                }
            }

            _epgCards = new List <EpgCard>();

            foreach (Card card in cards)
            {
                if (!card.Enabled || !card.GrabEPG)
                {
                    continue;
                }
                try
                {
                    RemoteControl.HostName = card.ReferencedServer().HostName;
                    if (!_tvController.CardPresent(card.IdCard))
                    {
                        continue;
                    }
                }
                catch (Exception e)
                {
                    Log.Error("card: unable to start job for card {0} at:{0}", e.Message, card.Name,
                              card.ReferencedServer().HostName);
                }

                EpgCard epgCard = new EpgCard(_tvController, card);
                _epgCards.Add(epgCard);
            }
            _epgCards.Sort(new EpgCardPriorityComparer());
            _epgTimer.Interval = timerInterval;
            _epgTimer.Enabled  = true;
        }
コード例 #2
0
 public static void CardNotPresent(int cardId, TVController controller)
 {
     Isolate.WhenCalled(() => controller.CardPresent(cardId)).WillReturn(false);
 }