コード例 #1
0
        //<param name="mode">The initialization mode.</param>
        internal override void Initialize(InitializationModes mode)
        {
            //Set Starting Paramaters Here

            //Timers to zero
            deadmanstimer = 0.0;
            //Split vigilance times into an array
            try
            {
                string[] splitvigilancetimes = vigilancetimes.Split(',');
                vigilancearray = new int[splitvigilancetimes.Length];
                for (int i = 0; i < vigilancearray.Length; i++)
                {
                    vigilancearray[i] = Int32.Parse(splitvigilancetimes[i], NumberStyles.Number, CultureInfo.InvariantCulture);
                }
            }
            catch
            {
                InternalFunctions.LogError("vigilancetimes", 0);
            }
            //
            if (DRAEnabled == false || DRAStartState == -1)
            {
                Train.drastate = false;
            }
            else
            {
                Train.drastate = true;
                Train.TractionManager.DemandPowerCutoff("Power cutoff was demanded by the DRA");
            }
            DeadmansHandleState = DeadmanStates.None;
        }
コード例 #2
0
ファイル: StringArrayParser.cs プロジェクト: leezer3/bvec_ats
 /// <summary>Parses a comma separated string to an array of doubles</summary>
 /// <param name="InputString">The input string.</param>
 /// <param name="OutputArray">The array to output to.</param>
 /// <param name="FailingValue">The error string to pass to the debug logger if this fails.</param>
 public static void ParseStringToDoubleArray(string InputString, ref double[] OutputArray, string FailingValue)
 {
     try
     {
         string[] splitheatingrate = InputString.Split(',');
         OutputArray = new double[splitheatingrate.Length];
         for (int i = 0; i < OutputArray.Length; i++)
         {
             OutputArray[i] = Double.Parse(splitheatingrate[i], NumberStyles.Number, CultureInfo.InvariantCulture);
         }
     }
     catch
     {
         InternalFunctions.LogError("An error occured whilst attempting to parse " + FailingValue, 6);
     }
 }
コード例 #3
0
ファイル: Gearbox.cs プロジェクト: leezer3/bvec_ats
        /// <summary>Call this function to initialise the gearbox</summary>
        internal void Initialize()
        {
            var geararray        = new int[] { };
            var gearfadeinarray  = new int[] { };
            var gearfadeoutarray = new int[] { };

            //First, test whether we have a correctly setup gearbox
            if (GearRatios != null && GearFadeInRanges != null && GearFadeOutRanges != null)
            {
                try
                {
                    //Split gear ratios into an array
                    var splitgearratios = GearRatios.Split(',');
                    geararray = new int[splitgearratios.Length];
                    for (var i = 0; i < geararray.Length; i++)
                    {
                        geararray[i] = (int)(double.Parse(splitgearratios[i], CultureInfo.InvariantCulture));
                    }
                }
                catch
                {
                    InternalFunctions.LogError("gearratios", 0);
                }
                try
                {
                    //Split gear fade in range into an array
                    var splitgearfade = GearFadeOutRanges.Split(',');
                    gearfadeinarray = new int[splitgearfade.Length];
                    for (var i = 0; i < gearfadeinarray.Length; i++)
                    {
                        gearfadeinarray[i] = (int)double.Parse(splitgearfade[i], NumberStyles.Number, CultureInfo.InvariantCulture);
                    }
                }
                catch
                {
                    InternalFunctions.LogError("gearfadeinrange", 0);
                }
                try
                {
                    //Split gear fade out range into an array
                    var splitgearfade1 = GearFadeOutRanges.Split(',');
                    gearfadeoutarray = new int[splitgearfade1.Length];
                    for (var i = 0; i < gearfadeoutarray.Length; i++)
                    {
                        gearfadeoutarray[i] =
                            (int)double.Parse(splitgearfade1[i], NumberStyles.Number, CultureInfo.InvariantCulture);
                    }
                }
                catch
                {
                    InternalFunctions.LogError("gearfadeoutrange", 0);
                }

                if (geararray.Length != gearfadeinarray.Length && geararray.Length != gearfadeoutarray.Length)
                {
                    var i = 0;
                    while (i < geararray.Length)
                    {
                        //Add the gear to the gearbox
                        Gears[i].GearRatio    = geararray[i];
                        Gears[i].FadeInRange  = gearfadeinarray[i];
                        Gears[i].FadeOutRange = gearfadeoutarray[i];
                        i++;
                    }
                }
                else
                {
                    InternalFunctions.LogError("gearratios, gearfadeinrange and gearfadeoutrange should be of identical lengths.", 6);
                }
            }
            //Return the total number of gears plus one [Neutral]
            TotalGears = Gears.Count + 1;
        }