Exemplo n.º 1
0
        /// <summary>
        /// Handle the given message
        /// </summary>
        /// <returns>True if handled</returns>
        protected virtual bool SetLocoSpeed(LocoSpeedRequest msg)
        {
            log.Trace("Received: SetLocoSpeed: slot={0}, speed={1}", msg.Slot, msg.Speed);
            var slot = slotTable.FindBySlotNumber(msg.Slot, false, -1);

            if (slot == null)
            {
                return(false);
            }
            slot.Speed = msg.Speed;
            stateDispatcher.PostAction(slot.SlotUpdated);
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handle the given message
        /// </summary>
        /// <returns>True if handled</returns>
        protected virtual bool ReceiveLocoSpeed(LocoSpeedRequest msg)
        {
            log.Trace("Received: SetLocoSpeed: slot={0}, speed={1}", msg.Slot, msg.Speed);
            var slot = locSlotMap[msg.Slot];

            if (slot == null)
            {
                // We do not know this slot, so we don't care about it.
                return(true);
            }

            // Update the slot
            slot.Speed = msg.Speed;
            slot.Touch();
            UpdateLocFromSlot(slot);
            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Send the speed and direction of the given loc towards the railway.
        /// </summary>
        /// <return>True on success</return>
        public bool SendLocSpeedAndDirection(ILocState loc)
        {
            log.Trace("OnSendLocSpeedAndDirection: {0}", loc);
            var slot = RequestSlot(loc);

            if (slot == null)
            {
                log.Error("No slot available for {0}", loc);
                return(false);
            }

            // Send loc speed
            log.Trace("Send: LocoSpeedRequest: slot={0}, speed={1}", slot.SlotNumber, loc.Speed.Requested);
            var spdMsg = new LocoSpeedRequest(slot.SlotNumber, loc.SpeedInSteps.Requested);

            spdMsg.Execute(lb);
            slot.Touch();
            return(true);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Loc set speed
 /// </summary>
 public override bool Visit(LocoSpeedRequest msg, Client data)
 {
     return(data.ReceiveLocoSpeed(msg));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Loc set speed
 /// </summary>
 public override bool Visit(LocoSpeedRequest msg, Master data)
 {
     return(data.SetLocoSpeed(msg));
 }
Exemplo n.º 6
0
 public virtual TReturn Visit(LocoSpeedRequest msg, TData data)
 {
     return(default(TReturn));
 }