Advertisement
KSA_MissionCtrl

droptestlow.ks 4/14

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