Example #1
0
        /// <summary>
        /// Send the loc direction and F1-F4 of the given loc towards the railway.
        /// </summary>
        /// <return>True on success</return>
        public bool SendLocDirectionAndFunctions(ILocState loc)
        {
            log.Trace("SendLocDirectionAndFunctions: {0}", loc);
            var slot = RequestSlot(loc);

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

            // Send loc direction
            log.Trace("Send: LocoDirFuncRequest: slot={0}, direction={1}", slot.SlotNumber, loc.Direction.Requested);
            var forward = (loc.Direction.Requested == LocDirection.Forward);
            var f1      = loc.GetFunctionRequestedState(LocFunction.F1);
            var f2      = loc.GetFunctionRequestedState(LocFunction.F2);
            var f3      = loc.GetFunctionRequestedState(LocFunction.F3);
            var f4      = loc.GetFunctionRequestedState(LocFunction.F4);
            var dirMsg  = new LocoDirFuncRequest(slot.SlotNumber,
                                                 forward, loc.F0.Requested, f1, f2, f3, f4);

            dirMsg.Execute(lb);
            slot.Touch();
            return(true);
        }
Example #2
0
        /// <summary>
        /// Handle the given message
        /// </summary>
        /// <returns>True if handled</returns>
        protected virtual bool ReceiveLocoDirFunc(LocoDirFuncRequest msg)
        {
            log.Trace("Received: SetLocoDirFunc: slot={0}, dir={1}", msg.Slot, msg.Forward);
            var slot = locSlotMap[msg.Slot];

            if (slot == null)
            {
                // We do not know this slot, so we don't care about it.
                return(true);
            }
            slot.DirF = msg.DirF;
            slot.Touch();
            UpdateLocFromSlot(slot);
            return(true);
        }
Example #3
0
        /// <summary>
        /// Handle the given message
        /// </summary>
        /// <returns>True if handled</returns>
        protected virtual bool SetLocoDirFunc(LocoDirFuncRequest msg)
        {
            log.Trace("Received: SetLocoDirFunc: slot={0}, dir={1}", msg.Slot, msg.Direction);
            var slot = slotTable.FindBySlotNumber(msg.Slot, false, -1);

            if (slot == null)
            {
                return(false);
            }
            slot.Direction = msg.Direction;
            slot.F0        = msg.F0;
            slot.F1        = msg.F1;
            slot.F2        = msg.F2;
            slot.F3        = msg.F3;
            slot.F4        = msg.F4;
            stateDispatcher.PostAction(slot.SlotUpdated);
            return(true);
        }
Example #4
0
 /// <summary>
 /// Loc set direction and functions
 /// </summary>
 public override bool Visit(LocoDirFuncRequest msg, Client data)
 {
     return(data.ReceiveLocoDirFunc(msg));
 }
Example #5
0
 /// <summary>
 /// Loc set direction and functions
 /// </summary>
 public override bool Visit(LocoDirFuncRequest msg, Master data)
 {
     return(data.SetLocoDirFunc(msg));
 }
 public virtual TReturn Visit(LocoDirFuncRequest msg, TData data)
 {
     return(default(TReturn));
 }