private void Assent() { double pastAp = starship.Orbit.ApoapsisAltitude - InitAlt; while (starship.Flight(starship.Orbit.Body.ReferenceFrame).VerticalSpeed > 0 || starship.Flight(starship.SurfaceReferenceFrame).SurfaceAltitude < Startup.GetInstance().GetFlightInfo().getMaxAltitude()) { double Ap = starship.Orbit.ApoapsisAltitude - InitAlt; float TWRTarget; if (Ap >= Startup.GetInstance().GetFlightInfo().getMaxAltitude()) { TWRTarget = 0.6f; } else { TWRTarget = 1.2f; } if (starship.Flight(starship.SurfaceReferenceFrame).SurfaceAltitude >= Startup.GetInstance().GetFlightInfo().getMaxAltitude()) { TWRTarget = 0.4f; starship.Control.Throttle = TWRTarget; break; } TWRTarget = ThrottleToTWR(TWRTarget); if (TWRTarget < 0.001f) { TWRTarget = 0.001f; } starship.Control.Throttle = TWRTarget; starship.AutoPilot.TargetHeading = (float)RetroHead(); starship.AutoPilot.TargetPitch = 90 - ((float)PitchRetro() / 4f); } }
public void Assent() { grassHopper.AutoPilot.Engage(); grassHopper.AutoPilot.TargetPitchAndHeading(90, 90); Merlin.Active = true; grassHopper.Control.Throttle = ThrottleToTWR(0.80f); Thread.Sleep(9000); if (TWR() < 0.75) { Console.WriteLine($"TWR = {TWR()} (0.74 required for liftoff)"); Merlin.Active = false; grassHopper.Control.Throttle = 0; Console.WriteLine("Abort"); } else { Console.WriteLine("Liftoff"); grassHopper.Control.Throttle = ThrottleToTWR(1.10f); } Thread.Sleep(5000); grassHopper.AutoPilot.TargetPitchAndHeading(85.5f, 1568); while (grassHopper.Flight(grassHopper.SurfaceReferenceFrame).SurfaceAltitude - InitAlt < Startup.GetInstance().GetFlightInfo().getMaxAltitude()) { grassHopper.Control.Throttle = ThrottleToTWR(1.10f); } GuidanceEvent(); AngleLimit = LimitOfAngle(grassHopper.Flight(grassHopper.SurfaceReferenceFrame).SurfaceAltitude - InitAlt, Distance(InitLat, ImpactPos().Item1, InitLon, ImpactPos().Item2)); while ((grassHopper.Flight(grassHopper.Orbit.Body.ReferenceFrame).VerticalSpeed > 0)) { grassHopper.Control.Throttle = ThrottleToTWR(0.8f); } }
public Startup() { CommandFire.FireRegistery(); instance = this; flightInfo = new FlightInfo(); //connection = new Connection(address: IPAddress.Parse("127.0.0.1"), rpcPort: 50000, streamPort: 50001); // Tester ::1 Console.WriteLine("Falcon is in startup"); int conNumber = 1; while (connection == null) { Console.WriteLine($"Connection tentative {conNumber}"); conNumber += 1; try { connection = new Connection(name: "UbuntuComputer", address: IPAddress.Parse("192.168.1.88"), rpcPort: 50000, streamPort: 50001); } catch { Thread.Sleep(1000); } } //connectionFirstStage = new Connection(address: IPAddress.Parse("192.168.1.88"), rpcPort: 50000, streamPort: 50001); connectionFirstStage = connection; Console.WriteLine("Program startup in 5 seconds..."); //Thread.Sleep(5000); if (Startup.GetInstance().GetFlightInfo().getMultiPhaseDragon() == true) { using (connection) { var krpc = connection.KRPC(); var spaceCenter = connection.SpaceCenter(); spacexEvent = new DragonEvent(spaceCenter.ActiveVessel, connection); } } else if (Startup.GetInstance().GetFlightInfo().getJustLandingBurn()) { var krpc = connection.KRPC(); var spaceCenter = connection.SpaceCenter(); spacexEvent = new LandingBurnEvent(spaceCenter.ActiveVessel, connection); } else if (Startup.GetInstance().GetFlightInfo().getDragonV2() == true) { var krpc = connection.KRPC(); var spaceCenter = connection.SpaceCenter(); spacexEvent = new DragonV2Event(spaceCenter.ActiveVessel, connection); } else if (GetFlightInfo().getHyperloop() == true) { var krpc = connection.KRPC(); var spaceCenter = connection.SpaceCenter(); spacexEvent = new Hyperloop(spaceCenter.ActiveVessel, connection); } else if (Startup.GetInstance().GetFlightInfo().getRocket() == "FH") { var krpc = connection.KRPC(); var spaceCenter = connection.SpaceCenter(); spacexEvent = new FalconheavyEvent(spaceCenter.ActiveVessel, connection); } else if (Startup.GetInstance().GetFlightInfo().getRocket() == "A5") { var krpc = connection.KRPC(); var spaceCenter = connection.SpaceCenter(); spacexEvent = new Ariane5Event(spaceCenter.ActiveVessel, connection); } else if (Startup.GetInstance().GetFlightInfo().getRocket() == "F9RDev") { var krpc = connection.KRPC(); var spaceCenter = connection.SpaceCenter(); spacexEvent = new F9RDevEvent(spaceCenter.ActiveVessel, connection); } else if (Startup.GetInstance().GetFlightInfo().getRocket() == "H2A") { var krpc = connection.KRPC(); var spaceCenter = connection.SpaceCenter(); spacexEvent = new H2AEvent(spaceCenter.ActiveVessel, connection); } else { var krpc = connection.KRPC(); var spaceCenter = connection.SpaceCenter(); spacexEvent = new Falcon9Event(spaceCenter.ActiveVessel, connection, connectionFirstStage); } }
public void CountDown() { var canvas = connection.UI().StockCanvas; var screenSize = canvas.RectTransform.Size; var panel = canvas.AddPanel(); var rect = panel.RectTransform; rect.Size = Tuple.Create(300.0 * 1, 150.0 * 1); rect.Position = Tuple.Create(Convert.ToDouble(screenSize.Item1) / 2 - 200 * 2.3, Convert.ToDouble(screenSize.Item2) / 2 - 80 * 2.3); float remeningHour = Startup.GetInstance().GetFlightInfo().getRemeningHour(); float remeningMinute = Startup.GetInstance().GetFlightInfo().getRemeningMinute(); float remeningSecond = Startup.GetInstance().GetFlightInfo().getRemeningSecond(); var time = panel.AddText($"T-{remeningHour}:{remeningMinute}:{remeningSecond}"); time.RectTransform.Anchor = Tuple.Create(0.7, 0.23); time.RectTransform.Position = Tuple.Create(0.0, 0.0); time.RectTransform.Size = Tuple.Create(350.0 * 1, 200.0 * 1); time.Color = Tuple.Create(0.0, 0.0, 0.0); time.Size = 40; time.Visible = true; var alt = panel.AddText($"{Math.Round(H2A.Flight(H2A.SurfaceReferenceFrame).SurfaceAltitude - initSurfaceAlt)}m"); alt.RectTransform.Anchor = Tuple.Create(0.7, -0.00); alt.RectTransform.Position = Tuple.Create(0.0, 0.0); alt.RectTransform.Size = Tuple.Create(350.0 * 1, 200.0 * 1); alt.Color = Tuple.Create(0.0, 0.0, 0.0); alt.Size = 40; alt.Visible = true; var speed = panel.AddText($"{Math.Round(H2A.Flight(H2A.SurfaceReferenceFrame).TrueAirSpeed)}m/s"); speed.RectTransform.Anchor = Tuple.Create(0.7, -0.23); speed.RectTransform.Position = Tuple.Create(0.0, 0.0); speed.RectTransform.Size = Tuple.Create(350.0 * 1, 200.0 * 1); speed.Color = Tuple.Create(0.0, 0.0, 0.0); speed.Size = 40; speed.Visible = true; Console.WriteLine($"T-{remeningHour}:{remeningMinute}:{remeningSecond}"); //Console.WriteLine(initSurfaceAlt); //Console.WriteLine(H2A.Flight(H2A.SurfaceReferenceFrame).SurfaceAltitude); while (T0 == false) { Thread.Sleep(1000); alt.Content = $"{Math.Round(H2A.Flight(H2A.SurfaceReferenceFrame).SurfaceAltitude - initSurfaceAlt)}m"; speed.Content = $"{Math.Round(H2A.Flight(H2A.SurfaceReferenceFrame).TrueAirSpeed)}m/s"; if (Hold == false) { remeningSecond -= 1; if (remeningSecond < 0) { remeningSecond = 59; remeningMinute -= 1; if (remeningMinute < 0) { remeningMinute = 59; remeningHour -= 1; } } if (remeningHour < 1) { if (remeningMinute < 10) { if (remeningSecond < 10) { //Console.WriteLine($"T-0{remeningMinute}:0{remeningSecond}"); time.Content = $"T-0{remeningMinute}:0{remeningSecond}"; } else { //Console.WriteLine($"T-0{remeningMinute}:{remeningSecond}"); time.Content = $"T-0{remeningMinute}:{remeningSecond}"; } } else { if (remeningSecond < 10) { //Console.WriteLine($"T-{remeningMinute}:0{remeningSecond}"); time.Content = $"T-{remeningMinute}:0{remeningSecond}"; } else { //Console.WriteLine($"T-{remeningMinute}:{remeningSecond}"); time.Content = $"T-{remeningMinute}:{remeningSecond}"; } } } else { if (remeningMinute < 10) { if (remeningSecond < 10) { //Console.WriteLine($"T-{remeningHour}:0{remeningMinute}:0{remeningSecond}"); time.Content = $"T-{remeningHour}:0{remeningMinute}:0{remeningSecond}"; } else { //Console.WriteLine($"T-{remeningHour}:0{remeningMinute}:{remeningSecond}"); time.Content = $"T-{remeningHour}:0{remeningMinute}:{remeningSecond}"; } } else { if (remeningSecond < 10) { //Console.WriteLine($"T-{remeningHour}:{remeningMinute}:0{remeningSecond}"); time.Content = $"T-{remeningMinute}:0{remeningSecond}"; } else { //Console.WriteLine($"T-{remeningHour}:{remeningMinute}:{remeningSecond}"); time.Content = $"T-{remeningHour}:{remeningMinute}:{remeningSecond}"; } } } if (remeningHour == 0 && remeningMinute == 0 && remeningSecond < 8) { T4 = true; } if (remeningHour < 0) { T0 = true; break; } } } float second = 0; float minute = 0; float hour = 0; remeningHour = hour; remeningMinute = minute; remeningSecond = second; Console.WriteLine($"T+0{remeningMinute}:0{remeningSecond}"); time.Content = $"T+0{remeningMinute}:0{remeningSecond}"; while (true) { Thread.Sleep(1000); alt.Content = $"{Math.Round(H2A.Flight(H2A.SurfaceReferenceFrame).SurfaceAltitude - initSurfaceAlt)}m"; speed.Content = $"{Math.Round(H2A.Flight(H2A.SurfaceReferenceFrame).TrueAirSpeed)}m/s"; if (Hold == false) { remeningSecond += 1; if (remeningSecond > 59) { remeningSecond = 0; remeningMinute += 1; if (remeningMinute > 59) { remeningMinute = 0; remeningHour += 1; } } if (remeningHour < 1) { if (remeningMinute < 10) { if (remeningSecond < 10) { //Console.WriteLine($"T+0{remeningMinute}:0{remeningSecond}"); time.Content = $"T+0{remeningMinute}:0{remeningSecond}"; } else { //Console.WriteLine($"T+0{remeningMinute}:{remeningSecond}"); time.Content = $"T+0{remeningMinute}:{remeningSecond}"; } } else { if (remeningSecond < 10) { //Console.WriteLine($"T+{remeningMinute}:0{remeningSecond}"); time.Content = $"T+{remeningMinute}:0{remeningSecond}"; } else { //Console.WriteLine($"T+{remeningMinute}:{remeningSecond}"); time.Content = $"T+{remeningMinute}:{remeningSecond}"; } } } else { if (remeningMinute < 10) { if (remeningSecond < 10) { //Console.WriteLine($"T+{remeningHour}:0{remeningMinute}:0{remeningSecond}"); time.Content = $"T+{remeningHour}:0{remeningMinute}:0{remeningSecond}"; } else { //Console.WriteLine($"T+{remeningHour}:0{remeningMinute}:{remeningSecond}"); time.Content = $"T+{remeningHour}:0{remeningMinute}:{remeningSecond}"; } } else { if (remeningSecond < 10) { //Console.WriteLine($"T+{remeningHour}:{remeningMinute}:0{remeningSecond}"); time.Content = $"T+{remeningMinute}:0{remeningSecond}"; } else { //Console.WriteLine($"T+{remeningHour}:{remeningMinute}:{remeningSecond}"); time.Content = $"T+{remeningHour}:{remeningMinute}:{remeningSecond}"; } } } } } }