/// <summary>
 /// Default ctor
 /// </summary>
 public TurnTableItem(ITurnTable entity, ITurnTableState state, ItemContext context, bool interactive)
     : base(entity, false, context)
 {
     this.state = state;
     state.RequestedStateChanged += (s, _) => Invalidate();
     if (interactive)
     {
         MouseHandler = new ClickHandler(MouseHandler, state);
     }
 }
示例#2
0
        /// <summary>
        /// Send the position of the given turntable towards the railway.
        /// This method is called on my worker thread.
        /// </summary>
        protected override void OnSendTurnTablePosition(ITurnTableState turnTable)
        {
            Log.Trace("Send: TurnTable: position={0}", turnTable.Position.Requested);
            // Signal new address
            SendSwitchRequest(turnTable.WriteAddress, SwitchDirection.Off, turnTable.InvertWrite);
            // Calc address
            var position = turnTable.Position.Requested;

            foreach (var positionAddress in turnTable.PositionAddresses)
            {
                // Send 1 address bit
                var bit = ((position & 0x01) != 0) ? SwitchDirection.Straight : SwitchDirection.Off;
                SendSwitchRequest(positionAddress, bit, turnTable.InvertPositions);
                position >>= 1;
            }
            // New address complete
            SendSwitchRequest(turnTable.WriteAddress, SwitchDirection.Straight, turnTable.InvertWrite);

            // Wait for busy flag
            // TODO
        }
示例#3
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public TurnTableWithState(ITurnTableState turnTable, int position)
 {
     this.turnTable = turnTable;
     this.position  = position;
 }
示例#4
0
 /// <summary>
 /// Send the position of the given turntable towards the railway.
 /// This method is called on my worker thread.
 /// </summary>
 protected override void OnSendTurnTablePosition(ITurnTableState turnTable)
 {
     Log.Trace("OnSendTurnTablePosition: {0}", turnTable);
     turnTable.Position.Actual = turnTable.Position.Requested;
 }
 /// <summary>
 /// Default ctor
 /// </summary>
 public TurnTableGotoNextPositionMenuItem(ITurnTableState turnTable)
 {
     this.turnTable = turnTable;
     Text           = Strings.TurnTableGotoNextPosition;
 }
示例#6
0
 /// <summary>
 /// Send the position of the given turntable towards the railway.
 /// This method is called on my worker thread.
 /// </summary>
 protected virtual void OnSendTurnTablePosition(ITurnTableState turnTable)
 {
     throw new NotImplementedException();
 }
示例#7
0
 /// <summary>
 /// Send the direction of the given turntable towards the railway.
 /// </summary>
 public void SendTurnTablePosition(ITurnTableState turnTable)
 {
     PostWorkerAction(() => OnSendTurnTablePosition(turnTable));
 }
 /// <summary>
 /// Default ctor
 /// </summary>
 public ClickHandler(MouseHandler next, ITurnTableState state)
     : base(next, state)
 {
     this.state = state;
 }
 /// <summary>
 /// Default ctor
 /// </summary>
 public TurnTableGotoPositionMenuItem(ITurnTableState turnTable, int position)
 {
     this.turnTable = turnTable;
     this.position  = position;
     Text           = string.Format(Strings.TurnTableGotoPositionX, position);
 }