Ejemplo n.º 1
0
 public static void WaitUntil(double time)
 {
     while (UniversalTime.Get() < time)
     {
         double remaining = time - UniversalTime.Get();
         int    newWarpFacter;
         if (remaining < 10)
         {
             newWarpFacter = 0;
         }
         else if (remaining < 60)
         {
             newWarpFacter = 2;
         }
         else if (remaining < 60 * 60)
         {
             newWarpFacter = 4;
         }
         else
         {
             newWarpFacter = 7;
         }
         if (Client.SpaceCenter().RailsWarpFactor != newWarpFacter)
         {
             Client.SpaceCenter().RailsWarpFactor = newWarpFacter;
         }
         System.Threading.Thread.Sleep(StandardDelay);
     }
     Client.SpaceCenter().RailsWarpFactor = 0;
 }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 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();
            }
        }