示例#1
0
        public void SetSpeedAndDirection([FromBody] SpeedAndDirection data)
        {
            _GetTrain(data.EAddress);

            locomotiveStateService.SetState(data);
            controlService.SetSpeedAndDirection(data);
        }
 public void SetSpeedAndDirection(SpeedAndDirection data)
 {
     if (eLinkController.IsConnected)
     {
         eLinkController.SetLocomotiveSpeedAndDirection(data);
     }
 }
示例#3
0
 public void SetLocomotiveSpeedAndDirection(SpeedAndDirection data)
 {
     try
     {
         var msg = new SetLocoSpeedAndDirection_SpeedSteps128Message(data.EAddress, (byte)data.speed, (data.Direction == EDirection.Forwards) ? Direction.Forward : Direction.Reverse);
         msg.Write(serialPort.BaseStream);
     }
     catch (InvalidOperationException e)
     {
         //TODO return the exception information to the client
         IsConnected = false;
     }
 }
示例#4
0
        public void SetState(SpeedAndDirection data)
        {
            SpeedAndDirection speedAndDirection = speedAndDirectionState.FirstOrDefault(o => o.EAddress == data.EAddress);

            if (speedAndDirection == null)
            {
                speedAndDirectionState.Add(data);
            }
            else
            {
                speedAndDirection.speed     = data.speed;
                speedAndDirection.Direction = data.Direction;
            }
        }
示例#5
0
        public SpeedAndDirection GetState(ILocomotive locomotive)
        {
            SpeedAndDirection speedAndDirection = speedAndDirectionState.FirstOrDefault(o => o.EAddress == locomotive.Functions.EAddress);

            if (speedAndDirection == null)
            {
                speedAndDirection = new SpeedAndDirection()
                {
                    EAddress  = locomotive.Functions.EAddress,
                    speed     = 0,
                    Direction = EDirection.Forwards
                };
                speedAndDirectionState.Add(speedAndDirection);
            }

            return(speedAndDirection);
        }