Exemplo n.º 1
0
 /// <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);
     }
 }
Exemplo n.º 2
0
 /// <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);
     }
 }
Exemplo n.º 3
0
 /// <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));
     }
 }
Exemplo n.º 4
0
        /// <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);
        }
Exemplo n.º 5
0
 /// <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);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public SwitchWithState(ISwitchState @switch, SwitchDirection direction)
 {
     this.@switch   = @switch;
     this.direction = direction;
 }
Exemplo n.º 7
0
 /// <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);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public Switch(Client client, int id, ISwitchState junctionState)
     : base(client, id)
 {
     this.junctionState = junctionState;
 }
Exemplo n.º 9
0
 /// <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();
 }
Exemplo n.º 10
0
 /// <summary>
 /// Send the direction of the given switch towards the railway.
 /// </summary>
 public void SendSwitchDirection(ISwitchState @switch)
 {
     PostWorkerAction(() => OnSendSwitchDirectionAndStartFeedback(@switch));
 }
Exemplo n.º 11
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public ClickHandler(MouseHandler next, ISwitchState state)
     : base(next, state)
 {
     this.state = state;
 }