Exemple #1
0
        /// <summary>
        /// executes 'node,' does NOT delete 'node'
        /// </summary>
        /// <param name="node"></param>
        /// <param name="burnAngleErrMarigin"></param>
        void ExecuteManuverNode(Node node, double burnAngleErrMarigin, double deltaVErrMarigin = 0.1)
        {
            //telling the autopilot to point the spacecraft at the node
            Ship.AutoPilot.TargetDirection = node.BurnVector();

            //weighting for the vessel to be pointed at the node
            while (Ship.AutoPilot.Error > burnAngleErrMarigin)
            {
                System.Threading.Thread.Sleep(StandardDelay);
            }

            //warping to the manuver
            WaitUntil(UniversalTime.Get() + node.TimeTo);

            //executing the manuver
            while (node.RemainingDeltaV > deltaVErrMarigin)
            {
                Ship.AutoPilot.TargetDirection = node.RemainingBurnVector(Ship.OrbitalReferenceFrame);
                if (Ship.AutoPilot.Error <= burnAngleErrMarigin)
                {
                    if (node.RemainingDeltaV >= 100)
                    {
                        Ship.Control.Throttle = 1;
                    }
                    else
                    {
                        Ship.Control.Throttle = (float)(node.RemainingDeltaV / 100);
                    }
                }
                else
                {
                    Ship.Control.Throttle = 0;
                }
                CheckStage();
                System.Threading.Thread.Sleep(StandardDelay);
                WriteLine("Delta-V = " + node.RemainingDeltaV);
            }
            Ship.Control.Throttle = 0;
        }
Exemple #2
0
        public static string GetEnvironmentInfo()
        {
            var tickCount              = UniversalTime.GetTickCount();
            var totalDays              = (double)tickCount / DateTimeConstants.MillisecondsPerDay;
            var zeroDateTime           = LocalTime.Default.Now.AddDays(-totalDays);
            var tickCountString        = $"{tickCount} ({totalDays:N2} days(s) from {zeroDateTime:yyyy.MM.dd HH:mm:ss})";
            var workingSet             = Environment.WorkingSet;
            var dotNetFrameworkRelease = GetDotNetFrameworkRelease();
            var dotNetFrameworkVersion = GetDotNetFrameworkVersion(dotNetFrameworkRelease);
            var windowsVersionInfo     = GetWindowsVersionInfo();

            var message = $@"Environment information
MachineName:            {Environment.MachineName}
ProcessorCount:         {Environment.ProcessorCount}
OSVersion:              {Environment.OSVersion}
Windows ProductName:    {windowsVersionInfo.ProductName}
Windows ReleaseId:      {windowsVersionInfo.ReleaseId}
Windows CurrentBuild:   {windowsVersionInfo.CurrentBuild}
Is64BitOperatingSystem: {Environment.Is64BitOperatingSystem}
Is64BitProcess:         {Environment.Is64BitProcess}
IntPtr.Size:            {IntPtr.Size} ({IntPtr.Size * 8} bit)
CLR version:            {Environment.Version}
.NET Framework release: {dotNetFrameworkRelease}
.NET Framework version: {dotNetFrameworkVersion}
UserDomainName:         {Environment.UserDomainName}
UserName:               {Environment.UserName}
UserInteractive:        {Environment.UserInteractive}
CurrentDirectory:       {Environment.CurrentDirectory}
CommandLine:            {Environment.CommandLine},
GC IsServerGC:          {GCSettings.IsServerGC}
GC LargeObjectHeapCompactionMode: {GCSettings.LargeObjectHeapCompactionMode}
GC LatencyMode:         {GCSettings.LatencyMode}
WorkingSet:             {(double) workingSet / (1024 * 1024):N} MB ({workingSet} bytes)
TickCount:              {tickCountString}
Stopwatch.Frequency:    {Stopwatch.Frequency}";

            return(message);
        }
Exemple #3
0
        private Node CreateNode(Elements changing, double newValue)
        {
            switch (changing)
            {
            case Elements.Apoapsis:
            {
                return(Ship.Control.AddNode(
                           Ship.Orbit.TimeToPeriapsis + UniversalTime.Get(),
                           (float)(VisaVersaEquation(Ship.Orbit.Periapsis, (Ship.Orbit.Periapsis + newValue) / 2)
                                   - VelocityAtRadius(Ship.Orbit.Periapsis))));
            }

            case Elements.Periapsis:
            {
                return(Ship.Control.AddNode(
                           Ship.Orbit.TimeToApoapsis + UniversalTime.Get(),
                           (float)(VisaVersaEquation(Ship.Orbit.Apoapsis, (Ship.Orbit.Apoapsis + newValue) / 2)
                                   - VelocityAtRadius(Ship.Orbit.Apoapsis))));
            }

            default: throw new NotImplementedException();
            }
        }
Exemple #4
0
        public void TestCompareTo()
        {
            UniversalTime date = new UniversalTime(1974, 8, 16, 0, 30, 0);

            Assert.AreEqual(0, date.CompareTo(new UniversalTime(1974, 8, 16, 0, 30, 0)));
            Assert.AreEqual(-1, date.CompareTo(new UniversalTime(1975, 8, 16, 0, 30, 0)));
            Assert.AreEqual(1, date.CompareTo(new UniversalTime(1973, 8, 16, 0, 30, 0)));
            Assert.AreEqual(7, date.CompareTo(new UniversalTime(1974, 1, 16, 0, 30, 0)));
            Assert.AreEqual(-4, date.CompareTo(new UniversalTime(1974, 12, 16, 0, 30, 0)));
            Assert.AreEqual(6, date.CompareTo(new UniversalTime(1974, 8, 10, 0, 30, 0)));
            Assert.AreEqual(-14, date.CompareTo(new UniversalTime(1974, 8, 30, 0, 30, 0)));
            Assert.AreEqual(-1, date.CompareTo(new UniversalTime(1974, 8, 16, 1, 30, 0)));
            Assert.AreEqual(20, date.CompareTo(new UniversalTime(1974, 8, 16, 0, 10, 0)));
            Assert.AreEqual(-20, date.CompareTo(new UniversalTime(1974, 8, 16, 0, 50, 0)));
            Assert.AreEqual(-10, date.CompareTo(new UniversalTime(1974, 8, 16, 0, 30, 10)));

            Assert.AreEqual(0, date.CompareTo(new DateTime(1974, 8, 16, 0, 30, 0, 500)));
            Assert.AreEqual(0, date.CompareTo(new DateTimeOffset(1974, 8, 16, 0, 30, 0, 500, TimeSpan.FromHours(1))));
            Assert.AreEqual(-1, date.CompareTo(1));
            object o = new UniversalTime(1974, 8, 16, 0, 30, 0);

            Assert.AreEqual(0, date.CompareTo(o));
        }
Exemple #5
0
        public void TestToString()
        {
            UniversalTime date0 = new UniversalTime(1974, 8, 16, 0, 30, 0);
            UniversalTime date1 = new UniversalTime(1974, 8, 18, 15, 3, 25);

            Assert.AreEqual("16/08/1974 00:30:00", date0.ToString());
            Assert.AreEqual("16/08/1974 00:30:00", date0.ToString(""));
            Assert.AreEqual("16/08/1974 00:30:00", date0.ToString("", null));
            Assert.AreEqual("16/08/1974 00:30:00", date0.ToString("", System.Globalization.CultureInfo.GetCultureInfo("fr-FR")));
            Assert.AreEqual("16/08/1974 00:30:00", date0.ToString("", System.Globalization.CultureInfo.GetCultureInfo("en-us")));

            Assert.AreEqual("d 16 8 74 \\", date0.ToString(@"\d d M y \"));

            var culture = System.Globalization.CultureInfo.GetCultureInfo("en-us");

            Assert.AreEqual("16 16 Fri Friday Friday", date0.ToString("d dd ddd dddd ddddd", culture));
            Assert.AreEqual("18 18 Sun Sunday Sunday", date1.ToString("d dd ddd dddd ddddd", culture));
            Assert.AreEqual("16 16 ven. vendredi vendredi", date0.ToString("d dd ddd dddd ddddd", System.Globalization.CultureInfo.GetCultureInfo("fr-FR")));

            Assert.AreEqual("8 08 Aug August August", date0.ToString("M MM MMM MMMM MMMMM", culture));

            Assert.AreEqual("74 74 1974 1974 1974", date0.ToString("y yy yyy yyyy yyyyy", culture));

            Assert.AreEqual("0 00 00 00 00", date0.ToString("h hh hhh hhhh hhhhh", culture));
            Assert.AreEqual("3 03 03 03 03", date1.ToString("h hh hhh hhhh hhhhh", culture));
            Assert.AreEqual("0 00 00 00 00", date0.ToString("H HH HHH HHHH HHHHH", culture));
            Assert.AreEqual("15 15 15 15 15", date1.ToString("H HH HHH HHHH HHHHH", culture));

            Assert.AreEqual("30 30 30 30 30", date0.ToString("m mm mmm mmmm mmmmm", culture));
            Assert.AreEqual("3 03 03 03 03", date1.ToString("m mm mmm mmmm mmmmm", culture));

            Assert.AreEqual("0 00 00 00 00", date0.ToString("s ss sss ssss sssss", culture));
            Assert.AreEqual("25 25 25 25 25", date1.ToString("s ss sss ssss sssss", culture));

            Assert.AreEqual("A AM AM", date0.ToString("t tt ttt", culture));
            Assert.AreEqual("P PM PM", date1.ToString("t tt ttt", culture));
        }