Set up code for quickly handling antennas and solar panels.
This commit is contained in:
parent
27ad3c11d7
commit
081fcb3618
29
boot/simustrap.ks
Normal file
29
boot/simustrap.ks
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
function Antennas {
|
||||||
|
parameter enable is true.
|
||||||
|
|
||||||
|
local eventName is "Activate".
|
||||||
|
if not enable {
|
||||||
|
set eventName to "Deactivate".
|
||||||
|
}
|
||||||
|
|
||||||
|
for p in SHIP:PARTS {
|
||||||
|
if p:MODULES:Find("ModuleRTAntenna") > -1 and p:GetModule("ModuleRTAntenna"):ALLEVENTNAMES:Find(eventName) > -1 {
|
||||||
|
p:GetModule("ModuleRTAntenna"):DoEvent(eventName).
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function SolarPanels {
|
||||||
|
parameter enable is true.
|
||||||
|
|
||||||
|
if enable {
|
||||||
|
PANELS on.
|
||||||
|
} else {
|
||||||
|
PANELS off.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wait until SHIP:UNPACKED.
|
||||||
|
wait 5.0.
|
||||||
|
Antennas().
|
||||||
|
SolarPanels().
|
|
@ -2,11 +2,15 @@
|
||||||
// Assumes stage 0 contains only parachutes.
|
// Assumes stage 0 contains only parachutes.
|
||||||
// Primarily written for small science payload probes.
|
// Primarily written for small science payload probes.
|
||||||
|
|
||||||
|
RunOncePath("lib/systems").
|
||||||
|
|
||||||
function PerformReentry {
|
function PerformReentry {
|
||||||
parameter retractAntennae is true.
|
parameter retractAntennae is true.
|
||||||
|
|
||||||
SAS off.
|
SAS off.
|
||||||
|
|
||||||
|
print "Reentry mode activated. Control permanently locked.".
|
||||||
|
|
||||||
// stage until only stage 0 remains.
|
// stage until only stage 0 remains.
|
||||||
until STAGE:NUMBER <= 1 {
|
until STAGE:NUMBER <= 1 {
|
||||||
stage.
|
stage.
|
||||||
|
@ -15,11 +19,7 @@ function PerformReentry {
|
||||||
lock STEERING to SHIP:SRFRETROGRADE.
|
lock STEERING to SHIP:SRFRETROGRADE.
|
||||||
|
|
||||||
if retractAntennae {
|
if retractAntennae {
|
||||||
for p in SHIP:PARTS {
|
Antennas(false).
|
||||||
if p:MODULES:Find("ModuleRTAntenna") > -1 and p:GetModule("ModuleRTAntenna"):ALLEVENTNAMES:Find("Deactivate") > -1 {
|
|
||||||
p:GetModule("ModuleRTAntenna"):DoEvent("Deactivate").
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
when SHIP:ALTITUDE - SHIP:GEOPOSITION:TERRAINHEIGHT < 2500 then {
|
when SHIP:ALTITUDE - SHIP:GEOPOSITION:TERRAINHEIGHT < 2500 then {
|
||||||
|
|
25
lib/systems.ks
Normal file
25
lib/systems.ks
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
|
||||||
|
function Antennas {
|
||||||
|
parameter enable is true.
|
||||||
|
|
||||||
|
local eventName is "Activate".
|
||||||
|
if not enable {
|
||||||
|
set eventName to "Deactivate".
|
||||||
|
}
|
||||||
|
|
||||||
|
for p in SHIP:PARTS {
|
||||||
|
if p:MODULES:Find("ModuleRTAntenna") > -1 and p:GetModule("ModuleRTAntenna"):ALLEVENTNAMES:Find(eventName) > -1 {
|
||||||
|
p:GetModule("ModuleRTAntenna"):DoEvent(eventName).
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function SolarPanels {
|
||||||
|
parameter enable is true.
|
||||||
|
|
||||||
|
if enable {
|
||||||
|
PANELS on.
|
||||||
|
} else {
|
||||||
|
PANELS off.
|
||||||
|
}
|
||||||
|
}
|
17
lib/ui.ks
17
lib/ui.ks
|
@ -13,6 +13,17 @@ function MakeButton {
|
||||||
return b.
|
return b.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function MakeToggle {
|
||||||
|
parameter p.
|
||||||
|
parameter l.
|
||||||
|
parameter f.
|
||||||
|
|
||||||
|
local btn is p:AddButton(l).
|
||||||
|
set btn:TOGGLE to true.
|
||||||
|
set btn:onClick to f.
|
||||||
|
return btn.
|
||||||
|
}
|
||||||
|
|
||||||
function MakeMenu {
|
function MakeMenu {
|
||||||
parameter stack. // the stack where menu stuff goes
|
parameter stack. // the stack where menu stuff goes
|
||||||
parameter btn. // the button that should show this menu
|
parameter btn. // the button that should show this menu
|
||||||
|
@ -58,9 +69,7 @@ function AddStockButtons {
|
||||||
parameter row.
|
parameter row.
|
||||||
parameter bootname.
|
parameter bootname.
|
||||||
|
|
||||||
local btn is row:AddButton("Term").
|
MakeToggle(row, "Term", {
|
||||||
set btn:TOGGLE to true.
|
|
||||||
set btn:ONTOGGLE to {
|
|
||||||
parameter d.
|
parameter d.
|
||||||
|
|
||||||
if d {
|
if d {
|
||||||
|
@ -68,7 +77,7 @@ function AddStockButtons {
|
||||||
} else {
|
} else {
|
||||||
CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Close Terminal").
|
CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Close Terminal").
|
||||||
}
|
}
|
||||||
}.
|
}).
|
||||||
|
|
||||||
MakeButton(row, "Update", {
|
MakeButton(row, "Update", {
|
||||||
switch to 0.
|
switch to 0.
|
||||||
|
|
|
@ -6,6 +6,7 @@ RunOncePath("/lib/throttle").
|
||||||
RunOncePath("/lib/stabilize_rocket").
|
RunOncePath("/lib/stabilize_rocket").
|
||||||
RunOncePath("/lib/launch_rocket").
|
RunOncePath("/lib/launch_rocket").
|
||||||
RunOncePath("/lib/sensors").
|
RunOncePath("/lib/sensors").
|
||||||
|
RunOncePath("/lib/systems").
|
||||||
RunOncePath("/lib/reentry").
|
RunOncePath("/lib/reentry").
|
||||||
|
|
||||||
clearguis().
|
clearguis().
|
||||||
|
@ -29,7 +30,31 @@ AddStockButtons(rows[0], "rocket").
|
||||||
|
|
||||||
MakeMenu(
|
MakeMenu(
|
||||||
stk,
|
stk,
|
||||||
MakeButton(rows[0], "SENS"),
|
MakeButton(rows[0], "Config"),
|
||||||
|
List(
|
||||||
|
List("Torque Epsilon Max", "SCALAR", "0.001"),
|
||||||
|
List("Max Stopping Time", "SCALAR", "2.0")
|
||||||
|
),
|
||||||
|
"Apply",
|
||||||
|
{
|
||||||
|
parameter options.
|
||||||
|
set STEERINGMANAGER:TORQUEEPSILONMAX to options["Torque Epsilon Max"]:TEXT:ToNumber().
|
||||||
|
set STEERINGMANAGER:MAXSTOPPINGTIME to options["Max Stopping Time"]:TEXT:ToNumber().
|
||||||
|
}
|
||||||
|
).
|
||||||
|
|
||||||
|
MakeToggle(rows[0], "Solar", {
|
||||||
|
parameter d.
|
||||||
|
SolarPanels(d).
|
||||||
|
}).
|
||||||
|
|
||||||
|
MakeButton(rows[0], "Ant", {
|
||||||
|
Antennas().
|
||||||
|
}).
|
||||||
|
|
||||||
|
MakeMenu(
|
||||||
|
stk,
|
||||||
|
MakeButton(rows[1], "Sensors"),
|
||||||
List(
|
List(
|
||||||
List("Pressure", "RO", "-1"),
|
List("Pressure", "RO", "-1"),
|
||||||
List("Temperature", "RO", "-1"),
|
List("Temperature", "RO", "-1"),
|
||||||
|
@ -44,7 +69,7 @@ MakeMenu(
|
||||||
|
|
||||||
MakeMenu(
|
MakeMenu(
|
||||||
stk,
|
stk,
|
||||||
MakeButton(rows[0], "GRND"),
|
MakeButton(rows[1], "Ground"),
|
||||||
List(
|
List(
|
||||||
List("Burn Distance", "RO", "-1"),
|
List("Burn Distance", "RO", "-1"),
|
||||||
List("Stopping Time", "RO", "-1"),
|
List("Stopping Time", "RO", "-1"),
|
||||||
|
@ -61,29 +86,16 @@ MakeMenu(
|
||||||
set options["Stopping Distance"]:TEXT to StoppingDistance():TOSTRING.
|
set options["Stopping Distance"]:TEXT to StoppingDistance():TOSTRING.
|
||||||
}
|
}
|
||||||
).
|
).
|
||||||
|
|
||||||
MakeMenu(
|
|
||||||
stk,
|
|
||||||
MakeButton(rows[1], "REENTRY"),
|
|
||||||
List(
|
|
||||||
List("Retract Antennae", "BOOL", true)
|
|
||||||
),
|
|
||||||
"Execute",
|
|
||||||
{
|
|
||||||
parameter options.
|
|
||||||
PerformReentry(options["Retract Antennae"]:PRESSED).
|
|
||||||
}
|
|
||||||
).
|
|
||||||
|
|
||||||
MakeButton(rows[1], "HOVER", { Hover(). }).
|
MakeButton(rows[1], "Hover", { Hover(). }).
|
||||||
MakeButton(rows[1], "LAND", { Land(). }).
|
MakeButton(rows[1], "Land", { Land(). }).
|
||||||
|
|
||||||
MakeMenu(
|
MakeMenu(
|
||||||
stk,
|
stk,
|
||||||
MakeButton(rows[2], "LNCH"),
|
MakeButton(rows[2], "Launch"),
|
||||||
List(
|
List(
|
||||||
List("Target Apoapsis", "SCALAR", "80000"),
|
List("Target Apoapsis", "SCALAR", "80000"),
|
||||||
List("Initial Pitch", "SCALAR", "20"),
|
List("Initial Pitch", "SCALAR", "30"),
|
||||||
List("Pitch Time", "SCALAR", "45"),
|
List("Pitch Time", "SCALAR", "45"),
|
||||||
List("Atmo TWR", "SCALAR", "2.0"),
|
List("Atmo TWR", "SCALAR", "2.0"),
|
||||||
List("Minimum Pitch", "SCALAR", "5"),
|
List("Minimum Pitch", "SCALAR", "5"),
|
||||||
|
@ -105,7 +117,7 @@ MakeMenu(
|
||||||
|
|
||||||
MakeMenu(
|
MakeMenu(
|
||||||
stk,
|
stk,
|
||||||
MakeButton(rows[2], "NODE"),
|
MakeButton(rows[2], "Node"),
|
||||||
List(
|
List(
|
||||||
List("Node dV", "RO", "0"),
|
List("Node dV", "RO", "0"),
|
||||||
List("Node Burn Time", "RO", "0")
|
List("Node Burn Time", "RO", "0")
|
||||||
|
@ -148,20 +160,17 @@ MakeMenu(
|
||||||
|
|
||||||
MakeMenu(
|
MakeMenu(
|
||||||
stk,
|
stk,
|
||||||
MakeButton(rows[2], "Config"),
|
MakeButton(rows[2], "Reentry"),
|
||||||
List(
|
List(
|
||||||
List("Torque Epsilon Max", "SCALAR", "0.001"),
|
List("Retract Antennae", "BOOL", true)
|
||||||
List("Max Stopping Time", "SCALAR", "2.0")
|
|
||||||
),
|
),
|
||||||
"Apply",
|
"Execute",
|
||||||
{
|
{
|
||||||
parameter options.
|
parameter options.
|
||||||
set STEERINGMANAGER:TORQUEEPSILONMAX to options["Torque Epsilon Max"]:TEXT:ToNumber().
|
PerformReentry(options["Retract Antennae"]:PRESSED).
|
||||||
set STEERINGMANAGER:MAXSTOPPINGTIME to options["Max Stopping Time"]:TEXT:ToNumber().
|
|
||||||
}
|
}
|
||||||
).
|
).
|
||||||
|
|
||||||
|
|
||||||
iface:show().
|
iface:show().
|
||||||
wait until false.
|
wait until false.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user