Example #1
0
        private void ApplyTrain()
        {
            lock (NearestTrain.LockObj)
            {
                NearestTrain.EnableSimulation = checkBoxEnableTrain.Checked;

                if (!NearestTrain.IsExtensionsCfg)
                {
                    NearestTrainSpecs specs = NearestTrain.Specs;
                    specs.NumberOfCars  = (int)numericUpDownCars.Value;
                    specs.PowerNotches  = (int)numericUpDownPowerNotches.Value;
                    specs.IsAirBrake    = checkBoxAirBrake.Checked;
                    specs.BrakeNotches  = (int)numericUpDownBrakeNotches.Value;
                    specs.HasHoldBrake  = checkBoxHoldBrake.Checked;
                    specs.HasConstSpeed = checkBoxConstSpeed.Checked;
                }

                NearestTrainStatus status = NearestTrain.Status;

                // Physics
                status.Speed        = (int)numericUpDownSpeed.Value;
                status.Acceleration = (int)numericUpDownAccel.Value;

                // Brake system
                if (!NearestTrain.IsExtensionsCfg)
                {
                    status.MainReservoirPressure       = (int)numericUpDownMain.Value;
                    status.EqualizingReservoirPressure = (int)numericUpDownEqualizing.Value;
                    status.BrakePipePressure           = (int)numericUpDownPipe.Value;
                    status.BrakeCylinderPressure       = (int)numericUpDownCylinder.Value;
                    status.StraightAirPipePressure     = (int)numericUpDownAirPipe.Value;
                }

                // Door
                status.LeftDoorState            = (double)numericUpDownLeft.Value;
                status.LeftDoorAnticipatedOpen  = checkBoxLeftTarget.Checked;
                status.RightDoorState           = (double)numericUpDownRight.Value;
                status.RightDoorAnticipatedOpen = checkBoxRightTarget.Checked;

                // Handle
                status.Reverser       = (int)numericUpDownReverser.Value;
                status.PowerNotch     = (int)numericUpDownPowerNotch.Value;
                status.BrakeNotch     = (int)numericUpDownBrakeNotch.Value;
                status.HoldBrake      = checkBoxSetHoldBrake.Checked;
                status.EmergencyBrake = checkBoxSetEmergency.Checked;
                status.ConstSpeed     = checkBoxSetConstSpeed.Checked;

                // Plugin
                NearestTrain.EnablePluginSimulation = checkBoxEnablePlugin.Checked;
                NearestTrain.Status.PluginStates    = PluginStates.ToArray();

                NearestTrain.RequiredApply = true;
            }
        }
Example #2
0
        private void UpdateTrain()
        {
            lock (NearestTrain.LockObj)
            {
                checkBoxEnableTrain.Checked = NearestTrain.EnableSimulation;
                tabControlSettings.Enabled  = checkBoxEnableTrain.Checked;

                // Update Spec
                NearestTrainSpecs specs = NearestTrain.Specs;
                numericUpDownCars.Enabled = !NearestTrain.IsExtensionsCfg;
                numericUpDownCars.Value   = specs.NumberOfCars;

                numericUpDownPowerNotches.Enabled = !NearestTrain.IsExtensionsCfg;
                numericUpDownPowerNotches.Value   = specs.PowerNotches;

                checkBoxAirBrake.Enabled = !NearestTrain.IsExtensionsCfg;
                checkBoxAirBrake.Checked = specs.IsAirBrake;

                numericUpDownBrakeNotches.Enabled = !NearestTrain.IsExtensionsCfg && !specs.IsAirBrake;
                numericUpDownBrakeNotches.Value   = specs.BrakeNotches;

                checkBoxHoldBrake.Enabled = !NearestTrain.IsExtensionsCfg && !specs.IsAirBrake;
                checkBoxHoldBrake.Checked = specs.HasHoldBrake;

                checkBoxConstSpeed.Enabled = !NearestTrain.IsExtensionsCfg;
                checkBoxConstSpeed.Checked = specs.HasConstSpeed;

                // Update Status
                NearestTrainStatus status = NearestTrain.Status;

                numericUpDownSpeed.Value = (decimal)status.Speed;
                numericUpDownAccel.Value = (decimal)status.Acceleration;

                numericUpDownMain.Enabled = !NearestTrain.IsExtensionsCfg;
                numericUpDownMain.Value   = (decimal)status.MainReservoirPressure;

                numericUpDownEqualizing.Enabled = !NearestTrain.IsExtensionsCfg;
                numericUpDownEqualizing.Value   = (decimal)status.EqualizingReservoirPressure;

                numericUpDownPipe.Enabled = !NearestTrain.IsExtensionsCfg;
                numericUpDownPipe.Value   = (decimal)status.BrakePipePressure;

                numericUpDownCylinder.Enabled = !NearestTrain.IsExtensionsCfg;
                numericUpDownCylinder.Value   = (decimal)status.BrakeCylinderPressure;

                numericUpDownAirPipe.Enabled = !NearestTrain.IsExtensionsCfg;
                numericUpDownAirPipe.Value   = (decimal)status.StraightAirPipePressure;

                numericUpDownLeft.Value     = (decimal)status.LeftDoorState;
                checkBoxLeftTarget.Checked  = status.LeftDoorAnticipatedOpen;
                numericUpDownRight.Value    = (decimal)status.RightDoorState;
                checkBoxRightTarget.Checked = status.RightDoorAnticipatedOpen;

                numericUpDownReverser.Value     = status.Reverser;
                numericUpDownPowerNotch.Maximum = specs.PowerNotches;
                numericUpDownPowerNotch.Value   = status.PowerNotch;
                numericUpDownBrakeNotch.Maximum = specs.BrakeNotches;
                numericUpDownBrakeNotch.Value   = status.BrakeNotch;
                checkBoxSetHoldBrake.Enabled    = checkBoxHoldBrake.Checked;
                checkBoxSetHoldBrake.Checked    = status.HoldBrake;
                checkBoxSetEmergency.Checked    = status.EmergencyBrake;
                checkBoxSetConstSpeed.Enabled   = checkBoxConstSpeed.Checked;
                checkBoxSetConstSpeed.Checked   = status.ConstSpeed;

                checkBoxEnablePlugin.Checked = NearestTrain.EnablePluginSimulation;
                panelPlugin.Enabled          = checkBoxEnablePlugin.Checked;
                PluginStates = status.PluginStates.ToList();
            }

            UpdatePluginListView();
        }