Advertisement
KSA_MissionCtrl

sndRocket.ks 6/18

Jun 18th, 2015
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. function LogData {
  2. parameter text.
  3.  
  4. // print to both the console and log
  5. print "[" + time:clock + "] " + text.
  6. log "[" + time:clock + "] " + text to missionlog.
  7.  
  8. // make a copy on the local KSC archive
  9. copy missionlog to 0.
  10. }.
  11.  
  12. function Launch {
  13. clearscreen.
  14. LogData("Sounding Rocket Flight Program initiating...").
  15.  
  16. // find all our parts
  17. set sep to ship:partstagged("sep")[0].
  18. set exp to ship:partstagged("exp")[0].
  19. set srb to ship:partstagged("srb")[0].
  20. set chute to ship:partstagged("chute")[0].
  21. set clamp to ship:partstagged("clamp")[0].
  22. set probe to ship:partstitled("Avionics Package")[0].
  23. set fairings to ship:partstagged("fairing").
  24.  
  25. // perform pre-launch checks
  26. if fairings:length < 2 {
  27. LogData("Fairing parts missing, only found " + fairings:length).
  28. return false.
  29. }.
  30.  
  31. list engines in englist.
  32. for eng in englist {
  33. if eng:thrustlimit <> 48 {
  34. LogData("Improper thrust limiter set. Thrust set to " + eng:thrustlimit + "%").
  35. return false.
  36. }
  37. }
  38.  
  39. // all good, begin the countdown
  40. LogData("GO for launch!").
  41. wait 1.
  42. LogData("T-10").
  43. wait 1.
  44. LogData("T-9").
  45. wait 1.
  46. LogData("T-8").
  47. wait 1.
  48. LogData("T-7").
  49. wait 1.
  50. LogData("T-6").
  51. wait 1.
  52. LogData("T-5").
  53. wait 1.
  54. LogData("T-4").
  55. wait 1.
  56. LogData("T-3").
  57. wait 1.
  58. LogData("T-2").
  59. wait 1.
  60. LogData("T-1").
  61. wait 1.
  62.  
  63. // fire the engine and detach from the launch stick
  64. srb:getmodule("ModuleEngines"):doevent("activate engine").
  65. clamp:getmodule("ModuleAnchoredDecoupler"):doevent("decouple").
  66. LogData("Liftoff!!").
  67.  
  68. // wait until engine expires
  69. until srb:getmodule("ModuleEngines"):getfield("status") = "flame-out!" {}.
  70. LogData("SRB flame out detected. Decoupling").
  71.  
  72. // ditch the SRB and dump the fairings and then await subsonic velocity
  73. sep:getmodule("ModuleDecouple"):doevent("decouple").
  74. LogData("Releasing payload fairings").
  75. for fairing in fairings {
  76. fairing:getmodule("ModuleDecouple"):doevent("decouple").
  77. }
  78. LogData("Awaiting subsonic velocity for chute deployment").
  79. until ship:airspeed <= 260 {}.
  80.  
  81. // pop the chute
  82. LogData("Deploying chute").
  83. chute:getmodule("ModuleParachute"):doevent("deploy chute").
  84.  
  85. // confirm chute is open and run science experiments
  86. until chute:getmodule("ModuleParachute"):hasevent("cut parachute") {}.
  87. LogData("Chute deployed, running experiments").
  88. toggle AG1.
  89.  
  90. return true.
  91. }
  92.  
  93. // done! All data will be stored for retrieval, as battery power will not last until landing
  94. if Launch() {
  95. LogData("All events have executed. Awaiting landing & retrieval").
  96. }.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement