示例#1
0
        /// <summary>
        /// Handle the given message
        /// </summary>
        /// <returns>True if handled</returns>
        protected virtual bool ReceiveSwitchReport(SwitchReport msg)
        {
            var actual         = msg.SensorLevel ? SwitchDirection.Straight : SwitchDirection.Off;
            var invertedActual = msg.SensorLevel ? SwitchDirection.Off : SwitchDirection.Straight;
            var address        = msg.Address;

            log.Trace("Received: SwitchReport: address={0}, level={1}", address, actual);
            stateDispatcher.PostAction(() =>
            {
                var foundSwitch = false;
                foreach (var @switch in cs.Junctions.OfType <ISwitchState>().Where(x => x.HasFeedback && (x.FeedbackAddress.ValueAsInt == address)))
                {
                    @switch.Direction.Actual = @switch.InvertFeedback ? invertedActual : actual;
                    foundSwitch = true;
                }
                if (!foundSwitch)
                {
                    railwayState.OnUnknownSwitch(new Address(AddressType.LocoNet, string.Empty, address));
                    log.Info(Strings.SwitchReportForUnknownAddress, actual, address);
                }
            });
            return(true);
        }
示例#2
0
 /// <summary>
 /// Switch feedback
 /// </summary>
 public override bool Visit(SwitchReport msg, Client data)
 {
     return(data.ReceiveSwitchReport(msg));
 }
示例#3
0
 /// <summary>
 /// Switch feedback
 /// </summary>
 public override bool Visit(SwitchReport msg, Master data)
 {
     return(data.SwitchReport(msg));
 }
 public virtual TReturn Visit(SwitchReport msg, TData data)
 {
     return(default(TReturn));
 }