Advertisement
KSA_MissionCtrl

sndRocket.ks 7/28

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