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); } }
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; } }
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; } }
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); }