Пример #1
0
        /// <summary>
        /// Informs to the itinerary that an active feedback have been received to check it.
        /// </summary>
        /// <param name="status">Feedback status information received from command station.</param>
        /// <param name="element">Involved element.</param>
        /// <returns>
        /// A value indicating if the feedback signal has been processed by the current itinerary (<c>true</c>)
        /// or the signal is not related to the current itinerary (<c>false</c>).
        /// </returns>
        public bool FeedbackReceived(FeedbackPointAddressStatus status, Element element)
        {
            Logger.LogDebug(this, "[CLASS].FeedbackReceived([{0}], [{1}])", status, element);

            // Check if itinerary have pending feedback responses
            if (this.FeedbackSequence.Count <= 0)
            {
                return(false);
            }

            // Check if feedback corresponds to the current itinerary
            if (!this.FeedbackSequence[0].FeedbackEncoderConnection.EncoderInput.MatchStatus(status) || !status.Active)
            {
                return(false);
            }

            ItineraryFeedbackPoint fp = this.FeedbackSequence[0];

            this.FeedbackSequence.Remove(fp);

            switch (fp.Action)
            {
            case ItineraryFeedbackPoint.FeedbackAction.CompleteRoute:
                this.RouteCompleted(fp.Route);
                break;

            case ItineraryFeedbackPoint.FeedbackAction.Brake:
                // Start braking to 20% of current speed
                break;

            case ItineraryFeedbackPoint.FeedbackAction.Stop:
                // Stop train
                this.RouteCompleted(fp.Route);
                break;

            case ItineraryFeedbackPoint.FeedbackAction.Skip:
            default:
                break;
            }

            return(true);
        }
Пример #2
0
 /// <summary>
 /// Check if a status received from command statios matches the current input.
 /// </summary>
 /// <param name="status">Status received from the command station.</param>
 /// <returns>A value indicating if the status corresponds to the current input.</returns>
 public bool MatchStatus(FeedbackPointAddressStatus status)
 {
     return(this.Address.Equals(status.Address) && this.PointAddress.Equals(status.PointAddress));
 }