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.
|
||||
// Primarily written for small science payload probes.
|
||||
|
||||
RunOncePath("lib/systems").
|
||||
|
||||
function PerformReentry {
|
||||
parameter retractAntennae is true.
|
||||
|
||||
SAS off.
|
||||
|
||||
print "Reentry mode activated. Control permanently locked.".
|
||||
|
||||
// stage until only stage 0 remains.
|
||||
until STAGE:NUMBER <= 1 {
|
||||
stage.
|
||||
|
@ -15,11 +19,7 @@ function PerformReentry {
|
|||
lock STEERING to SHIP:SRFRETROGRADE.
|
||||
|
||||
if retractAntennae {
|
||||
for p in SHIP:PARTS {
|
||||
if p:MODULES:Find("ModuleRTAntenna") > -1 and p:GetModule("ModuleRTAntenna"):ALLEVENTNAMES:Find("Deactivate") > -1 {
|
||||
p:GetModule("ModuleRTAntenna"):DoEvent("Deactivate").
|
||||
}
|
||||
}
|
||||
Antennas(false).
|
||||
}
|
||||
|
||||
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.
|
||||
}
|
||||
|
||||
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 {
|
||||
parameter stack. // the stack where menu stuff goes
|
||||
parameter btn. // the button that should show this menu
|
||||
|
@ -58,9 +69,7 @@ function AddStockButtons {
|
|||
parameter row.
|
||||
parameter bootname.
|
||||
|
||||
local btn is row:AddButton("Term").
|
||||
set btn:TOGGLE to true.
|
||||
set btn:ONTOGGLE to {
|
||||
MakeToggle(row, "Term", {
|
||||
parameter d.
|
||||
|
||||
if d {
|
||||
|
@ -68,7 +77,7 @@ function AddStockButtons {
|
|||
} else {
|
||||
CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Close Terminal").
|
||||
}
|
||||
}.
|
||||
}).
|
||||
|
||||
MakeButton(row, "Update", {
|
||||
switch to 0.
|
||||
|
|
|
@ -6,6 +6,7 @@ RunOncePath("/lib/throttle").
|
|||
RunOncePath("/lib/stabilize_rocket").
|
||||
RunOncePath("/lib/launch_rocket").
|
||||
RunOncePath("/lib/sensors").
|
||||
RunOncePath("/lib/systems").
|
||||
RunOncePath("/lib/reentry").
|
||||
|
||||
clearguis().
|
||||
|
@ -29,7 +30,31 @@ AddStockButtons(rows[0], "rocket").
|
|||
|
||||
MakeMenu(
|
||||
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("Pressure", "RO", "-1"),
|
||||
List("Temperature", "RO", "-1"),
|
||||
|
@ -44,7 +69,7 @@ MakeMenu(
|
|||
|
||||
MakeMenu(
|
||||
stk,
|
||||
MakeButton(rows[0], "GRND"),
|
||||
MakeButton(rows[1], "Ground"),
|
||||
List(
|
||||
List("Burn Distance", "RO", "-1"),
|
||||
List("Stopping Time", "RO", "-1"),
|
||||
|
@ -62,28 +87,15 @@ MakeMenu(
|
|||
}
|
||||
).
|
||||
|
||||
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], "LAND", { Land(). }).
|
||||
MakeButton(rows[1], "Hover", { Hover(). }).
|
||||
MakeButton(rows[1], "Land", { Land(). }).
|
||||
|
||||
MakeMenu(
|
||||
stk,
|
||||
MakeButton(rows[2], "LNCH"),
|
||||
MakeButton(rows[2], "Launch"),
|
||||
List(
|
||||
List("Target Apoapsis", "SCALAR", "80000"),
|
||||
List("Initial Pitch", "SCALAR", "20"),
|
||||
List("Initial Pitch", "SCALAR", "30"),
|
||||
List("Pitch Time", "SCALAR", "45"),
|
||||
List("Atmo TWR", "SCALAR", "2.0"),
|
||||
List("Minimum Pitch", "SCALAR", "5"),
|
||||
|
@ -105,7 +117,7 @@ MakeMenu(
|
|||
|
||||
MakeMenu(
|
||||
stk,
|
||||
MakeButton(rows[2], "NODE"),
|
||||
MakeButton(rows[2], "Node"),
|
||||
List(
|
||||
List("Node dV", "RO", "0"),
|
||||
List("Node Burn Time", "RO", "0")
|
||||
|
@ -148,20 +160,17 @@ MakeMenu(
|
|||
|
||||
MakeMenu(
|
||||
stk,
|
||||
MakeButton(rows[2], "Config"),
|
||||
MakeButton(rows[2], "Reentry"),
|
||||
List(
|
||||
List("Torque Epsilon Max", "SCALAR", "0.001"),
|
||||
List("Max Stopping Time", "SCALAR", "2.0")
|
||||
List("Retract Antennae", "BOOL", true)
|
||||
),
|
||||
"Apply",
|
||||
"Execute",
|
||||
{
|
||||
parameter options.
|
||||
set STEERINGMANAGER:TORQUEEPSILONMAX to options["Torque Epsilon Max"]:TEXT:ToNumber().
|
||||
set STEERINGMANAGER:MAXSTOPPINGTIME to options["Max Stopping Time"]:TEXT:ToNumber().
|
||||
PerformReentry(options["Retract Antennae"]:PRESSED).
|
||||
}
|
||||
).
|
||||
|
||||
|
||||
iface:show().
|
||||
wait until false.
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user