private String Format(DelayedCommand dc) { StringBuilder s = new StringBuilder(); if (dc.AttitudeCommand != null) { switch (dc.AttitudeCommand.Mode) { case FlightMode.Off: s.Append("Mode: Off"); break; case FlightMode.KillRot: s.Append("Mode: Kill rotation"); break; case FlightMode.AttitudeHold: s.Append("Mode: Hold, "); switch (dc.AttitudeCommand.Attitude) { case FlightAttitude.Prograde: s.Append("Prograde"); break; case FlightAttitude.Retrograde: s.Append("Retrograde"); break; case FlightAttitude.NormalPlus: s.Append("Normal +"); break; case FlightAttitude.NormalMinus: s.Append("Normal -"); break; case FlightAttitude.RadialPlus: s.Append("Radial +"); break; case FlightAttitude.RadialMinus: s.Append("Radial -"); break; case FlightAttitude.Surface: s.Append(dc.AttitudeCommand.Orientation.eulerAngles.x.ToString("F1")); s.Append(", "); s.Append(dc.AttitudeCommand.Orientation.eulerAngles.y.ToString("F1")); s.Append(", "); s.Append(dc.AttitudeCommand.Orientation.eulerAngles.z.ToString("F1")); break; } break; case FlightMode.AltitudeHold: s.Append("Mode: Hold, "); s.Append(RTUtil.FormatSI(dc.AttitudeCommand.Altitude, "m")); break; } } else if (dc.ActionGroupCommand != null) { s.Append("Toggle "); s.Append(dc.ActionGroupCommand.ActionGroup.ToString()); } else if (dc.BurnCommand != null) { s.Append("Burn "); s.Append(dc.BurnCommand.Throttle.ToString("P2")); if (dc.BurnCommand.Duration != Single.NaN) { s.Append(", "); s.Append(dc.BurnCommand.Duration.ToString("F2")); s.Append("s"); } if (dc.BurnCommand.DeltaV != Single.NaN) { s.Append(", "); s.Append(dc.BurnCommand.DeltaV.ToString("F2")); s.Append("m/s"); } } else if (dc.DriveCommand != null) { dc.DriveCommand.GetDescription(s); } else if (dc.Event != null) { s.Append(dc.Event.BaseEvent.listParent.part.partInfo.title); s.Append(": "); s.Append(dc.Event.BaseEvent.GUIName); } double delay = Math.Max(dc.TimeStamp - RTUtil.GetGameTime(), 0); if (delay > 0 || dc.ExtraDelay > 0) { s.AppendLine(); s.Append("Signal delay: "); s.Append(delay.ToString("F2")); s.Append("s"); if (dc.ExtraDelay > 0) { s.Append(" (+"); s.Append(dc.ExtraDelay.ToString("F2")); s.Append("s)"); } } return s.ToString(); }
private String Format(DelayedCommand dc) { StringBuilder s = new StringBuilder(); if (dc.AttitudeCommand != null) { switch (dc.AttitudeCommand.Mode) { case FlightMode.Off: s.AppendLine("Mode: Off"); break; case FlightMode.KillRot: s.AppendLine("Mode: Kill rotation"); break; case FlightMode.AttitudeHold: s.Append("Mode: Hold "); switch (dc.AttitudeCommand.Frame) { case ReferenceFrame.Maneuver: s.Append("Maneuver "); break; case ReferenceFrame.Orbit: s.Append("OBT "); break; case ReferenceFrame.Surface: s.Append("SRF "); break; case ReferenceFrame.TargetVelocity: s.Append("TGT "); break; case ReferenceFrame.TargetParallel: s.Append("PAR "); break; } switch (dc.AttitudeCommand.Attitude) { case FlightAttitude.Prograde: s.AppendLine("Prograde"); break; case FlightAttitude.Retrograde: s.AppendLine("Retrograde"); break; case FlightAttitude.NormalPlus: s.AppendLine("Normal +"); break; case FlightAttitude.NormalMinus: s.AppendLine("Normal -"); break; case FlightAttitude.RadialPlus: s.AppendLine("Radial +"); break; case FlightAttitude.RadialMinus: s.AppendLine("Radial -"); break; case FlightAttitude.Surface: s.Append(dc.AttitudeCommand.Orientation.eulerAngles.x.ToString("F1")); s.Append("°, "); s.Append((360 - dc.AttitudeCommand.Orientation.eulerAngles.y).ToString("F1")); s.Append("°, "); s.Append(RTUtil.Format360To180(180 - dc.AttitudeCommand.Orientation.eulerAngles.z).ToString("F1")); s.AppendLine("°"); break; } break; case FlightMode.AltitudeHold: s.Append("Mode: Hold "); s.AppendLine(RTUtil.FormatSI(dc.AttitudeCommand.Altitude, "m")); break; } } if (dc.ActionGroupCommand != null) { s.Append("Toggle "); s.AppendLine(dc.ActionGroupCommand.ActionGroup.ToString()); } if (dc.BurnCommand != null) { s.Append("Burn "); s.Append(dc.BurnCommand.Throttle.ToString("P2")); if (dc.BurnCommand.Duration != Single.NaN) { s.Append(", "); s.Append(dc.BurnCommand.Duration.ToString("F2")); s.Append("s"); } if (dc.BurnCommand.DeltaV != Single.NaN) { s.Append(", "); s.Append(dc.BurnCommand.DeltaV.ToString("F2")); s.Append("m/s"); } s.AppendLine(); } if (dc.EventCommand != null) { s.Append(dc.EventCommand.BaseEvent.listParent.part.partInfo.title); s.Append(": "); s.AppendLine(dc.EventCommand.BaseEvent.GUIName); } if (dc.CancelCommand != null) { s.AppendLine("Cancelling a command"); } if (dc.TargetCommand != null) { s.Append("Target: "); s.AppendLine(dc.TargetCommand.Target != null ? dc.TargetCommand.Target.GetName() : "None"); } if (s.ToString().Equals("")) return ""; double delay = Math.Max(dc.TimeStamp - RTUtil.GameTime, 0); if (delay > 0 || dc.ExtraDelay > 0) { s.Append("Signal delay: "); s.Append(delay.ToString("F2")); s.Append("s"); if (dc.ExtraDelay > 0) { s.Append(" (+"); s.Append(dc.ExtraDelay.ToString("F2")); s.Append("s)"); } s.AppendLine(); } return s.ToString().TrimEnd(Environment.NewLine.ToCharArray()); }
public IEnumerator OnClickCancel(DelayedCommand dc) { yield return null; mFlightComputer.Enqueue(DelayedCommand.Cancel(dc)); }
public int CompareTo(DelayedCommand dc) { return TimeStamp.CompareTo(dc.TimeStamp); }
public void Upload(String fileName) { Log("Loading program \"{0}\".", fileName); Int32[] newCode; try { newCode = mProgcom.Assemble(fileName); } catch (FormatException) { Log("ERROR: Compilation failed."); return; } catch (Exception) { Log("ERROR: Unknown error."); return; } Log("Successfully assembled."); Log("Transmitting program (ETA: {0})", RTUtil.FormatDuration(mProgcom.Delay)); DelayedCommand dc = new DelayedCommand() { Program = newCode }; dc.TimeStamp += mProgcom.Delay; mQueue.Enqueue(dc); }
private String Format(DelayedCommand dc) { StringBuilder s = new StringBuilder(); if (dc.AttitudeCommand != null) { switch (dc.AttitudeCommand.Mode) { case FlightMode.Off: s.Append("Mode: Off"); break; case FlightMode.KillRot: s.Append("Mode: Kill rotation"); break; case FlightMode.AttitudeHold: s.Append("Mode: Hold attitude, "); switch (dc.AttitudeCommand.Attitude) { case FlightAttitude.Prograde: s.Append("Prograde"); break; case FlightAttitude.Retrograde: s.Append("Retrograde"); break; case FlightAttitude.NormalPlus: s.Append("Normal +"); break; case FlightAttitude.NormalMinus: s.Append("Normal -"); break; case FlightAttitude.RadialPlus: s.Append("Radial +"); break; case FlightAttitude.RadialMinus: s.Append("Radial -"); break; case FlightAttitude.Surface: s.Append("Surface: "); s.Append(dc.AttitudeCommand.Orientation.eulerAngles.x.ToString("F2")); s.Append(", "); s.Append(dc.AttitudeCommand.Orientation.eulerAngles.y.ToString("F2")); s.Append(", "); s.Append(dc.AttitudeCommand.Orientation.eulerAngles.z.ToString("F2")); break; } break; case FlightMode.AltitudeHold: s.Append("Mode: Hold attitude, "); s.Append(RTUtil.FormatSI(dc.AttitudeCommand.Altitude, "m")); break; } } else if (dc.ActionGroupCommand != null) { s.Append("Toggle "); s.Append(dc.ActionGroupCommand.ActionGroup.ToString()); } else if (dc.BurnCommand != null) { s.Append("Burn "); s.Append(dc.BurnCommand.Throttle.ToString("P2")); s.Append(", "); s.Append(dc.BurnCommand.Duration.ToString("F2")); s.Append("s"); s.Append(", "); s.Append(dc.BurnCommand.DeltaV.ToString("F2")); s.Append("m/s"); } double delay = dc.TimeStamp - RTUtil.GetGameTime(); if (delay > 0) { s.AppendLine(); s.Append("Active in: "); s.Append(delay.ToString("F2")); s.Append("s"); } return s.ToString(); }