Пример #1
0
        private void RebuildDial()
        {
            if (Notches == null)
            {
                //Build a best-guess collection of notches
                _minAngle = DEFAULT_MIN_ANGLE;
                _maxAngle = DEFAULT_MAX_ANGLE;

                int    spaces       = (DefaultNotchCount - 1);
                double notchSpacing = (_maxAngle - _minAngle) / spaces;

                double realMin = RealMinimum, realMax = RealMaximum;

                var notches = from i in Enumerable.Range(0, DefaultNotchCount)
                              let adjustedAngle = _minAngle + (i * notchSpacing)
                                                  let labelValue = realMin + (i * ((realMax - realMin) / spaces))
                                                                   select new Dial360Notch {
                    Angle = adjustedAngle,
                    Label = labelValue.ToString(CultureInfo.InvariantCulture),
                };

                DialPoints.ItemsSource = notches;
            }
            else
            {
                //Use the data-bound collection of notches
                var angles = Notches.Select(n => n.Angle).ToArray();

                _minAngle = angles.Min();
                _maxAngle = angles.Max();

                DialPoints.ItemsSource = Notches;
            }
        }
Пример #2
0
        public ScriptedBrakeController(ScriptedBrakeController controller, MSTSLocomotive locomotive)
        {
            Simulator  = locomotive.Simulator;
            Locomotive = locomotive;

            scriptName                     = controller.scriptName;
            MaxPressurePSI                 = controller.MaxPressurePSI;
            MaxOverchargePressurePSI       = controller.MaxOverchargePressurePSI;
            ReleaseRatePSIpS               = controller.ReleaseRatePSIpS;
            QuickReleaseRatePSIpS          = controller.QuickReleaseRatePSIpS;
            OverchargeEliminationRatePSIpS = controller.OverchargeEliminationRatePSIpS;
            ApplyRatePSIpS                 = controller.ApplyRatePSIpS;
            SlowApplicationRatePSIpS       = controller.SlowApplicationRatePSIpS;
            EmergencyRatePSIpS             = controller.EmergencyRatePSIpS;
            FullServReductionPSI           = controller.FullServReductionPSI;
            MinReductionPSI                = controller.MinReductionPSI;

            CurrentValue = controller.CurrentValue;
            MinimumValue = controller.MinimumValue;
            MaximumValue = controller.MaximumValue;
            StepSize     = controller.StepSize;

            controller.Notches.ForEach(
                (item) => { Notches.Add(new MSTSNotch(item)); }
                );

            Initialize();
        }
Пример #3
0
 public void Rotate()
 {
     Position++;
     if (Position > 26)
     {
         Position = 1;
     }
     if (EnableNotch && Notches.Contains(Position))
     {
         if (RotateNotch != null)
         {
             RotateNotch();
         }
     }
 }
Пример #4
0
 public void RotateBack()
 {
     Position--;
     if (Position < 1)
     {
         Position = 26;
     }
     if (EnableNotch && Notches.Contains(Position))
     {
         if (RotateNotchBack != null)
         {
             RotateNotchBack();
         }
     }
 }
Пример #5
0
        public void Parse(string lowercasetoken, STFReader stf)
        {
            switch (lowercasetoken)
            {
            case "engine(trainbrakescontrollermaxsystempressure":
            case "engine(enginebrakescontrollermaxsystempressure":
                MaxPressurePSI = stf.ReadFloatBlock(STFReader.Units.PressureDefaultPSI, null);
                break;

            case "engine(ortstrainbrakescontrollermaxoverchargepressure":
                MaxOverchargePressurePSI = stf.ReadFloatBlock(STFReader.Units.PressureDefaultPSI, null);
                break;

            case "engine(trainbrakescontrollermaxreleaserate":
            case "engine(enginebrakescontrollermaxreleaserate":
                ReleaseRatePSIpS = stf.ReadFloatBlock(STFReader.Units.PressureRateDefaultPSIpS, null);
                break;

            case "engine(trainbrakescontrollermaxquickreleaserate":
            case "engine(enginebrakescontrollermaxquickreleaserate":
                QuickReleaseRatePSIpS = stf.ReadFloatBlock(STFReader.Units.PressureRateDefaultPSIpS, null);
                break;

            case "engine(ortstrainbrakescontrolleroverchargeeliminationrate":
                OverchargeEliminationRatePSIpS = stf.ReadFloatBlock(STFReader.Units.PressureRateDefaultPSIpS, null);
                break;

            case "engine(trainbrakescontrollermaxapplicationrate":
            case "engine(enginebrakescontrollermaxapplicationrate":
                ApplyRatePSIpS = stf.ReadFloatBlock(STFReader.Units.PressureRateDefaultPSIpS, null);
                break;

            case "engine(trainbrakescontrolleremergencyapplicationrate":
            case "engine(enginebrakescontrolleremergencyapplicationrate":
                EmergencyRatePSIpS = stf.ReadFloatBlock(STFReader.Units.PressureRateDefaultPSIpS, null);
                break;

            case "engine(trainbrakescontrollerfullservicepressuredrop":
            case "engine(enginebrakescontrollerfullservicepressuredrop":
                FullServReductionPSI = stf.ReadFloatBlock(STFReader.Units.PressureDefaultPSI, null);
                break;

            case "engine(trainbrakescontrollerminpressurereduction":
            case "engine(enginebrakescontrollerminpressurereduction":
                MinReductionPSI = stf.ReadFloatBlock(STFReader.Units.PressureDefaultPSI, null);
                break;

            case "engine(ortstrainbrakescontrollerslowapplicationrate":
            case "engine(ortsenginebrakescontrollerslowapplicationrate":
                SlowApplicationRatePSIpS = stf.ReadFloatBlock(STFReader.Units.PressureRateDefaultPSIpS, null);
                break;

            case "engine(enginecontrollers(brake_train":
            case "engine(enginecontrollers(brake_engine":
            case "engine(enginecontrollers(brake_brakeman":
                stf.MustMatch("(");
                MinimumValue = stf.ReadFloat(STFReader.Units.None, null);
                MaximumValue = stf.ReadFloat(STFReader.Units.None, null);
                StepSize     = stf.ReadFloat(STFReader.Units.None, null);
                CurrentValue = stf.ReadFloat(STFReader.Units.None, null);
                string token = stf.ReadItem();                      // s/b numnotches
                if (string.Compare(token, "NumNotches", true) != 0) // handle error in gp38.eng where extra parameter provided before NumNotches statement
                {
                    stf.ReadItem();
                }
                stf.MustMatch("(");
                stf.ReadInt(null);
                stf.ParseBlock(new STFReader.TokenProcessor[] {
                    new STFReader.TokenProcessor("notch", () => {
                        stf.MustMatch("(");
                        float value = stf.ReadFloat(STFReader.Units.None, null);
                        int smooth  = stf.ReadInt(null);
                        string type = stf.ReadString();
                        Notches.Add(new MSTSNotch(value, smooth, type, stf));
                        if (type != ")")
                        {
                            stf.SkipRestOfBlock();
                        }
                    }),
                });
                break;

            case "engine(ortstrainbrakecontroller":
            case "engine(ortsenginebrakecontroller":
                if (Locomotive.Train as AITrain == null)
                {
                    scriptName = stf.ReadStringBlock(null);
                }
                break;
            }
        }