コード例 #1
0
        private static ICardStopReservationTicket RequestCardStopReservation(ITvCardHandler tvcard, IUser user)
        {
            ICardStopReservationTicket cardStopReservation = null;

            CardTuneState cardTuneState;
            bool          hasMoreStopReservations;

            lock (tvcard.Tuner.CardReservationsLock)
            {
                bool isCardIdle          = (tvcard.Tuner.CardTuneState == CardTuneState.Idle);
                bool isCardTuned         = (tvcard.Tuner.CardTuneState == CardTuneState.Tuned);
                bool isCardTunePending   = (tvcard.Tuner.CardTuneState == CardTuneState.TunePending);
                bool isCardTuneCancelled = (tvcard.Tuner.CardTuneState == CardTuneState.TuneCancelled);

                bool isCardStopIdle = (tvcard.Tuner.CardStopState == CardStopState.Idle);
                bool isCardStopped  = (tvcard.Tuner.CardStopState == CardStopState.Stopped);

                bool isCardAvail = (isCardIdle || isCardTuned || isCardTunePending || isCardTuneCancelled) && (isCardStopped || isCardStopIdle);

                if (isCardAvail)
                {
                    tvcard.Tuner.CardStopState = CardStopState.StopPending;
                    cardStopReservation        = new CardStopReservationTicket();
                    tvcard.Tuner.ReservationsForStop.Add(cardStopReservation);
                }

                cardTuneState           = tvcard.Tuner.CardTuneState;
                hasMoreStopReservations = (tvcard.Tuner.ReservationsForStop.Count > 0);
            }

            if (cardStopReservation != null)
            {
                Log.Debug("CardTuner.RequestCardStopReservation: placed reservation with id={0}, user={1}", cardStopReservation.Id, user.Name);
            }
            else
            {
                if (hasMoreStopReservations)
                {
                    Log.Debug(
                        "CardTuner.RequestCardStopReservation: failed reservation user={0}, cardstate={1}, res id blocking={2}",
                        user.Name, cardTuneState, "n/a");
                }
                else
                {
                    Log.Debug(
                        "CardTuner.RequestCardStopReservation: failed reservation user={0}, cardstate={1}",
                        user.Name, cardTuneState);
                }
            }

            return(cardStopReservation);
        }
コード例 #2
0
    private static ICardStopReservationTicket RequestCardStopReservation(ITvCardHandler tvcard, IUser user)
    {
      ICardStopReservationTicket cardStopReservation = null;

      CardTuneState cardTuneState;
      bool hasMoreStopReservations;

      lock (tvcard.Tuner.CardReservationsLock)
      {
        bool isCardIdle = (tvcard.Tuner.CardTuneState == CardTuneState.Idle);
        bool isCardTuned = (tvcard.Tuner.CardTuneState == CardTuneState.Tuned);
        bool isCardTunePending = (tvcard.Tuner.CardTuneState == CardTuneState.TunePending);
        bool isCardTuneCancelled = (tvcard.Tuner.CardTuneState == CardTuneState.TuneCancelled);

        bool isCardStopIdle = (tvcard.Tuner.CardStopState == CardStopState.Idle);
        bool isCardStopped = (tvcard.Tuner.CardStopState == CardStopState.Stopped);

        bool isCardAvail = (isCardIdle || isCardTuned || isCardTunePending || isCardTuneCancelled) && (isCardStopped || isCardStopIdle);

        if (isCardAvail)
        {          
          tvcard.Tuner.CardStopState = CardStopState.StopPending;
          cardStopReservation = new CardStopReservationTicket();          
          tvcard.Tuner.ReservationsForStop.Add(cardStopReservation);
        }

        cardTuneState = tvcard.Tuner.CardTuneState;
        hasMoreStopReservations = (tvcard.Tuner.ReservationsForStop.Count > 0);

      }

      if (cardStopReservation != null)
      {
        Log.Debug("CardTuner.RequestCardStopReservation: placed reservation with id={0}, user={1}", cardStopReservation.Id, user.Name);
      }
      else
      {
        if (hasMoreStopReservations)
        {
          Log.Debug(
            "CardTuner.RequestCardStopReservation: failed reservation user={0}, cardstate={1}, res id blocking={2}",
            user.Name, cardTuneState, "n/a");
        }
        else
        {
          Log.Debug(
            "CardTuner.RequestCardStopReservation: failed reservation user={0}, cardstate={1}",
            user.Name, cardTuneState);
        }
      }

      return cardStopReservation;
    }