Advertisement
KSA_MissionCtrl

droptesthi.ks

Apr 2nd, 2015
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 33.77 KB | None | 0 0
  1. //create access to all the parts
  2. set hichute to ship:partstagged("hi")[0].
  3. set lochute to ship:partstagged("lo")[0].
  4. set comms to ship:partstagged("antenna")[0].
  5. set probe to ship:partstagged("core")[0].
  6. set battlist to ship:partsdubbed("z-200 rechargeable battery bank").
  7. set caplist to ship:partsdubbed("cap-101 capacitor").
  8. set goolist to ship:partstagged("goo").
  9.  
  10. // program behavior variables
  11. set deployupperheight to 21000.
  12. set loweratmosphere to 18000.
  13. set deploylowerheight to 2500.
  14. set maxdropspeed to 12.
  15. set commtimeout to 15.
  16. set transmissiontimeout to 5.
  17. set lowbattlvl to 25. // for when no data is being transmitted
  18. set lowbattlvltrans to 150. // for when data is being transmitted
  19. set discharged to false.
  20. set transtime to 0.
  21.  
  22. clearscreen.
  23. abort off.
  24. print "[" + time:clock + "] Program running... confirming systems".
  25. log "[" + time:clock + "] Program running... confirming systems" to droplog.
  26.  
  27. print "[" + time:clock + "] " + battlist:length + " Battery(s) found".
  28. log "[" + time:clock + "] " + battlist:length + " Battery(s) found" to droplog.
  29. print "[" + time:clock + "] " + caplist:length + " Capacitor(s) found".
  30. log "[" + time:clock + "] " + caplist:length + " Capacitor(s) found" to droplog.
  31. print "[" + time:clock + "] " + goolist:length + " Goo canister(s) found".
  32. log "[" + time:clock + "] " + goolist:length + " Goo canister(s) found" to droplog.
  33.  
  34. print "[" + time:clock + "] Operational systems confirmed".
  35. log "[" + time:clock + "] Operational systems confirmed" to droplog.
  36.  
  37. for batt in battlist {
  38. set batt:resources[0]:enabled to true.
  39. }.
  40. print "[" + time:clock + "] All batteries enabled".
  41. log "[" + time:clock + "] All batteries enabled" to droplog.
  42. print "[" + time:clock + "] Awaiting chute deployment".
  43. log "[" + time:clock + "] Awaiting chute deployment" to droplog.
  44.  
  45. until hichute:getmodule("realchutemodule"):allevents[0] = "(callable) cut chute, is kspevent" {
  46. if not discharged and ship:resources[0]:amount < lowbattlvl {
  47. set capnum to 0.
  48. until capnum = caplist:length {
  49. if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
  50. caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
  51. Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
  52. log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
  53. break.
  54. }.
  55. set capnum to capnum + 1.
  56. }.
  57. if capnum = caplist:length {
  58. set discharged to true.
  59. Print "[" + time:clock + "] All capacitors drained".
  60. log "[" + time:clock + "] All capacitors drained" to droplog.
  61. }.
  62. }.
  63. wait 0.001.
  64. }.
  65. Print "[" + time:clock + "] Chute deployment confirmed. Awaiting full deployment".
  66. log "[" + time:clock + "] Chute deployment confirmed. Awaiting full deployment" to droplog.
  67.  
  68. until alt:radar < deployupperheight and ship:verticalspeed*-1 < maxdropspeed {
  69. if not discharged and ship:resources[0]:amount < lowbattlvl {
  70. set capnum to 0.
  71. until capnum = caplist:length {
  72. if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
  73. caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
  74. Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
  75. log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
  76. break.
  77. }.
  78. set capnum to capnum + 1.
  79. }.
  80. if capnum = caplist:length {
  81. set discharged to true.
  82. Print "[" + time:clock + "] All capacitors drained".
  83. log "[" + time:clock + "] All capacitors drained" to droplog.
  84. }.
  85. }.
  86. wait 0.001.
  87. }.
  88. Print "[" + time:clock + "] Full chute deployment confirmed".
  89. log "[" + time:clock + "] Full chute deployment confirmed" to droplog.
  90. comms:getmodule("modulertantenna"):doevent("activate").
  91. Print "[" + time:clock + "] Communications antenna deployed. Awaiting connection".
  92. log "[" + time:clock + "] Communications antenna deployed. Awaiting connection" to droplog.
  93.  
  94. set timer to time:seconds.
  95. until probe:getmodule("modulespu"):getfield("spu") = "operational." {
  96. if not discharged and ship:resources[0]:amount < lowbattlvl {
  97. set capnum to 0.
  98. until capnum = caplist:length {
  99. if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
  100. caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
  101. Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
  102. log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
  103. break.
  104. }.
  105. set capnum to capnum + 1.
  106. }.
  107. if capnum = caplist:length {
  108. set discharged to true.
  109. Print "[" + time:clock + "] All capacitors drained".
  110. log "[" + time:clock + "] All capacitors drained" to droplog.
  111. }.
  112. }.
  113. if time:seconds - timer > commtimeout {
  114. Print "[" + time:clock + "] Communications link failed!".
  115. log "[" + time:clock + "] Communications link failed!" to droplog.
  116. shutdown.
  117. }
  118. wait 0.001.
  119. }.
  120. Print "[" + time:clock + "] Communications link established".
  121. log "[" + time:clock + "] Communications link established" to droplog.
  122. Print "[" + time:clock + "] First upper atmospheric experiment run commencing".
  123. log "[" + time:clock + "] First upper atmospheric experiment run commencing" to droplog.
  124.  
  125. toggle AG4.
  126. // goo containers are only run once per atmosphere level (upper/lower)
  127. for goo in goolist {
  128. // we don't care which goo pod is run - if a goo container is unused, it will have an event available
  129. if goo:getmodule("modulescienceexperiment"):allevents:length > 0 {
  130. goo:getmodule("modulescienceexperiment"):doevent("observe mystery goo").
  131. break.
  132. }.
  133. }.
  134. Print "[" + time:clock + "] Awaiting data transmission".
  135. log "[" + time:clock + "] Awaiting data transmission" to droplog.
  136.  
  137. set timer to time:seconds.
  138. set nodata to false.
  139. // until the comms message changes from "idle", nothing is being transmitted
  140. until comms:getmodule("modulertdatatransmitter"):getfield("comms") = "uploading data..." {
  141. // keep tabs on our power status - release capcitor charge as necessary
  142. if not discharged and ship:resources[0]:amount < lowbattlvl {
  143. set capnum to 0.
  144. until capnum = caplist:length {
  145. if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
  146. caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
  147. Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
  148. log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
  149. break.
  150. }.
  151. set capnum to capnum + 1.
  152. }.
  153. if capnum = caplist:length {
  154. set discharged to true.
  155. Print "[" + time:clock + "] All capacitors drained".
  156. log "[" + time:clock + "] All capacitors drained" to droplog.
  157. }.
  158. }.
  159. // keeps tabs on our connection to Mission Control
  160. if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
  161. Print "[" + time:clock + "] Connection lost".
  162. log "[" + time:clock + "] Connection lost" to droplog.
  163. shutdown.
  164. }.
  165. // if the user recycles all experiments, no data will be sent
  166. if time:seconds - timer > commtimeout {
  167. set nodata to true.
  168. break.
  169. }
  170. wait 0.001.
  171. }.
  172.  
  173. if nodata {
  174. // aborts the second run as well - no data means no data for this entire biome level
  175. Print "[" + time:clock + "] Aborting upper atmospheric runs due to no data to transmit".
  176. log "[" + time:clock + "] Aborting upper atmospheric runs due to no data to transmit" to droplog.
  177. } else {
  178. Print "[" + time:clock + "] Data transmission has begun".
  179. log "[" + time:clock + "] Data transmission has begun" to droplog.
  180.  
  181. until time:seconds - transtime > transmissiontimeout {
  182. if not discharged and ship:resources[0]:amount < lowbattlvltrans {
  183. set capnum to 0.
  184. until capnum = caplist:length {
  185. if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
  186. caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
  187. Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
  188. log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
  189. break.
  190. }.
  191. set capnum to capnum + 1.
  192. }.
  193. if capnum = caplist:length {
  194. set discharged to true.
  195. Print "[" + time:clock + "] All capacitors drained".
  196. log "[" + time:clock + "] All capacitors drained" to droplog.
  197. }.
  198. }.
  199. if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
  200. Print "[" + time:clock + "] Connection lost".
  201. log "[" + time:clock + "] Connection lost" to droplog.
  202. shutdown.
  203. }.
  204. if transtime < time:seconds and comms:getmodule("modulertdatatransmitter"):getfield("comms") = "uploading data..." {
  205. lock transtime to time:seconds.
  206. }.
  207. if transtime = time:seconds and comms:getmodule("modulertdatatransmitter"):getfield("comms") = "idle" {
  208. set transtime to time:seconds.
  209. }.
  210. wait 0.001.
  211. }.
  212. Print "[" + time:clock + "] Data transmission has ended".
  213. log "[" + time:clock + "] Data transmission has ended" to droplog.
  214.  
  215. if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
  216. Print "[" + time:clock + "] Connection lost".
  217. log "[" + time:clock + "] Connection lost" to droplog.
  218. shutdown.
  219. }.
  220.  
  221. // if we haven't reached the lower atmosphere yet, take a second run for additional data
  222. if alt:radar > loweratmosphere {
  223. Print "[" + time:clock + "] Second upper atmospheric experiment run commencing".
  224. log "[" + time:clock + "] Second upper atmospheric experiment run commencing" to droplog.
  225. toggle AG4.
  226. for goo in goolist {
  227. if goo:getmodule("modulescienceexperiment"):allevents:length > 0 {
  228. goo:getmodule("modulescienceexperiment"):doevent("observe mystery goo").
  229. break.
  230. }.
  231. }.
  232. Print "[" + time:clock + "] Awaiting data transmission".
  233. log "[" + time:clock + "] Awaiting data transmission" to droplog.
  234.  
  235. set timer to time:seconds.
  236. set nodata to false.
  237. until comms:getmodule("modulertdatatransmitter"):getfield("comms") = "uploading data..." {
  238. if not discharged and ship:resources[0]:amount < lowbattlvl {
  239. set capnum to 0.
  240. until capnum = caplist:length {
  241. if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
  242. caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
  243. Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
  244. log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
  245. break.
  246. }.
  247. set capnum to capnum + 1.
  248. }.
  249. if capnum = caplist:length {
  250. set discharged to true.
  251. Print "[" + time:clock + "] All capacitors drained".
  252. log "[" + time:clock + "] All capacitors drained" to droplog.
  253. }.
  254. }.
  255. if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
  256. Print "[" + time:clock + "] Connection lost".
  257. log "[" + time:clock + "] Connection lost" to droplog.
  258. shutdown.
  259. }.
  260. if time:seconds - timer > commtimeout {
  261. set nodata to true.
  262. break.
  263. }
  264. wait 0.001.
  265. }.
  266.  
  267. if nodata {
  268. Print "[" + time:clock + "] Aborting second upper atmospheric run due to no data to transmit".
  269. log "[" + time:clock + "] Aborting second upper atmospheric run due to no data to transmit" to droplog.
  270. } else {
  271. Print "[" + time:clock + "] Data transmission has begun".
  272. log "[" + time:clock + "] Data transmission has begun" to droplog.
  273.  
  274. until time:seconds - transtime > transmissiontimeout {
  275. if not discharged and ship:resources[0]:amount < lowbattlvltrans {
  276. set capnum to 0.
  277. until capnum = caplist:length {
  278. if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
  279. caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
  280. Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
  281. log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
  282. break.
  283. }.
  284. set capnum to capnum + 1.
  285. }.
  286. if capnum = caplist:length {
  287. set discharged to true.
  288. Print "[" + time:clock + "] All capacitors drained".
  289. log "[" + time:clock + "] All capacitors drained" to droplog.
  290. }.
  291. }.
  292. if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
  293. Print "[" + time:clock + "] Connection lost".
  294. log "[" + time:clock + "] Connection lost" to droplog.
  295. shutdown.
  296. }.
  297. if transtime < time:seconds and comms:getmodule("modulertdatatransmitter"):getfield("comms") = "uploading data..." {
  298. lock transtime to time:seconds.
  299. }.
  300. if transtime = time:seconds and comms:getmodule("modulertdatatransmitter"):getfield("comms") = "idle" {
  301. set transtime to time:seconds.
  302. }.
  303. wait 0.01.
  304. }.
  305.  
  306. Print "[" + time:clock + "] Data transmission has ended".
  307. log "[" + time:clock + "] Data transmission has ended" to droplog.
  308. }.
  309. } else {
  310. Print "[" + time:clock + "] Aborting second upper atmospheric run due to altitude".
  311. log "[" + time:clock + "] Aborting second upper atmospheric run due to altitude" to droplog.
  312. }.
  313. }.
  314.  
  315. if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
  316. Print "[" + time:clock + "] Connection lost".
  317. log "[" + time:clock + "] Connection lost" to droplog.
  318. shutdown.
  319. }.
  320.  
  321. Print "[" + time:clock + "] Advancing to lower atmosphere".
  322. log "[" + time:clock + "] Advancing to lower atmosphere" to droplog.
  323. comms:getmodule("modulertantenna"):doevent("deactivate").
  324. Print "[" + time:clock + "] Communications antenna retracted".
  325. log "[" + time:clock + "] Communications antenna retracted" to droplog.
  326. hichute:getmodule("realchutemodule"):doevent("cut chute").
  327. Print "[" + time:clock + "] Chute cut".
  328. log "[" + time:clock + "] Chute cut" to droplog.
  329. Print "[" + time:clock + "] Awaiting chute deployment".
  330. log "[" + time:clock + "] Awaiting chute deployment" to droplog.
  331.  
  332. until lochute:getmodule("realchutemodule"):allevents[0] = "(callable) cut chute, is kspevent" {
  333. if not discharged and ship:resources[0]:amount < lowbattlvl {
  334. set capnum to 0.
  335. until capnum = caplist:length {
  336. if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
  337. caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
  338. Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
  339. log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
  340. break.
  341. }.
  342. set capnum to capnum + 1.
  343. }.
  344. if capnum = caplist:length {
  345. set discharged to true.
  346. Print "[" + time:clock + "] All capacitors drained".
  347. log "[" + time:clock + "] All capacitors drained" to droplog.
  348. }.
  349. }.
  350. wait 0.001.
  351. }.
  352. Print "[" + time:clock + "] Chute deployment confirmed. Awaiting full deployment".
  353. log "[" + time:clock + "] Chute deployment confirmed. Awaiting full deployment" to droplog.
  354.  
  355. until alt:radar < deploylowerheight and ship:verticalspeed*-1 < maxdropspeed {
  356. if not discharged and ship:resources[0]:amount < lowbattlvl {
  357. set capnum to 0.
  358. until capnum = caplist:length {
  359. if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
  360. caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
  361. Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
  362. log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
  363. break.
  364. }.
  365. set capnum to capnum + 1.
  366. }.
  367. if capnum = caplist:length {
  368. set discharged to true.
  369. Print "[" + time:clock + "] All capacitors drained".
  370. log "[" + time:clock + "] All capacitors drained" to droplog.
  371. }.
  372. }.
  373. wait 0.001.
  374. }.
  375. Print "[" + time:clock + "] Full chute deployment confirmed".
  376. log "[" + time:clock + "] Full chute deployment confirmed" to droplog.
  377. comms:getmodule("modulertantenna"):doevent("activate").
  378. Print "[" + time:clock + "] Communications antenna deployed. Awaiting connection".
  379. log "[" + time:clock + "] Communications antenna deployed. Awaiting connection" to droplog.
  380.  
  381. set timer to time:seconds.
  382. until probe:getmodule("modulespu"):getfield("spu") = "operational." {
  383. if not discharged and ship:resources[0]:amount < lowbattlvl {
  384. set capnum to 0.
  385. until capnum = caplist:length {
  386. if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
  387. caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
  388. Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
  389. log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
  390. break.
  391. }.
  392. set capnum to capnum + 1.
  393. }.
  394. if capnum = caplist:length {
  395. set discharged to true.
  396. Print "[" + time:clock + "] All capacitors drained".
  397. log "[" + time:clock + "] All capacitors drained" to droplog.
  398. }.
  399. }.
  400. if time:seconds - timer > commtimeout {
  401. Print "[" + time:clock + "] Communications link failed!".
  402. log "[" + time:clock + "] Communications link failed!" to droplog.
  403. shutdown.
  404. }
  405. wait 0.001.
  406. }.
  407. Print "[" + time:clock + "] Communications link established".
  408. log "[" + time:clock + "] Communications link established" to droplog.
  409. Print "[" + time:clock + "] First lower atmospheric experiment run commencing".
  410. log "[" + time:clock + "] First lower atmospheric experiment run commencing" to droplog.
  411.  
  412. toggle AG4.
  413. // goo containers are only run once per atmosphere level (upper/lower)
  414. for goo in goolist {
  415. // we don't care which goo pod is run - if a goo container is unused, it will have an event available
  416. if goo:getmodule("modulescienceexperiment"):allevents:length > 0 {
  417. goo:getmodule("modulescienceexperiment"):doevent("observe mystery goo").
  418. break.
  419. }.
  420. }.
  421. Print "[" + time:clock + "] Awaiting data transmission".
  422. log "[" + time:clock + "] Awaiting data transmission" to droplog.
  423.  
  424. set timer to time:seconds.
  425. set nodata to false.
  426. // until the comms message changes from "idle", nothing is being transmitted
  427. until comms:getmodule("modulertdatatransmitter"):getfield("comms") = "uploading data..." {
  428. // keep tabs on our power status - release capcitor charge as necessary
  429. if not discharged and ship:resources[0]:amount < lowbattlvl {
  430. set capnum to 0.
  431. until capnum = caplist:length {
  432. if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
  433. caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
  434. Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
  435. log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
  436. break.
  437. }.
  438. set capnum to capnum + 1.
  439. }.
  440. if capnum = caplist:length {
  441. set discharged to true.
  442. Print "[" + time:clock + "] All capacitors drained".
  443. log "[" + time:clock + "] All capacitors drained" to droplog.
  444. }.
  445. }.
  446. // keeps tabs on our connection to Mission Control
  447. if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
  448. Print "[" + time:clock + "] Connection lost".
  449. log "[" + time:clock + "] Connection lost" to droplog.
  450. shutdown.
  451. }.
  452. // if the user recycles all experiments, no data will be sent
  453. if time:seconds - timer > commtimeout {
  454. set nodata to true.
  455. break.
  456. }
  457. wait 0.001.
  458. }.
  459.  
  460. if nodata {
  461. // aborts the second run as well - no data means no data for this entire biome level
  462. Print "[" + time:clock + "] Aborting lower atmospheric runs due to no data to transmit".
  463. log "[" + time:clock + "] Aborting lower atmospheric runs due to no data to transmit" to droplog.
  464. } else {
  465. Print "[" + time:clock + "] Data transmission has begun".
  466. log "[" + time:clock + "] Data transmission has begun" to droplog.
  467.  
  468. until time:seconds - transtime > transmissiontimeout {
  469. if not discharged and ship:resources[0]:amount < lowbattlvl {
  470. set capnum to 0.
  471. until capnum = caplist:length {
  472. if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
  473. caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
  474. Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
  475. log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
  476. break.
  477. }.
  478. set capnum to capnum + 1.
  479. }.
  480. if capnum = caplist:length {
  481. set discharged to true.
  482. Print "[" + time:clock + "] All capacitors drained".
  483. log "[" + time:clock + "] All capacitors drained" to droplog.
  484. }.
  485. }.
  486. if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
  487. Print "[" + time:clock + "] Connection lost".
  488. log "[" + time:clock + "] Connection lost" to droplog.
  489. shutdown.
  490. }.
  491. if transtime < time:seconds and comms:getmodule("modulertdatatransmitter"):getfield("comms") = "uploading data..." {
  492. lock transtime to time:seconds.
  493. }.
  494. if transtime = time:seconds and comms:getmodule("modulertdatatransmitter"):getfield("comms") = "idle" {
  495. set transtime to time:seconds.
  496. }.
  497. wait 0.001.
  498. }.
  499. Print "[" + time:clock + "] Data transmission has ended".
  500. log "[" + time:clock + "] Data transmission has ended" to droplog.
  501.  
  502. if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
  503. Print "[" + time:clock + "] Connection lost".
  504. log "[" + time:clock + "] Connection lost" to droplog.
  505. shutdown.
  506. }.
  507.  
  508. // if we'haven't landed yet, take a second run for additional data
  509. if ship:verticalspeed < 0 {
  510. Print "[" + time:clock + "] Second lower atmospheric experiment run commencing".
  511. log "[" + time:clock + "] Second lower atmospheric experiment run commencing" to droplog.
  512. toggle AG4.
  513. for goo in goolist {
  514. if goo:getmodule("modulescienceexperiment"):allevents:length > 0 {
  515. goo:getmodule("modulescienceexperiment"):doevent("observe mystery goo").
  516. break.
  517. }.
  518. }.
  519. Print "[" + time:clock + "] Awaiting data transmission".
  520. log "[" + time:clock + "] Awaiting data transmission" to droplog.
  521.  
  522. set timer to time:seconds.
  523. set nodata to false.
  524. until comms:getmodule("modulertdatatransmitter"):getfield("comms") = "uploading data..." {
  525. if not discharged and ship:resources[0]:amount < lowbattlvl {
  526. set capnum to 0.
  527. until capnum = caplist:length {
  528. if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
  529. caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
  530. Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
  531. log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
  532. break.
  533. }.
  534. set capnum to capnum + 1.
  535. }.
  536. if capnum = caplist:length {
  537. set discharged to true.
  538. Print "[" + time:clock + "] All capacitors drained".
  539. log "[" + time:clock + "] All capacitors drained" to droplog.
  540. }.
  541. }.
  542. if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
  543. Print "[" + time:clock + "] Connection lost".
  544. log "[" + time:clock + "] Connection lost" to droplog.
  545. shutdown.
  546. }.
  547. if time:seconds - timer > commtimeout {
  548. set nodata to true.
  549. break.
  550. }
  551. wait 0.001.
  552. }.
  553.  
  554. if nodata {
  555. Print "[" + time:clock + "] Aborting second lower atmospheric run due to no data to transmit".
  556. log "[" + time:clock + "] Aborting second lower atmospheric run due to no data to transmit" to droplog.
  557. } else {
  558. Print "[" + time:clock + "] Data transmission has begun".
  559. log "[" + time:clock + "] Data transmission has begun" to droplog.
  560.  
  561. until time:seconds - transtime > transmissiontimeout {
  562. if not discharged and ship:resources[0]:amount < lowbattlvl {
  563. set capnum to 0.
  564. until capnum = caplist:length {
  565. if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
  566. caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
  567. Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
  568. log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
  569. break.
  570. }.
  571. set capnum to capnum + 1.
  572. }.
  573. if capnum = caplist:length {
  574. set discharged to true.
  575. Print "[" + time:clock + "] All capacitors drained".
  576. log "[" + time:clock + "] All capacitors drained" to droplog.
  577. }.
  578. }.
  579. if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
  580. Print "[" + time:clock + "] Connection lost".
  581. log "[" + time:clock + "] Connection lost" to droplog.
  582. shutdown.
  583. }.
  584. if transtime < time:seconds and comms:getmodule("modulertdatatransmitter"):getfield("comms") = "uploading data..." {
  585. lock transtime to time:seconds.
  586. }.
  587. if transtime = time:seconds and comms:getmodule("modulertdatatransmitter"):getfield("comms") = "idle" {
  588. set transtime to time:seconds.
  589. }.
  590. wait 0.001.
  591. }.
  592.  
  593. Print "[" + time:clock + "] Data transmission has ended".
  594. log "[" + time:clock + "] Data transmission has ended" to droplog.
  595. }.
  596. }.
  597. }.
  598.  
  599. // go into a wait state if we haven't landed during the last transmission sequence
  600. if ship:verticalspeed < 0 {
  601. Print "[" + time:clock + "] Awaiting landing".
  602. until ship:verticalspeed >= 0 {
  603. if not discharged and ship:resources[0]:amount < lowbattlvl {
  604. set capnum to 0.
  605. until capnum = caplist:length {
  606. if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
  607. caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
  608. Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
  609. log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
  610. break.
  611. }.
  612. set capnum to capnum + 1.
  613. }.
  614. if capnum = caplist:length {
  615. set discharged to true.
  616. Print "[" + time:clock + "] All capacitors drained".
  617. log "[" + time:clock + "] All capacitors drained" to droplog.
  618. }.
  619. }.
  620. if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
  621. Print "[" + time:clock + "] Connection lost".
  622. log "[" + time:clock + "] Connection lost" to droplog.
  623. shutdown.
  624. }.
  625. wait 0.001.
  626. }.
  627. }.
  628.  
  629. Print "[" + time:clock + "] Landing confirmed. First ground level experiment run commencing".
  630. log "[" + time:clock + "] Landing confirmed. First ground level experiment run commencing" to droplog.
  631. toggle AG4.
  632. for goo in goolist {
  633. if goo:getmodule("modulescienceexperiment"):allevents:length > 0 {
  634. goo:getmodule("modulescienceexperiment"):doevent("observe mystery goo").
  635. break.
  636. }.
  637. }.
  638. Print "[" + time:clock + "] Awaiting data transmission".
  639. log "[" + time:clock + "] Awaiting data transmission" to droplog.
  640.  
  641. set timer to time:seconds.
  642. set nodata to false.
  643. until comms:getmodule("modulertdatatransmitter"):getfield("comms") = "uploading data..." {
  644. if not discharged and ship:resources[0]:amount < lowbattlvl {
  645. set capnum to 0.
  646. until capnum = caplist:length {
  647. if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
  648. caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
  649. Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
  650. log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
  651. break.
  652. }.
  653. set capnum to capnum + 1.
  654. }.
  655. if capnum = caplist:length {
  656. set discharged to true.
  657. Print "[" + time:clock + "] All capacitors drained".
  658. log "[" + time:clock + "] All capacitors drained" to droplog.
  659. }.
  660. }.
  661. if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
  662. Print "[" + time:clock + "] Connection lost".
  663. log "[" + time:clock + "] Connection lost" to droplog.
  664. shutdown.
  665. }.
  666. if time:seconds - timer > commtimeout {
  667. set nodata to true.
  668. break.
  669. }
  670. wait 0.001.
  671. }.
  672.  
  673. if nodata {
  674. Print "[" + time:clock + "] Aborting ground level runs due to no data to transmit".
  675. log "[" + time:clock + "] Aborting ground level runs due to no data to transmit" to droplog.
  676. } else {
  677. Print "[" + time:clock + "] Data transmission has begun".
  678. log "[" + time:clock + "] Data transmission has begun" to droplog.
  679.  
  680. until time:seconds - transtime > transmissiontimeout {
  681. if not discharged and ship:resources[0]:amount < lowbattlvl {
  682. set capnum to 0.
  683. until capnum = caplist:length {
  684. if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
  685. caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
  686. Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
  687. log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
  688. break.
  689. }.
  690. set capnum to capnum + 1.
  691. }.
  692. if capnum = caplist:length {
  693. set discharged to true.
  694. Print "[" + time:clock + "] All capacitors drained".
  695. log "[" + time:clock + "] All capacitors drained" to droplog.
  696. }.
  697. }.
  698. if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
  699. Print "[" + time:clock + "] Connection lost".
  700. log "[" + time:clock + "] Connection lost" to droplog.
  701. shutdown.
  702. }.
  703. if transtime < time:seconds and comms:getmodule("modulertdatatransmitter"):getfield("comms") = "uploading data..." {
  704. lock transtime to time:seconds.
  705. }.
  706. if transtime = time:seconds and comms:getmodule("modulertdatatransmitter"):getfield("comms") = "idle" {
  707. set transtime to time:seconds.
  708. }.
  709. wait 0.001.
  710. }.
  711. Print "[" + time:clock + "] Data transmission has ended".
  712. log "[" + time:clock + "] Data transmission has ended" to droplog.
  713.  
  714. if ship:resources[0]:amount > 0 {
  715. Print "[" + time:clock + "] Second ground level experiment run commencing".
  716. log "[" + time:clock + "] Second ground level experiment run commencing" to droplog.
  717. toggle AG4.
  718. for goo in goolist {
  719. if goo:getmodule("modulescienceexperiment"):allevents:length > 0 {
  720. goo:getmodule("modulescienceexperiment"):doevent("observe mystery goo").
  721. break.
  722. }.
  723. }.
  724. Print "[" + time:clock + "] Awaiting data transmission".
  725. log "[" + time:clock + "] Awaiting data transmission" to droplog.
  726.  
  727. set timer to time:seconds.
  728. set nodata to false.
  729. until comms:getmodule("modulertdatatransmitter"):getfield("comms") = "uploading data..." {
  730. if not discharged and ship:resources[0]:amount < lowbattlvl {
  731. set capnum to 0.
  732. until capnum = caplist:length {
  733. if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
  734. caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
  735. Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
  736. log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
  737. break.
  738. }.
  739. set capnum to capnum + 1.
  740. }.
  741. if capnum = caplist:length {
  742. set discharged to true.
  743. Print "[" + time:clock + "] All capacitors drained".
  744. log "[" + time:clock + "] All capacitors drained" to droplog.
  745. }.
  746. }.
  747. if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
  748. Print "[" + time:clock + "] Connection lost".
  749. log "[" + time:clock + "] Connection lost" to droplog.
  750. shutdown.
  751. }.
  752. if time:seconds - timer > commtimeout {
  753. set nodata to true.
  754. break.
  755. }
  756. wait 0.001.
  757. }.
  758.  
  759. if nodata {
  760. Print "[" + time:clock + "] Aborting second ground level run due to no data to transmit".
  761. log "[" + time:clock + "] Aborting second ground level run due to no data to transmit" to droplog.
  762. } else {
  763. Print "[" + time:clock + "] Data transmission has begun".
  764. log "[" + time:clock + "] Data transmission has begun" to droplog.
  765.  
  766. until time:seconds - transtime > transmissiontimeout {
  767. if not discharged and ship:resources[0]:amount < lowbattlvl {
  768. set capnum to 0.
  769. until capnum = caplist:length {
  770. if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
  771. caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
  772. Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
  773. log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
  774. break.
  775. }.
  776. set capnum to capnum + 1.
  777. }.
  778. if capnum = caplist:length {
  779. set discharged to true.
  780. Print "[" + time:clock + "] All capacitors drained".
  781. log "[" + time:clock + "] All capacitors drained" to droplog.
  782. }.
  783. }.
  784. if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
  785. Print "[" + time:clock + "] Connection lost".
  786. log "[" + time:clock + "] Connection lost" to droplog.
  787. shutdown.
  788. }.
  789. if transtime < time:seconds and comms:getmodule("modulertdatatransmitter"):getfield("comms") = "uploading data..." {
  790. lock transtime to time:seconds.
  791. }.
  792. if transtime = time:seconds and comms:getmodule("modulertdatatransmitter"):getfield("comms") = "idle" {
  793. set transtime to time:seconds.
  794. }.
  795. wait 0.001.
  796. }.
  797.  
  798. Print "[" + time:clock + "] Data transmission has ended".
  799. log "[" + time:clock + "] Data transmission has ended" to droplog.
  800. }.
  801. }.
  802. }.
  803. Print "[" + time:clock + "] All events have executed".
  804. log "[" + time:clock + "] All events have executed" to droplog.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement