/// <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); }
/// <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); }
/// <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); }
/// <summary> /// Loc set speed /// </summary> public override bool Visit(LocoSpeedRequest msg, Client data) { return(data.ReceiveLocoSpeed(msg)); }
/// <summary> /// Loc set speed /// </summary> public override bool Visit(LocoSpeedRequest msg, Master data) { return(data.SetLocoSpeed(msg)); }
public virtual TReturn Visit(LocoSpeedRequest msg, TData data) { return(default(TReturn)); }