private void drawPIDValues(SASList controllerID, string inputName) { SASController controller = controllerID.GetSAS(this); controller.bShow = GUILayout.Toggle(controller.bShow, inputName, GeneralUI.UISkin.customStyles[(int)myStyles.btnToggle]); if (controller.bShow) { controller.PGain = GeneralUI.labPlusNumBox(GeneralUI.KpLabel, controller.PGain.ToString("N3"), 45); controller.IGain = GeneralUI.labPlusNumBox(GeneralUI.KiLabel, controller.IGain.ToString("N3"), 45); controller.DGain = GeneralUI.labPlusNumBox(GeneralUI.KdLabel, controller.DGain.ToString("N3"), 45); controller.Scalar = GeneralUI.labPlusNumBox(GeneralUI.ScalarLabel, controller.Scalar.ToString("N3"), 45); } }
void setCtrlState(SASList ID, double error, double rate, ref float axisCtrlState) { PIDmode mode = PIDmode.PID; if (!vesModule.vesselRef.checkLanded() && vesModule.vesselRef.IsControllable) { mode = PIDmode.PD; // no integral when it can't do anything useful } if (allowControl(ID)) { axisCtrlState = ID.GetSAS(this).ResponseF(error, rate, mode); } else if (!Utils.hasInput(ID)) { axisCtrlState = 0; // kill off stock SAS inputs } // nothing happens if player input is present }
/// <summary> /// Draws a toggle button and text box of specified widths with update button. /// </summary> /// <param name="toggleText"></param> /// <param name="boxVal"></param> /// <param name="toggleWidth"></param> /// <param name="boxWidth"></param> /// <returns></returns> public double TogPlusNumBox(string toggleText, SASList controllerID, double currentVal, float toggleWidth, float boxWidth) { double setPoint = controllerID.GetSAS(this).SetPoint; GUILayout.BeginHorizontal(); bool tempState = GUILayout.Toggle(bActive[(int)controllerID], toggleText, GeneralUI.UISkin.customStyles[(int)myStyles.btnToggle], GUILayout.Width(toggleWidth)); if (tempState != bActive[(int)controllerID]) { bActive[(int)controllerID] = tempState; if (bActive[(int)controllerID]) { setPoint = currentVal; targets[(int)controllerID] = currentVal.ToString("0.00"); } } string tempText = GUILayout.TextField(targets[(int)controllerID], GeneralUI.UISkin.customStyles[(int)myStyles.numBoxText], GUILayout.Width(boxWidth)); targets[(int)controllerID] = tempText; if (GUILayout.Button("u")) { double temp; if (double.TryParse(targets[(int)controllerID], out temp)) { setPoint = temp; } bActive[(int)controllerID] = true; } GUILayout.EndHorizontal(); return(setPoint); }
void updateSetpoint(SASList ID, double setpoint) { ID.GetSAS(this).SetPoint = setpoint; targets[(int)ID] = setpoint.ToString("0.00"); }
void setCtrlState(SASList ID, double error, double rate, ref float axisCtrlState) { PIDmode mode = PIDmode.PID; if (!vesModule.vesselRef.checkLanded() && vesModule.vesselRef.IsControllable) mode = PIDmode.PD; // no integral when it can't do anything useful if (allowControl(ID)) axisCtrlState = ID.GetSAS(this).ResponseF(error, rate, mode); else if (!Utils.hasInput(ID)) axisCtrlState = 0; // kill off stock SAS inputs // nothing happens if player input is present }
/// <summary> /// Draws a toggle button and text box of specified widths with update button. /// </summary> /// <param name="toggleText"></param> /// <param name="boxVal"></param> /// <param name="toggleWidth"></param> /// <param name="boxWidth"></param> /// <returns></returns> public double TogPlusNumBox(string toggleText, SASList controllerID, double currentVal, float toggleWidth, float boxWidth) { double setPoint = controllerID.GetSAS(this).SetPoint; GUILayout.BeginHorizontal(); bool tempState = GUILayout.Toggle(bActive[(int)controllerID], toggleText, GeneralUI.UISkin.customStyles[(int)myStyles.btnToggle], GUILayout.Width(toggleWidth)); if (tempState != bActive[(int)controllerID]) { bActive[(int)controllerID] = tempState; if (bActive[(int)controllerID]) { setPoint = currentVal; targets[(int)controllerID] = currentVal.ToString("0.00"); } } string tempText = GUILayout.TextField(targets[(int)controllerID], GeneralUI.UISkin.customStyles[(int)myStyles.numBoxText], GUILayout.Width(boxWidth)); targets[(int)controllerID] = tempText; if (GUILayout.Button("u")) { double temp; if (double.TryParse(targets[(int)controllerID], out temp)) setPoint = temp; bActive[(int)controllerID] = true; } GUILayout.EndHorizontal(); return setPoint; }