private IEnumerator OnPowerClick(PowerModes nextPowerMode) { yield return(null); if (mFlightComputer.InputAllowed) { switch (nextPowerMode) { case PowerModes.Hibernate: mPowerMode = PowerModes.Hibernate; mFlightComputer.Enqueue(HibernationCommand.Hibernate()); break; case PowerModes.AntennaSaver: mPowerMode = PowerModes.AntennaSaver; mFlightComputer.Enqueue(HibernationCommand.AntennaSaver()); break; case PowerModes.Wake: mPowerMode = PowerModes.Wake; mFlightComputer.Enqueue(HibernationCommand.WakeUp()); break; default: mPowerMode = PowerModes.Normal; break; } } }
private void Confirm() { ICommand newCommand; switch (mMode) { default: case ComputerMode.Off: mAttitude = FlightAttitude.Null; newCommand = AttitudeCommand.Off(); break; case ComputerMode.Kill: mAttitude = FlightAttitude.Null; newCommand = AttitudeCommand.KillRot(); break; case ComputerMode.Node: mAttitude = FlightAttitude.Null; newCommand = AttitudeCommand.ManeuverNode(); break; case ComputerMode.TargetPos: mAttitude = (mAttitude == FlightAttitude.Null) ? FlightAttitude.Prograde : mAttitude; newCommand = AttitudeCommand.WithAttitude(Attitude, ReferenceFrame.TargetParallel); break; case ComputerMode.Orbital: mAttitude = (mAttitude == FlightAttitude.Null) ? FlightAttitude.Prograde : mAttitude; newCommand = AttitudeCommand.WithAttitude(Attitude, ReferenceFrame.Orbit); break; case ComputerMode.Surface: mAttitude = (mAttitude == FlightAttitude.Null) ? FlightAttitude.Prograde : mAttitude; newCommand = AttitudeCommand.WithAttitude(Attitude, ReferenceFrame.Surface); break; case ComputerMode.TargetVel: mAttitude = (mAttitude == FlightAttitude.Null) ? FlightAttitude.Prograde : mAttitude; newCommand = AttitudeCommand.WithAttitude(Attitude, ReferenceFrame.TargetVelocity); break; case ComputerMode.Custom: mAttitude = FlightAttitude.Null; newCommand = AttitudeCommand.WithSurface(Pitch, Heading, Roll); break; } mFlightComputer.Enqueue(newCommand); }
private IEnumerator OnApplyClick() { yield return(null); if (mFlightComputer.InputAllowed) { kp = RTUtil.ConstrictNum(kp, false); ki = RTUtil.ConstrictNum(ki, false); kd = RTUtil.ConstrictNum(kd, false); mFlightComputer.Enqueue(PIDCommand.WithNewChanges(Double.Parse(kp), Double.Parse(ki), Double.Parse(kd))); } }
//exposed method called by other mods, passing a ConfigNode to RemoteTech public static bool QueueCommandToFlightComputer(ConfigNode externalData) { if (RTCore.Instance == null) { return(false); } //check we were actually passed a config node if (externalData == null) { return(false); } // check our min values if (!externalData.HasValue("GUIDString") && !externalData.HasValue("Executor") && !externalData.HasValue("ReflectionType")) { return(false); } try { Guid externalVesselId = new Guid(externalData.GetValue("GUIDString")); // you can only push a new external command if the vessel guid is the current active vessel if (FlightGlobals.ActiveVessel.id != externalVesselId) { RTLog.Verbose("Passed Guid is not the active Vessels guid", RTLogLevel.API); return(false); } // maybe we should look if this vessel hasLocal control or not. If so, we can execute the command // immediately // get the flight computer FlightComputer.FlightComputer computer = RTCore.Instance.Satellites[externalVesselId].FlightComputer; var extCmd = FlightComputer.Commands.ExternalAPICommand.FromExternal(externalData); computer.Enqueue(extCmd); return(true); } catch (Exception ex) { RTLog.Verbose(ex.Message, RTLogLevel.API); } return(false); }
private IEnumerator OnControlClick(FlightControlOutput output) { yield return(null); if (mFlightComputer.InputAllowed) { switch (output) { case FlightControlOutput.IgnorePitch: if ((mControlOutputMask & FlightControlOutput.IgnorePitch) == FlightControlOutput.IgnorePitch) { mControlOutputMask &= ~FlightControlOutput.IgnorePitch; } else { mControlOutputMask |= FlightControlOutput.IgnorePitch; } break; case FlightControlOutput.IgnoreHeading: if ((mControlOutputMask & FlightControlOutput.IgnoreHeading) == FlightControlOutput.IgnoreHeading) { mControlOutputMask &= ~FlightControlOutput.IgnoreHeading; } else { mControlOutputMask |= FlightControlOutput.IgnoreHeading; } break; case FlightControlOutput.IgnoreRoll: if ((mControlOutputMask & FlightControlOutput.IgnoreRoll) == FlightControlOutput.IgnoreRoll) { mControlOutputMask &= ~FlightControlOutput.IgnoreRoll; } else { mControlOutputMask |= FlightControlOutput.IgnoreRoll; } break; } bool pitch = (mControlOutputMask & FlightControlOutput.IgnorePitch) == FlightControlOutput.IgnorePitch, heading = (mControlOutputMask & FlightControlOutput.IgnoreHeading) == FlightControlOutput.IgnoreHeading, roll = (mControlOutputMask & FlightControlOutput.IgnoreRoll) == FlightControlOutput.IgnoreRoll; mFlightComputer.Enqueue(FlightControlCommand.WithPHR(pitch, heading, roll)); } }
private void EnqueueTurn() { mFlightComputer.Enqueue(DriveCommand.Turn(mSteering, Turn, Speed)); }
public IEnumerator OnClickCancel(ICommand c) { yield return(null); mFlightComputer.Enqueue(CancelCommand.WithCommand(c)); }