Ejemplo n.º 1
0
        private void UpdateState(object sender, EventArgs e)
        {
            train.Update(clock.Interval / 1000.0);
            TrainState ts = train.GetState();

            brakeBox.Checked          = train.GetBrake();
            emergencyBrakeBox.Checked = train.GetEmergencyBrake();
            brakeFailureBox.Checked   = ts.BrakeFailure;
            switch (ts.Direction)
            {
            case CommonLib.Direction.East:
                directionTextBox.Text = "East";
                break;

            case CommonLib.Direction.North:
                directionTextBox.Text = "North";
                break;

            case CommonLib.Direction.Northeast:
                directionTextBox.Text = "Northeast";
                break;

            case CommonLib.Direction.Northwest:
                directionTextBox.Text = "Northwest";
                break;

            case CommonLib.Direction.South:
                directionTextBox.Text = "South";
                break;

            case CommonLib.Direction.Southeast:
                directionTextBox.Text = "Southeast";
                break;

            case CommonLib.Direction.Southwest:
                directionTextBox.Text = "Southwest";
                break;

            case CommonLib.Direction.West:
                directionTextBox.Text = "West";
                break;

            default:
                break;                         // Unreachable
            }
            progressTextBox.Text     = String.Format("{0:F0}", (ts.BlockProgress / ts.CurrentBlock.LengthMeters) * 100);
            speedTextBox.Text        = String.Format("{0:F3}", ts.Speed);
            accelerationTextBox.Text = String.Format("{0:F3}", train.GetAcceleration());
        }