2021-08-02 01:34:19 +00:00
|
|
|
@lazyglobal off.
|
|
|
|
|
2021-07-21 09:24:46 +00:00
|
|
|
runoncepath("/lib/navigation").
|
2021-07-26 19:13:03 +00:00
|
|
|
runoncepath("/lib/throttle").
|
2021-08-02 01:46:17 +00:00
|
|
|
runoncepath("/lib/node").
|
2021-08-01 05:23:39 +00:00
|
|
|
runoncepath("/lib/stabilize_rocket").
|
2021-08-02 01:32:00 +00:00
|
|
|
runoncepath("/lib/ui").
|
2021-07-21 09:24:46 +00:00
|
|
|
|
2021-08-01 21:46:28 +00:00
|
|
|
clearguis().
|
|
|
|
|
2021-08-01 05:23:39 +00:00
|
|
|
global done is false.
|
|
|
|
on AG9 {
|
|
|
|
set done to true.
|
|
|
|
return true.
|
|
|
|
}
|
2021-07-21 09:24:46 +00:00
|
|
|
|
2021-07-19 08:46:05 +00:00
|
|
|
// Main UI.
|
2021-08-02 01:32:00 +00:00
|
|
|
local iface is gui(250, 300).
|
|
|
|
set iface:X to 200.
|
|
|
|
set iface:Y to 700.
|
2021-07-18 23:32:45 +00:00
|
|
|
|
2021-07-21 09:24:46 +00:00
|
|
|
// Main menu elements in here.
|
2021-08-02 01:32:00 +00:00
|
|
|
local top is iface:AddVLayout().
|
|
|
|
local row is makeRow(top).
|
2021-07-19 04:54:32 +00:00
|
|
|
|
2021-08-02 01:32:00 +00:00
|
|
|
local btn is row:AddButton("TERM").
|
2021-07-21 09:24:46 +00:00
|
|
|
set btn:TOGGLE to true.
|
|
|
|
set btn:ONTOGGLE to {
|
2021-08-02 01:32:00 +00:00
|
|
|
parameter d.
|
2021-07-19 08:46:05 +00:00
|
|
|
|
2021-08-02 01:32:00 +00:00
|
|
|
if d {
|
2021-07-21 09:24:46 +00:00
|
|
|
CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Open Terminal").
|
|
|
|
} else {
|
|
|
|
CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Close Terminal").
|
2021-07-22 22:29:18 +00:00
|
|
|
}
|
2021-07-21 09:24:46 +00:00
|
|
|
}.
|
2021-07-19 04:54:32 +00:00
|
|
|
|
2021-08-02 01:32:00 +00:00
|
|
|
makeButton(row, "CONF", { stk:ShowOnly(panes["conf"]). }).
|
2021-07-19 04:54:32 +00:00
|
|
|
|
2021-08-02 01:32:00 +00:00
|
|
|
set row to makeRow(top).
|
2021-07-22 22:29:18 +00:00
|
|
|
|
2021-08-02 01:32:00 +00:00
|
|
|
makeButton(row, "HOVER", { Hover(). }).
|
|
|
|
makeButton(row, "LAND", { Land(). }).
|
2021-08-01 05:23:39 +00:00
|
|
|
|
2021-08-02 01:32:00 +00:00
|
|
|
set row to makeRow(top).
|
2021-08-01 05:23:39 +00:00
|
|
|
|
2021-08-02 01:32:00 +00:00
|
|
|
makeButton(row, "LNCH", { stk:ShowOnly(panes["launch"]). }).
|
2021-08-01 05:23:39 +00:00
|
|
|
|
2021-08-02 01:32:00 +00:00
|
|
|
makeButton(row, "NODE", {
|
2021-08-02 01:37:42 +00:00
|
|
|
if HASNODE {
|
|
|
|
set nodeDV:TEXT to NEXTNODE:DELTAV:MAG:ToString.
|
|
|
|
set nodeBT:TEXT to BurnTime(NEXTNODE:DELTAV:MAG):ToString.
|
|
|
|
}
|
2021-08-02 01:32:00 +00:00
|
|
|
stk:ShowOnly(panes["node"]).
|
|
|
|
}).
|
2021-07-19 04:54:32 +00:00
|
|
|
|
2021-08-02 01:32:00 +00:00
|
|
|
makeButton(row, "TWR", { stk:ShowOnly(panes["twr"]). }).
|
2021-07-26 19:13:03 +00:00
|
|
|
|
2021-08-02 01:32:00 +00:00
|
|
|
local stk is iface:AddStack().
|
|
|
|
local panes is Lex().
|
2021-07-19 07:43:07 +00:00
|
|
|
|
2021-07-22 22:29:18 +00:00
|
|
|
// Build launch menu
|
2021-08-02 01:32:00 +00:00
|
|
|
local top is stk:AddVLayout().
|
|
|
|
panes:Add("launch", top).
|
2021-07-20 01:36:04 +00:00
|
|
|
|
2021-08-02 01:37:42 +00:00
|
|
|
local box is top:AddScrollBox().
|
2021-07-21 09:24:46 +00:00
|
|
|
|
2021-08-02 01:32:00 +00:00
|
|
|
set row to makeRow(box).
|
|
|
|
row:AddLabel("Target Apoapsis").
|
|
|
|
local targetApo is row:AddTextField("80000"). // todo: config params should go into a nested lexicon
|
2021-07-21 09:24:46 +00:00
|
|
|
|
2021-08-02 01:32:00 +00:00
|
|
|
set row to makeRow(box).
|
|
|
|
row:AddLabel("Atmo TWR").
|
|
|
|
local targetTWR is row:AddTextField("1.6").
|
2021-07-21 09:24:46 +00:00
|
|
|
|
2021-08-02 01:32:00 +00:00
|
|
|
set row to makeRow(box).
|
|
|
|
row:AddLabel("Initial Pitch").
|
|
|
|
local initialPitch is row:AddTextField("85").
|
2021-07-21 09:24:46 +00:00
|
|
|
|
2021-08-02 01:32:00 +00:00
|
|
|
set row to makeRow(box).
|
|
|
|
row:AddLabel("Minimum Pitch").
|
|
|
|
local minimumPitch is row:AddTextField("5").
|
2021-07-21 09:24:46 +00:00
|
|
|
|
2021-08-02 01:32:00 +00:00
|
|
|
set row to makeRow(box).
|
|
|
|
row:AddLabel("Gravity Turn Alt").
|
|
|
|
local gravTurnStart is row:AddTextField("8000").
|
2021-07-21 09:24:46 +00:00
|
|
|
|
2021-08-02 01:32:00 +00:00
|
|
|
set row to makeRow(box).
|
|
|
|
row:AddLabel("Gravity Turn Pitch").
|
|
|
|
local gravPitch is row:AddTextField("75").
|
2021-07-21 09:24:46 +00:00
|
|
|
|
2021-08-02 01:45:47 +00:00
|
|
|
makeButton(top, "Execute", {
|
|
|
|
run "/launch"(
|
|
|
|
targetApo:TEXT:ToNumber(),
|
|
|
|
gravTurnStart:TEXT:ToNumber(),
|
|
|
|
gravPitch:TEXT:ToNumber(),
|
|
|
|
initialPitch:TEXT:ToNumber(),
|
|
|
|
minimumPitch:TEXT:ToNumber()
|
|
|
|
).
|
|
|
|
}).
|
2021-07-26 19:13:03 +00:00
|
|
|
// End Launch Menu
|
|
|
|
|
|
|
|
// Build conf menu
|
2021-08-02 01:32:00 +00:00
|
|
|
local top is stk:AddVLayout().
|
|
|
|
panes:Add("conf", top).
|
2021-07-26 19:13:03 +00:00
|
|
|
|
2021-08-02 01:32:00 +00:00
|
|
|
set box to top:AddScrollbox().
|
2021-07-26 19:13:03 +00:00
|
|
|
|
2021-08-02 01:32:00 +00:00
|
|
|
set row to makeRow(box).
|
|
|
|
row:AddLabel("Torque Epsilon Max").
|
|
|
|
local maxEpsilon is row:AddTextField("0.001").
|
2021-07-21 09:24:46 +00:00
|
|
|
|
2021-08-02 01:32:00 +00:00
|
|
|
set row to makeRow(box).
|
|
|
|
row:AddLabel("Max Stopping Time").
|
|
|
|
local maxStopTime is row:AddTextField("2.0").
|
2021-07-21 09:24:46 +00:00
|
|
|
|
2021-08-02 01:45:47 +00:00
|
|
|
makeButton(top, "Apply", {
|
2021-07-26 19:13:03 +00:00
|
|
|
set STEERINGMANAGER:TORQUEEPSILONMAX to maxEpsilon:TEXT:ToNumber().
|
|
|
|
set STEERINGMANAGER:MAXSTOPPINGTIME to maxStopTime:TEXT:ToNumber().
|
2021-08-02 01:45:47 +00:00
|
|
|
}).
|
2021-07-26 19:13:03 +00:00
|
|
|
// end conf menu
|
2021-07-22 22:29:18 +00:00
|
|
|
|
2021-07-26 19:13:03 +00:00
|
|
|
// twr menu
|
2021-08-02 01:32:00 +00:00
|
|
|
local top is stk:AddVLayout().
|
|
|
|
panes:Add("twr", top).
|
2021-07-22 22:29:18 +00:00
|
|
|
|
2021-08-02 01:32:00 +00:00
|
|
|
set row to makeRow(top).
|
|
|
|
row:AddLabel("Target TWR").
|
|
|
|
local twrLock is row:AddTextField("1.6").
|
2021-07-26 19:13:03 +00:00
|
|
|
|
2021-08-02 01:45:47 +00:00
|
|
|
makeButton(top, "Lock TWR", {
|
2021-07-26 19:13:03 +00:00
|
|
|
local done is false.
|
|
|
|
on AG9 {
|
|
|
|
set done to true.
|
|
|
|
}
|
|
|
|
|
2021-08-01 05:23:39 +00:00
|
|
|
print "Locking throttle to target TWR.".
|
2021-07-26 19:13:03 +00:00
|
|
|
local tgt is twrLock:TEXT:ToNumber().
|
|
|
|
lock THROTTLE to ThrottleToTWR(tgt).
|
|
|
|
wait until done.
|
2021-08-01 05:23:39 +00:00
|
|
|
print "Throttle unlocked.".
|
2021-08-02 01:45:47 +00:00
|
|
|
}).
|
2021-07-26 19:13:03 +00:00
|
|
|
// end twr menu
|
2021-07-22 22:29:18 +00:00
|
|
|
|
2021-08-01 05:23:39 +00:00
|
|
|
// node menu
|
2021-08-02 01:32:00 +00:00
|
|
|
local top is stk:AddVLayout().
|
|
|
|
panes:Add("node", top).
|
2021-08-01 05:23:39 +00:00
|
|
|
|
2021-08-02 01:32:00 +00:00
|
|
|
set row to makeRow(top).
|
|
|
|
row:AddLabel("Node dV").
|
|
|
|
local nodeDV is row:AddLabel().
|
2021-08-01 05:23:39 +00:00
|
|
|
|
2021-08-02 01:32:00 +00:00
|
|
|
set row to makeRow(top).
|
|
|
|
row:AddLabel("Node Burn Time").
|
|
|
|
local nodeBT is row:AddLabel().
|
2021-08-01 05:23:39 +00:00
|
|
|
|
2021-08-02 01:45:47 +00:00
|
|
|
makeButton(top, "Execute", { ExecNode(). }).
|
2021-08-01 05:23:39 +00:00
|
|
|
// end node menu
|
|
|
|
|
2021-08-02 01:32:00 +00:00
|
|
|
iface:show().
|
2021-07-18 23:32:45 +00:00
|
|
|
wait until false.
|