/// <summary> /// The feedback timeout of the given switch it reached. /// Set the actual direction. /// </summary> private void OnSwitchFeedbackTimeout(ISwitchState @switch, SwitchDirection requestedDirection) { if (@switch.Direction.Requested == requestedDirection) { @switch.Direction.Actual = requestedDirection; Log.Debug("Switch feedback time for {0}", @switch); } }
/// <summary> /// Default ctor /// </summary> public SwitchItem(ISwitch entity, ISwitchState state, ItemContext context, bool interactive) : base(entity, false, context) { this.state = state; state.RequestedStateChanged += (s, _) => Invalidate(); if (interactive) { MouseHandler = new ClickHandler(null, state); } }
/// <summary> /// Send the direction of the given switch towards the railway. /// This method is called on my worker thread. /// When the direction is set, arrange the feedback if needed. /// </summary> private void OnSendSwitchDirectionAndStartFeedback(ISwitchState @switch) { OnSendSwitchDirection(@switch); if ([email protected] || @switch.RailwayState.VirtualMode.Enabled) { // Wait for feedback var direction = @switch.Direction.Requested; PostWorkerDelayedAction(TimeSpan.FromMilliseconds(@switch.SwitchDuration), () => OnSwitchFeedbackTimeout(@switch, direction)); } }
/// <summary> /// Send the direction of the given switch towards the railway. /// This method is called on my worker thread. /// </summary> protected override void OnSendSwitchDirection(ISwitchState @switch) { Log.Trace("OnSendSwitchDirection: {0}", @switch); var direction = @switch.Direction.Requested; if (@switch.Invert) { direction = direction.Invert(); } var msg = new SwitchMessage() { Sender = sender, Mode = MessageBase.ModeRequest, Address = @switch.Address.Value, Direction = direction.ToString().ToLower() }; publishMessage(msg.Topic, msg, null); }
/// <summary> /// Send the direction of the given switch towards the railway. /// This method is called on my worker thread. /// </summary> protected override void OnSendSwitchDirection(ISwitchState @switch) { SendSwitchRequest(@switch.Address, @switch.Direction.Requested, @switch.Invert); }
/// <summary> /// Default ctor /// </summary> public SwitchWithState(ISwitchState @switch, SwitchDirection direction) { this.@switch = @switch; this.direction = direction; }
/// <summary> /// Send the direction of the given switch towards the railway. /// This method is called on my worker thread. /// </summary> protected override void OnSendSwitchDirection(ISwitchState @switch) { // Do nothing here, the base implementation sets actual after a delay Log.Trace("OnSendSwitchDirection: {0}", @switch); }
/// <summary> /// Default ctor /// </summary> public Switch(Client client, int id, ISwitchState junctionState) : base(client, id) { this.junctionState = junctionState; }
/// <summary> /// Send the direction of the given switch towards the railway. /// This method is called on my worker thread. /// </summary> protected virtual void OnSendSwitchDirection(ISwitchState @switch) { throw new NotImplementedException(); }
/// <summary> /// Send the direction of the given switch towards the railway. /// </summary> public void SendSwitchDirection(ISwitchState @switch) { PostWorkerAction(() => OnSendSwitchDirectionAndStartFeedback(@switch)); }
/// <summary> /// Default ctor /// </summary> public ClickHandler(MouseHandler next, ISwitchState state) : base(next, state) { this.state = state; }