cosmos 3.0.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (912) hide show
  1. checksums.yaml +4 -4
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +48 -48
  4. data/.travis.yml +7 -7
  5. data/CONTRIBUTING.txt +50 -50
  6. data/Gemfile +6 -6
  7. data/Guardfile +27 -27
  8. data/LICENSE.txt +879 -879
  9. data/Manifest.txt +1116 -1114
  10. data/README.md +109 -107
  11. data/Rakefile +214 -214
  12. data/autohotkey/config/data/diamond.STL +57 -57
  13. data/autohotkey/config/system/system.txt +34 -34
  14. data/autohotkey/config/targets/COSMOS/cmd_tlm/cosmos_server_cmds.txt +41 -41
  15. data/autohotkey/config/targets/COSMOS/cmd_tlm/cosmos_server_tlm.txt +15 -15
  16. data/autohotkey/config/targets/COSMOS/cmd_tlm_server.txt +6 -6
  17. data/autohotkey/config/targets/COSMOS/target.txt +5 -5
  18. data/autohotkey/config/targets/INST/cmd_tlm/inst_cmds.txt +121 -121
  19. data/autohotkey/config/targets/INST/cmd_tlm/inst_tlm.txt +247 -247
  20. data/autohotkey/config/targets/INST/cmd_tlm_server.txt +5 -5
  21. data/autohotkey/config/targets/INST/lib/example_limits_response.rb +30 -30
  22. data/autohotkey/config/targets/INST/lib/sim_inst.rb +305 -294
  23. data/autohotkey/config/targets/INST/screens/adcs.txt +46 -46
  24. data/autohotkey/config/targets/INST/screens/array.txt +7 -7
  25. data/autohotkey/config/targets/INST/screens/block.txt +8 -8
  26. data/autohotkey/config/targets/INST/screens/commanding.txt +30 -30
  27. data/autohotkey/config/targets/INST/screens/graphs.txt +14 -14
  28. data/autohotkey/config/targets/INST/screens/ground.txt +25 -25
  29. data/autohotkey/config/targets/INST/screens/health_status.txt +33 -33
  30. data/autohotkey/config/targets/INST/screens/hs.txt +49 -49
  31. data/autohotkey/config/targets/INST/screens/image.txt +21 -21
  32. data/autohotkey/config/targets/INST/screens/latest.txt +23 -23
  33. data/autohotkey/config/targets/INST/screens/mech.txt +25 -25
  34. data/autohotkey/config/targets/INST/screens/other.txt +25 -25
  35. data/autohotkey/config/targets/INST/screens/params.txt +25 -25
  36. data/autohotkey/config/targets/INST/screens/tabs.txt +68 -68
  37. data/autohotkey/config/targets/INST/target.txt +26 -26
  38. data/autohotkey/config/targets/META/cmd_tlm/meta_cmd.txt +10 -10
  39. data/autohotkey/config/targets/META/cmd_tlm/meta_tlm.txt +9 -9
  40. data/autohotkey/config/targets/SYSTEM/cmd_tlm/limits_groups.txt +7 -7
  41. data/autohotkey/config/targets/SYSTEM/screens/error.txt +11 -11
  42. data/autohotkey/config/tools/cmd_tlm_server/cmd_tlm_server.txt +22 -22
  43. data/autohotkey/config/tools/data_viewer/data_viewer.txt +11 -11
  44. data/autohotkey/config/tools/handbook_creator/handbook_creator.txt +49 -49
  45. data/autohotkey/config/tools/handbook_creator/templates/command_packets.html.erb +86 -86
  46. data/autohotkey/config/tools/handbook_creator/templates/command_toc.html.erb +38 -38
  47. data/autohotkey/config/tools/handbook_creator/templates/footer.html.erb +9 -9
  48. data/autohotkey/config/tools/handbook_creator/templates/header.html.erb +25 -25
  49. data/autohotkey/config/tools/handbook_creator/templates/limits_groups.html.erb +13 -13
  50. data/autohotkey/config/tools/handbook_creator/templates/nav.html.erb +27 -27
  51. data/autohotkey/config/tools/handbook_creator/templates/overview.html.erb +1 -1
  52. data/autohotkey/config/tools/handbook_creator/templates/pdf_cover.html.erb +23 -23
  53. data/autohotkey/config/tools/handbook_creator/templates/pdf_footer.html.erb +33 -33
  54. data/autohotkey/config/tools/handbook_creator/templates/pdf_header.html.erb +41 -41
  55. data/autohotkey/config/tools/handbook_creator/templates/telemetry_packets.html.erb +80 -80
  56. data/autohotkey/config/tools/handbook_creator/templates/telemetry_toc.html.erb +38 -38
  57. data/autohotkey/config/tools/handbook_creator/templates/title.html.erb +1 -1
  58. data/autohotkey/config/tools/launcher/launcher.txt +38 -38
  59. data/autohotkey/config/tools/script_runner/script_runner.txt +3 -3
  60. data/autohotkey/config/tools/table_manager/ConfigTables_def.txt +8 -8
  61. data/autohotkey/config/tools/table_manager/OneDimensionalTable_def.txt +19 -19
  62. data/autohotkey/config/tools/table_manager/TwoDimensionalTable_def.txt +248 -248
  63. data/autohotkey/config/tools/test_runner/test_runner.txt +8 -8
  64. data/autohotkey/config/tools/test_runner/test_runner2.txt +11 -11
  65. data/autohotkey/config/tools/test_runner/test_runner3.txt +6 -6
  66. data/autohotkey/config/tools/test_runner/test_runner4.txt +1 -1
  67. data/autohotkey/config/tools/tlm_extractor/tlm_extractor.txt +13 -13
  68. data/autohotkey/config/tools/tlm_extractor/tlm_extractor2.txt +9 -9
  69. data/autohotkey/config/tools/tlm_grapher/bad.txt +50 -50
  70. data/autohotkey/config/tools/tlm_grapher/temp1-4.txt +51 -51
  71. data/autohotkey/config/tools/tlm_grapher/test2.txt +111 -111
  72. data/autohotkey/config/tools/tlm_viewer/tlm_viewer.txt +24 -24
  73. data/autohotkey/config/tools/tlm_viewer/tlm_viewer2.txt +4 -4
  74. data/autohotkey/config/tools/tlm_viewer/tlm_viewer3.txt +3 -3
  75. data/autohotkey/lib/example_background_task.rb +42 -42
  76. data/autohotkey/lib/user_version.rb +3 -3
  77. data/autohotkey/procedures/clear_util.rb +7 -7
  78. data/autohotkey/procedures/collect.rb +18 -18
  79. data/autohotkey/procedures/collect_util.rb +14 -14
  80. data/autohotkey/procedures/example_test.rb +67 -67
  81. data/autohotkey/procedures/example_test2.rb +74 -74
  82. data/autohotkey/procedures/script_test.rb +17 -17
  83. data/autohotkey/procedures/syntax_error.rb +18 -18
  84. data/autohotkey/tools/CmdExtractorAHK +16 -16
  85. data/autohotkey/tools/CmdSender +14 -14
  86. data/autohotkey/tools/CmdSenderAHK +18 -18
  87. data/autohotkey/tools/CmdTlmServer +14 -14
  88. data/autohotkey/tools/CmdTlmServerAHK +28 -28
  89. data/autohotkey/tools/CmdTlmServerAHK2 +17 -17
  90. data/autohotkey/tools/DataViewer +14 -14
  91. data/autohotkey/tools/DataViewerAHK +17 -17
  92. data/autohotkey/tools/HandbookCreatorAHK +20 -20
  93. data/autohotkey/tools/LauncherAHK +17 -17
  94. data/autohotkey/tools/LimitsMonitorAHK +20 -20
  95. data/autohotkey/tools/OpenGLBuilderAHK +20 -20
  96. data/autohotkey/tools/PacketViewer +14 -14
  97. data/autohotkey/tools/PacketViewerAHK +18 -18
  98. data/autohotkey/tools/PacketViewerAHK2 +17 -17
  99. data/autohotkey/tools/Replay +14 -14
  100. data/autohotkey/tools/Replay.bat +59 -59
  101. data/autohotkey/tools/ReplayAHK +17 -17
  102. data/autohotkey/tools/ScriptRunner +14 -14
  103. data/autohotkey/tools/ScriptRunnerAHK +20 -20
  104. data/autohotkey/tools/ScriptRunnerAHK2 +17 -17
  105. data/autohotkey/tools/TableManager +14 -14
  106. data/autohotkey/tools/TableManagerAHK +30 -30
  107. data/autohotkey/tools/TestRunner +15 -15
  108. data/autohotkey/tools/TestRunnerAHK +17 -17
  109. data/autohotkey/tools/TestRunnerAHK2 +17 -17
  110. data/autohotkey/tools/TestRunnerAHK3 +17 -17
  111. data/autohotkey/tools/TestRunnerAHK4 +17 -17
  112. data/autohotkey/tools/TlmExtractor +15 -15
  113. data/autohotkey/tools/TlmExtractorAHK +19 -19
  114. data/autohotkey/tools/TlmExtractorAHK2 +16 -16
  115. data/autohotkey/tools/TlmExtractorAHK3 +16 -16
  116. data/autohotkey/tools/TlmGrapher +14 -14
  117. data/autohotkey/tools/TlmGrapherAHK +19 -19
  118. data/autohotkey/tools/TlmGrapherAHK2 +23 -23
  119. data/autohotkey/tools/TlmGrapherAHK3 +17 -17
  120. data/autohotkey/tools/TlmGrapherAHK4 +17 -17
  121. data/autohotkey/tools/TlmViewer +14 -14
  122. data/autohotkey/tools/TlmViewerAHK +28 -28
  123. data/autohotkey/tools/TlmViewerAHK2 +18 -18
  124. data/autohotkey/tools/TlmViewerAHK3 +18 -18
  125. data/autohotkey/tools/TlmViewerAHK4 +18 -18
  126. data/autohotkey/tools/TlmViewerAHK5 +18 -18
  127. data/autohotkey/tools/autohotkey.rb +37 -37
  128. data/autohotkey/tools/cmd_extractor.ahk +27 -27
  129. data/autohotkey/tools/cmd_sender.ahk +182 -162
  130. data/autohotkey/tools/cmd_tlm_server.ahk +89 -89
  131. data/autohotkey/tools/cmd_tlm_server2.ahk +45 -45
  132. data/autohotkey/tools/data_viewer.ahk +135 -135
  133. data/autohotkey/tools/handbook_creator.ahk +23 -23
  134. data/autohotkey/tools/launcher.ahk +41 -41
  135. data/autohotkey/tools/limits_monitor.ahk +70 -70
  136. data/autohotkey/tools/open_gl_builder.ahk +134 -134
  137. data/autohotkey/tools/packet_viewer.ahk +143 -143
  138. data/autohotkey/tools/packet_viewer2.ahk +9 -9
  139. data/autohotkey/tools/replay.ahk +98 -98
  140. data/autohotkey/tools/script_runner.ahk +589 -589
  141. data/autohotkey/tools/script_runner2.ahk +34 -31
  142. data/autohotkey/tools/table_manager.ahk +220 -220
  143. data/autohotkey/tools/test_runner.ahk +262 -259
  144. data/autohotkey/tools/test_runner2.ahk +52 -52
  145. data/autohotkey/tools/test_runner3.ahk +13 -13
  146. data/autohotkey/tools/tlm_extractor.ahk +272 -272
  147. data/autohotkey/tools/tlm_grapher.ahk +642 -642
  148. data/autohotkey/tools/tlm_grapher2.ahk +115 -115
  149. data/autohotkey/tools/tlm_grapher3.ahk +24 -24
  150. data/autohotkey/tools/tlm_viewer.ahk +133 -133
  151. data/autohotkey/tools/tlm_viewer2.ahk +50 -49
  152. data/autohotkey/tools/tlm_viewer4.ahk +4 -4
  153. data/autohotkey/tools/tlm_viewer5.ahk +20 -20
  154. data/bin/cosmos +96 -96
  155. data/bin/cstol_converter +1166 -1166
  156. data/bin/rubysloc +85 -85
  157. data/cosmos.gemspec +98 -97
  158. data/data/about.txt +4 -4
  159. data/data/crc.txt +306 -305
  160. data/data/diamond.STL +57 -57
  161. data/data/legal.txt +9 -9
  162. data/demo/Gemfile +6 -6
  163. data/demo/Launcher +15 -15
  164. data/demo/Launcher.bat +59 -59
  165. data/demo/Rakefile +61 -61
  166. data/demo/config/data/crc.txt +222 -206
  167. data/demo/config/data/diamond.STL +57 -57
  168. data/demo/config/data/meta_init.txt +4 -4
  169. data/demo/config/system/system.txt +34 -34
  170. data/demo/config/system/system2.txt +33 -33
  171. data/demo/config/targets/COSMOS/cmd_tlm/cosmos_server_cmds.txt +41 -41
  172. data/demo/config/targets/COSMOS/cmd_tlm/cosmos_server_tlm.txt +15 -15
  173. data/demo/config/targets/COSMOS/cmd_tlm_server.txt +6 -6
  174. data/demo/config/targets/COSMOS/screens/limits_change.txt +20 -20
  175. data/demo/config/targets/COSMOS/screens/version.txt +19 -19
  176. data/demo/config/targets/COSMOS/target.txt +11 -11
  177. data/demo/config/targets/EXAMPLE/cmd_tlm/example_cmds.txt +2 -2
  178. data/demo/config/targets/EXAMPLE/cmd_tlm/example_tlm.txt +3 -3
  179. data/demo/config/targets/EXAMPLE/cmd_tlm_server.txt +6 -6
  180. data/demo/config/targets/EXAMPLE/lib/example_interface.rb +22 -22
  181. data/demo/config/targets/EXAMPLE/target.txt +6 -6
  182. data/demo/config/targets/INST/cmd_tlm/inst_cmds.txt +121 -121
  183. data/demo/config/targets/INST/cmd_tlm/inst_tlm.txt +247 -247
  184. data/demo/config/targets/INST/cmd_tlm_server.txt +5 -5
  185. data/demo/config/targets/INST/lib/example_limits_response.rb +30 -30
  186. data/demo/config/targets/INST/lib/sim_inst.rb +305 -294
  187. data/demo/config/targets/INST/screens/adcs.txt +46 -46
  188. data/demo/config/targets/INST/screens/array.txt +15 -15
  189. data/demo/config/targets/INST/screens/block.txt +8 -8
  190. data/demo/config/targets/INST/screens/commanding.txt +30 -30
  191. data/demo/config/targets/INST/screens/graphs.txt +14 -14
  192. data/demo/config/targets/INST/screens/ground.txt +25 -25
  193. data/demo/config/targets/INST/screens/hs.txt +44 -44
  194. data/demo/config/targets/INST/screens/latest.txt +23 -23
  195. data/demo/config/targets/INST/screens/other.txt +29 -29
  196. data/demo/config/targets/INST/screens/tabs.txt +70 -70
  197. data/demo/config/targets/INST/target.txt +33 -33
  198. data/demo/config/targets/META/cmd_tlm/meta_cmd.txt +10 -10
  199. data/demo/config/targets/META/cmd_tlm/meta_tlm.txt +13 -13
  200. data/demo/config/targets/SYSTEM/cmd_tlm/limits_groups.txt +7 -7
  201. data/demo/config/targets/SYSTEM/cmd_tlm/override.txt +29 -29
  202. data/demo/config/targets/SYSTEM/screens/status.txt +12 -12
  203. data/demo/config/targets/TEMPLATED/cmd_tlm/templated_cmds.txt +13 -12
  204. data/demo/config/targets/TEMPLATED/cmd_tlm/templated_tlm.txt +3 -3
  205. data/demo/config/targets/TEMPLATED/cmd_tlm_server.txt +6 -6
  206. data/demo/config/targets/TEMPLATED/lib/templated_interface.rb +54 -48
  207. data/demo/config/targets/TEMPLATED/target.txt +6 -6
  208. data/demo/config/tools/cmd_tlm_server/cmd_tlm_server.txt +33 -33
  209. data/demo/config/tools/cmd_tlm_server/cmd_tlm_server2.txt +29 -29
  210. data/demo/config/tools/data_viewer/data_viewer.txt +11 -11
  211. data/demo/config/tools/handbook_creator/handbook_creator.txt +66 -66
  212. data/demo/config/tools/handbook_creator/templates/command_packets.html.erb +86 -86
  213. data/demo/config/tools/handbook_creator/templates/command_toc.html.erb +38 -38
  214. data/demo/config/tools/handbook_creator/templates/footer.html.erb +9 -9
  215. data/demo/config/tools/handbook_creator/templates/header.html.erb +25 -25
  216. data/demo/config/tools/handbook_creator/templates/limits_groups.html.erb +13 -13
  217. data/demo/config/tools/handbook_creator/templates/nav.html.erb +27 -27
  218. data/demo/config/tools/handbook_creator/templates/overview.html.erb +1 -1
  219. data/demo/config/tools/handbook_creator/templates/pdf_cover.html.erb +23 -23
  220. data/demo/config/tools/handbook_creator/templates/pdf_footer.html.erb +33 -33
  221. data/demo/config/tools/handbook_creator/templates/pdf_header.html.erb +41 -41
  222. data/demo/config/tools/handbook_creator/templates/telemetry_packets.html.erb +80 -80
  223. data/demo/config/tools/handbook_creator/templates/telemetry_toc.html.erb +38 -38
  224. data/demo/config/tools/handbook_creator/templates/title.html.erb +1 -1
  225. data/demo/config/tools/launcher/launcher.txt +45 -45
  226. data/demo/config/tools/launcher/launcher2.txt +45 -45
  227. data/demo/config/tools/script_runner/script_runner.txt +3 -3
  228. data/demo/config/tools/table_manager/ConfigTables_def.txt +8 -8
  229. data/demo/config/tools/table_manager/ExampleTableDefinition.txt +24 -24
  230. data/demo/config/tools/table_manager/MCConfigurationTable_fsw1_def.txt +25 -25
  231. data/demo/config/tools/table_manager/MCConfigurationTable_fsw2_def.txt +25 -25
  232. data/demo/config/tools/table_manager/PPSSelectionTable_def.txt +8 -8
  233. data/demo/config/tools/table_manager/TLMMonitoringTable_def.txt +248 -248
  234. data/demo/config/tools/test_runner/test_runner.txt +17 -17
  235. data/demo/config/tools/tlm_extractor/tlm_extractor.txt +13 -13
  236. data/demo/config/tools/tlm_extractor/tlm_extractor2.txt +2 -2
  237. data/demo/config/tools/tlm_extractor/tlm_extractor3.txt +2 -2
  238. data/demo/config/tools/tlm_extractor/tlm_extractor4.txt +2 -2
  239. data/demo/config/tools/tlm_viewer/tlm_viewer.txt +41 -41
  240. data/demo/lib/example_background_task.rb +57 -52
  241. data/demo/lib/example_target.rb +113 -108
  242. data/demo/lib/scpi_target.rb +74 -74
  243. data/demo/lib/user_version.rb +3 -3
  244. data/demo/procedures/checks.rb +11 -11
  245. data/demo/procedures/clear_util.rb +7 -7
  246. data/demo/procedures/collect.rb +18 -18
  247. data/demo/procedures/collect_util.rb +14 -14
  248. data/demo/procedures/cosmos_api_test.rb +293 -293
  249. data/demo/procedures/disconnect.rb +29 -29
  250. data/demo/procedures/example_test.rb +182 -182
  251. data/demo/procedures/plot_test.rb +8 -8
  252. data/demo/procedures/run_example_test.rb +3 -3
  253. data/demo/procedures/test.rb +51 -51
  254. data/demo/tools/CmdExtractor +15 -15
  255. data/demo/tools/CmdExtractor.bat +59 -59
  256. data/demo/tools/CmdSender +15 -15
  257. data/demo/tools/CmdSender.bat +59 -59
  258. data/demo/tools/CmdTlmServer +15 -15
  259. data/demo/tools/CmdTlmServer.bat +59 -59
  260. data/demo/tools/DataViewer +15 -15
  261. data/demo/tools/DataViewer.bat +59 -59
  262. data/demo/tools/ExampleTarget +15 -15
  263. data/demo/tools/ExampleTarget.bat +59 -59
  264. data/demo/tools/HandbookCreator +15 -15
  265. data/demo/tools/HandbookCreator.bat +61 -61
  266. data/demo/tools/Launcher +15 -15
  267. data/demo/tools/Launcher.bat +59 -59
  268. data/demo/tools/LimitsMonitor +15 -15
  269. data/demo/tools/LimitsMonitor.bat +59 -59
  270. data/demo/tools/OpenGLBuilder +15 -15
  271. data/demo/tools/OpenGLBuilder.bat +59 -59
  272. data/demo/tools/PacketViewer +15 -15
  273. data/demo/tools/PacketViewer.bat +59 -59
  274. data/demo/tools/Replay +15 -15
  275. data/demo/tools/Replay.bat +59 -59
  276. data/demo/tools/ScpiTarget +15 -15
  277. data/demo/tools/ScpiTarget.bat +59 -59
  278. data/demo/tools/ScriptRunner +15 -15
  279. data/demo/tools/ScriptRunner.bat +59 -59
  280. data/demo/tools/TableManager +15 -15
  281. data/demo/tools/TableManager.bat +59 -59
  282. data/demo/tools/TestRunner +15 -15
  283. data/demo/tools/TestRunner.bat +59 -59
  284. data/demo/tools/TlmExtractor +15 -15
  285. data/demo/tools/TlmExtractor.bat +59 -59
  286. data/demo/tools/TlmGrapher +15 -15
  287. data/demo/tools/TlmGrapher.bat +59 -59
  288. data/demo/tools/TlmViewer +15 -15
  289. data/demo/tools/TlmViewer.bat +59 -59
  290. data/demo/tools/mac/CmdExtractor.app/Contents/Info.plist +38 -38
  291. data/demo/tools/mac/CmdExtractor.app/Contents/MacOS/CmdExtractor.rb +15 -15
  292. data/demo/tools/mac/CmdExtractor.app/Contents/MacOS/main.sh +6 -6
  293. data/demo/tools/mac/CmdSender.app/Contents/Info.plist +38 -38
  294. data/demo/tools/mac/CmdSender.app/Contents/MacOS/CmdSender.rb +15 -15
  295. data/demo/tools/mac/CmdSender.app/Contents/MacOS/main.sh +6 -6
  296. data/demo/tools/mac/CmdTlmServer.app/Contents/Info.plist +38 -38
  297. data/demo/tools/mac/CmdTlmServer.app/Contents/MacOS/CmdTlmServer.rb +15 -15
  298. data/demo/tools/mac/CmdTlmServer.app/Contents/MacOS/main.sh +6 -6
  299. data/demo/tools/mac/DataViewer.app/Contents/Info.plist +38 -38
  300. data/demo/tools/mac/DataViewer.app/Contents/MacOS/DataViewer.rb +15 -15
  301. data/demo/tools/mac/DataViewer.app/Contents/MacOS/main.sh +6 -6
  302. data/demo/tools/mac/HandbookCreator.app/Contents/Info.plist +38 -38
  303. data/demo/tools/mac/HandbookCreator.app/Contents/MacOS/HandbookCreator.rb +15 -15
  304. data/demo/tools/mac/HandbookCreator.app/Contents/MacOS/main.sh +6 -6
  305. data/demo/tools/mac/Launcher.app/Contents/Info.plist +38 -38
  306. data/demo/tools/mac/Launcher.app/Contents/MacOS/Launcher.rb +15 -15
  307. data/demo/tools/mac/Launcher.app/Contents/MacOS/main.sh +6 -6
  308. data/demo/tools/mac/LimitsMonitor.app/Contents/Info.plist +38 -38
  309. data/demo/tools/mac/LimitsMonitor.app/Contents/MacOS/LimitsMonitor.rb +15 -15
  310. data/demo/tools/mac/LimitsMonitor.app/Contents/MacOS/main.sh +6 -6
  311. data/demo/tools/mac/OpenGLBuilder.app/Contents/Info.plist +38 -38
  312. data/demo/tools/mac/OpenGLBuilder.app/Contents/MacOS/OpenGLBuilder.rb +15 -15
  313. data/demo/tools/mac/OpenGLBuilder.app/Contents/MacOS/main.sh +6 -6
  314. data/demo/tools/mac/PacketViewer.app/Contents/Info.plist +38 -38
  315. data/demo/tools/mac/PacketViewer.app/Contents/MacOS/PacketViewer.rb +15 -15
  316. data/demo/tools/mac/PacketViewer.app/Contents/MacOS/main.sh +6 -6
  317. data/demo/tools/mac/Replay.app/Contents/Info.plist +38 -38
  318. data/demo/tools/mac/Replay.app/Contents/MacOS/Replay.rb +15 -15
  319. data/demo/tools/mac/Replay.app/Contents/MacOS/main.sh +6 -6
  320. data/demo/tools/mac/ScriptRunner.app/Contents/Info.plist +38 -38
  321. data/demo/tools/mac/ScriptRunner.app/Contents/MacOS/ScriptRunner.rb +15 -15
  322. data/demo/tools/mac/ScriptRunner.app/Contents/MacOS/main.sh +6 -6
  323. data/demo/tools/mac/TableManager.app/Contents/Info.plist +38 -38
  324. data/demo/tools/mac/TableManager.app/Contents/MacOS/TableManager.rb +15 -15
  325. data/demo/tools/mac/TableManager.app/Contents/MacOS/main.sh +6 -6
  326. data/demo/tools/mac/TestRunner.app/Contents/Info.plist +38 -38
  327. data/demo/tools/mac/TestRunner.app/Contents/MacOS/TestRunner.rb +15 -15
  328. data/demo/tools/mac/TestRunner.app/Contents/MacOS/main.sh +6 -6
  329. data/demo/tools/mac/TlmExtractor.app/Contents/Info.plist +38 -38
  330. data/demo/tools/mac/TlmExtractor.app/Contents/MacOS/TlmExtractor.rb +15 -15
  331. data/demo/tools/mac/TlmExtractor.app/Contents/MacOS/main.sh +6 -6
  332. data/demo/tools/mac/TlmGrapher.app/Contents/Info.plist +38 -38
  333. data/demo/tools/mac/TlmGrapher.app/Contents/MacOS/TlmGrapher.rb +15 -15
  334. data/demo/tools/mac/TlmGrapher.app/Contents/MacOS/main.sh +6 -6
  335. data/demo/tools/mac/TlmViewer.app/Contents/Info.plist +38 -38
  336. data/demo/tools/mac/TlmViewer.app/Contents/MacOS/TlmViewer.rb +15 -15
  337. data/demo/tools/mac/TlmViewer.app/Contents/MacOS/main.sh +6 -6
  338. data/ext/cosmos/ext/array/array.c +111 -111
  339. data/ext/cosmos/ext/array/extconf.rb +13 -13
  340. data/ext/cosmos/ext/buffered_file/buffered_file.c +167 -167
  341. data/ext/cosmos/ext/buffered_file/extconf.rb +13 -13
  342. data/ext/cosmos/ext/config_parser/config_parser.c +237 -237
  343. data/ext/cosmos/ext/config_parser/extconf.rb +13 -13
  344. data/ext/cosmos/ext/cosmos_io/cosmos_io.c +117 -117
  345. data/ext/cosmos/ext/cosmos_io/extconf.rb +13 -13
  346. data/ext/cosmos/ext/crc/crc.c +341 -341
  347. data/ext/cosmos/ext/crc/extconf.rb +12 -12
  348. data/ext/cosmos/ext/line_graph/extconf.rb +13 -13
  349. data/ext/cosmos/ext/line_graph/line_graph.c +501 -501
  350. data/ext/cosmos/ext/low_fragmentation_array/extconf.rb +12 -12
  351. data/ext/cosmos/ext/low_fragmentation_array/low_fragmentation_array.c +261 -261
  352. data/ext/cosmos/ext/packet/extconf.rb +13 -13
  353. data/ext/cosmos/ext/packet/packet.c +339 -339
  354. data/ext/cosmos/ext/platform/extconf.rb +13 -13
  355. data/ext/cosmos/ext/platform/platform.c +81 -81
  356. data/ext/cosmos/ext/polynomial_conversion/extconf.rb +13 -13
  357. data/ext/cosmos/ext/polynomial_conversion/polynomial_conversion.c +73 -73
  358. data/ext/cosmos/ext/string/extconf.rb +13 -13
  359. data/ext/cosmos/ext/string/string.c +49 -49
  360. data/ext/cosmos/ext/structure/structure.c +894 -894
  361. data/ext/cosmos/ext/tabbed_plots_config/extconf.rb +13 -13
  362. data/ext/cosmos/ext/tabbed_plots_config/tabbed_plots_config.c +51 -51
  363. data/ext/cosmos/ext/telemetry/extconf.rb +13 -13
  364. data/ext/cosmos/ext/telemetry/telemetry.c +306 -306
  365. data/ext/mkrf_conf.rb +40 -40
  366. data/install/Gemfile +6 -6
  367. data/install/Launcher +14 -14
  368. data/install/Launcher.bat +59 -59
  369. data/install/Rakefile +61 -61
  370. data/install/config/data/crc.txt +134 -133
  371. data/install/config/system/system.txt +29 -29
  372. data/install/config/targets/COSMOS/cmd_tlm/cosmos_server_cmds.txt +41 -41
  373. data/install/config/targets/COSMOS/cmd_tlm/cosmos_server_tlm.txt +15 -15
  374. data/install/config/targets/COSMOS/cmd_tlm_server.txt +6 -6
  375. data/install/config/targets/COSMOS/screens/limits_change.txt +20 -20
  376. data/install/config/targets/COSMOS/screens/version.txt +19 -19
  377. data/install/config/targets/COSMOS/target.txt +8 -8
  378. data/install/config/tools/cmd_tlm_server/cmd_tlm_server.txt +2 -2
  379. data/install/config/tools/data_viewer/data_viewer.txt +3 -3
  380. data/install/config/tools/handbook_creator/handbook_creator.txt +49 -49
  381. data/install/config/tools/handbook_creator/templates/command_packets.html.erb +86 -86
  382. data/install/config/tools/handbook_creator/templates/command_toc.html.erb +38 -38
  383. data/install/config/tools/handbook_creator/templates/footer.html.erb +9 -9
  384. data/install/config/tools/handbook_creator/templates/header.html.erb +25 -25
  385. data/install/config/tools/handbook_creator/templates/limits_groups.html.erb +13 -13
  386. data/install/config/tools/handbook_creator/templates/nav.html.erb +27 -27
  387. data/install/config/tools/handbook_creator/templates/overview.html.erb +1 -1
  388. data/install/config/tools/handbook_creator/templates/pdf_cover.html.erb +23 -23
  389. data/install/config/tools/handbook_creator/templates/pdf_footer.html.erb +33 -33
  390. data/install/config/tools/handbook_creator/templates/pdf_header.html.erb +41 -41
  391. data/install/config/tools/handbook_creator/templates/telemetry_packets.html.erb +80 -80
  392. data/install/config/tools/handbook_creator/templates/telemetry_toc.html.erb +38 -38
  393. data/install/config/tools/handbook_creator/templates/title.html.erb +1 -1
  394. data/install/config/tools/launcher/launcher.txt +39 -39
  395. data/install/config/tools/script_runner/script_runner.txt +3 -3
  396. data/install/config/tools/test_runner/test_runner.txt +8 -8
  397. data/install/config/tools/tlm_viewer/tlm_viewer.txt +5 -5
  398. data/install/lib/user_version.rb +3 -3
  399. data/install/tools/CmdExtractor +15 -15
  400. data/install/tools/CmdExtractor.bat +59 -59
  401. data/install/tools/CmdSender +15 -15
  402. data/install/tools/CmdSender.bat +59 -59
  403. data/install/tools/CmdTlmServer +15 -15
  404. data/install/tools/CmdTlmServer.bat +59 -59
  405. data/install/tools/DataViewer +15 -15
  406. data/install/tools/DataViewer.bat +59 -59
  407. data/install/tools/HandbookCreator +15 -15
  408. data/install/tools/HandbookCreator.bat +61 -61
  409. data/install/tools/Launcher +15 -15
  410. data/install/tools/Launcher.bat +59 -59
  411. data/install/tools/LimitsMonitor +15 -15
  412. data/install/tools/LimitsMonitor.bat +59 -59
  413. data/install/tools/OpenGLBuilder +15 -15
  414. data/install/tools/OpenGLBuilder.bat +59 -59
  415. data/install/tools/PacketViewer +15 -15
  416. data/install/tools/PacketViewer.bat +59 -59
  417. data/install/tools/Replay +15 -15
  418. data/install/tools/Replay.bat +59 -59
  419. data/install/tools/ScriptRunner +15 -15
  420. data/install/tools/ScriptRunner.bat +59 -59
  421. data/install/tools/TableManager +15 -15
  422. data/install/tools/TableManager.bat +59 -59
  423. data/install/tools/TestRunner +15 -15
  424. data/install/tools/TestRunner.bat +59 -59
  425. data/install/tools/TlmExtractor +15 -15
  426. data/install/tools/TlmExtractor.bat +59 -59
  427. data/install/tools/TlmGrapher +15 -15
  428. data/install/tools/TlmGrapher.bat +59 -59
  429. data/install/tools/TlmViewer +15 -15
  430. data/install/tools/TlmViewer.bat +59 -59
  431. data/install/tools/mac/CmdExtractor.app/Contents/Info.plist +38 -38
  432. data/install/tools/mac/CmdExtractor.app/Contents/MacOS/CmdExtractor.rb +15 -15
  433. data/install/tools/mac/CmdExtractor.app/Contents/MacOS/main.sh +6 -6
  434. data/install/tools/mac/CmdSender.app/Contents/Info.plist +38 -38
  435. data/install/tools/mac/CmdSender.app/Contents/MacOS/CmdSender.rb +15 -15
  436. data/install/tools/mac/CmdSender.app/Contents/MacOS/main.sh +6 -6
  437. data/install/tools/mac/CmdTlmServer.app/Contents/Info.plist +38 -38
  438. data/install/tools/mac/CmdTlmServer.app/Contents/MacOS/CmdTlmServer.rb +15 -15
  439. data/install/tools/mac/CmdTlmServer.app/Contents/MacOS/main.sh +6 -6
  440. data/install/tools/mac/DataViewer.app/Contents/Info.plist +38 -38
  441. data/install/tools/mac/DataViewer.app/Contents/MacOS/DataViewer.rb +15 -15
  442. data/install/tools/mac/DataViewer.app/Contents/MacOS/main.sh +6 -6
  443. data/install/tools/mac/HandbookCreator.app/Contents/Info.plist +38 -38
  444. data/install/tools/mac/HandbookCreator.app/Contents/MacOS/HandbookCreator.rb +15 -15
  445. data/install/tools/mac/HandbookCreator.app/Contents/MacOS/main.sh +6 -6
  446. data/install/tools/mac/Launcher.app/Contents/Info.plist +38 -38
  447. data/install/tools/mac/Launcher.app/Contents/MacOS/Launcher.rb +15 -15
  448. data/install/tools/mac/Launcher.app/Contents/MacOS/main.sh +6 -6
  449. data/install/tools/mac/LimitsMonitor.app/Contents/Info.plist +38 -38
  450. data/install/tools/mac/LimitsMonitor.app/Contents/MacOS/LimitsMonitor.rb +15 -15
  451. data/install/tools/mac/LimitsMonitor.app/Contents/MacOS/main.sh +6 -6
  452. data/install/tools/mac/OpenGLBuilder.app/Contents/Info.plist +38 -38
  453. data/install/tools/mac/OpenGLBuilder.app/Contents/MacOS/OpenGLBuilder.rb +15 -15
  454. data/install/tools/mac/OpenGLBuilder.app/Contents/MacOS/main.sh +6 -6
  455. data/install/tools/mac/PacketViewer.app/Contents/Info.plist +38 -38
  456. data/install/tools/mac/PacketViewer.app/Contents/MacOS/PacketViewer.rb +15 -15
  457. data/install/tools/mac/PacketViewer.app/Contents/MacOS/main.sh +6 -6
  458. data/install/tools/mac/Replay.app/Contents/Info.plist +38 -38
  459. data/install/tools/mac/Replay.app/Contents/MacOS/Replay.rb +15 -15
  460. data/install/tools/mac/Replay.app/Contents/MacOS/main.sh +6 -6
  461. data/install/tools/mac/ScriptRunner.app/Contents/Info.plist +38 -38
  462. data/install/tools/mac/ScriptRunner.app/Contents/MacOS/ScriptRunner.rb +15 -15
  463. data/install/tools/mac/ScriptRunner.app/Contents/MacOS/main.sh +6 -6
  464. data/install/tools/mac/TableManager.app/Contents/Info.plist +38 -38
  465. data/install/tools/mac/TableManager.app/Contents/MacOS/TableManager.rb +15 -15
  466. data/install/tools/mac/TableManager.app/Contents/MacOS/main.sh +6 -6
  467. data/install/tools/mac/TestRunner.app/Contents/Info.plist +38 -38
  468. data/install/tools/mac/TestRunner.app/Contents/MacOS/TestRunner.rb +15 -15
  469. data/install/tools/mac/TestRunner.app/Contents/MacOS/main.sh +6 -6
  470. data/install/tools/mac/TlmExtractor.app/Contents/Info.plist +38 -38
  471. data/install/tools/mac/TlmExtractor.app/Contents/MacOS/TlmExtractor.rb +15 -15
  472. data/install/tools/mac/TlmExtractor.app/Contents/MacOS/main.sh +6 -6
  473. data/install/tools/mac/TlmGrapher.app/Contents/Info.plist +38 -38
  474. data/install/tools/mac/TlmGrapher.app/Contents/MacOS/TlmGrapher.rb +15 -15
  475. data/install/tools/mac/TlmGrapher.app/Contents/MacOS/main.sh +6 -6
  476. data/install/tools/mac/TlmViewer.app/Contents/Info.plist +38 -38
  477. data/install/tools/mac/TlmViewer.app/Contents/MacOS/TlmViewer.rb +15 -15
  478. data/install/tools/mac/TlmViewer.app/Contents/MacOS/main.sh +6 -6
  479. data/lib/cosmos.rb +63 -63
  480. data/lib/cosmos/ccsds/ccsds_packet.rb +63 -63
  481. data/lib/cosmos/ccsds/ccsds_parser.rb +143 -143
  482. data/lib/cosmos/config/config_parser.rb +324 -324
  483. data/lib/cosmos/conversions.rb +13 -13
  484. data/lib/cosmos/conversions/conversion.rb +47 -47
  485. data/lib/cosmos/conversions/generic_conversion.rb +55 -55
  486. data/lib/cosmos/conversions/new_packet_log_conversion.rb +45 -45
  487. data/lib/cosmos/conversions/polynomial_conversion.rb +57 -57
  488. data/lib/cosmos/conversions/processor_conversion.rb +46 -46
  489. data/lib/cosmos/conversions/received_count_conversion.rb +33 -33
  490. data/lib/cosmos/conversions/received_time_formatted_conversion.rb +37 -37
  491. data/lib/cosmos/conversions/received_time_seconds_conversion.rb +37 -37
  492. data/lib/cosmos/conversions/segmented_polynomial_conversion.rb +128 -128
  493. data/lib/cosmos/conversions/unix_time_conversion.rb +50 -50
  494. data/lib/cosmos/conversions/unix_time_formatted_conversion.rb +44 -44
  495. data/lib/cosmos/conversions/unix_time_seconds_conversion.rb +44 -44
  496. data/lib/cosmos/core_ext.rb +18 -18
  497. data/lib/cosmos/core_ext/array.rb +354 -354
  498. data/lib/cosmos/core_ext/class.rb +51 -51
  499. data/lib/cosmos/core_ext/cosmos_io.rb +29 -29
  500. data/lib/cosmos/core_ext/exception.rb +52 -52
  501. data/lib/cosmos/core_ext/file.rb +75 -75
  502. data/lib/cosmos/core_ext/hash.rb +28 -28
  503. data/lib/cosmos/core_ext/io.rb +75 -75
  504. data/lib/cosmos/core_ext/kernel.rb +38 -38
  505. data/lib/cosmos/core_ext/math.rb +119 -119
  506. data/lib/cosmos/core_ext/matrix.rb +146 -146
  507. data/lib/cosmos/core_ext/objectspace.rb +29 -29
  508. data/lib/cosmos/core_ext/range.rb +22 -22
  509. data/lib/cosmos/core_ext/socket.rb +32 -32
  510. data/lib/cosmos/core_ext/string.rb +310 -310
  511. data/lib/cosmos/core_ext/stringio.rb +24 -24
  512. data/lib/cosmos/core_ext/time.rb +446 -446
  513. data/lib/cosmos/gui/choosers/combobox_chooser.rb +130 -130
  514. data/lib/cosmos/gui/choosers/file_chooser.rb +68 -68
  515. data/lib/cosmos/gui/choosers/float_chooser.rb +82 -82
  516. data/lib/cosmos/gui/choosers/integer_chooser.rb +80 -80
  517. data/lib/cosmos/gui/choosers/string_chooser.rb +53 -53
  518. data/lib/cosmos/gui/choosers/telemetry_chooser.rb +317 -317
  519. data/lib/cosmos/gui/dialogs/about_dialog.rb +128 -128
  520. data/lib/cosmos/gui/dialogs/calendar_dialog.rb +136 -136
  521. data/lib/cosmos/gui/dialogs/cmd_details_dialog.rb +52 -52
  522. data/lib/cosmos/gui/dialogs/cmd_tlm_raw_dialog.rb +149 -149
  523. data/lib/cosmos/gui/dialogs/details_dialog.rb +174 -174
  524. data/lib/cosmos/gui/dialogs/exception_dialog.rb +97 -97
  525. data/lib/cosmos/gui/dialogs/exception_list_dialog.rb +59 -59
  526. data/lib/cosmos/gui/dialogs/find_replace_dialog.rb +196 -196
  527. data/lib/cosmos/gui/dialogs/legal_dialog.rb +169 -168
  528. data/lib/cosmos/gui/dialogs/packet_log_dialog.rb +118 -118
  529. data/lib/cosmos/gui/dialogs/progress_dialog.rb +270 -262
  530. data/lib/cosmos/gui/dialogs/pry_dialog.rb +165 -161
  531. data/lib/cosmos/gui/dialogs/scroll_text_dialog.rb +37 -37
  532. data/lib/cosmos/gui/dialogs/select_dialog.rb +54 -54
  533. data/lib/cosmos/gui/dialogs/set_tlm_dialog.rb +131 -131
  534. data/lib/cosmos/gui/dialogs/splash.rb +113 -113
  535. data/lib/cosmos/gui/dialogs/tlm_details_dialog.rb +206 -206
  536. data/lib/cosmos/gui/dialogs/tlm_edit_dialog.rb +81 -81
  537. data/lib/cosmos/gui/line_graph/line_graph.rb +456 -456
  538. data/lib/cosmos/gui/line_graph/line_graph_dialog.rb +34 -34
  539. data/lib/cosmos/gui/line_graph/line_graph_drawing.rb +494 -494
  540. data/lib/cosmos/gui/line_graph/line_graph_popups.rb +116 -116
  541. data/lib/cosmos/gui/line_graph/line_graph_scaling.rb +460 -460
  542. data/lib/cosmos/gui/line_graph/line_graph_script.rb +26 -26
  543. data/lib/cosmos/gui/line_graph/lines.rb +290 -290
  544. data/lib/cosmos/gui/line_graph/overview_graph.rb +459 -459
  545. data/lib/cosmos/gui/opengl/earth_model.rb +22 -22
  546. data/lib/cosmos/gui/opengl/gl_bounds.rb +67 -67
  547. data/lib/cosmos/gui/opengl/gl_light.rb +39 -39
  548. data/lib/cosmos/gui/opengl/gl_material.rb +29 -29
  549. data/lib/cosmos/gui/opengl/gl_scene.rb +72 -72
  550. data/lib/cosmos/gui/opengl/gl_shape.rb +146 -146
  551. data/lib/cosmos/gui/opengl/gl_viewer.rb +724 -712
  552. data/lib/cosmos/gui/opengl/gl_viewport.rb +35 -35
  553. data/lib/cosmos/gui/opengl/moon_model.rb +22 -22
  554. data/lib/cosmos/gui/opengl/opengl.rb +8 -8
  555. data/lib/cosmos/gui/opengl/stl_reader.rb +211 -211
  556. data/lib/cosmos/gui/opengl/stl_shape.rb +124 -124
  557. data/lib/cosmos/gui/opengl/texture_mapped_sphere.rb +202 -202
  558. data/lib/cosmos/gui/qt.rb +813 -786
  559. data/lib/cosmos/gui/qt_tool.rb +378 -373
  560. data/lib/cosmos/gui/text/completion.rb +381 -381
  561. data/lib/cosmos/gui/text/completion_line_edit.rb +30 -30
  562. data/lib/cosmos/gui/text/completion_text_edit.rb +179 -179
  563. data/lib/cosmos/gui/text/ruby_editor.rb +395 -395
  564. data/lib/cosmos/gui/utilities/screenshot.rb +25 -25
  565. data/lib/cosmos/gui/utilities/script_module_gui.rb +203 -203
  566. data/lib/cosmos/gui/widgets/full_text_search_line_edit.rb +161 -161
  567. data/lib/cosmos/gui/widgets/packet_log_frame.rb +305 -305
  568. data/lib/cosmos/gui/widgets/realtime_button_bar.rb +98 -98
  569. data/lib/cosmos/interfaces.rb +11 -11
  570. data/lib/cosmos/interfaces/cmd_tlm_server_interface.rb +153 -149
  571. data/lib/cosmos/interfaces/interface.rb +213 -213
  572. data/lib/cosmos/interfaces/linc_interface.rb +360 -360
  573. data/lib/cosmos/interfaces/serial_interface.rb +76 -76
  574. data/lib/cosmos/interfaces/simulated_target_interface.rb +129 -128
  575. data/lib/cosmos/interfaces/stream_interface.rb +156 -156
  576. data/lib/cosmos/interfaces/tcpip_client_interface.rb +60 -60
  577. data/lib/cosmos/interfaces/tcpip_server_interface.rb +154 -154
  578. data/lib/cosmos/interfaces/udp_interface.rb +173 -173
  579. data/lib/cosmos/io/buffered_file.rb +11 -11
  580. data/lib/cosmos/io/cosmos_snmp.rb +50 -50
  581. data/lib/cosmos/io/io_multiplexer.rb +89 -89
  582. data/lib/cosmos/io/json_drb.rb +344 -320
  583. data/lib/cosmos/io/json_drb_object.rb +137 -137
  584. data/lib/cosmos/io/json_rpc.rb +365 -365
  585. data/lib/cosmos/io/posix_serial_driver.rb +145 -145
  586. data/lib/cosmos/io/raw_logger.rb +174 -174
  587. data/lib/cosmos/io/raw_logger_pair.rb +71 -71
  588. data/lib/cosmos/io/serial_driver.rb +85 -85
  589. data/lib/cosmos/io/stderr.rb +36 -36
  590. data/lib/cosmos/io/stdout.rb +36 -36
  591. data/lib/cosmos/io/tcpip_server.rb +583 -532
  592. data/lib/cosmos/io/udp_sockets.rb +152 -152
  593. data/lib/cosmos/io/win32_serial_driver.rb +147 -147
  594. data/lib/cosmos/packet_logs.rb +6 -6
  595. data/lib/cosmos/packet_logs/meta_packet_log_writer.rb +107 -107
  596. data/lib/cosmos/packet_logs/packet_log_reader.rb +441 -439
  597. data/lib/cosmos/packet_logs/packet_log_writer.rb +321 -309
  598. data/lib/cosmos/packet_logs/packet_log_writer_pair.rb +30 -30
  599. data/lib/cosmos/packets/binary_accessor.rb +921 -921
  600. data/lib/cosmos/packets/commands.rb +291 -291
  601. data/lib/cosmos/packets/limits.rb +263 -263
  602. data/lib/cosmos/packets/limits_response.rb +38 -38
  603. data/lib/cosmos/packets/packet.rb +714 -699
  604. data/lib/cosmos/packets/packet_config.rb +1034 -1034
  605. data/lib/cosmos/packets/packet_item.rb +317 -317
  606. data/lib/cosmos/packets/packet_item_limits.rb +128 -128
  607. data/lib/cosmos/packets/structure.rb +421 -386
  608. data/lib/cosmos/packets/structure_item.rb +233 -233
  609. data/lib/cosmos/packets/telemetry.rb +317 -317
  610. data/lib/cosmos/processors.rb +6 -6
  611. data/lib/cosmos/processors/new_packet_log_processor.rb +34 -34
  612. data/lib/cosmos/processors/processor.rb +71 -71
  613. data/lib/cosmos/processors/statistics_processor.rb +65 -65
  614. data/lib/cosmos/processors/watermark_processor.rb +44 -44
  615. data/lib/cosmos/script.rb +9 -9
  616. data/lib/cosmos/script/extract.rb +115 -115
  617. data/lib/cosmos/script/script.rb +1513 -1493
  618. data/lib/cosmos/streams/burst_stream_protocol.rb +25 -25
  619. data/lib/cosmos/streams/fixed_stream_protocol.rb +111 -111
  620. data/lib/cosmos/streams/length_stream_protocol.rb +140 -140
  621. data/lib/cosmos/streams/preidentified_stream_protocol.rb +118 -118
  622. data/lib/cosmos/streams/serial_stream.rb +152 -143
  623. data/lib/cosmos/streams/stream.rb +57 -57
  624. data/lib/cosmos/streams/stream_protocol.rb +369 -369
  625. data/lib/cosmos/streams/tcpip_client_stream.rb +77 -77
  626. data/lib/cosmos/streams/tcpip_socket_stream.rb +139 -139
  627. data/lib/cosmos/streams/template_stream_protocol.rb +140 -140
  628. data/lib/cosmos/streams/terminated_stream_protocol.rb +81 -81
  629. data/lib/cosmos/system.rb +4 -4
  630. data/lib/cosmos/system/system.rb +558 -558
  631. data/lib/cosmos/system/target.rb +178 -178
  632. data/lib/cosmos/tools/cmd_extractor/cmd_extractor.rb +254 -253
  633. data/lib/cosmos/tools/cmd_sender/cmd_sender.rb +716 -716
  634. data/lib/cosmos/tools/cmd_sender/cmd_sender_item_delegate.rb +77 -77
  635. data/lib/cosmos/tools/cmd_sender/cmd_sender_text_edit.rb +70 -70
  636. data/lib/cosmos/tools/cmd_tlm_server/api.rb +936 -940
  637. data/lib/cosmos/tools/cmd_tlm_server/background_task.rb +46 -46
  638. data/lib/cosmos/tools/cmd_tlm_server/background_tasks.rb +67 -63
  639. data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server.rb +511 -497
  640. data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_config.rb +241 -241
  641. data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb +1033 -1008
  642. data/lib/cosmos/tools/cmd_tlm_server/commanding.rb +112 -112
  643. data/lib/cosmos/tools/cmd_tlm_server/connections.rb +176 -176
  644. data/lib/cosmos/tools/cmd_tlm_server/interface_thread.rb +241 -221
  645. data/lib/cosmos/tools/cmd_tlm_server/interfaces.rb +127 -127
  646. data/lib/cosmos/tools/cmd_tlm_server/packet_logging.rb +132 -132
  647. data/lib/cosmos/tools/cmd_tlm_server/router_thread.rb +66 -66
  648. data/lib/cosmos/tools/cmd_tlm_server/routers.rb +97 -97
  649. data/lib/cosmos/tools/data_viewer/data_viewer.rb +628 -600
  650. data/lib/cosmos/tools/data_viewer/data_viewer_component.rb +167 -167
  651. data/lib/cosmos/tools/data_viewer/dump_component.rb +40 -40
  652. data/lib/cosmos/tools/handbook_creator/handbook_creator.rb +149 -149
  653. data/lib/cosmos/tools/handbook_creator/handbook_creator_config.rb +360 -360
  654. data/lib/cosmos/tools/launcher/launcher.rb +184 -184
  655. data/lib/cosmos/tools/launcher/launcher_config.rb +175 -167
  656. data/lib/cosmos/tools/launcher/launcher_multitool.rb +40 -41
  657. data/lib/cosmos/tools/launcher/launcher_tool.rb +104 -104
  658. data/lib/cosmos/tools/limits_monitor/limits_monitor.rb +796 -768
  659. data/lib/cosmos/tools/opengl_builder/opengl_builder.rb +416 -416
  660. data/lib/cosmos/tools/opengl_builder/scene_config.rb +118 -118
  661. data/lib/cosmos/tools/packet_viewer/packet_viewer.rb +525 -525
  662. data/lib/cosmos/tools/replay/replay.rb +495 -488
  663. data/lib/cosmos/tools/replay/replay_server.rb +91 -91
  664. data/lib/cosmos/tools/script_runner/script_audit.rb +147 -139
  665. data/lib/cosmos/tools/script_runner/script_runner.rb +914 -914
  666. data/lib/cosmos/tools/script_runner/script_runner_config.rb +40 -40
  667. data/lib/cosmos/tools/script_runner/script_runner_frame.rb +1892 -1859
  668. data/lib/cosmos/tools/table_manager/table.rb +70 -70
  669. data/lib/cosmos/tools/table_manager/table_config.rb +764 -764
  670. data/lib/cosmos/tools/table_manager/table_item.rb +74 -74
  671. data/lib/cosmos/tools/table_manager/table_manager.rb +1065 -1065
  672. data/lib/cosmos/tools/table_manager/table_manager_core.rb +539 -539
  673. data/lib/cosmos/tools/test_runner/results_writer.rb +283 -283
  674. data/lib/cosmos/tools/test_runner/test.rb +480 -480
  675. data/lib/cosmos/tools/test_runner/test_runner.rb +1157 -1157
  676. data/lib/cosmos/tools/test_runner/test_runner_chooser.rb +338 -338
  677. data/lib/cosmos/tools/tlm_extractor/text_item_chooser.rb +60 -60
  678. data/lib/cosmos/tools/tlm_extractor/tlm_extractor.rb +1008 -1008
  679. data/lib/cosmos/tools/tlm_extractor/tlm_extractor_config.rb +371 -371
  680. data/lib/cosmos/tools/tlm_extractor/tlm_extractor_processor.rb +60 -60
  681. data/lib/cosmos/tools/tlm_grapher/data_object_adders/housekeeping_data_object_adder.rb +75 -75
  682. data/lib/cosmos/tools/tlm_grapher/data_object_adders/singlexy_data_object_adder.rb +44 -44
  683. data/lib/cosmos/tools/tlm_grapher/data_object_adders/xy_data_object_adder.rb +94 -94
  684. data/lib/cosmos/tools/tlm_grapher/data_object_editors/data_object_editor.rb +61 -61
  685. data/lib/cosmos/tools/tlm_grapher/data_object_editors/housekeeping_data_object_editor.rb +180 -180
  686. data/lib/cosmos/tools/tlm_grapher/data_object_editors/linegraph_data_object_editor.rb +141 -141
  687. data/lib/cosmos/tools/tlm_grapher/data_object_editors/singlexy_data_object_editor.rb +30 -30
  688. data/lib/cosmos/tools/tlm_grapher/data_object_editors/xy_data_object_editor.rb +173 -173
  689. data/lib/cosmos/tools/tlm_grapher/data_objects/data_object.rb +177 -177
  690. data/lib/cosmos/tools/tlm_grapher/data_objects/housekeeping_data_object.rb +412 -409
  691. data/lib/cosmos/tools/tlm_grapher/data_objects/linegraph_data_object.rb +176 -176
  692. data/lib/cosmos/tools/tlm_grapher/data_objects/singlexy_data_object.rb +25 -25
  693. data/lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb +323 -320
  694. data/lib/cosmos/tools/tlm_grapher/plot_editors/linegraph_plot_editor.rb +181 -181
  695. data/lib/cosmos/tools/tlm_grapher/plot_editors/plot_editor.rb +28 -28
  696. data/lib/cosmos/tools/tlm_grapher/plot_editors/singlexy_plot_editor.rb +30 -30
  697. data/lib/cosmos/tools/tlm_grapher/plot_editors/xy_plot_editor.rb +59 -59
  698. data/lib/cosmos/tools/tlm_grapher/plot_gui_objects/linegraph_plot_gui_object.rb +172 -172
  699. data/lib/cosmos/tools/tlm_grapher/plot_gui_objects/singlexy_plot_gui_object.rb +27 -27
  700. data/lib/cosmos/tools/tlm_grapher/plot_gui_objects/xy_plot_gui_object.rb +74 -74
  701. data/lib/cosmos/tools/tlm_grapher/plots/linegraph_plot.rb +201 -201
  702. data/lib/cosmos/tools/tlm_grapher/plots/plot.rb +69 -69
  703. data/lib/cosmos/tools/tlm_grapher/plots/singlexy_plot.rb +20 -20
  704. data/lib/cosmos/tools/tlm_grapher/plots/xy_plot.rb +61 -61
  705. data/lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb +1278 -1278
  706. data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_config.rb +430 -430
  707. data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_data_object_editor.rb +107 -107
  708. data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_logfile_thread.rb +111 -95
  709. data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_plot_editor.rb +101 -101
  710. data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_realtime_thread.rb +72 -66
  711. data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_tab.rb +57 -57
  712. data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_tool.rb +1004 -1004
  713. data/lib/cosmos/tools/tlm_grapher/tlm_grapher.rb +87 -87
  714. data/lib/cosmos/tools/tlm_viewer/screen.rb +486 -458
  715. data/lib/cosmos/tools/tlm_viewer/tlm_viewer.rb +563 -544
  716. data/lib/cosmos/tools/tlm_viewer/tlm_viewer_config.rb +287 -287
  717. data/lib/cosmos/tools/tlm_viewer/widgets.rb +53 -53
  718. data/lib/cosmos/tools/tlm_viewer/widgets/aging_widget.rb +110 -110
  719. data/lib/cosmos/tools/tlm_viewer/widgets/array_widget.rb +70 -70
  720. data/lib/cosmos/tools/tlm_viewer/widgets/block_widget.rb +61 -61
  721. data/lib/cosmos/tools/tlm_viewer/widgets/button_widget.rb +39 -39
  722. data/lib/cosmos/tools/tlm_viewer/widgets/canvas_widget.rb +62 -62
  723. data/lib/cosmos/tools/tlm_viewer/widgets/canvasimage_widget.rb +41 -41
  724. data/lib/cosmos/tools/tlm_viewer/widgets/canvasimagevalue_widget.rb +57 -57
  725. data/lib/cosmos/tools/tlm_viewer/widgets/canvaslabel_widget.rb +37 -37
  726. data/lib/cosmos/tools/tlm_viewer/widgets/canvaslabelvalue_widget.rb +56 -56
  727. data/lib/cosmos/tools/tlm_viewer/widgets/canvasline_widget.rb +55 -55
  728. data/lib/cosmos/tools/tlm_viewer/widgets/canvaslinevalue_widget.rb +66 -66
  729. data/lib/cosmos/tools/tlm_viewer/widgets/canvasvalue_widget.rb +124 -124
  730. data/lib/cosmos/tools/tlm_viewer/widgets/checkbutton_widget.rb +31 -31
  731. data/lib/cosmos/tools/tlm_viewer/widgets/combobox_widget.rb +30 -30
  732. data/lib/cosmos/tools/tlm_viewer/widgets/formatfontvalue_widget.rb +36 -36
  733. data/lib/cosmos/tools/tlm_viewer/widgets/formatvalue_widget.rb +35 -35
  734. data/lib/cosmos/tools/tlm_viewer/widgets/horizontal_widget.rb +27 -27
  735. data/lib/cosmos/tools/tlm_viewer/widgets/horizontalbox_widget.rb +31 -31
  736. data/lib/cosmos/tools/tlm_viewer/widgets/horizontalline_widget.rb +26 -26
  737. data/lib/cosmos/tools/tlm_viewer/widgets/label_widget.rb +29 -29
  738. data/lib/cosmos/tools/tlm_viewer/widgets/labelformatvalue_widget.rb +39 -39
  739. data/lib/cosmos/tools/tlm_viewer/widgets/labelprogressbar_widget.rb +38 -38
  740. data/lib/cosmos/tools/tlm_viewer/widgets/labeltrendlimitsbar_widget.rb +38 -38
  741. data/lib/cosmos/tools/tlm_viewer/widgets/labelvalue_widget.rb +39 -39
  742. data/lib/cosmos/tools/tlm_viewer/widgets/labelvaluedesc_widget.rb +42 -42
  743. data/lib/cosmos/tools/tlm_viewer/widgets/labelvaluelimitsbar_widget.rb +37 -37
  744. data/lib/cosmos/tools/tlm_viewer/widgets/labelvaluerangebar_widget.rb +37 -37
  745. data/lib/cosmos/tools/tlm_viewer/widgets/layout_widget.rb +34 -34
  746. data/lib/cosmos/tools/tlm_viewer/widgets/limitsbar_widget.rb +178 -178
  747. data/lib/cosmos/tools/tlm_viewer/widgets/linegraph_widget.rb +54 -54
  748. data/lib/cosmos/tools/tlm_viewer/widgets/matrixbycolumns_widget.rb +47 -47
  749. data/lib/cosmos/tools/tlm_viewer/widgets/multi_widget.rb +116 -116
  750. data/lib/cosmos/tools/tlm_viewer/widgets/progressbar_widget.rb +34 -34
  751. data/lib/cosmos/tools/tlm_viewer/widgets/radiobutton_widget.rb +30 -30
  752. data/lib/cosmos/tools/tlm_viewer/widgets/rangebar_widget.rb +57 -57
  753. data/lib/cosmos/tools/tlm_viewer/widgets/screenshotbutton_widget.rb +34 -34
  754. data/lib/cosmos/tools/tlm_viewer/widgets/scrollwindow_widget.rb +35 -35
  755. data/lib/cosmos/tools/tlm_viewer/widgets/sectionheader_widget.rb +33 -33
  756. data/lib/cosmos/tools/tlm_viewer/widgets/tabbook_widget.rb +26 -26
  757. data/lib/cosmos/tools/tlm_viewer/widgets/tabitem_widget.rb +28 -28
  758. data/lib/cosmos/tools/tlm_viewer/widgets/textbox_widget.rb +47 -47
  759. data/lib/cosmos/tools/tlm_viewer/widgets/textfield_widget.rb +26 -26
  760. data/lib/cosmos/tools/tlm_viewer/widgets/timegraph_widget.rb +88 -88
  761. data/lib/cosmos/tools/tlm_viewer/widgets/title_widget.rb +27 -27
  762. data/lib/cosmos/tools/tlm_viewer/widgets/trendbar_widget.rb +130 -130
  763. data/lib/cosmos/tools/tlm_viewer/widgets/trendlimitsbar_widget.rb +46 -46
  764. data/lib/cosmos/tools/tlm_viewer/widgets/value_widget.rb +43 -43
  765. data/lib/cosmos/tools/tlm_viewer/widgets/valuelimitsbar_widget.rb +37 -37
  766. data/lib/cosmos/tools/tlm_viewer/widgets/valuerangebar_widget.rb +37 -37
  767. data/lib/cosmos/tools/tlm_viewer/widgets/vertical_widget.rb +35 -35
  768. data/lib/cosmos/tools/tlm_viewer/widgets/verticalbox_widget.rb +37 -37
  769. data/lib/cosmos/tools/tlm_viewer/widgets/widget.rb +257 -257
  770. data/lib/cosmos/top_level.rb +647 -596
  771. data/lib/cosmos/utilities.rb +11 -10
  772. data/lib/cosmos/utilities/crc.rb +166 -166
  773. data/lib/cosmos/utilities/csv.rb +83 -83
  774. data/lib/cosmos/utilities/logger.rb +137 -137
  775. data/lib/cosmos/utilities/low_fragmentation_array.rb +11 -11
  776. data/lib/cosmos/utilities/message_log.rb +74 -74
  777. data/lib/cosmos/utilities/quaternion.rb +258 -258
  778. data/lib/cosmos/utilities/ruby_lex_utils.rb +313 -313
  779. data/lib/cosmos/utilities/simulated_target.rb +99 -99
  780. data/lib/cosmos/utilities/sleeper.rb +44 -0
  781. data/lib/cosmos/version.rb +12 -12
  782. data/lib/cosmos/win32/excel.rb +66 -66
  783. data/lib/cosmos/win32/win32.rb +387 -387
  784. data/lib/cosmos/win32/win32_main.rb +311 -311
  785. data/roodi.yml +24 -24
  786. data/run_gui_tests.bat +32 -32
  787. data/spec/ccsds/ccsds_packet_spec.rb +67 -67
  788. data/spec/ccsds/ccsds_parser_spec.rb +148 -148
  789. data/spec/config/config_parser_spec.rb +322 -322
  790. data/spec/conversions/conversion_spec.rb +31 -31
  791. data/spec/conversions/generic_conversion_spec.rb +45 -45
  792. data/spec/conversions/new_packet_log_conversion_spec.rb +39 -39
  793. data/spec/conversions/polynomial_conversion_spec.rb +40 -40
  794. data/spec/conversions/processor_conversion_spec.rb +45 -45
  795. data/spec/conversions/received_count_conversion_spec.rb +43 -43
  796. data/spec/conversions/received_time_formatted_conversion_spec.rb +49 -49
  797. data/spec/conversions/received_time_seconds_conversion_spec.rb +50 -50
  798. data/spec/conversions/segmented_polynomial_conversion_spec.rb +51 -51
  799. data/spec/conversions/unix_time_formatted_conversion_spec.rb +74 -74
  800. data/spec/conversions/unix_time_seconds_conversion_spec.rb +76 -76
  801. data/spec/core_ext/array_spec.rb +186 -186
  802. data/spec/core_ext/class_spec.rb +36 -36
  803. data/spec/core_ext/cosmos_io_spec.rb +77 -77
  804. data/spec/core_ext/exception_spec.rb +91 -91
  805. data/spec/core_ext/file_spec.rb +72 -72
  806. data/spec/core_ext/hash_spec.rb +24 -24
  807. data/spec/core_ext/io_spec.rb +46 -46
  808. data/spec/core_ext/kernel_spec.rb +54 -54
  809. data/spec/core_ext/math_spec.rb +116 -116
  810. data/spec/core_ext/matrix_spec.rb +66 -66
  811. data/spec/core_ext/objectspace_spec.rb +29 -29
  812. data/spec/core_ext/range_spec.rb +21 -21
  813. data/spec/core_ext/socket_spec.rb +32 -32
  814. data/spec/core_ext/string_spec.rb +223 -223
  815. data/spec/core_ext/stringio_spec.rb +21 -21
  816. data/spec/core_ext/time_spec.rb +151 -151
  817. data/spec/gui/line_graph/line_clip_spec.rb +322 -322
  818. data/spec/install/config/system/system.txt +33 -33
  819. data/spec/install/config/targets/COSMOS/cmd_tlm/cosmos_server_cmds.txt +41 -41
  820. data/spec/install/config/targets/COSMOS/cmd_tlm/cosmos_server_tlm.txt +15 -15
  821. data/spec/install/config/targets/COSMOS/cmd_tlm_server.txt +6 -6
  822. data/spec/install/config/targets/COSMOS/screens/limits_change.txt +20 -20
  823. data/spec/install/config/targets/COSMOS/screens/version.txt +19 -19
  824. data/spec/install/config/targets/COSMOS/target.txt +5 -5
  825. data/spec/install/config/targets/INST/cmd_tlm/inst_cmd_linc.txt +30 -30
  826. data/spec/install/config/targets/INST/cmd_tlm/inst_cmds.txt +111 -111
  827. data/spec/install/config/targets/INST/cmd_tlm/inst_tlm.txt +236 -236
  828. data/spec/install/config/targets/INST/cmd_tlm/inst_tlm_linc.txt +25 -25
  829. data/spec/install/config/targets/INST/cmd_tlm_server.txt +5 -5
  830. data/spec/install/config/targets/INST/lib/sim_inst.rb +305 -294
  831. data/spec/install/config/targets/INST/target.txt +10 -10
  832. data/spec/install/config/targets/META/cmd_tlm/meta_cmd.txt +4 -4
  833. data/spec/install/config/targets/META/cmd_tlm/meta_tlm.txt +4 -4
  834. data/spec/install/config/targets/SYSTEM/cmd_tlm/limits_groups.txt +7 -7
  835. data/spec/interfaces/cmd_tlm_server_interface_spec.rb +150 -150
  836. data/spec/interfaces/interface_spec.rb +130 -131
  837. data/spec/interfaces/linc_interface_spec.rb +199 -199
  838. data/spec/interfaces/serial_interface_spec.rb +56 -56
  839. data/spec/interfaces/simulated_target_interface_spec.rb +128 -128
  840. data/spec/interfaces/stream_interface_spec.rb +157 -157
  841. data/spec/interfaces/tcpip_client_interface_spec.rb +54 -54
  842. data/spec/interfaces/tcpip_server_interface_spec.rb +151 -151
  843. data/spec/interfaces/udp_interface_spec.rb +175 -177
  844. data/spec/io/buffered_file_spec.rb +113 -113
  845. data/spec/io/io_multiplexer_spec.rb +94 -94
  846. data/spec/io/json_drb_object_spec.rb +99 -99
  847. data/spec/io/json_drb_spec.rb +311 -311
  848. data/spec/io/json_rpc_spec.rb +264 -264
  849. data/spec/io/raw_logger_pair_spec.rb +76 -76
  850. data/spec/io/raw_logger_spec.rb +133 -133
  851. data/spec/io/serial_driver_spec.rb +61 -61
  852. data/spec/io/stderr_spec.rb +32 -32
  853. data/spec/io/stdout_spec.rb +32 -32
  854. data/spec/io/tcpip_server_spec.rb +338 -338
  855. data/spec/io/udp_sockets_spec.rb +94 -94
  856. data/spec/io/win32_serial_driver_spec.rb +88 -88
  857. data/spec/packet_logs/meta_packet_log_writer_spec.rb +170 -170
  858. data/spec/packet_logs/packet_log_reader_spec.rb +408 -408
  859. data/spec/packet_logs/packet_log_writer_pair_spec.rb +30 -30
  860. data/spec/packet_logs/packet_log_writer_spec.rb +223 -223
  861. data/spec/packets/binary_accessor_spec.rb +2073 -2073
  862. data/spec/packets/commands_spec.rb +369 -369
  863. data/spec/packets/limits_response_spec.rb +25 -25
  864. data/spec/packets/limits_spec.rb +326 -326
  865. data/spec/packets/packet_config_spec.rb +1620 -1620
  866. data/spec/packets/packet_item_limits_spec.rb +161 -161
  867. data/spec/packets/packet_item_spec.rb +386 -386
  868. data/spec/packets/packet_spec.rb +1057 -949
  869. data/spec/packets/structure_item_spec.rb +195 -195
  870. data/spec/packets/structure_spec.rb +419 -419
  871. data/spec/packets/telemetry_spec.rb +535 -535
  872. data/spec/processors/new_packet_log_processor_spec.rb +39 -39
  873. data/spec/processors/processor_spec.rb +55 -55
  874. data/spec/processors/statistics_processor_spec.rb +60 -60
  875. data/spec/processors/watermark_processor_spec.rb +51 -51
  876. data/spec/script/script_spec.rb +654 -654
  877. data/spec/spec_helper.rb +154 -148
  878. data/spec/streams/burst_stream_protocol_spec.rb +32 -32
  879. data/spec/streams/fixed_stream_protocol_spec.rb +110 -110
  880. data/spec/streams/length_stream_protocol_spec.rb +297 -297
  881. data/spec/streams/preidentified_stream_protocol_spec.rb +118 -118
  882. data/spec/streams/serial_stream_spec.rb +105 -105
  883. data/spec/streams/stream_protocol_spec.rb +332 -332
  884. data/spec/streams/stream_spec.rb +29 -29
  885. data/spec/streams/tcpip_client_stream_spec.rb +54 -54
  886. data/spec/streams/tcpip_socket_stream_spec.rb +146 -146
  887. data/spec/streams/template_stream_protocol_spec.rb +151 -151
  888. data/spec/streams/terminated_stream_protocol_spec.rb +123 -123
  889. data/spec/system/system_spec.rb +645 -645
  890. data/spec/system/target_spec.rb +248 -248
  891. data/spec/tools/cmd_tlm_server/api_spec.rb +1087 -1113
  892. data/spec/tools/cmd_tlm_server/background_task_spec.rb +32 -32
  893. data/spec/tools/cmd_tlm_server/background_tasks_spec.rb +81 -81
  894. data/spec/tools/cmd_tlm_server/cmd_tlm_server_config_spec.rb +411 -411
  895. data/spec/tools/cmd_tlm_server/cmd_tlm_server_spec.rb +415 -415
  896. data/spec/tools/cmd_tlm_server/commanding_spec.rb +123 -123
  897. data/spec/tools/cmd_tlm_server/connections_spec.rb +147 -147
  898. data/spec/tools/cmd_tlm_server/interface_thread_spec.rb +306 -306
  899. data/spec/tools/cmd_tlm_server/interfaces_spec.rb +252 -238
  900. data/spec/tools/cmd_tlm_server/packet_logging_spec.rb +143 -143
  901. data/spec/tools/cmd_tlm_server/router_thread_spec.rb +98 -101
  902. data/spec/tools/cmd_tlm_server/routers_spec.rb +223 -208
  903. data/spec/top_level/top_level_spec.rb +334 -321
  904. data/spec/utilities/crc_spec.rb +45 -45
  905. data/spec/utilities/csv_spec.rb +97 -97
  906. data/spec/utilities/logger_spec.rb +102 -102
  907. data/spec/utilities/message_log_spec.rb +89 -89
  908. data/spec/utilities/quaternion_spec.rb +107 -107
  909. data/spec/utilities/ruby_lex_utils_spec.rb +86 -86
  910. data/tasks/manifest.rake +22 -22
  911. data/tasks/spec.rake +23 -23
  912. metadata +18 -2
@@ -1,115 +1,115 @@
1
- # encoding: ascii-8bit
2
-
3
- # Copyright 2014 Ball Aerospace & Technologies Corp.
4
- # All Rights Reserved.
5
- #
6
- # This program is free software; you can modify and/or redistribute it
7
- # under the terms of the GNU General Public License
8
- # as published by the Free Software Foundation; version 3 with
9
- # attribution addendums as found in the LICENSE.txt
10
-
11
- module Cosmos
12
-
13
- module Extract
14
- SCANNING_REGULAR_EXPRESSION = %r{ (?:"(?:[^\\"]|\\.)*") | (?:'(?:[^\\']|\\.)*') | (?:\[.*\]) | \S+ }x #"
15
-
16
- private
17
-
18
- def add_cmd_parameter(keyword, value, cmd_params)
19
- quotes_removed = value.remove_quotes
20
- if value == quotes_removed
21
- cmd_params[keyword] = value.convert_to_value
22
- else
23
- cmd_params[keyword] = quotes_removed
24
- end
25
- end
26
-
27
- def extract_fields_from_cmd_text(text)
28
- split_string = text.split(/\s*with\s*/i, 2)
29
- raise "ERROR: 'with' must be followed by parameters : #{text}" if split_string.length == 1 and text =~ /\s*with\s*/i
30
-
31
- # Extract target_name and cmd_name
32
- first_half = split_string[0].split
33
- raise "ERROR: Both Target Name and Command Name must be given : #{text}" if first_half.length < 2
34
- raise "ERROR: Only Target Name and Command Name must be given before 'with' : #{text}" if first_half.length > 2
35
- target_name = first_half[0]
36
- cmd_name = first_half[1]
37
- cmd_params = {}
38
-
39
- if split_string.length == 2
40
- # Extract Command Parameters
41
- second_half = split_string[1].scan(SCANNING_REGULAR_EXPRESSION)
42
- keyword = nil
43
- value = nil
44
- comma = nil
45
- second_half.each do |item|
46
- unless keyword
47
- keyword = item
48
- next
49
- end
50
- unless value
51
- if item[-1..-1] == ','
52
- value = item[0..-2]
53
- comma = true
54
- else
55
- value = item
56
- next
57
- end
58
- end
59
- unless comma
60
- raise "Missing comma in command parameters: #{text}" if item != ','
61
- end
62
- add_cmd_parameter(keyword, value, cmd_params)
63
- keyword = nil
64
- value = nil
65
- comma = nil
66
- end
67
- if keyword
68
- if value
69
- add_cmd_parameter(keyword, value, cmd_params)
70
- else
71
- raise "Missing value for last command parameter: #{text}"
72
- end
73
- end
74
- end
75
-
76
- return [target_name, cmd_name, cmd_params]
77
- end
78
-
79
- def extract_fields_from_tlm_text (text)
80
- split_string = text.split
81
- raise "ERROR: Telemetry Item must be specified as 'TargetName PacketName ItemName' : #{text}" if split_string.length != 3
82
- target_name = split_string[0]
83
- packet_name = split_string[1]
84
- item_name = split_string[2]
85
- return [target_name, packet_name, item_name]
86
- end
87
-
88
- def extract_fields_from_set_tlm_text(text)
89
- split_string = text.split
90
- raise "ERROR: Set Telemetry Item must be specified as 'TargetName PacketName ItemName = Value' : #{text}" if split_string.length != 5
91
- target_name = split_string[0]
92
- packet_name = split_string[1]
93
- item_name = split_string[2]
94
- value = split_string[4].convert_to_value
95
- value = value.remove_quotes if String === value
96
- return [target_name, packet_name, item_name, value]
97
- end
98
-
99
- def extract_fields_from_check_text (text)
100
- split_string = text.split
101
- raise "ERROR: Check improperly specified: #{text}" if split_string.length < 3
102
- target_name = split_string[0]
103
- packet_name = split_string[1]
104
- item_name = split_string[2]
105
- comparison_to_eval = nil
106
- return [target_name, packet_name, item_name, comparison_to_eval] if split_string.length == 3
107
- raise "ERROR: Check improperly specified: #{text}" if split_string.length < 4
108
- comparison_to_eval = split_string[3..(split_string.length - 1)].join(" ")
109
- raise "ERROR: Use '==' instead of '=': #{text}" if split_string[3] == '='
110
- return [target_name, packet_name, item_name, comparison_to_eval]
111
- end
112
-
113
- end # module Extract
114
-
115
- end # module Cosmos
1
+ # encoding: ascii-8bit
2
+
3
+ # Copyright 2014 Ball Aerospace & Technologies Corp.
4
+ # All Rights Reserved.
5
+ #
6
+ # This program is free software; you can modify and/or redistribute it
7
+ # under the terms of the GNU General Public License
8
+ # as published by the Free Software Foundation; version 3 with
9
+ # attribution addendums as found in the LICENSE.txt
10
+
11
+ module Cosmos
12
+
13
+ module Extract
14
+ SCANNING_REGULAR_EXPRESSION = %r{ (?:"(?:[^\\"]|\\.)*") | (?:'(?:[^\\']|\\.)*') | (?:\[.*\]) | \S+ }x #"
15
+
16
+ private
17
+
18
+ def add_cmd_parameter(keyword, value, cmd_params)
19
+ quotes_removed = value.remove_quotes
20
+ if value == quotes_removed
21
+ cmd_params[keyword] = value.convert_to_value
22
+ else
23
+ cmd_params[keyword] = quotes_removed
24
+ end
25
+ end
26
+
27
+ def extract_fields_from_cmd_text(text)
28
+ split_string = text.split(/\s*with\s*/i, 2)
29
+ raise "ERROR: 'with' must be followed by parameters : #{text}" if split_string.length == 1 and text =~ /\s*with\s*/i
30
+
31
+ # Extract target_name and cmd_name
32
+ first_half = split_string[0].split
33
+ raise "ERROR: Both Target Name and Command Name must be given : #{text}" if first_half.length < 2
34
+ raise "ERROR: Only Target Name and Command Name must be given before 'with' : #{text}" if first_half.length > 2
35
+ target_name = first_half[0]
36
+ cmd_name = first_half[1]
37
+ cmd_params = {}
38
+
39
+ if split_string.length == 2
40
+ # Extract Command Parameters
41
+ second_half = split_string[1].scan(SCANNING_REGULAR_EXPRESSION)
42
+ keyword = nil
43
+ value = nil
44
+ comma = nil
45
+ second_half.each do |item|
46
+ unless keyword
47
+ keyword = item
48
+ next
49
+ end
50
+ unless value
51
+ if item[-1..-1] == ','
52
+ value = item[0..-2]
53
+ comma = true
54
+ else
55
+ value = item
56
+ next
57
+ end
58
+ end
59
+ unless comma
60
+ raise "Missing comma in command parameters: #{text}" if item != ','
61
+ end
62
+ add_cmd_parameter(keyword, value, cmd_params)
63
+ keyword = nil
64
+ value = nil
65
+ comma = nil
66
+ end
67
+ if keyword
68
+ if value
69
+ add_cmd_parameter(keyword, value, cmd_params)
70
+ else
71
+ raise "Missing value for last command parameter: #{text}"
72
+ end
73
+ end
74
+ end
75
+
76
+ return [target_name, cmd_name, cmd_params]
77
+ end
78
+
79
+ def extract_fields_from_tlm_text (text)
80
+ split_string = text.split
81
+ raise "ERROR: Telemetry Item must be specified as 'TargetName PacketName ItemName' : #{text}" if split_string.length != 3
82
+ target_name = split_string[0]
83
+ packet_name = split_string[1]
84
+ item_name = split_string[2]
85
+ return [target_name, packet_name, item_name]
86
+ end
87
+
88
+ def extract_fields_from_set_tlm_text(text)
89
+ split_string = text.split
90
+ raise "ERROR: Set Telemetry Item must be specified as 'TargetName PacketName ItemName = Value' : #{text}" if split_string.length != 5
91
+ target_name = split_string[0]
92
+ packet_name = split_string[1]
93
+ item_name = split_string[2]
94
+ value = split_string[4].convert_to_value
95
+ value = value.remove_quotes if String === value
96
+ return [target_name, packet_name, item_name, value]
97
+ end
98
+
99
+ def extract_fields_from_check_text (text)
100
+ split_string = text.split
101
+ raise "ERROR: Check improperly specified: #{text}" if split_string.length < 3
102
+ target_name = split_string[0]
103
+ packet_name = split_string[1]
104
+ item_name = split_string[2]
105
+ comparison_to_eval = nil
106
+ return [target_name, packet_name, item_name, comparison_to_eval] if split_string.length == 3
107
+ raise "ERROR: Check improperly specified: #{text}" if split_string.length < 4
108
+ comparison_to_eval = split_string[3..(split_string.length - 1)].join(" ")
109
+ raise "ERROR: Use '==' instead of '=': #{text}" if split_string[3] == '='
110
+ return [target_name, packet_name, item_name, comparison_to_eval]
111
+ end
112
+
113
+ end # module Extract
114
+
115
+ end # module Cosmos
@@ -1,1493 +1,1513 @@
1
- # encoding: ascii-8bit
2
-
3
- # Copyright 2014 Ball Aerospace & Technologies Corp.
4
- # All Rights Reserved.
5
- #
6
- # This program is free software; you can modify and/or redistribute it
7
- # under the terms of the GNU General Public License
8
- # as published by the Free Software Foundation; version 3 with
9
- # attribution addendums as found in the LICENSE.txt
10
-
11
- require 'cosmos'
12
- require 'cosmos/io/json_drb_object'
13
- require 'cosmos/tools/cmd_tlm_server/cmd_tlm_server'
14
- require 'cosmos/script/extract'
15
-
16
- $cmd_tlm_server = nil
17
- $cmd_tlm_disconnect = false
18
-
19
- module Cosmos
20
- class CheckError < RuntimeError; end
21
- class StopScript < StandardError; end
22
- class SkipTestCase < StandardError; end
23
-
24
- module Script
25
- DEFAULT_TLM_POLLING_RATE = 0.25
26
-
27
- private
28
-
29
- include Extract
30
-
31
- #######################################
32
- # Methods accessing cmd_tlm_server
33
- #######################################
34
-
35
- #
36
- # Methods involving commands
37
- #
38
-
39
- # Send a command to the specified target
40
- # Supports two signatures:
41
- # cmd(target_name, cmd_name, cmd_params = {})
42
- # or
43
- # cmd('target_name cmd_name with cmd_param1 value1, cmd_param2 value2')
44
- def cmd(*args)
45
- begin
46
- target_name, cmd_name, cmd_params = $cmd_tlm_server.cmd(*args)
47
- Logger.info build_cmd_output_string(target_name, cmd_name, cmd_params)
48
- rescue HazardousError => e
49
- ok_to_proceed = prompt_for_hazardous(e.target_name,
50
- e.cmd_name,
51
- e.hazardous_description)
52
- if ok_to_proceed
53
- target_name, cmd_name, cmd_params =
54
- $cmd_tlm_server.cmd_no_hazardous_check(*args)
55
- Logger.info build_cmd_output_string(target_name, cmd_name, cmd_params)
56
- else
57
- Logger.warn "Hazardous command not sent"
58
- prompt_for_script_abort
59
- end
60
- end
61
- end
62
-
63
- # Send a command to the specified target without range checking parameters
64
- # Supports two signatures:
65
- # cmd_no_range_check(target_name, cmd_name, cmd_params = {})
66
- # or
67
- # cmd_no_range_check('target_name cmd_name with cmd_param1 value1, cmd_param2 value2')
68
- def cmd_no_range_check(*args)
69
- begin
70
- target_name, cmd_name, cmd_params = $cmd_tlm_server.cmd_no_range_check(*args)
71
- Logger.warn "Command #{target_name} #{cmd_name} being sent ignoring range checks"
72
- Logger.info build_cmd_output_string(target_name, cmd_name, cmd_params)
73
- rescue HazardousError => e
74
- ok_to_proceed = prompt_for_hazardous(e.target_name,
75
- e.cmd_name,
76
- e.hazardous_description)
77
- if ok_to_proceed
78
- target_name, cmd_name, cmd_params = $cmd_tlm_server.cmd_no_checks(*args)
79
- Logger.warn "Command #{target_name} #{cmd_name} being sent ignoring range checks"
80
- Logger.info build_cmd_output_string(target_name, cmd_name, cmd_params)
81
- else
82
- Logger.warn "Hazardous command not sent"
83
- prompt_for_script_abort
84
- end
85
- end
86
- end
87
-
88
- # Send a command to the specified target without hazardous checks
89
- # Supports two signatures:
90
- # cmd_no_hazardous_check(target_name, cmd_name, cmd_params = {})
91
- # or
92
- # cmd_no_hazardous_check('target_name cmd_name with cmd_param1 value1, cmd_param2 value2')
93
- def cmd_no_hazardous_check(*args)
94
- target_name, cmd_name, cmd_params = $cmd_tlm_server.cmd_no_hazardous_check(*args)
95
- Logger.warn "Command #{target_name} #{cmd_name} being sent ignoring hazardous warnings"
96
- Logger.info build_cmd_output_string(target_name, cmd_name, cmd_params)
97
- end
98
-
99
- # Send a command to the specified target without range checking or hazardous checks
100
- # Supports two signatures:
101
- # cmd_no_checks(target_name, cmd_name, cmd_params = {})
102
- # or
103
- # cmd_no_checks('target_name cmd_name with cmd_param1 value1, cmd_param2 value2')
104
- def cmd_no_checks(*args)
105
- target_name, cmd_name, cmd_params = $cmd_tlm_server.cmd_no_checks(*args)
106
- Logger.warn "Command #{target_name} #{cmd_name} being sent ignoring range checks"
107
- Logger.warn "Command #{target_name} #{cmd_name} being sent ignoring hazardous warnings"
108
- Logger.info build_cmd_output_string(target_name, cmd_name, cmd_params)
109
- end
110
-
111
- # Send a command to the specified target without running conversions
112
- # Supports two signatures:
113
- # cmd_raw(target_name, cmd_name, cmd_params = {})
114
- # or
115
- # cmd_raw('target_name cmd_name with cmd_param1 value1, cmd_param2 value2')
116
- def cmd_raw(*args)
117
- begin
118
- target_name, cmd_name, cmd_params = $cmd_tlm_server.cmd_raw(*args)
119
- Logger.info build_cmd_output_string(target_name, cmd_name, cmd_params, true)
120
- rescue HazardousError => e
121
- ok_to_proceed = prompt_for_hazardous(e.target_name,
122
- e.cmd_name,
123
- e.hazardous_description)
124
- if ok_to_proceed
125
- target_name, cmd_name, cmd_params =
126
- $cmd_tlm_server.cmd_raw_no_hazardous_check(*args)
127
- Logger.info build_cmd_output_string(target_name, cmd_name, cmd_params, true)
128
- else
129
- Logger.warn "Hazardous command not sent"
130
- prompt_for_script_abort
131
- end
132
- end
133
- end
134
-
135
- # Send a command to the specified target without range checking parameters or running conversions
136
- # Supports two signatures:
137
- # cmd_raw_no_range_check(target_name, cmd_name, cmd_params = {})
138
- # or
139
- # cmd_raw_no_range_check('target_name cmd_name with cmd_param1 value1, cmd_param2 value2')
140
- def cmd_raw_no_range_check(*args)
141
- begin
142
- target_name, cmd_name, cmd_params = $cmd_tlm_server.cmd_raw_no_range_check(*args)
143
- Logger.warn "Command #{target_name} #{cmd_name} being sent ignoring range checks"
144
- Logger.info build_cmd_output_string(target_name, cmd_name, cmd_params, true)
145
- rescue HazardousError => e
146
- ok_to_proceed = prompt_for_hazardous(e.target_name,
147
- e.cmd_name,
148
- e.hazardous_description)
149
- if ok_to_proceed
150
- target_name, cmd_name, cmd_params = $cmd_tlm_server.cmd_raw_no_checks(*args)
151
- Logger.warn "Command #{target_name} #{cmd_name} being sent ignoring range checks"
152
- Logger.info build_cmd_output_string(target_name, cmd_name, cmd_params, true)
153
- else
154
- Logger.warn "Hazardous command not sent"
155
- prompt_for_script_abort
156
- end
157
- end
158
- end
159
-
160
- # Send a command to the specified target without hazardous checks or running conversions
161
- # Supports two signatures:
162
- # cmd_raw_no_hazardous_check(target_name, cmd_name, cmd_params = {})
163
- # or
164
- # cmd_raw_no_hazardous_check('target_name cmd_name with cmd_param1 value1, cmd_param2 value2')
165
- def cmd_raw_no_hazardous_check(*args)
166
- target_name, cmd_name, cmd_params = $cmd_tlm_server.cmd_raw_no_hazardous_check(*args)
167
- Logger.warn "Command #{target_name} #{cmd_name} being sent ignoring hazardous warnings"
168
- Logger.info build_cmd_output_string(target_name, cmd_name, cmd_params, true)
169
- end
170
-
171
- # Send a command to the specified target without range checking or hazardous checks or running conversions
172
- # Supports two signatures:
173
- # cmd_raw_no_checks(target_name, cmd_name, cmd_params = {})
174
- # or
175
- # cmd_raw_no_checks('target_name cmd_name with cmd_param1 value1, cmd_param2 value2')
176
- def cmd_raw_no_checks(*args)
177
- target_name, cmd_name, cmd_params = $cmd_tlm_server.cmd_raw_no_checks(*args)
178
- Logger.warn "Command #{target_name} #{cmd_name} being sent ignoring range checks"
179
- Logger.warn "Command #{target_name} #{cmd_name} being sent ignoring hazardous warnings"
180
- Logger.info build_cmd_output_string(target_name, cmd_name, cmd_params, true)
181
- end
182
-
183
- # Sends raw data through an interface
184
- def send_raw(interface_name, data)
185
- return $cmd_tlm_server.send_raw(interface_name, data)
186
- end
187
-
188
- # Sends raw data through an interface from a file
189
- def send_raw_file(interface_name, filename)
190
- data = nil
191
- File.open(filename, 'rb') {|file| data = file.read}
192
- return $cmd_tlm_server.send_raw(interface_name, data)
193
- end
194
-
195
- def get_cmd_list(target_name)
196
- return $cmd_tlm_server.get_cmd_list(target_name)
197
- end
198
-
199
- def get_cmd_param_list(target_name, cmd_name)
200
- return $cmd_tlm_server.get_cmd_param_list(target_name, cmd_name)
201
- end
202
-
203
- def get_cmd_hazardous(target_name, cmd_name, cmd_params = {})
204
- return $cmd_tlm_server.get_cmd_hazardous(target_name, cmd_name, cmd_params)
205
- end
206
-
207
- #
208
- # Methods involving telemetry
209
- #
210
-
211
- # Poll for the converted value of a telemetry item
212
- # Supports two signatures:
213
- # tlm(target_name, packet_name, item_name)
214
- # or
215
- # tlm('target_name packet_name item_name')
216
- def tlm(*args)
217
- return $cmd_tlm_server.tlm(*args)
218
- end
219
-
220
- # Poll for the raw value of a telemetry item
221
- # Supports two signatures:
222
- # tlm_raw(target_name, packet_name, item_name)
223
- # or
224
- # tlm_raw('target_name packet_name item_name')
225
- def tlm_raw(*args)
226
- return $cmd_tlm_server.tlm_raw(*args)
227
- end
228
-
229
- # Poll for the formatted value of a telemetry item
230
- # Supports two signatures:
231
- # tlm_formatted(target_name, packet_name, item_name)
232
- # or
233
- # tlm_formatted('target_name packet_name item_name')
234
- def tlm_formatted(*args)
235
- return $cmd_tlm_server.tlm_formatted(*args)
236
- end
237
-
238
- # Poll for the formatted with units value of a telemetry item
239
- # Supports two signatures:
240
- # tlm_with_units(target_name, packet_name, item_name)
241
- # or
242
- # tlm_with_units('target_name packet_name item_name')
243
- def tlm_with_units(*args)
244
- return $cmd_tlm_server.tlm_with_units(*args)
245
- end
246
-
247
- def tlm_variable(*args)
248
- return $cmd_tlm_server.tlm_variable(*args)
249
- end
250
-
251
- # Set a telemetry point
252
- def set_tlm(*args)
253
- return $cmd_tlm_server.set_tlm(*args)
254
- end
255
-
256
- # Set the raw value of a telemetry point
257
- def set_tlm_raw(*args)
258
- return $cmd_tlm_server.set_tlm_raw(*args)
259
- end
260
-
261
- def get_tlm_packet(target_name, packet_name, value_types = :CONVERTED)
262
- result = $cmd_tlm_server.get_tlm_packet(target_name, packet_name, value_types)
263
- result.each do |entry|
264
- entry[2] = entry[2].to_s.intern if entry[2]
265
- end
266
- result
267
- end
268
-
269
- def get_tlm_values(items, value_types = :CONVERTED)
270
- result = $cmd_tlm_server.get_tlm_values(items, value_types)
271
- result[1].length.times do |index|
272
- result[1][index] = result[1][index].to_s.intern if result[1][index]
273
- end
274
- result[3] = result[3].to_s.intern
275
- result
276
- end
277
-
278
- def get_tlm_list(target_name)
279
- return $cmd_tlm_server.get_tlm_list(target_name)
280
- end
281
-
282
- def get_tlm_item_list(target_name, packet_name)
283
- return $cmd_tlm_server.get_tlm_item_list(target_name, packet_name)
284
- end
285
-
286
- def get_tlm_details(items)
287
- $cmd_tlm_server.get_tlm_details(items)
288
- end
289
-
290
- def get_out_of_limits
291
- result = $cmd_tlm_server.get_out_of_limits
292
- result.each do |entry|
293
- entry[3] = entry[3].to_s.intern if entry[3]
294
- end
295
- result
296
- end
297
-
298
- def get_overall_limits_state (ignored_items = nil)
299
- return $cmd_tlm_server.get_overall_limits_state(ignored_items).to_s.intern
300
- end
301
-
302
- def limits_enabled?(*args)
303
- return $cmd_tlm_server.limits_enabled?(*args)
304
- end
305
-
306
- def enable_limits(*args)
307
- return $cmd_tlm_server.enable_limits(*args)
308
- end
309
-
310
- def disable_limits(*args)
311
- return $cmd_tlm_server.disable_limits(*args)
312
- end
313
-
314
- def get_limits(target_name, packet_name, item_name, limits_set = nil)
315
- results = $cmd_tlm_server.get_limits(target_name, packet_name, item_name, limits_set)
316
- results[0] = results[0].to_s.intern if results[0]
317
- return results
318
- end
319
-
320
- def set_limits(target_name, packet_name, item_name, red_low, yellow_low, yellow_high, red_high, green_low = nil, green_high = nil, limits_set = :CUSTOM, persistence = nil, enabled = true)
321
- results = $cmd_tlm_server.set_limits(target_name, packet_name, item_name, red_low, yellow_low, yellow_high, red_high, green_low, green_high, limits_set, persistence, enabled)
322
- results[0] = results[0].to_s.intern if results[0]
323
- return results
324
- end
325
-
326
- def get_limits_groups
327
- return $cmd_tlm_server.get_limits_groups
328
- end
329
-
330
- def enable_limits_group(group_name)
331
- return $cmd_tlm_server.enable_limits_group(group_name)
332
- end
333
-
334
- def disable_limits_group(group_name)
335
- return $cmd_tlm_server.disable_limits_group(group_name)
336
- end
337
-
338
- def get_limits_sets
339
- result = $cmd_tlm_server.get_limits_sets
340
- result.each_with_index do |limits_set, index|
341
- result[index] = limits_set.to_s.intern
342
- end
343
- return result
344
- end
345
-
346
- def set_limits_set(limits_set)
347
- return $cmd_tlm_server.set_limits_set(limits_set)
348
- end
349
-
350
- def get_limits_set
351
- result = $cmd_tlm_server.get_limits_set
352
- # Limits sets are always represented as symbols
353
- result.to_s.intern
354
- end
355
-
356
- #
357
- # General Purpose Methods
358
- #
359
-
360
- def get_target_list
361
- return $cmd_tlm_server.get_target_list
362
- end
363
-
364
- def subscribe_limits_events(queue_size = CmdTlmServer::DEFAULT_LIMITS_EVENT_QUEUE_SIZE)
365
- return $cmd_tlm_server.subscribe_limits_events(queue_size)
366
- end
367
-
368
- def unsubscribe_limits_events(id)
369
- return $cmd_tlm_server.unsubscribe_limits_events(id)
370
- end
371
-
372
- def get_limits_event(id, non_block = false)
373
- result = $cmd_tlm_server.get_limits_event(id, non_block)
374
- if result
375
- result[0] = result[0].to_s.intern
376
- if result[0] == :LIMITS_CHANGE
377
- result[1][3] = result[1][3].to_s.intern if result[1][3]
378
- result[1][4] = result[1][4].to_s.intern if result[1][4]
379
- elsif result[0] == :LIMITS_SETTINGS
380
- result[1][3] = result[1][3].to_s.intern if result[1][3]
381
- else
382
- result[1] = result[1].to_s.intern
383
- end
384
- end
385
- result
386
- end
387
-
388
- def subscribe_packet_data(packets, queue_size = CmdTlmServer::DEFAULT_PACKET_DATA_QUEUE_SIZE)
389
- result = $cmd_tlm_server.subscribe_packet_data(packets, queue_size)
390
- result
391
- end
392
-
393
- def unsubscribe_packet_data(id)
394
- result = $cmd_tlm_server.unsubscribe_packet_data(id)
395
- result
396
- end
397
-
398
- def get_packet_data(id, non_block = false)
399
- results = $cmd_tlm_server.get_packet_data(id, non_block)
400
- if Array === results and results[3] and results[4]
401
- results[3] = Time.at(results[3], results[4])
402
- results.delete_at(4)
403
- end
404
- results
405
- end
406
-
407
- def get_packet(id, non_block = false)
408
- packet = nil
409
- buffer, target_name, packet_name, received_time, received_count = get_packet_data(id, non_block)
410
- if buffer
411
- packet = System.telemetry.packet(target_name, packet_name).clone
412
- packet.buffer = buffer
413
- packet.received_time = received_time
414
- packet.received_count = received_count
415
- end
416
- packet
417
- end
418
-
419
- #
420
- # Methods for scripting
421
- #
422
-
423
- def play_wav_file(wav_filename)
424
- if defined? Qt
425
- Qt.execute_in_main_thread(true) do
426
- if Qt::CoreApplication.instance and Qt::Sound.isAvailable
427
- Cosmos.set_working_dir do
428
- Qt::Sound.play(wav_filename.to_s)
429
- end
430
- end
431
- end
432
- end
433
- end
434
-
435
- def status_bar(message)
436
- script_runner = nil
437
- ObjectSpace.each_object {|object| if ScriptRunner === object then script_runner = object; break; end}
438
- script_runner.script_set_status(message) if script_runner
439
- end
440
-
441
- def ask_string(question, allow_blank = false)
442
- answer = ''
443
- while answer.empty?
444
- print question + " "
445
- answer = gets
446
- answer.chomp!
447
- break if allow_blank
448
- end
449
- return answer
450
- end
451
-
452
- def ask(question, allow_blank = false)
453
- string = ask_string(question, allow_blank)
454
- value = string.convert_to_value
455
- return value
456
- end
457
-
458
- def prompt(string)
459
- prompt_to_continue(string)
460
- end
461
-
462
- def message_box(string, *buttons)
463
- prompt_message_box(string, buttons)
464
- end
465
-
466
- def _check(*args)
467
- target_name, packet_name, item_name, comparison_to_eval =
468
- check_process_args(args, 'check')
469
- value = yield(target_name, packet_name, item_name)
470
- if comparison_to_eval
471
- check_eval(target_name, packet_name, item_name, comparison_to_eval, value)
472
- else
473
- Logger.info "CHECK: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} == #{value}"
474
- end
475
- end
476
-
477
- # Check the converted value of a telmetry item against a condition
478
- # Always print the value of the telemetry item to STDOUT
479
- # If the condition check fails, raise an error
480
- # Supports two signatures:
481
- # check(target_name, packet_name, item_name, comparison_to_eval)
482
- # or
483
- # check('target_name packet_name item_name > 1')
484
- def check(*args)
485
- _check(*args) {|tgt,pkt,item| tlm(tgt,pkt,item) }
486
- end
487
-
488
- # Check the formatted value of a telmetry item against a condition
489
- # Always print the value of the telemetry item to STDOUT
490
- # If the condition check fails, raise an error
491
- # Supports two signatures:
492
- # check(target_name, packet_name, item_name, comparison_to_eval)
493
- # or
494
- # check('target_name packet_name item_name > 1')
495
- def check_formatted(*args)
496
- _check(*args) {|tgt,pkt,item| tlm_formatted(tgt,pkt,item) }
497
- end
498
-
499
- # Check the formatted with units value of a telmetry item against a condition
500
- # Always print the value of the telemetry item to STDOUT
501
- # If the condition check fails, raise an error
502
- # Supports two signatures:
503
- # check(target_name, packet_name, item_name, comparison_to_eval)
504
- # or
505
- # check('target_name packet_name item_name > 1')
506
- def check_with_units(*args)
507
- _check(*args) {|tgt,pkt,item| tlm_with_units(tgt,pkt,item) }
508
- end
509
-
510
- # Check the raw value of a telmetry item against a condition
511
- # Always print the value of the telemetry item to STDOUT
512
- # If the condition check fails, raise an error
513
- # Supports two signatures:
514
- # check(target_name, packet_name, item_name, comparison_to_eval)
515
- # or
516
- # check('target_name packet_name item_name > 1')
517
- def check_raw(*args)
518
- _check(*args) {|tgt,pkt,item| tlm_raw(tgt,pkt,item) }
519
- end
520
-
521
- def _check_tolerance(*args)
522
- target_name, packet_name, item_name, expected_value, tolerance =
523
- check_tolerance_process_args(args, 'check_tolerance')
524
- value = yield(target_name, packet_name, item_name)
525
- range = (expected_value - tolerance)..(expected_value + tolerance)
526
- if range.include?(value)
527
- Logger.info "CHECK: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} was within range #{range.first} to #{range.last} with value == #{value}"
528
- else
529
- message = "CHECK: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} failed to be within range #{range.first} to #{range.last} with value == #{value}"
530
- if $cmd_tlm_disconnect
531
- Logger.error message
532
- else
533
- raise CheckError, message
534
- end
535
- end
536
- end
537
-
538
- # Check the converted value of a telmetry item against an expected value with a tolerance
539
- # Always print the value of the telemetry item to STDOUT
540
- # If the condition check fails, raise an error
541
- # Supports two signatures:
542
- # check_tolerance(target_name, packet_name, item_name, expected_value, tolerance)
543
- # or
544
- # check_tolerance('target_name packet_name item_name', expected_value, tolerance)
545
- def check_tolerance(*args)
546
- _check_tolerance(*args) {|tgt,pkt,item| tlm(tgt,pkt,item) }
547
- end
548
-
549
- # Check the raw value of a telmetry item against an expected value with a tolerance
550
- # Always print the value of the telemetry item to STDOUT
551
- # If the condition check fails, raise an error
552
- # Supports two signatures:
553
- # check_tolerance_raw(target_name, packet_name, item_name, expected_value, tolerance)
554
- # or
555
- # check_tolerance_raw('target_name packet_name item_name', expected_value, tolerance)
556
- def check_tolerance_raw(*args)
557
- _check_tolerance(*args) {|tgt,pkt,item| tlm_raw(tgt,pkt,item) }
558
- end
559
-
560
- # Check to see if an expression is true without waiting. If the expression
561
- # is not true, the script will pause.
562
- def check_expression(exp_to_eval, context = nil)
563
- success = cosmos_script_wait_implementation_expression(exp_to_eval, 0, DEFAULT_TLM_POLLING_RATE, context)
564
- if success
565
- Logger.info "CHECK: #{exp_to_eval} is TRUE"
566
- else
567
- message = "CHECK: #{exp_to_eval} is FALSE"
568
- if $cmd_tlm_disconnect
569
- Logger.error message
570
- else
571
- raise CheckError, message
572
- end
573
- end
574
- end
575
-
576
- # Wait on an expression to be true. On a timeout, the script will continue.
577
- # Supports multiple signatures:
578
- # wait(time)
579
- # wait('target_name packet_name item_name > 1', timeout, polling_rate)
580
- # wait('target_name', 'packet_name', 'item_name', comparison_to_eval, timeout, polling_rate)
581
- def wait(*args)
582
- wait_process_args(args, 'wait', :CONVERTED)
583
- end
584
-
585
- # Wait on an expression to be true. On a timeout, the script will continue.
586
- # Supports multiple signatures:
587
- # wait(time)
588
- # wait_raw('target_name packet_name item_name > 1', timeout, polling_rate)
589
- # wait_raw('target_name', 'packet_name', 'item_name', comparison_to_eval, timeout, polling_rate)
590
- def wait_raw(*args)
591
- wait_process_args(args, 'wait_raw', :RAW)
592
- end
593
-
594
- def _wait_tolerance(raw, *args)
595
- type = (raw ? :RAW : :CONVERTED)
596
- type_string = 'wait_tolerance'
597
- type_string += '_raw' if raw
598
- target_name, packet_name, item_name, expected_value, tolerance, timeout, polling_rate = wait_tolerance_process_args(args, type_string)
599
- start_time = Time.now
600
- success, value = cosmos_script_wait_implementation_tolerance(target_name, packet_name, item_name, type, expected_value, tolerance, timeout, polling_rate)
601
- time = Time.now - start_time
602
- range = (expected_value - tolerance)..(expected_value + tolerance)
603
- if success
604
- Logger.info "WAIT: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} was within range #{range.first} to #{range.last} with value == #{value} after waiting #{time} seconds"
605
- else
606
- Logger.warn "WAIT: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} failed to be within range #{range.first} to #{range.last} with value == #{value} after waiting #{time} seconds"
607
- end
608
- time
609
- end
610
-
611
- # Wait on an expression to be true. On a timeout, the script will continue.
612
- # Supports multiple signatures:
613
- # wait_tolerance('target_name packet_name item_name', expected_value, tolerance, timeout, polling_rate)
614
- # wait_tolerance('target_name', 'packet_name', 'item_name', expected_value, tolerance, timeout, polling_rate)
615
- def wait_tolerance(*args)
616
- _wait_tolerance(false, *args)
617
- end
618
-
619
- # Wait on an expression to be true. On a timeout, the script will continue.
620
- # Supports multiple signatures:
621
- # wait_tolerance_raw('target_name packet_name item_name', expected_value, tolerance, timeout, polling_rate)
622
- # wait_tolerance_raw('target_name', 'packet_name', 'item_name', expected_value, tolerance, timeout, polling_rate)
623
- def wait_tolerance_raw(*args)
624
- _wait_tolerance(true, *args)
625
- end
626
-
627
- # Wait on a custom expression to be true
628
- def wait_expression(exp_to_eval, timeout, polling_rate = DEFAULT_TLM_POLLING_RATE, context = nil)
629
- start_time = Time.now
630
- success = cosmos_script_wait_implementation_expression(exp_to_eval, timeout, polling_rate, context)
631
- time = Time.now - start_time
632
- if success
633
- Logger.info "WAIT: #{exp_to_eval} is TRUE after waiting #{time} seconds"
634
- else
635
- Logger.warn "WAIT: #{exp_to_eval} is FALSE after waiting #{time} seconds"
636
- end
637
- time
638
- end
639
-
640
- def _wait_check(raw, *args)
641
- type = (raw ? :RAW : :CONVERTED)
642
- target_name, packet_name, item_name, comparison_to_eval, timeout, polling_rate = wait_check_process_args(args, 'wait_check')
643
- start_time = Time.now
644
- success, value = cosmos_script_wait_implementation(target_name, packet_name, item_name, type, comparison_to_eval, timeout, polling_rate)
645
- time = Time.now - start_time
646
- if success
647
- Logger.info "CHECK: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} #{comparison_to_eval} success with value == #{value} after waiting #{time} seconds"
648
- else
649
- message = "CHECK: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} #{comparison_to_eval} failed with value == #{value} after waiting #{time} seconds"
650
- if $cmd_tlm_disconnect
651
- Logger.error message
652
- else
653
- raise CheckError, message
654
- end
655
- end
656
- time
657
- end
658
-
659
- # Wait for the converted value of a telmetry item against a condition or for a timeout
660
- # and then check against the condition
661
- # Supports two signatures:
662
- # wait_check(target_name, packet_name, item_name, comparison_to_eval, timeout, polling_rate)
663
- # or
664
- # wait_check('target_name packet_name item_name > 1', timeout, polling_rate)
665
- def wait_check(*args)
666
- _wait_check(false, *args)
667
- end
668
-
669
- # Wait for the raw value of a telmetry item against a condition or for a timeout
670
- # and then check against the condition
671
- # Supports two signatures:
672
- # wait_check_raw(target_name, packet_name, item_name, comparison_to_eval, timeout, polling_rate)
673
- # or
674
- # wait_check_raw('target_name packet_name item_name > 1', timeout, polling_rate)
675
- def wait_check_raw(*args)
676
- _wait_check(true, *args)
677
- end
678
-
679
- def _wait_check_tolerance(raw, *args)
680
- type_string = 'wait_check_tolerance'
681
- type_string += '_raw' if raw
682
- type = (raw ? :RAW : :CONVERTED)
683
- target_name, packet_name, item_name, expected_value, tolerance, timeout, polling_rate = wait_tolerance_process_args(args, type_string)
684
- start_time = Time.now
685
- success, value = cosmos_script_wait_implementation_tolerance(target_name, packet_name, item_name, type, expected_value, tolerance, timeout, polling_rate)
686
- time = Time.now - start_time
687
- range = (expected_value - tolerance)..(expected_value + tolerance)
688
- if success
689
- Logger.info "CHECK: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} was within range #{range.first} to #{range.last} with value == #{value} after waiting #{time} seconds"
690
- else
691
- message = "CHECK: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} failed to be within range #{range.first} to #{range.last} with value == #{value} after waiting #{time} seconds"
692
- if $cmd_tlm_disconnect
693
- Logger.error message
694
- else
695
- raise CheckError, message
696
- end
697
- end
698
- time
699
- end
700
-
701
- def wait_check_tolerance(*args)
702
- _wait_check_tolerance(false, *args)
703
- end
704
-
705
- def wait_check_tolerance_raw(*args)
706
- _wait_check_tolerance(true, *args)
707
- end
708
-
709
- # Wait on an expression to be true. On a timeout, the script will pause.
710
- def wait_check_expression(exp_to_eval,
711
- timeout,
712
- polling_rate = DEFAULT_TLM_POLLING_RATE,
713
- context = nil)
714
- start_time = Time.now
715
- success = cosmos_script_wait_implementation_expression(exp_to_eval,
716
- timeout,
717
- polling_rate,
718
- context)
719
- time = Time.now - start_time
720
- if success
721
- Logger.info "CHECK: #{exp_to_eval} is TRUE after waiting #{time} seconds"
722
- else
723
- message = "CHECK: #{exp_to_eval} is FALSE after waiting #{time} seconds"
724
- if $cmd_tlm_disconnect
725
- Logger.error message
726
- else
727
- raise CheckError, message
728
- end
729
- end
730
- time
731
- end
732
- alias wait_expression_stop_on_timeout wait_check_expression
733
-
734
- # Wait for a telemetry packet to be received a certain number of times or timeout
735
- def _wait_packet(check,
736
- target_name,
737
- packet_name,
738
- num_packets,
739
- timeout,
740
- polling_rate = DEFAULT_TLM_POLLING_RATE)
741
- type = (check ? 'CHECK' : 'WAIT')
742
- initial_count = tlm(target_name, packet_name, 'RECEIVED_COUNT')
743
- start_time = Time.now
744
- success, value = cosmos_script_wait_implementation(target_name,
745
- packet_name,
746
- 'RECEIVED_COUNT',
747
- :CONVERTED,
748
- ">= #{initial_count + num_packets}",
749
- timeout,
750
- polling_rate)
751
- time = Time.now - start_time
752
- if success
753
- Logger.info "#{type}: #{target_name.upcase} #{packet_name.upcase} received #{value - initial_count} times after waiting #{time} seconds"
754
- else
755
- message = "#{type}: #{target_name.upcase} #{packet_name.upcase} expected to be received #{num_packets} times but only received #{value - initial_count} times after waiting #{time} seconds"
756
- if check
757
- if $cmd_tlm_disconnect
758
- Logger.error message
759
- else
760
- raise CheckError, message
761
- end
762
- else
763
- Logger.warn message
764
- end
765
- end
766
- time
767
- end
768
-
769
- def wait_packet(target_name,
770
- packet_name,
771
- num_packets,
772
- timeout,
773
- polling_rate = DEFAULT_TLM_POLLING_RATE)
774
- _wait_packet(false, target_name, packet_name, num_packets, timeout, polling_rate)
775
- end
776
-
777
- # Wait for a telemetry packet to be received a certain number of times or timeout and raise an error
778
- def wait_check_packet(target_name,
779
- packet_name,
780
- num_packets,
781
- timeout,
782
- polling_rate = DEFAULT_TLM_POLLING_RATE)
783
- _wait_packet(true, target_name, packet_name, num_packets, timeout, polling_rate)
784
- end
785
-
786
- def get_interface_names
787
- return $cmd_tlm_server.get_interface_names
788
- end
789
-
790
- def connect_interface(interface_name, *params)
791
- return $cmd_tlm_server.connect_interface(interface_name, *params)
792
- end
793
-
794
- def disconnect_interface(interface_name)
795
- return $cmd_tlm_server.disconnect_interface(interface_name)
796
- end
797
-
798
- def interface_state(interface_name)
799
- return $cmd_tlm_server.interface_state(interface_name)
800
- end
801
-
802
- def map_target_to_interface(target_name, interface_name)
803
- return $cmd_tlm_server.map_target_to_interface(target_name, interface_name)
804
- end
805
-
806
- def get_router_names
807
- return $cmd_tlm_server.get_router_names
808
- end
809
-
810
- def connect_router(router_name, *params)
811
- return $cmd_tlm_server.connect_router(router_name, *params)
812
- end
813
-
814
- def disconnect_router(router_name)
815
- return $cmd_tlm_server.disconnect_router(router_name)
816
- end
817
-
818
- def router_state(router_name)
819
- return $cmd_tlm_server.router_state(router_name)
820
- end
821
-
822
- def get_cmd_log_filename(packet_log_writer_name = 'DEFAULT')
823
- return $cmd_tlm_server.get_cmd_log_filename(packet_log_writer_name)
824
- end
825
-
826
- def get_tlm_log_filename(packet_log_writer_name = 'DEFAULT')
827
- return $cmd_tlm_server.get_tlm_log_filename(packet_log_writer_name)
828
- end
829
-
830
- def start_logging(packet_log_writer_name = 'ALL', label = nil)
831
- return $cmd_tlm_server.start_logging(packet_log_writer_name, label)
832
- end
833
-
834
- def stop_logging(packet_log_writer_name = 'ALL')
835
- return $cmd_tlm_server.stop_logging(packet_log_writer_name)
836
- end
837
-
838
- def start_cmd_log(packet_log_writer_name = 'ALL', label = nil)
839
- return $cmd_tlm_server.start_cmd_log(packet_log_writer_name, label)
840
- end
841
-
842
- def start_tlm_log(packet_log_writer_name = 'ALL', label = nil)
843
- return $cmd_tlm_server.start_tlm_log(packet_log_writer_name, label)
844
- end
845
-
846
- def stop_cmd_log(packet_log_writer_name = 'ALL')
847
- return $cmd_tlm_server.stop_cmd_log(packet_log_writer_name)
848
- end
849
-
850
- def stop_tlm_log(packet_log_writer_name = 'ALL')
851
- return $cmd_tlm_server.stop_tlm_log(packet_log_writer_name)
852
- end
853
-
854
- def start_raw_logging_interface(interface_name = 'ALL')
855
- return $cmd_tlm_server.start_raw_logging_interface(interface_name)
856
- end
857
-
858
- def stop_raw_logging_interface(interface_name = 'ALL')
859
- return $cmd_tlm_server.stop_raw_logging_interface(interface_name)
860
- end
861
-
862
- def start_raw_logging_router(router_name = 'ALL')
863
- return $cmd_tlm_server.start_raw_logging_router(router_name)
864
- end
865
-
866
- def stop_raw_logging_router(router_name = 'ALL')
867
- return $cmd_tlm_server.stop_raw_logging_router(router_name)
868
- end
869
-
870
- def get_server_message_log_filename
871
- return $cmd_tlm_server.get_server_message_log_filename
872
- end
873
-
874
- def start_new_server_message_log
875
- return $cmd_tlm_server.start_new_server_message_log
876
- end
877
-
878
- #######################################
879
- # Methods accessing tlm_viewer
880
- #######################################
881
-
882
- def display(display_name, x_pos = nil, y_pos = nil)
883
- tlm_viewer = JsonDRbObject.new "localhost", System.ports['TLMVIEWER_API']
884
- begin
885
- tlm_viewer.display(display_name, x_pos, y_pos)
886
- tlm_viewer.disconnect
887
- rescue DRb::DRbConnError
888
- # No Listening Tlm Viewer - So Start One
889
- if Kernel.is_windows?
890
- Cosmos.run_process('rubyw "' + File.join(Cosmos::USERPATH, 'tools', 'TlmViewer') + '"' + " --system #{File.basename(System.initial_filename)}")
891
- elsif Kernel.is_mac? and File.exist?(File.join(Cosmos::USERPATH, 'tools', 'mac', 'TlmViewer.app'))
892
- Cosmos.run_process('open "' + File.join(Cosmos::USERPATH, 'tools', 'mac', 'TlmViewer.app') + '"' + " --args --system #{File.basename(System.initial_filename)}")
893
- else
894
- Cosmos.run_process('ruby "' + File.join(Cosmos::USERPATH, 'tools', 'TlmViewer') + '"' + " --system #{File.basename(System.initial_filename)}")
895
- end
896
- sleep(5)
897
- begin
898
- tlm_viewer.display(display_name, x_pos, y_pos)
899
- tlm_viewer.disconnect
900
- rescue DRb::DRbConnError
901
- raise "Unable to Successfully Start Listening Telemetry Viewer: #{display_name} could not be displayed"
902
- rescue Errno::ENOENT
903
- raise "Display Screen File: #{display_name}.txt does not exist"
904
- end
905
- rescue Errno::ENOENT
906
- raise "Display Screen File: #{display_name}.txt does not exist"
907
- end
908
- end
909
-
910
- def clear(display_name)
911
- tlm_viewer = JsonDRbObject.new "localhost", System.ports['TLMVIEWER_API']
912
- begin
913
- tlm_viewer.clear(display_name)
914
- tlm_viewer.disconnect
915
- rescue DRb::DRbConnError
916
- raise "No Listening Telemetry Viewer: #{display_name} could not be cleared"
917
- rescue Errno::ENOENT
918
- raise "Display Screen File: #{display_name}.txt does not exist"
919
- end
920
- end
921
-
922
- #######################################
923
- # Methods accessing script runner
924
- #######################################
925
-
926
- def set_line_delay(delay)
927
- if defined? ScriptRunnerFrame
928
- ScriptRunnerFrame.line_delay = delay if delay >= 0.0
929
- end
930
- end
931
-
932
- def get_line_delay
933
- if defined? ScriptRunnerFrame
934
- ScriptRunnerFrame.line_delay
935
- end
936
- end
937
-
938
- def get_scriptrunner_message_log_filename
939
- filename = nil
940
- if defined? ScriptRunnerFrame
941
- filename = ScriptRunnerFrame.instance.message_log.filename if ScriptRunnerFrame.instance and ScriptRunnerFrame.instance.message_log
942
- end
943
- return filename
944
- end
945
-
946
- def start_new_scriptrunner_message_log
947
- if defined? ScriptRunnerFrame
948
- # A new log will be created at the next message
949
- ScriptRunnerFrame.instance.stop_message_log if ScriptRunnerFrame.instance
950
- end
951
- end
952
-
953
- #######################################
954
- # Methods for debugging
955
- #######################################
956
-
957
- def insert_return(*params)
958
- if defined? ScriptRunnerFrame
959
- if ScriptRunnerFrame.instance
960
- ScriptRunnerFrame.instance.inline_return = true
961
- ScriptRunnerFrame.instance.inline_return_params = params
962
- end
963
- end
964
- end
965
-
966
- def step_mode
967
- if defined? ScriptRunnerFrame
968
- ScriptRunnerFrame.step_mode = true
969
- end
970
- end
971
-
972
- def run_mode
973
- if defined? ScriptRunnerFrame
974
- ScriptRunnerFrame.step_mode = false
975
- end
976
- end
977
-
978
- def show_backtrace(value = true)
979
- if defined? ScriptRunnerFrame
980
- ScriptRunnerFrame.show_backtrace = value
981
- end
982
- end
983
-
984
- ##########################################
985
- # End Methods accessing other systems
986
- ##########################################
987
-
988
- def start(procedure_name)
989
- # Handle not-giving an extension
990
- procedure_name_with_extension = nil
991
- procedure_name_with_extension = procedure_name + '.rb' if File.extname(procedure_name).empty?
992
-
993
- file_text = ''
994
- path = nil
995
-
996
- # Find filename in search path
997
- ($:).each do |directory|
998
- if File.exist?(directory + '/' + procedure_name) and not File.directory?(directory + '/' + procedure_name)
999
- path = directory + '/' + procedure_name
1000
- break
1001
- end
1002
-
1003
- if procedure_name_with_extension and File.exist?(directory + '/' + procedure_name_with_extension)
1004
- procedure_name = procedure_name_with_extension
1005
- path = directory + '/' + procedure_name
1006
- break
1007
- end
1008
- end
1009
-
1010
- # Handle absolute path
1011
- path = procedure_name if !path and File.exist?(procedure_name)
1012
- path = procedure_name_with_extension if !path and procedure_name_with_extension and File.exist?(procedure_name_with_extension)
1013
-
1014
- raise "Procedure not found : #{procedure_name}" unless path
1015
-
1016
- if defined? ScriptRunnerFrame and ScriptRunnerFrame.instance
1017
- result = false
1018
- md5 = nil
1019
- begin
1020
- md5 = Cosmos.md5_files([path]).hexdigest
1021
- rescue Exception => error
1022
- raise "Error calculating md5 on procedure file : #{path}"
1023
- end
1024
-
1025
- # Check RAM based instrumented cache
1026
- instrumented_cache = ScriptRunnerFrame.instrumented_cache[path]
1027
- instrumented_script = nil
1028
- if instrumented_cache and md5 == instrumented_cache[1]
1029
- # Use cached instrumentation
1030
- instrumented_script = instrumented_cache[0]
1031
- else
1032
- use_file_cache = true
1033
- cache_filename = nil
1034
- flat_path = nil
1035
-
1036
- # Check for cache directory existence
1037
- Cosmos.set_working_dir do
1038
- cache_path = File.join(System.paths['TMP'], 'script_runner')
1039
- unless File.directory?(cache_path)
1040
- # Try to create .cache directory
1041
- begin
1042
- Dir.mkdir(cache_path)
1043
- rescue
1044
- use_file_cache = false
1045
- end
1046
- end
1047
-
1048
- if use_file_cache
1049
- # Check file based instrumented cache
1050
- flat_path = path.gsub("/", "_").gsub("\\", "_").gsub(":", "_").gsub(" ", "_")
1051
- flat_path_with_md5 = flat_path + '_' + md5
1052
- cache_filename = File.join(cache_path, flat_path_with_md5)
1053
- end
1054
-
1055
- if use_file_cache and File.exist?(cache_filename)
1056
- # Use file cached instrumentation
1057
- File.open(cache_filename, 'r') {|file| instrumented_script = file.read}
1058
- else
1059
- # Have to instrument
1060
- result = true
1061
-
1062
- # Build instrumentation
1063
- begin
1064
- file_text = File.read(path)
1065
- rescue Exception => error
1066
- raise "Error reading procedure file : #{path}"
1067
- end
1068
-
1069
- instrumented_script = ScriptRunnerFrame.instrument_script(file_text, path, true)
1070
-
1071
- # Cache instrumentation into file
1072
- if use_file_cache
1073
- begin
1074
- File.open(cache_filename, 'w') {|file| file.write(instrumented_script)}
1075
- rescue
1076
- # Oh well, failed to write cache file
1077
- end
1078
- end
1079
- end
1080
- end
1081
-
1082
- # Cache instrumentation into RAM
1083
- ScriptRunnerFrame.instrumented_cache[path] = [instrumented_script, md5]
1084
- end
1085
-
1086
- Object.class_eval(instrumented_script, path, 1)
1087
- else # No ScriptRunnerFrame so just start it locally
1088
- result = true
1089
-
1090
- begin
1091
- Kernel::load(path)
1092
- rescue LoadError => error
1093
- raise RuntimeError.new("Error loading : #{procedure_name} : #{error.message}")
1094
- end
1095
- end
1096
- result
1097
- end
1098
-
1099
- # Require an additional ruby file
1100
- def load_utility(procedure_name)
1101
- result = false
1102
- if defined? ScriptRunnerFrame and ScriptRunnerFrame.instance
1103
- saved = ScriptRunnerFrame.instance.use_instrumentation
1104
- begin
1105
- ScriptRunnerFrame.instance.use_instrumentation = false
1106
- result = start(procedure_name)
1107
- ensure
1108
- ScriptRunnerFrame.instance.use_instrumentation = saved
1109
- end
1110
- else # Just call start
1111
- result = start(procedure_name)
1112
- end
1113
- result
1114
- end
1115
- alias require_utility load_utility
1116
-
1117
- ##########################################
1118
- # Protected Methods
1119
- ##########################################
1120
-
1121
- def check_process_args(args, function_name)
1122
- case args.length
1123
- when 1
1124
- target_name, packet_name, item_name, comparison_to_eval = extract_fields_from_check_text(args[0])
1125
- when 4
1126
- target_name = args[0]
1127
- packet_name = args[1]
1128
- item_name = args[2]
1129
- comparison_to_eval = args[3]
1130
- else
1131
- # Invalid number of arguments
1132
- raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{function_name}()"
1133
- end
1134
- return [target_name, packet_name, item_name, comparison_to_eval]
1135
- end
1136
-
1137
- def check_tolerance_process_args(args, function_name)
1138
- case args.length
1139
- when 3
1140
- target_name, packet_name, item_name = extract_fields_from_tlm_text(args[0])
1141
- expected_value = args[1]
1142
- tolerance = args[2]
1143
- when 5
1144
- target_name = args[0]
1145
- packet_name = args[1]
1146
- item_name = args[2]
1147
- expected_value = args[3]
1148
- tolerance = args[4]
1149
- else
1150
- # Invalid number of arguments
1151
- raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{function_name}()"
1152
- end
1153
- return [target_name, packet_name, item_name, expected_value, tolerance]
1154
- end
1155
-
1156
- def wait_process_args(args, function_name, value_type)
1157
- time = nil
1158
-
1159
- case args.length
1160
- when 0
1161
- start_time = Time.now
1162
- cosmos_script_sleep()
1163
- time = Time.now - start_time
1164
- Logger.info("WAIT: Indefinite for actual time of #{time} seconds")
1165
- when 1
1166
- if args[0].kind_of? Numeric
1167
- start_time = Time.now
1168
- cosmos_script_sleep(args[0])
1169
- time = Time.now - start_time
1170
- Logger.info("WAIT: #{args[0]} seconds with actual time of #{time} seconds")
1171
- else
1172
- raise "Non-numeric wait time specified"
1173
- end
1174
- when 2, 3
1175
- target_name, packet_name, item_name, comparison_to_eval = extract_fields_from_check_text(args[0])
1176
- timeout = args[1]
1177
- if args.length == 3
1178
- polling_rate = args[2]
1179
- else
1180
- polling_rate = DEFAULT_TLM_POLLING_RATE
1181
- end
1182
- start_time = Time.now
1183
- success, value = cosmos_script_wait_implementation(target_name, packet_name, item_name, value_type, comparison_to_eval, timeout, polling_rate)
1184
- time = Time.now - start_time
1185
- if success
1186
- Logger.info "WAIT: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} #{comparison_to_eval} success with value == #{value} after waiting #{time} seconds"
1187
- else
1188
- Logger.warn "WAIT: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} #{comparison_to_eval} failed with value == #{value} after waiting #{time} seconds"
1189
- end
1190
- when 5, 6
1191
- target_name = args[0]
1192
- packet_name = args[1]
1193
- item_name = args[2]
1194
- comparison_to_eval = args[3]
1195
- timeout = args[4]
1196
- if args.length == 6
1197
- polling_rate = args[5]
1198
- else
1199
- polling_rate = DEFAULT_TLM_POLLING_RATE
1200
- end
1201
- start_time = Time.now
1202
- success, value = cosmos_script_wait_implementation(target_name, packet_name, item_name, value_type, comparison_to_eval, timeout, polling_rate)
1203
- time = Time.now - start_time
1204
- if success
1205
- Logger.info "WAIT: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} #{comparison_to_eval} success with value == #{value} after waiting #{time} seconds"
1206
- else
1207
- Logger.warn "WAIT: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} #{comparison_to_eval} failed with value == #{value} after waiting #{time} seconds"
1208
- end
1209
- else
1210
- # Invalid number of arguments
1211
- raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{function_name}()"
1212
- end
1213
- time
1214
- end
1215
-
1216
- def wait_tolerance_process_args(args, function_name)
1217
- case args.length
1218
- when 4, 5
1219
- target_name, packet_name, item_name = extract_fields_from_tlm_text(args[0])
1220
- expected_value = args[1]
1221
- tolerance = args[2]
1222
- timeout = args[3]
1223
- if args.length == 5
1224
- polling_rate = args[4]
1225
- else
1226
- polling_rate = DEFAULT_TLM_POLLING_RATE
1227
- end
1228
- when 6, 7
1229
- target_name = args[0]
1230
- packet_name = args[1]
1231
- item_name = args[2]
1232
- expected_value = args[3]
1233
- tolerance = args[4]
1234
- timeout = args[5]
1235
- if args.length == 7
1236
- polling_rate = args[6]
1237
- else
1238
- polling_rate = DEFAULT_TLM_POLLING_RATE
1239
- end
1240
- else
1241
- # Invalid number of arguments
1242
- raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{function_name}()"
1243
- end
1244
- return [target_name, packet_name, item_name, expected_value, tolerance, timeout, polling_rate]
1245
- end
1246
-
1247
- def wait_check_process_args(args, function_name)
1248
- case args.length
1249
- when 2,3
1250
- target_name, packet_name, item_name, comparison_to_eval = extract_fields_from_check_text(args[0])
1251
- timeout = args[1]
1252
- if args.length == 3
1253
- polling_rate = args[2]
1254
- else
1255
- polling_rate = DEFAULT_TLM_POLLING_RATE
1256
- end
1257
- when 5,6
1258
- target_name = args[0]
1259
- packet_name = args[1]
1260
- item_name = args[2]
1261
- comparison_to_eval = args[3]
1262
- timeout = args[4]
1263
- if args.length == 6
1264
- polling_rate = args[5]
1265
- else
1266
- polling_rate = DEFAULT_TLM_POLLING_RATE
1267
- end
1268
- else
1269
- # Invalid number of arguments
1270
- raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{function_name}()"
1271
- end
1272
- return [target_name, packet_name, item_name, comparison_to_eval, timeout, polling_rate]
1273
- end
1274
-
1275
- # sleep in a script - returns true if canceled mid sleep
1276
- def cosmos_script_sleep(sleep_time = nil)
1277
- return false if $cmd_tlm_disconnect
1278
- if defined? ScriptRunnerFrame and ScriptRunnerFrame.instance
1279
- sleep_time = 30000000 unless sleep_time # Handle infinite wait
1280
- if sleep_time > 0.0
1281
- end_time = Time.now + sleep_time
1282
- until (Time.now >= end_time)
1283
- sleep(0.01)
1284
- if ScriptRunnerFrame.instance.pause?
1285
- ScriptRunnerFrame.instance.perform_pause
1286
- return true
1287
- end
1288
- return true if ScriptRunnerFrame.instance.go?
1289
- raise StopScript if ScriptRunnerFrame.instance.stop?
1290
- end
1291
- end
1292
- else
1293
- if sleep_time
1294
- sleep(sleep_time)
1295
- else
1296
- print 'Infinite Wait - Press Enter to Continue: '
1297
- gets()
1298
- end
1299
- end
1300
- return false
1301
- end
1302
-
1303
- def _cosmos_script_wait_implementation(target_name, packet_name, item_name, value_type, timeout, polling_rate)
1304
- end_time = Time.now + timeout
1305
- exp_to_eval = yield
1306
-
1307
- while true
1308
- work_start = Time.now
1309
- value = tlm_variable(target_name, packet_name, item_name, value_type)
1310
- if eval(exp_to_eval)
1311
- return true, value
1312
- end
1313
- break if Time.now >= end_time || $cmd_tlm_disconnect
1314
-
1315
- delta = Time.now - work_start
1316
- sleep_time = polling_rate - delta
1317
- end_delta = end_time - Time.now
1318
- sleep_time = end_delta if end_delta < sleep_time
1319
- sleep_time = 0 if sleep_time < 0
1320
- canceled = cosmos_script_sleep(sleep_time)
1321
-
1322
- if canceled
1323
- value = tlm_variable(target_name, packet_name, item_name, value_type)
1324
- if eval(exp_to_eval)
1325
- return true, value
1326
- else
1327
- return false, value
1328
- end
1329
- end
1330
- end
1331
-
1332
- return false, value
1333
- end
1334
-
1335
- # Wait for a converted telemetry item to pass a comparison
1336
- def cosmos_script_wait_implementation(target_name, packet_name, item_name, value_type, comparison_to_eval, timeout, polling_rate = DEFAULT_TLM_POLLING_RATE)
1337
- _cosmos_script_wait_implementation(target_name, packet_name, item_name, value_type, timeout, polling_rate) do
1338
- "value " + comparison_to_eval
1339
- end
1340
- end
1341
-
1342
- def cosmos_script_wait_implementation_tolerance(target_name, packet_name, item_name, value_type, expected_value, tolerance, timeout, polling_rate = DEFAULT_TLM_POLLING_RATE)
1343
- _cosmos_script_wait_implementation(target_name, packet_name, item_name, value_type, timeout, polling_rate) do
1344
- "((#{expected_value} - #{tolerance})..(#{expected_value} + #{tolerance})).include? value"
1345
- end
1346
- end
1347
-
1348
- # Wait on an expression to be true.
1349
- def cosmos_script_wait_implementation_expression(exp_to_eval, timeout, polling_rate, context)
1350
- end_time = Time.now + timeout
1351
- context = ScriptRunnerFrame.instance.script_binding if !context and defined? ScriptRunnerFrame and ScriptRunnerFrame.instance
1352
-
1353
- while true
1354
- work_start = Time.now
1355
- if eval(exp_to_eval, context)
1356
- return true
1357
- end
1358
- break if Time.now >= end_time
1359
-
1360
- delta = Time.now - work_start
1361
- sleep_time = polling_rate - delta
1362
- end_delta = end_time - Time.now
1363
- sleep_time = end_delta if end_delta < sleep_time
1364
- sleep_time = 0 if sleep_time < 0
1365
- canceled = cosmos_script_sleep(sleep_time)
1366
-
1367
- if canceled
1368
- if eval(exp_to_eval, context)
1369
- return true
1370
- else
1371
- return nil
1372
- end
1373
- end
1374
- end
1375
-
1376
- return nil
1377
- end
1378
-
1379
- def check_eval(target_name, packet_name, item_name, comparison_to_eval, value)
1380
- string = "value " + comparison_to_eval
1381
- if eval(string)
1382
- Logger.info "CHECK: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} #{comparison_to_eval} success with value == #{value}"
1383
- else
1384
- message = "CHECK: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} #{comparison_to_eval} failed with value == #{value}"
1385
- if $cmd_tlm_disconnect
1386
- Logger.error message
1387
- else
1388
- raise CheckError, message
1389
- end
1390
- end
1391
- end
1392
-
1393
- def build_cmd_output_string(target_name, cmd_name, cmd_params, raw = false)
1394
- if raw
1395
- output_string = 'cmd_raw("'
1396
- else
1397
- output_string = 'cmd("'
1398
- end
1399
- output_string << target_name + ' ' + cmd_name
1400
- if cmd_params.nil? or cmd_params.empty?
1401
- output_string += '")'
1402
- else
1403
- params = []
1404
- cmd_params.each do |key, value|
1405
- if value.class == String
1406
- if value.convert_to_value.class == String
1407
- value = value.inspect
1408
- if value.length > 256
1409
- value = value[0..255] + "...'"
1410
- end
1411
- value.gsub!('"',"'")
1412
- end
1413
- end
1414
- params << "#{key} #{value}"
1415
- end
1416
- params = params.join(", ")
1417
- output_string += ' with ' + params + '")'
1418
- end
1419
- return output_string
1420
- end
1421
-
1422
- def prompt_for_hazardous(target_name, cmd_name, hazardous_description)
1423
- message = "Warning: Command #{target_name} #{cmd_name} is Hazardous. "
1424
- message << "\n#{hazardous_description}\n" if hazardous_description
1425
- message << "Send? (y,n): "
1426
- print message
1427
- answer = gets.chomp
1428
- if answer.downcase == 'y'
1429
- return true
1430
- else
1431
- return false
1432
- end
1433
- end
1434
-
1435
- def prompt_for_script_abort
1436
- print "Stop running script? (y,n): "
1437
- answer = gets.chomp
1438
- if answer.downcase == 'y'
1439
- exit
1440
- else
1441
- return false
1442
- end
1443
- end
1444
-
1445
- def prompt_to_continue(string)
1446
- print "#{string}: "
1447
- gets.chomp
1448
- end
1449
-
1450
- def prompt_message_box(string, buttons)
1451
- print "#{string} (#{buttons.join(", ")}): "
1452
- gets.chomp
1453
- end
1454
-
1455
- ################################
1456
- # Module setup and config
1457
- ################################
1458
-
1459
- def set_cmd_tlm_disconnect(disconnect = false, config_file = CmdTlmServer::DEFAULT_CONFIG_FILE)
1460
- if disconnect != $cmd_tlm_disconnect
1461
- $cmd_tlm_disconnect = disconnect
1462
- initialize_script_module(config_file)
1463
- end
1464
- end
1465
-
1466
- def get_cmd_tlm_disconnect
1467
- return $cmd_tlm_disconnect
1468
- end
1469
-
1470
- def initialize_script_module(config_file = CmdTlmServer::DEFAULT_CONFIG_FILE)
1471
- if $cmd_tlm_disconnect
1472
- # Start up a standalone CTS in disconnected mode
1473
- $cmd_tlm_server = CmdTlmServer.new(config_file, false, true)
1474
- else
1475
- # Start a Json connect to the real CTS server
1476
- $cmd_tlm_server = JsonDRbObject.new('127.0.0.1', System.ports['CTS_API'])
1477
- end
1478
- end
1479
-
1480
- def self.included(base)
1481
- $cmd_tlm_disconnect = false
1482
- $cmd_tlm_server = nil
1483
- initialize_script_module()
1484
- end
1485
-
1486
- def shutdown_cmd_tlm
1487
- $cmd_tlm_server.disconnect if $cmd_tlm_server && !$cmd_tlm_disconnect
1488
- $cmd_tlm_server = nil
1489
- end
1490
-
1491
- end # module Script
1492
-
1493
- end # module Cosmos
1
+ # encoding: ascii-8bit
2
+
3
+ # Copyright 2014 Ball Aerospace & Technologies Corp.
4
+ # All Rights Reserved.
5
+ #
6
+ # This program is free software; you can modify and/or redistribute it
7
+ # under the terms of the GNU General Public License
8
+ # as published by the Free Software Foundation; version 3 with
9
+ # attribution addendums as found in the LICENSE.txt
10
+
11
+ require 'cosmos'
12
+ require 'cosmos/io/json_drb_object'
13
+ require 'cosmos/tools/cmd_tlm_server/cmd_tlm_server'
14
+ require 'cosmos/script/extract'
15
+
16
+ $cmd_tlm_server = nil
17
+ $cmd_tlm_disconnect = false
18
+
19
+ module Cosmos
20
+ class CheckError < RuntimeError; end
21
+ class StopScript < StandardError; end
22
+ class SkipTestCase < StandardError; end
23
+
24
+ module Script
25
+ DEFAULT_TLM_POLLING_RATE = 0.25
26
+
27
+ private
28
+
29
+ include Extract
30
+
31
+ #######################################
32
+ # Methods accessing cmd_tlm_server
33
+ #######################################
34
+
35
+ #
36
+ # Methods involving commands
37
+ #
38
+
39
+ # Send a command to the specified target
40
+ # Supports two signatures:
41
+ # cmd(target_name, cmd_name, cmd_params = {})
42
+ # or
43
+ # cmd('target_name cmd_name with cmd_param1 value1, cmd_param2 value2')
44
+ def cmd(*args)
45
+ begin
46
+ target_name, cmd_name, cmd_params = $cmd_tlm_server.cmd(*args)
47
+ Logger.info build_cmd_output_string(target_name, cmd_name, cmd_params)
48
+ rescue HazardousError => e
49
+ ok_to_proceed = prompt_for_hazardous(e.target_name,
50
+ e.cmd_name,
51
+ e.hazardous_description)
52
+ if ok_to_proceed
53
+ target_name, cmd_name, cmd_params =
54
+ $cmd_tlm_server.cmd_no_hazardous_check(*args)
55
+ Logger.info build_cmd_output_string(target_name, cmd_name, cmd_params)
56
+ else
57
+ Logger.warn "Hazardous command not sent"
58
+ prompt_for_script_abort
59
+ end
60
+ end
61
+ end
62
+
63
+ # Send a command to the specified target without range checking parameters
64
+ # Supports two signatures:
65
+ # cmd_no_range_check(target_name, cmd_name, cmd_params = {})
66
+ # or
67
+ # cmd_no_range_check('target_name cmd_name with cmd_param1 value1, cmd_param2 value2')
68
+ def cmd_no_range_check(*args)
69
+ begin
70
+ target_name, cmd_name, cmd_params = $cmd_tlm_server.cmd_no_range_check(*args)
71
+ Logger.warn "Command #{target_name} #{cmd_name} being sent ignoring range checks"
72
+ Logger.info build_cmd_output_string(target_name, cmd_name, cmd_params)
73
+ rescue HazardousError => e
74
+ ok_to_proceed = prompt_for_hazardous(e.target_name,
75
+ e.cmd_name,
76
+ e.hazardous_description)
77
+ if ok_to_proceed
78
+ target_name, cmd_name, cmd_params = $cmd_tlm_server.cmd_no_checks(*args)
79
+ Logger.warn "Command #{target_name} #{cmd_name} being sent ignoring range checks"
80
+ Logger.info build_cmd_output_string(target_name, cmd_name, cmd_params)
81
+ else
82
+ Logger.warn "Hazardous command not sent"
83
+ prompt_for_script_abort
84
+ end
85
+ end
86
+ end
87
+
88
+ # Send a command to the specified target without hazardous checks
89
+ # Supports two signatures:
90
+ # cmd_no_hazardous_check(target_name, cmd_name, cmd_params = {})
91
+ # or
92
+ # cmd_no_hazardous_check('target_name cmd_name with cmd_param1 value1, cmd_param2 value2')
93
+ def cmd_no_hazardous_check(*args)
94
+ target_name, cmd_name, cmd_params = $cmd_tlm_server.cmd_no_hazardous_check(*args)
95
+ Logger.warn "Command #{target_name} #{cmd_name} being sent ignoring hazardous warnings"
96
+ Logger.info build_cmd_output_string(target_name, cmd_name, cmd_params)
97
+ end
98
+
99
+ # Send a command to the specified target without range checking or hazardous checks
100
+ # Supports two signatures:
101
+ # cmd_no_checks(target_name, cmd_name, cmd_params = {})
102
+ # or
103
+ # cmd_no_checks('target_name cmd_name with cmd_param1 value1, cmd_param2 value2')
104
+ def cmd_no_checks(*args)
105
+ target_name, cmd_name, cmd_params = $cmd_tlm_server.cmd_no_checks(*args)
106
+ Logger.warn "Command #{target_name} #{cmd_name} being sent ignoring range checks"
107
+ Logger.warn "Command #{target_name} #{cmd_name} being sent ignoring hazardous warnings"
108
+ Logger.info build_cmd_output_string(target_name, cmd_name, cmd_params)
109
+ end
110
+
111
+ # Send a command to the specified target without running conversions
112
+ # Supports two signatures:
113
+ # cmd_raw(target_name, cmd_name, cmd_params = {})
114
+ # or
115
+ # cmd_raw('target_name cmd_name with cmd_param1 value1, cmd_param2 value2')
116
+ def cmd_raw(*args)
117
+ begin
118
+ target_name, cmd_name, cmd_params = $cmd_tlm_server.cmd_raw(*args)
119
+ Logger.info build_cmd_output_string(target_name, cmd_name, cmd_params, true)
120
+ rescue HazardousError => e
121
+ ok_to_proceed = prompt_for_hazardous(e.target_name,
122
+ e.cmd_name,
123
+ e.hazardous_description)
124
+ if ok_to_proceed
125
+ target_name, cmd_name, cmd_params =
126
+ $cmd_tlm_server.cmd_raw_no_hazardous_check(*args)
127
+ Logger.info build_cmd_output_string(target_name, cmd_name, cmd_params, true)
128
+ else
129
+ Logger.warn "Hazardous command not sent"
130
+ prompt_for_script_abort
131
+ end
132
+ end
133
+ end
134
+
135
+ # Send a command to the specified target without range checking parameters or running conversions
136
+ # Supports two signatures:
137
+ # cmd_raw_no_range_check(target_name, cmd_name, cmd_params = {})
138
+ # or
139
+ # cmd_raw_no_range_check('target_name cmd_name with cmd_param1 value1, cmd_param2 value2')
140
+ def cmd_raw_no_range_check(*args)
141
+ begin
142
+ target_name, cmd_name, cmd_params = $cmd_tlm_server.cmd_raw_no_range_check(*args)
143
+ Logger.warn "Command #{target_name} #{cmd_name} being sent ignoring range checks"
144
+ Logger.info build_cmd_output_string(target_name, cmd_name, cmd_params, true)
145
+ rescue HazardousError => e
146
+ ok_to_proceed = prompt_for_hazardous(e.target_name,
147
+ e.cmd_name,
148
+ e.hazardous_description)
149
+ if ok_to_proceed
150
+ target_name, cmd_name, cmd_params = $cmd_tlm_server.cmd_raw_no_checks(*args)
151
+ Logger.warn "Command #{target_name} #{cmd_name} being sent ignoring range checks"
152
+ Logger.info build_cmd_output_string(target_name, cmd_name, cmd_params, true)
153
+ else
154
+ Logger.warn "Hazardous command not sent"
155
+ prompt_for_script_abort
156
+ end
157
+ end
158
+ end
159
+
160
+ # Send a command to the specified target without hazardous checks or running conversions
161
+ # Supports two signatures:
162
+ # cmd_raw_no_hazardous_check(target_name, cmd_name, cmd_params = {})
163
+ # or
164
+ # cmd_raw_no_hazardous_check('target_name cmd_name with cmd_param1 value1, cmd_param2 value2')
165
+ def cmd_raw_no_hazardous_check(*args)
166
+ target_name, cmd_name, cmd_params = $cmd_tlm_server.cmd_raw_no_hazardous_check(*args)
167
+ Logger.warn "Command #{target_name} #{cmd_name} being sent ignoring hazardous warnings"
168
+ Logger.info build_cmd_output_string(target_name, cmd_name, cmd_params, true)
169
+ end
170
+
171
+ # Send a command to the specified target without range checking or hazardous checks or running conversions
172
+ # Supports two signatures:
173
+ # cmd_raw_no_checks(target_name, cmd_name, cmd_params = {})
174
+ # or
175
+ # cmd_raw_no_checks('target_name cmd_name with cmd_param1 value1, cmd_param2 value2')
176
+ def cmd_raw_no_checks(*args)
177
+ target_name, cmd_name, cmd_params = $cmd_tlm_server.cmd_raw_no_checks(*args)
178
+ Logger.warn "Command #{target_name} #{cmd_name} being sent ignoring range checks"
179
+ Logger.warn "Command #{target_name} #{cmd_name} being sent ignoring hazardous warnings"
180
+ Logger.info build_cmd_output_string(target_name, cmd_name, cmd_params, true)
181
+ end
182
+
183
+ # Sends raw data through an interface
184
+ def send_raw(interface_name, data)
185
+ return $cmd_tlm_server.send_raw(interface_name, data)
186
+ end
187
+
188
+ # Sends raw data through an interface from a file
189
+ def send_raw_file(interface_name, filename)
190
+ data = nil
191
+ File.open(filename, 'rb') {|file| data = file.read}
192
+ return $cmd_tlm_server.send_raw(interface_name, data)
193
+ end
194
+
195
+ def get_cmd_list(target_name)
196
+ return $cmd_tlm_server.get_cmd_list(target_name)
197
+ end
198
+
199
+ def get_cmd_param_list(target_name, cmd_name)
200
+ return $cmd_tlm_server.get_cmd_param_list(target_name, cmd_name)
201
+ end
202
+
203
+ def get_cmd_hazardous(target_name, cmd_name, cmd_params = {})
204
+ return $cmd_tlm_server.get_cmd_hazardous(target_name, cmd_name, cmd_params)
205
+ end
206
+
207
+ #
208
+ # Methods involving telemetry
209
+ #
210
+
211
+ # Poll for the converted value of a telemetry item
212
+ # Supports two signatures:
213
+ # tlm(target_name, packet_name, item_name)
214
+ # or
215
+ # tlm('target_name packet_name item_name')
216
+ def tlm(*args)
217
+ return $cmd_tlm_server.tlm(*args)
218
+ end
219
+
220
+ # Poll for the raw value of a telemetry item
221
+ # Supports two signatures:
222
+ # tlm_raw(target_name, packet_name, item_name)
223
+ # or
224
+ # tlm_raw('target_name packet_name item_name')
225
+ def tlm_raw(*args)
226
+ return $cmd_tlm_server.tlm_raw(*args)
227
+ end
228
+
229
+ # Poll for the formatted value of a telemetry item
230
+ # Supports two signatures:
231
+ # tlm_formatted(target_name, packet_name, item_name)
232
+ # or
233
+ # tlm_formatted('target_name packet_name item_name')
234
+ def tlm_formatted(*args)
235
+ return $cmd_tlm_server.tlm_formatted(*args)
236
+ end
237
+
238
+ # Poll for the formatted with units value of a telemetry item
239
+ # Supports two signatures:
240
+ # tlm_with_units(target_name, packet_name, item_name)
241
+ # or
242
+ # tlm_with_units('target_name packet_name item_name')
243
+ def tlm_with_units(*args)
244
+ return $cmd_tlm_server.tlm_with_units(*args)
245
+ end
246
+
247
+ def tlm_variable(*args)
248
+ return $cmd_tlm_server.tlm_variable(*args)
249
+ end
250
+
251
+ # Set a telemetry point
252
+ def set_tlm(*args)
253
+ return $cmd_tlm_server.set_tlm(*args)
254
+ end
255
+
256
+ # Set the raw value of a telemetry point
257
+ def set_tlm_raw(*args)
258
+ return $cmd_tlm_server.set_tlm_raw(*args)
259
+ end
260
+
261
+ def get_tlm_packet(target_name, packet_name, value_types = :CONVERTED)
262
+ result = $cmd_tlm_server.get_tlm_packet(target_name, packet_name, value_types)
263
+ result.each do |entry|
264
+ entry[2] = entry[2].to_s.intern if entry[2]
265
+ end
266
+ result
267
+ end
268
+
269
+ def get_tlm_values(items, value_types = :CONVERTED)
270
+ result = $cmd_tlm_server.get_tlm_values(items, value_types)
271
+ result[1].length.times do |index|
272
+ result[1][index] = result[1][index].to_s.intern if result[1][index]
273
+ end
274
+ result[3] = result[3].to_s.intern
275
+ result
276
+ end
277
+
278
+ def get_tlm_list(target_name)
279
+ return $cmd_tlm_server.get_tlm_list(target_name)
280
+ end
281
+
282
+ def get_tlm_item_list(target_name, packet_name)
283
+ return $cmd_tlm_server.get_tlm_item_list(target_name, packet_name)
284
+ end
285
+
286
+ def get_tlm_details(items)
287
+ $cmd_tlm_server.get_tlm_details(items)
288
+ end
289
+
290
+ def get_out_of_limits
291
+ result = $cmd_tlm_server.get_out_of_limits
292
+ result.each do |entry|
293
+ entry[3] = entry[3].to_s.intern if entry[3]
294
+ end
295
+ result
296
+ end
297
+
298
+ def get_overall_limits_state (ignored_items = nil)
299
+ return $cmd_tlm_server.get_overall_limits_state(ignored_items).to_s.intern
300
+ end
301
+
302
+ def limits_enabled?(*args)
303
+ return $cmd_tlm_server.limits_enabled?(*args)
304
+ end
305
+
306
+ def enable_limits(*args)
307
+ return $cmd_tlm_server.enable_limits(*args)
308
+ end
309
+
310
+ def disable_limits(*args)
311
+ return $cmd_tlm_server.disable_limits(*args)
312
+ end
313
+
314
+ def get_limits(target_name, packet_name, item_name, limits_set = nil)
315
+ results = $cmd_tlm_server.get_limits(target_name, packet_name, item_name, limits_set)
316
+ results[0] = results[0].to_s.intern if results[0]
317
+ return results
318
+ end
319
+
320
+ def set_limits(target_name, packet_name, item_name, red_low, yellow_low, yellow_high, red_high, green_low = nil, green_high = nil, limits_set = :CUSTOM, persistence = nil, enabled = true)
321
+ results = $cmd_tlm_server.set_limits(target_name, packet_name, item_name, red_low, yellow_low, yellow_high, red_high, green_low, green_high, limits_set, persistence, enabled)
322
+ results[0] = results[0].to_s.intern if results[0]
323
+ return results
324
+ end
325
+
326
+ def get_limits_groups
327
+ return $cmd_tlm_server.get_limits_groups
328
+ end
329
+
330
+ def enable_limits_group(group_name)
331
+ return $cmd_tlm_server.enable_limits_group(group_name)
332
+ end
333
+
334
+ def disable_limits_group(group_name)
335
+ return $cmd_tlm_server.disable_limits_group(group_name)
336
+ end
337
+
338
+ def get_limits_sets
339
+ result = $cmd_tlm_server.get_limits_sets
340
+ result.each_with_index do |limits_set, index|
341
+ result[index] = limits_set.to_s.intern
342
+ end
343
+ return result
344
+ end
345
+
346
+ def set_limits_set(limits_set)
347
+ return $cmd_tlm_server.set_limits_set(limits_set)
348
+ end
349
+
350
+ def get_limits_set
351
+ result = $cmd_tlm_server.get_limits_set
352
+ # Limits sets are always represented as symbols
353
+ result.to_s.intern
354
+ end
355
+
356
+ #
357
+ # General Purpose Methods
358
+ #
359
+
360
+ def get_target_list
361
+ return $cmd_tlm_server.get_target_list
362
+ end
363
+
364
+ def subscribe_limits_events(queue_size = CmdTlmServer::DEFAULT_LIMITS_EVENT_QUEUE_SIZE)
365
+ return $cmd_tlm_server.subscribe_limits_events(queue_size)
366
+ end
367
+
368
+ def unsubscribe_limits_events(id)
369
+ return $cmd_tlm_server.unsubscribe_limits_events(id)
370
+ end
371
+
372
+ def get_limits_event(id, non_block = false)
373
+ result = $cmd_tlm_server.get_limits_event(id, non_block)
374
+ if result
375
+ result[0] = result[0].to_s.intern
376
+ if result[0] == :LIMITS_CHANGE
377
+ result[1][3] = result[1][3].to_s.intern if result[1][3]
378
+ result[1][4] = result[1][4].to_s.intern if result[1][4]
379
+ elsif result[0] == :LIMITS_SETTINGS
380
+ result[1][3] = result[1][3].to_s.intern if result[1][3]
381
+ else
382
+ result[1] = result[1].to_s.intern
383
+ end
384
+ end
385
+ result
386
+ end
387
+
388
+ def subscribe_packet_data(packets, queue_size = CmdTlmServer::DEFAULT_PACKET_DATA_QUEUE_SIZE)
389
+ result = $cmd_tlm_server.subscribe_packet_data(packets, queue_size)
390
+ result
391
+ end
392
+
393
+ def unsubscribe_packet_data(id)
394
+ result = $cmd_tlm_server.unsubscribe_packet_data(id)
395
+ result
396
+ end
397
+
398
+ def get_packet_data(id, non_block = false)
399
+ results = $cmd_tlm_server.get_packet_data(id, non_block)
400
+ if Array === results and results[3] and results[4]
401
+ results[3] = Time.at(results[3], results[4])
402
+ results.delete_at(4)
403
+ end
404
+ results
405
+ end
406
+
407
+ def get_packet(id, non_block = false)
408
+ packet = nil
409
+ buffer, target_name, packet_name, received_time, received_count = get_packet_data(id, non_block)
410
+ if buffer
411
+ packet = System.telemetry.packet(target_name, packet_name).clone
412
+ packet.buffer = buffer
413
+ packet.received_time = received_time
414
+ packet.received_count = received_count
415
+ end
416
+ packet
417
+ end
418
+
419
+ #
420
+ # Methods for scripting
421
+ #
422
+
423
+ def play_wav_file(wav_filename)
424
+ if defined? Qt
425
+ Qt.execute_in_main_thread(true) do
426
+ if Qt::CoreApplication.instance and Qt::Sound.isAvailable
427
+ Cosmos.set_working_dir do
428
+ Qt::Sound.play(wav_filename.to_s)
429
+ end
430
+ end
431
+ end
432
+ end
433
+ end
434
+
435
+ def status_bar(message)
436
+ script_runner = nil
437
+ ObjectSpace.each_object {|object| if ScriptRunner === object then script_runner = object; break; end}
438
+ script_runner.script_set_status(message) if script_runner
439
+ end
440
+
441
+ def ask_string(question, allow_blank = false)
442
+ answer = ''
443
+ while answer.empty?
444
+ print question + " "
445
+ answer = gets
446
+ answer.chomp!
447
+ break if allow_blank
448
+ end
449
+ return answer
450
+ end
451
+
452
+ def ask(question, allow_blank = false)
453
+ string = ask_string(question, allow_blank)
454
+ value = string.convert_to_value
455
+ return value
456
+ end
457
+
458
+ def prompt(string)
459
+ prompt_to_continue(string)
460
+ end
461
+
462
+ def message_box(string, *buttons)
463
+ prompt_message_box(string, buttons)
464
+ end
465
+
466
+ def _check(*args)
467
+ target_name, packet_name, item_name, comparison_to_eval =
468
+ check_process_args(args, 'check')
469
+ value = yield(target_name, packet_name, item_name)
470
+ if comparison_to_eval
471
+ check_eval(target_name, packet_name, item_name, comparison_to_eval, value)
472
+ else
473
+ Logger.info "CHECK: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} == #{value}"
474
+ end
475
+ end
476
+
477
+ # Check the converted value of a telmetry item against a condition
478
+ # Always print the value of the telemetry item to STDOUT
479
+ # If the condition check fails, raise an error
480
+ # Supports two signatures:
481
+ # check(target_name, packet_name, item_name, comparison_to_eval)
482
+ # or
483
+ # check('target_name packet_name item_name > 1')
484
+ def check(*args)
485
+ _check(*args) {|tgt,pkt,item| tlm(tgt,pkt,item) }
486
+ end
487
+
488
+ # Check the formatted value of a telmetry item against a condition
489
+ # Always print the value of the telemetry item to STDOUT
490
+ # If the condition check fails, raise an error
491
+ # Supports two signatures:
492
+ # check(target_name, packet_name, item_name, comparison_to_eval)
493
+ # or
494
+ # check('target_name packet_name item_name > 1')
495
+ def check_formatted(*args)
496
+ _check(*args) {|tgt,pkt,item| tlm_formatted(tgt,pkt,item) }
497
+ end
498
+
499
+ # Check the formatted with units value of a telmetry item against a condition
500
+ # Always print the value of the telemetry item to STDOUT
501
+ # If the condition check fails, raise an error
502
+ # Supports two signatures:
503
+ # check(target_name, packet_name, item_name, comparison_to_eval)
504
+ # or
505
+ # check('target_name packet_name item_name > 1')
506
+ def check_with_units(*args)
507
+ _check(*args) {|tgt,pkt,item| tlm_with_units(tgt,pkt,item) }
508
+ end
509
+
510
+ # Check the raw value of a telmetry item against a condition
511
+ # Always print the value of the telemetry item to STDOUT
512
+ # If the condition check fails, raise an error
513
+ # Supports two signatures:
514
+ # check(target_name, packet_name, item_name, comparison_to_eval)
515
+ # or
516
+ # check('target_name packet_name item_name > 1')
517
+ def check_raw(*args)
518
+ _check(*args) {|tgt,pkt,item| tlm_raw(tgt,pkt,item) }
519
+ end
520
+
521
+ def _check_tolerance(*args)
522
+ target_name, packet_name, item_name, expected_value, tolerance =
523
+ check_tolerance_process_args(args, 'check_tolerance')
524
+ value = yield(target_name, packet_name, item_name)
525
+ range = (expected_value - tolerance)..(expected_value + tolerance)
526
+ if range.include?(value)
527
+ Logger.info "CHECK: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} was within range #{range.first} to #{range.last} with value == #{value}"
528
+ else
529
+ message = "CHECK: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} failed to be within range #{range.first} to #{range.last} with value == #{value}"
530
+ if $cmd_tlm_disconnect
531
+ Logger.error message
532
+ else
533
+ raise CheckError, message
534
+ end
535
+ end
536
+ end
537
+
538
+ # Check the converted value of a telmetry item against an expected value with a tolerance
539
+ # Always print the value of the telemetry item to STDOUT
540
+ # If the condition check fails, raise an error
541
+ # Supports two signatures:
542
+ # check_tolerance(target_name, packet_name, item_name, expected_value, tolerance)
543
+ # or
544
+ # check_tolerance('target_name packet_name item_name', expected_value, tolerance)
545
+ def check_tolerance(*args)
546
+ _check_tolerance(*args) {|tgt,pkt,item| tlm(tgt,pkt,item) }
547
+ end
548
+
549
+ # Check the raw value of a telmetry item against an expected value with a tolerance
550
+ # Always print the value of the telemetry item to STDOUT
551
+ # If the condition check fails, raise an error
552
+ # Supports two signatures:
553
+ # check_tolerance_raw(target_name, packet_name, item_name, expected_value, tolerance)
554
+ # or
555
+ # check_tolerance_raw('target_name packet_name item_name', expected_value, tolerance)
556
+ def check_tolerance_raw(*args)
557
+ _check_tolerance(*args) {|tgt,pkt,item| tlm_raw(tgt,pkt,item) }
558
+ end
559
+
560
+ # Check to see if an expression is true without waiting. If the expression
561
+ # is not true, the script will pause.
562
+ def check_expression(exp_to_eval, context = nil)
563
+ success = cosmos_script_wait_implementation_expression(exp_to_eval, 0, DEFAULT_TLM_POLLING_RATE, context)
564
+ if success
565
+ Logger.info "CHECK: #{exp_to_eval} is TRUE"
566
+ else
567
+ message = "CHECK: #{exp_to_eval} is FALSE"
568
+ if $cmd_tlm_disconnect
569
+ Logger.error message
570
+ else
571
+ raise CheckError, message
572
+ end
573
+ end
574
+ end
575
+
576
+ # Wait on an expression to be true. On a timeout, the script will continue.
577
+ # Supports multiple signatures:
578
+ # wait(time)
579
+ # wait('target_name packet_name item_name > 1', timeout, polling_rate)
580
+ # wait('target_name', 'packet_name', 'item_name', comparison_to_eval, timeout, polling_rate)
581
+ def wait(*args)
582
+ wait_process_args(args, 'wait', :CONVERTED)
583
+ end
584
+
585
+ # Wait on an expression to be true. On a timeout, the script will continue.
586
+ # Supports multiple signatures:
587
+ # wait(time)
588
+ # wait_raw('target_name packet_name item_name > 1', timeout, polling_rate)
589
+ # wait_raw('target_name', 'packet_name', 'item_name', comparison_to_eval, timeout, polling_rate)
590
+ def wait_raw(*args)
591
+ wait_process_args(args, 'wait_raw', :RAW)
592
+ end
593
+
594
+ def _wait_tolerance(raw, *args)
595
+ type = (raw ? :RAW : :CONVERTED)
596
+ type_string = 'wait_tolerance'
597
+ type_string += '_raw' if raw
598
+ target_name, packet_name, item_name, expected_value, tolerance, timeout, polling_rate = wait_tolerance_process_args(args, type_string)
599
+ start_time = Time.now
600
+ success, value = cosmos_script_wait_implementation_tolerance(target_name, packet_name, item_name, type, expected_value, tolerance, timeout, polling_rate)
601
+ time = Time.now - start_time
602
+ range = (expected_value - tolerance)..(expected_value + tolerance)
603
+ if success
604
+ Logger.info "WAIT: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} was within range #{range.first} to #{range.last} with value == #{value} after waiting #{time} seconds"
605
+ else
606
+ Logger.warn "WAIT: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} failed to be within range #{range.first} to #{range.last} with value == #{value} after waiting #{time} seconds"
607
+ end
608
+ time
609
+ end
610
+
611
+ # Wait on an expression to be true. On a timeout, the script will continue.
612
+ # Supports multiple signatures:
613
+ # wait_tolerance('target_name packet_name item_name', expected_value, tolerance, timeout, polling_rate)
614
+ # wait_tolerance('target_name', 'packet_name', 'item_name', expected_value, tolerance, timeout, polling_rate)
615
+ def wait_tolerance(*args)
616
+ _wait_tolerance(false, *args)
617
+ end
618
+
619
+ # Wait on an expression to be true. On a timeout, the script will continue.
620
+ # Supports multiple signatures:
621
+ # wait_tolerance_raw('target_name packet_name item_name', expected_value, tolerance, timeout, polling_rate)
622
+ # wait_tolerance_raw('target_name', 'packet_name', 'item_name', expected_value, tolerance, timeout, polling_rate)
623
+ def wait_tolerance_raw(*args)
624
+ _wait_tolerance(true, *args)
625
+ end
626
+
627
+ # Wait on a custom expression to be true
628
+ def wait_expression(exp_to_eval, timeout, polling_rate = DEFAULT_TLM_POLLING_RATE, context = nil)
629
+ start_time = Time.now
630
+ success = cosmos_script_wait_implementation_expression(exp_to_eval, timeout, polling_rate, context)
631
+ time = Time.now - start_time
632
+ if success
633
+ Logger.info "WAIT: #{exp_to_eval} is TRUE after waiting #{time} seconds"
634
+ else
635
+ Logger.warn "WAIT: #{exp_to_eval} is FALSE after waiting #{time} seconds"
636
+ end
637
+ time
638
+ end
639
+
640
+ def _wait_check(raw, *args)
641
+ type = (raw ? :RAW : :CONVERTED)
642
+ target_name, packet_name, item_name, comparison_to_eval, timeout, polling_rate = wait_check_process_args(args, 'wait_check')
643
+ start_time = Time.now
644
+ success, value = cosmos_script_wait_implementation(target_name, packet_name, item_name, type, comparison_to_eval, timeout, polling_rate)
645
+ time = Time.now - start_time
646
+ if success
647
+ Logger.info "CHECK: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} #{comparison_to_eval} success with value == #{value} after waiting #{time} seconds"
648
+ else
649
+ message = "CHECK: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} #{comparison_to_eval} failed with value == #{value} after waiting #{time} seconds"
650
+ if $cmd_tlm_disconnect
651
+ Logger.error message
652
+ else
653
+ raise CheckError, message
654
+ end
655
+ end
656
+ time
657
+ end
658
+
659
+ # Wait for the converted value of a telmetry item against a condition or for a timeout
660
+ # and then check against the condition
661
+ # Supports two signatures:
662
+ # wait_check(target_name, packet_name, item_name, comparison_to_eval, timeout, polling_rate)
663
+ # or
664
+ # wait_check('target_name packet_name item_name > 1', timeout, polling_rate)
665
+ def wait_check(*args)
666
+ _wait_check(false, *args)
667
+ end
668
+
669
+ # Wait for the raw value of a telmetry item against a condition or for a timeout
670
+ # and then check against the condition
671
+ # Supports two signatures:
672
+ # wait_check_raw(target_name, packet_name, item_name, comparison_to_eval, timeout, polling_rate)
673
+ # or
674
+ # wait_check_raw('target_name packet_name item_name > 1', timeout, polling_rate)
675
+ def wait_check_raw(*args)
676
+ _wait_check(true, *args)
677
+ end
678
+
679
+ def _wait_check_tolerance(raw, *args)
680
+ type_string = 'wait_check_tolerance'
681
+ type_string += '_raw' if raw
682
+ type = (raw ? :RAW : :CONVERTED)
683
+ target_name, packet_name, item_name, expected_value, tolerance, timeout, polling_rate = wait_tolerance_process_args(args, type_string)
684
+ start_time = Time.now
685
+ success, value = cosmos_script_wait_implementation_tolerance(target_name, packet_name, item_name, type, expected_value, tolerance, timeout, polling_rate)
686
+ time = Time.now - start_time
687
+ range = (expected_value - tolerance)..(expected_value + tolerance)
688
+ if success
689
+ Logger.info "CHECK: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} was within range #{range.first} to #{range.last} with value == #{value} after waiting #{time} seconds"
690
+ else
691
+ message = "CHECK: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} failed to be within range #{range.first} to #{range.last} with value == #{value} after waiting #{time} seconds"
692
+ if $cmd_tlm_disconnect
693
+ Logger.error message
694
+ else
695
+ raise CheckError, message
696
+ end
697
+ end
698
+ time
699
+ end
700
+
701
+ def wait_check_tolerance(*args)
702
+ _wait_check_tolerance(false, *args)
703
+ end
704
+
705
+ def wait_check_tolerance_raw(*args)
706
+ _wait_check_tolerance(true, *args)
707
+ end
708
+
709
+ # Wait on an expression to be true. On a timeout, the script will pause.
710
+ def wait_check_expression(exp_to_eval,
711
+ timeout,
712
+ polling_rate = DEFAULT_TLM_POLLING_RATE,
713
+ context = nil)
714
+ start_time = Time.now
715
+ success = cosmos_script_wait_implementation_expression(exp_to_eval,
716
+ timeout,
717
+ polling_rate,
718
+ context)
719
+ time = Time.now - start_time
720
+ if success
721
+ Logger.info "CHECK: #{exp_to_eval} is TRUE after waiting #{time} seconds"
722
+ else
723
+ message = "CHECK: #{exp_to_eval} is FALSE after waiting #{time} seconds"
724
+ if $cmd_tlm_disconnect
725
+ Logger.error message
726
+ else
727
+ raise CheckError, message
728
+ end
729
+ end
730
+ time
731
+ end
732
+ alias wait_expression_stop_on_timeout wait_check_expression
733
+
734
+ # Wait for a telemetry packet to be received a certain number of times or timeout
735
+ def _wait_packet(check,
736
+ target_name,
737
+ packet_name,
738
+ num_packets,
739
+ timeout,
740
+ polling_rate = DEFAULT_TLM_POLLING_RATE)
741
+ type = (check ? 'CHECK' : 'WAIT')
742
+ initial_count = tlm(target_name, packet_name, 'RECEIVED_COUNT')
743
+ start_time = Time.now
744
+ success, value = cosmos_script_wait_implementation(target_name,
745
+ packet_name,
746
+ 'RECEIVED_COUNT',
747
+ :CONVERTED,
748
+ ">= #{initial_count + num_packets}",
749
+ timeout,
750
+ polling_rate)
751
+ time = Time.now - start_time
752
+ if success
753
+ Logger.info "#{type}: #{target_name.upcase} #{packet_name.upcase} received #{value - initial_count} times after waiting #{time} seconds"
754
+ else
755
+ message = "#{type}: #{target_name.upcase} #{packet_name.upcase} expected to be received #{num_packets} times but only received #{value - initial_count} times after waiting #{time} seconds"
756
+ if check
757
+ if $cmd_tlm_disconnect
758
+ Logger.error message
759
+ else
760
+ raise CheckError, message
761
+ end
762
+ else
763
+ Logger.warn message
764
+ end
765
+ end
766
+ time
767
+ end
768
+
769
+ def wait_packet(target_name,
770
+ packet_name,
771
+ num_packets,
772
+ timeout,
773
+ polling_rate = DEFAULT_TLM_POLLING_RATE)
774
+ _wait_packet(false, target_name, packet_name, num_packets, timeout, polling_rate)
775
+ end
776
+
777
+ # Wait for a telemetry packet to be received a certain number of times or timeout and raise an error
778
+ def wait_check_packet(target_name,
779
+ packet_name,
780
+ num_packets,
781
+ timeout,
782
+ polling_rate = DEFAULT_TLM_POLLING_RATE)
783
+ _wait_packet(true, target_name, packet_name, num_packets, timeout, polling_rate)
784
+ end
785
+
786
+ def get_interface_names
787
+ return $cmd_tlm_server.get_interface_names
788
+ end
789
+
790
+ def connect_interface(interface_name, *params)
791
+ return $cmd_tlm_server.connect_interface(interface_name, *params)
792
+ end
793
+
794
+ def disconnect_interface(interface_name)
795
+ return $cmd_tlm_server.disconnect_interface(interface_name)
796
+ end
797
+
798
+ def interface_state(interface_name)
799
+ return $cmd_tlm_server.interface_state(interface_name)
800
+ end
801
+
802
+ def map_target_to_interface(target_name, interface_name)
803
+ return $cmd_tlm_server.map_target_to_interface(target_name, interface_name)
804
+ end
805
+
806
+ def get_router_names
807
+ return $cmd_tlm_server.get_router_names
808
+ end
809
+
810
+ def connect_router(router_name, *params)
811
+ return $cmd_tlm_server.connect_router(router_name, *params)
812
+ end
813
+
814
+ def disconnect_router(router_name)
815
+ return $cmd_tlm_server.disconnect_router(router_name)
816
+ end
817
+
818
+ def router_state(router_name)
819
+ return $cmd_tlm_server.router_state(router_name)
820
+ end
821
+
822
+ def get_cmd_log_filename(packet_log_writer_name = 'DEFAULT')
823
+ return $cmd_tlm_server.get_cmd_log_filename(packet_log_writer_name)
824
+ end
825
+
826
+ def get_tlm_log_filename(packet_log_writer_name = 'DEFAULT')
827
+ return $cmd_tlm_server.get_tlm_log_filename(packet_log_writer_name)
828
+ end
829
+
830
+ def start_logging(packet_log_writer_name = 'ALL', label = nil)
831
+ return $cmd_tlm_server.start_logging(packet_log_writer_name, label)
832
+ end
833
+
834
+ def stop_logging(packet_log_writer_name = 'ALL')
835
+ return $cmd_tlm_server.stop_logging(packet_log_writer_name)
836
+ end
837
+
838
+ def start_cmd_log(packet_log_writer_name = 'ALL', label = nil)
839
+ return $cmd_tlm_server.start_cmd_log(packet_log_writer_name, label)
840
+ end
841
+
842
+ def start_tlm_log(packet_log_writer_name = 'ALL', label = nil)
843
+ return $cmd_tlm_server.start_tlm_log(packet_log_writer_name, label)
844
+ end
845
+
846
+ def stop_cmd_log(packet_log_writer_name = 'ALL')
847
+ return $cmd_tlm_server.stop_cmd_log(packet_log_writer_name)
848
+ end
849
+
850
+ def stop_tlm_log(packet_log_writer_name = 'ALL')
851
+ return $cmd_tlm_server.stop_tlm_log(packet_log_writer_name)
852
+ end
853
+
854
+ def start_raw_logging_interface(interface_name = 'ALL')
855
+ return $cmd_tlm_server.start_raw_logging_interface(interface_name)
856
+ end
857
+
858
+ def stop_raw_logging_interface(interface_name = 'ALL')
859
+ return $cmd_tlm_server.stop_raw_logging_interface(interface_name)
860
+ end
861
+
862
+ def start_raw_logging_router(router_name = 'ALL')
863
+ return $cmd_tlm_server.start_raw_logging_router(router_name)
864
+ end
865
+
866
+ def stop_raw_logging_router(router_name = 'ALL')
867
+ return $cmd_tlm_server.stop_raw_logging_router(router_name)
868
+ end
869
+
870
+ def get_server_message_log_filename
871
+ return $cmd_tlm_server.get_server_message_log_filename
872
+ end
873
+
874
+ def start_new_server_message_log
875
+ return $cmd_tlm_server.start_new_server_message_log
876
+ end
877
+
878
+ #######################################
879
+ # Methods accessing tlm_viewer
880
+ #######################################
881
+
882
+ def display(display_name, x_pos = nil, y_pos = nil)
883
+ tlm_viewer = JsonDRbObject.new "localhost", System.ports['TLMVIEWER_API']
884
+ begin
885
+ tlm_viewer.display(display_name, x_pos, y_pos)
886
+ tlm_viewer.disconnect
887
+ rescue DRb::DRbConnError
888
+ # No Listening Tlm Viewer - So Start One
889
+ if Kernel.is_windows?
890
+ Cosmos.run_process('rubyw "' + File.join(Cosmos::USERPATH, 'tools', 'TlmViewer') + '"' + " --system #{File.basename(System.initial_filename)}")
891
+ elsif Kernel.is_mac? and File.exist?(File.join(Cosmos::USERPATH, 'tools', 'mac', 'TlmViewer.app'))
892
+ Cosmos.run_process('open "' + File.join(Cosmos::USERPATH, 'tools', 'mac', 'TlmViewer.app') + '"' + " --args --system #{File.basename(System.initial_filename)}")
893
+ else
894
+ Cosmos.run_process('ruby "' + File.join(Cosmos::USERPATH, 'tools', 'TlmViewer') + '"' + " --system #{File.basename(System.initial_filename)}")
895
+ end
896
+ sleep(5)
897
+ begin
898
+ tlm_viewer.display(display_name, x_pos, y_pos)
899
+ tlm_viewer.disconnect
900
+ rescue DRb::DRbConnError
901
+ raise "Unable to Successfully Start Listening Telemetry Viewer: #{display_name} could not be displayed"
902
+ rescue Errno::ENOENT
903
+ raise "Display Screen File: #{display_name}.txt does not exist"
904
+ end
905
+ rescue Errno::ENOENT
906
+ raise "Display Screen File: #{display_name}.txt does not exist"
907
+ end
908
+ end
909
+
910
+ def clear(display_name)
911
+ tlm_viewer = JsonDRbObject.new "localhost", System.ports['TLMVIEWER_API']
912
+ begin
913
+ tlm_viewer.clear(display_name)
914
+ tlm_viewer.disconnect
915
+ rescue DRb::DRbConnError
916
+ # No Listening Tlm Viewer - So Start One
917
+ if Kernel.is_windows?
918
+ Cosmos.run_process('rubyw "' + File.join(Cosmos::USERPATH, 'tools', 'TlmViewer') + '"' + " --system #{File.basename(System.initial_filename)}")
919
+ elsif Kernel.is_mac? and File.exist?(File.join(Cosmos::USERPATH, 'tools', 'mac', 'TlmViewer.app'))
920
+ Cosmos.run_process('open "' + File.join(Cosmos::USERPATH, 'tools', 'mac', 'TlmViewer.app') + '"' + " --args --system #{File.basename(System.initial_filename)}")
921
+ else
922
+ Cosmos.run_process('ruby "' + File.join(Cosmos::USERPATH, 'tools', 'TlmViewer') + '"' + " --system #{File.basename(System.initial_filename)}")
923
+ end
924
+ sleep(5)
925
+ begin
926
+ tlm_viewer.clear(display_name)
927
+ tlm_viewer.disconnect
928
+ rescue DRb::DRbConnError
929
+ raise "Unable to Successfully Start Listening Telemetry Viewer: #{display_name} could not be displayed"
930
+ rescue Errno::ENOENT
931
+ raise "Display Screen File: #{display_name}.txt does not exist"
932
+ end
933
+ rescue Errno::ENOENT
934
+ raise "Display Screen File: #{display_name}.txt does not exist"
935
+ end
936
+ end
937
+
938
+ #######################################
939
+ # Methods accessing script runner
940
+ #######################################
941
+
942
+ def set_line_delay(delay)
943
+ if defined? ScriptRunnerFrame
944
+ ScriptRunnerFrame.line_delay = delay if delay >= 0.0
945
+ end
946
+ end
947
+
948
+ def get_line_delay
949
+ if defined? ScriptRunnerFrame
950
+ ScriptRunnerFrame.line_delay
951
+ end
952
+ end
953
+
954
+ def get_scriptrunner_message_log_filename
955
+ filename = nil
956
+ if defined? ScriptRunnerFrame
957
+ filename = ScriptRunnerFrame.instance.message_log.filename if ScriptRunnerFrame.instance and ScriptRunnerFrame.instance.message_log
958
+ end
959
+ return filename
960
+ end
961
+
962
+ def start_new_scriptrunner_message_log
963
+ if defined? ScriptRunnerFrame
964
+ # A new log will be created at the next message
965
+ ScriptRunnerFrame.instance.stop_message_log if ScriptRunnerFrame.instance
966
+ end
967
+ end
968
+
969
+ #######################################
970
+ # Methods for debugging
971
+ #######################################
972
+
973
+ def insert_return(*params)
974
+ if defined? ScriptRunnerFrame
975
+ if ScriptRunnerFrame.instance
976
+ ScriptRunnerFrame.instance.inline_return = true
977
+ ScriptRunnerFrame.instance.inline_return_params = params
978
+ end
979
+ end
980
+ end
981
+
982
+ def step_mode
983
+ if defined? ScriptRunnerFrame
984
+ ScriptRunnerFrame.step_mode = true
985
+ end
986
+ end
987
+
988
+ def run_mode
989
+ if defined? ScriptRunnerFrame
990
+ ScriptRunnerFrame.step_mode = false
991
+ end
992
+ end
993
+
994
+ def show_backtrace(value = true)
995
+ if defined? ScriptRunnerFrame
996
+ ScriptRunnerFrame.show_backtrace = value
997
+ end
998
+ end
999
+
1000
+ ##########################################
1001
+ # End Methods accessing other systems
1002
+ ##########################################
1003
+
1004
+ def start(procedure_name)
1005
+ # Handle not-giving an extension
1006
+ procedure_name_with_extension = nil
1007
+ procedure_name_with_extension = procedure_name + '.rb' if File.extname(procedure_name).empty?
1008
+
1009
+ file_text = ''
1010
+ path = nil
1011
+
1012
+ # Find filename in search path
1013
+ ($:).each do |directory|
1014
+ if File.exist?(directory + '/' + procedure_name) and not File.directory?(directory + '/' + procedure_name)
1015
+ path = directory + '/' + procedure_name
1016
+ break
1017
+ end
1018
+
1019
+ if procedure_name_with_extension and File.exist?(directory + '/' + procedure_name_with_extension)
1020
+ procedure_name = procedure_name_with_extension
1021
+ path = directory + '/' + procedure_name
1022
+ break
1023
+ end
1024
+ end
1025
+
1026
+ # Handle absolute path
1027
+ path = procedure_name if !path and File.exist?(procedure_name)
1028
+ path = procedure_name_with_extension if !path and procedure_name_with_extension and File.exist?(procedure_name_with_extension)
1029
+
1030
+ raise "Procedure not found : #{procedure_name}" unless path
1031
+
1032
+ if defined? ScriptRunnerFrame and ScriptRunnerFrame.instance
1033
+ result = false
1034
+ md5 = nil
1035
+ begin
1036
+ md5 = Cosmos.md5_files([path]).hexdigest
1037
+ rescue Exception => error
1038
+ raise "Error calculating md5 on procedure file : #{path}"
1039
+ end
1040
+
1041
+ # Check RAM based instrumented cache
1042
+ instrumented_cache = ScriptRunnerFrame.instrumented_cache[path]
1043
+ instrumented_script = nil
1044
+ if instrumented_cache and md5 == instrumented_cache[1]
1045
+ # Use cached instrumentation
1046
+ instrumented_script = instrumented_cache[0]
1047
+ else
1048
+ use_file_cache = true
1049
+ cache_filename = nil
1050
+ flat_path = nil
1051
+
1052
+ # Check for cache directory existence
1053
+ Cosmos.set_working_dir do
1054
+ cache_path = File.join(System.paths['TMP'], 'script_runner')
1055
+ unless File.directory?(cache_path)
1056
+ # Try to create .cache directory
1057
+ begin
1058
+ Dir.mkdir(cache_path)
1059
+ rescue
1060
+ use_file_cache = false
1061
+ end
1062
+ end
1063
+
1064
+ if use_file_cache
1065
+ # Check file based instrumented cache
1066
+ flat_path = path.gsub("/", "_").gsub("\\", "_").gsub(":", "_").gsub(" ", "_")
1067
+ flat_path_with_md5 = flat_path + '_' + md5
1068
+ cache_filename = File.join(cache_path, flat_path_with_md5)
1069
+ end
1070
+
1071
+ if use_file_cache and File.exist?(cache_filename)
1072
+ # Use file cached instrumentation
1073
+ File.open(cache_filename, 'r') {|file| instrumented_script = file.read}
1074
+ else
1075
+ # Have to instrument
1076
+ result = true
1077
+
1078
+ # Build instrumentation
1079
+ begin
1080
+ file_text = File.read(path)
1081
+ rescue Exception => error
1082
+ raise "Error reading procedure file : #{path}"
1083
+ end
1084
+
1085
+ instrumented_script = ScriptRunnerFrame.instrument_script(file_text, path, true)
1086
+
1087
+ # Cache instrumentation into file
1088
+ if use_file_cache
1089
+ begin
1090
+ File.open(cache_filename, 'w') {|file| file.write(instrumented_script)}
1091
+ rescue
1092
+ # Oh well, failed to write cache file
1093
+ end
1094
+ end
1095
+ end
1096
+ end
1097
+
1098
+ # Cache instrumentation into RAM
1099
+ ScriptRunnerFrame.instrumented_cache[path] = [instrumented_script, md5]
1100
+ end
1101
+
1102
+ Object.class_eval(instrumented_script, path, 1)
1103
+ else # No ScriptRunnerFrame so just start it locally
1104
+ result = true
1105
+
1106
+ begin
1107
+ Kernel::load(path)
1108
+ rescue LoadError => error
1109
+ raise RuntimeError.new("Error loading : #{procedure_name} : #{error.message}")
1110
+ end
1111
+ end
1112
+ result
1113
+ end
1114
+
1115
+ # Require an additional ruby file
1116
+ def load_utility(procedure_name)
1117
+ result = false
1118
+ if defined? ScriptRunnerFrame and ScriptRunnerFrame.instance
1119
+ saved = ScriptRunnerFrame.instance.use_instrumentation
1120
+ begin
1121
+ ScriptRunnerFrame.instance.use_instrumentation = false
1122
+ result = start(procedure_name)
1123
+ ensure
1124
+ ScriptRunnerFrame.instance.use_instrumentation = saved
1125
+ end
1126
+ else # Just call start
1127
+ result = start(procedure_name)
1128
+ end
1129
+ result
1130
+ end
1131
+ alias require_utility load_utility
1132
+
1133
+ ##########################################
1134
+ # Protected Methods
1135
+ ##########################################
1136
+
1137
+ def check_process_args(args, function_name)
1138
+ case args.length
1139
+ when 1
1140
+ target_name, packet_name, item_name, comparison_to_eval = extract_fields_from_check_text(args[0])
1141
+ when 4
1142
+ target_name = args[0]
1143
+ packet_name = args[1]
1144
+ item_name = args[2]
1145
+ comparison_to_eval = args[3]
1146
+ else
1147
+ # Invalid number of arguments
1148
+ raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{function_name}()"
1149
+ end
1150
+ return [target_name, packet_name, item_name, comparison_to_eval]
1151
+ end
1152
+
1153
+ def check_tolerance_process_args(args, function_name)
1154
+ case args.length
1155
+ when 3
1156
+ target_name, packet_name, item_name = extract_fields_from_tlm_text(args[0])
1157
+ expected_value = args[1]
1158
+ tolerance = args[2]
1159
+ when 5
1160
+ target_name = args[0]
1161
+ packet_name = args[1]
1162
+ item_name = args[2]
1163
+ expected_value = args[3]
1164
+ tolerance = args[4]
1165
+ else
1166
+ # Invalid number of arguments
1167
+ raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{function_name}()"
1168
+ end
1169
+ return [target_name, packet_name, item_name, expected_value, tolerance]
1170
+ end
1171
+
1172
+ def wait_process_args(args, function_name, value_type)
1173
+ time = nil
1174
+
1175
+ case args.length
1176
+ when 0
1177
+ start_time = Time.now
1178
+ cosmos_script_sleep()
1179
+ time = Time.now - start_time
1180
+ Logger.info("WAIT: Indefinite for actual time of #{time} seconds")
1181
+ when 1
1182
+ if args[0].kind_of? Numeric
1183
+ start_time = Time.now
1184
+ cosmos_script_sleep(args[0])
1185
+ time = Time.now - start_time
1186
+ Logger.info("WAIT: #{args[0]} seconds with actual time of #{time} seconds")
1187
+ else
1188
+ raise "Non-numeric wait time specified"
1189
+ end
1190
+ when 2, 3
1191
+ target_name, packet_name, item_name, comparison_to_eval = extract_fields_from_check_text(args[0])
1192
+ timeout = args[1]
1193
+ if args.length == 3
1194
+ polling_rate = args[2]
1195
+ else
1196
+ polling_rate = DEFAULT_TLM_POLLING_RATE
1197
+ end
1198
+ start_time = Time.now
1199
+ success, value = cosmos_script_wait_implementation(target_name, packet_name, item_name, value_type, comparison_to_eval, timeout, polling_rate)
1200
+ time = Time.now - start_time
1201
+ if success
1202
+ Logger.info "WAIT: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} #{comparison_to_eval} success with value == #{value} after waiting #{time} seconds"
1203
+ else
1204
+ Logger.warn "WAIT: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} #{comparison_to_eval} failed with value == #{value} after waiting #{time} seconds"
1205
+ end
1206
+ when 5, 6
1207
+ target_name = args[0]
1208
+ packet_name = args[1]
1209
+ item_name = args[2]
1210
+ comparison_to_eval = args[3]
1211
+ timeout = args[4]
1212
+ if args.length == 6
1213
+ polling_rate = args[5]
1214
+ else
1215
+ polling_rate = DEFAULT_TLM_POLLING_RATE
1216
+ end
1217
+ start_time = Time.now
1218
+ success, value = cosmos_script_wait_implementation(target_name, packet_name, item_name, value_type, comparison_to_eval, timeout, polling_rate)
1219
+ time = Time.now - start_time
1220
+ if success
1221
+ Logger.info "WAIT: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} #{comparison_to_eval} success with value == #{value} after waiting #{time} seconds"
1222
+ else
1223
+ Logger.warn "WAIT: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} #{comparison_to_eval} failed with value == #{value} after waiting #{time} seconds"
1224
+ end
1225
+ else
1226
+ # Invalid number of arguments
1227
+ raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{function_name}()"
1228
+ end
1229
+ time
1230
+ end
1231
+
1232
+ def wait_tolerance_process_args(args, function_name)
1233
+ case args.length
1234
+ when 4, 5
1235
+ target_name, packet_name, item_name = extract_fields_from_tlm_text(args[0])
1236
+ expected_value = args[1]
1237
+ tolerance = args[2]
1238
+ timeout = args[3]
1239
+ if args.length == 5
1240
+ polling_rate = args[4]
1241
+ else
1242
+ polling_rate = DEFAULT_TLM_POLLING_RATE
1243
+ end
1244
+ when 6, 7
1245
+ target_name = args[0]
1246
+ packet_name = args[1]
1247
+ item_name = args[2]
1248
+ expected_value = args[3]
1249
+ tolerance = args[4]
1250
+ timeout = args[5]
1251
+ if args.length == 7
1252
+ polling_rate = args[6]
1253
+ else
1254
+ polling_rate = DEFAULT_TLM_POLLING_RATE
1255
+ end
1256
+ else
1257
+ # Invalid number of arguments
1258
+ raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{function_name}()"
1259
+ end
1260
+ return [target_name, packet_name, item_name, expected_value, tolerance, timeout, polling_rate]
1261
+ end
1262
+
1263
+ def wait_check_process_args(args, function_name)
1264
+ case args.length
1265
+ when 2,3
1266
+ target_name, packet_name, item_name, comparison_to_eval = extract_fields_from_check_text(args[0])
1267
+ timeout = args[1]
1268
+ if args.length == 3
1269
+ polling_rate = args[2]
1270
+ else
1271
+ polling_rate = DEFAULT_TLM_POLLING_RATE
1272
+ end
1273
+ when 5,6
1274
+ target_name = args[0]
1275
+ packet_name = args[1]
1276
+ item_name = args[2]
1277
+ comparison_to_eval = args[3]
1278
+ timeout = args[4]
1279
+ if args.length == 6
1280
+ polling_rate = args[5]
1281
+ else
1282
+ polling_rate = DEFAULT_TLM_POLLING_RATE
1283
+ end
1284
+ else
1285
+ # Invalid number of arguments
1286
+ raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{function_name}()"
1287
+ end
1288
+ return [target_name, packet_name, item_name, comparison_to_eval, timeout, polling_rate]
1289
+ end
1290
+
1291
+ # sleep in a script - returns true if canceled mid sleep
1292
+ def cosmos_script_sleep(sleep_time = nil)
1293
+ return false if $cmd_tlm_disconnect
1294
+ if defined? ScriptRunnerFrame and ScriptRunnerFrame.instance
1295
+ sleep_time = 30000000 unless sleep_time # Handle infinite wait
1296
+ if sleep_time > 0.0
1297
+ end_time = Time.now + sleep_time
1298
+ until (Time.now >= end_time)
1299
+ sleep(0.01)
1300
+ if ScriptRunnerFrame.instance.pause?
1301
+ ScriptRunnerFrame.instance.perform_pause
1302
+ return true
1303
+ end
1304
+ return true if ScriptRunnerFrame.instance.go?
1305
+ raise StopScript if ScriptRunnerFrame.instance.stop?
1306
+ end
1307
+ end
1308
+ else
1309
+ if sleep_time
1310
+ sleep(sleep_time)
1311
+ else
1312
+ print 'Infinite Wait - Press Enter to Continue: '
1313
+ gets()
1314
+ end
1315
+ end
1316
+ return false
1317
+ end
1318
+
1319
+ def _cosmos_script_wait_implementation(target_name, packet_name, item_name, value_type, timeout, polling_rate)
1320
+ end_time = Time.now + timeout
1321
+ exp_to_eval = yield
1322
+
1323
+ while true
1324
+ work_start = Time.now
1325
+ value = tlm_variable(target_name, packet_name, item_name, value_type)
1326
+ if eval(exp_to_eval)
1327
+ return true, value
1328
+ end
1329
+ break if Time.now >= end_time || $cmd_tlm_disconnect
1330
+
1331
+ delta = Time.now - work_start
1332
+ sleep_time = polling_rate - delta
1333
+ end_delta = end_time - Time.now
1334
+ sleep_time = end_delta if end_delta < sleep_time
1335
+ sleep_time = 0 if sleep_time < 0
1336
+ canceled = cosmos_script_sleep(sleep_time)
1337
+
1338
+ if canceled
1339
+ value = tlm_variable(target_name, packet_name, item_name, value_type)
1340
+ if eval(exp_to_eval)
1341
+ return true, value
1342
+ else
1343
+ return false, value
1344
+ end
1345
+ end
1346
+ end
1347
+
1348
+ return false, value
1349
+ end
1350
+
1351
+ # Wait for a converted telemetry item to pass a comparison
1352
+ def cosmos_script_wait_implementation(target_name, packet_name, item_name, value_type, comparison_to_eval, timeout, polling_rate = DEFAULT_TLM_POLLING_RATE)
1353
+ _cosmos_script_wait_implementation(target_name, packet_name, item_name, value_type, timeout, polling_rate) do
1354
+ "value " + comparison_to_eval
1355
+ end
1356
+ end
1357
+
1358
+ def cosmos_script_wait_implementation_tolerance(target_name, packet_name, item_name, value_type, expected_value, tolerance, timeout, polling_rate = DEFAULT_TLM_POLLING_RATE)
1359
+ _cosmos_script_wait_implementation(target_name, packet_name, item_name, value_type, timeout, polling_rate) do
1360
+ "((#{expected_value} - #{tolerance})..(#{expected_value} + #{tolerance})).include? value"
1361
+ end
1362
+ end
1363
+
1364
+ # Wait on an expression to be true.
1365
+ def cosmos_script_wait_implementation_expression(exp_to_eval, timeout, polling_rate, context)
1366
+ end_time = Time.now + timeout
1367
+ context = ScriptRunnerFrame.instance.script_binding if !context and defined? ScriptRunnerFrame and ScriptRunnerFrame.instance
1368
+
1369
+ while true
1370
+ work_start = Time.now
1371
+ if eval(exp_to_eval, context)
1372
+ return true
1373
+ end
1374
+ break if Time.now >= end_time
1375
+
1376
+ delta = Time.now - work_start
1377
+ sleep_time = polling_rate - delta
1378
+ end_delta = end_time - Time.now
1379
+ sleep_time = end_delta if end_delta < sleep_time
1380
+ sleep_time = 0 if sleep_time < 0
1381
+ canceled = cosmos_script_sleep(sleep_time)
1382
+
1383
+ if canceled
1384
+ if eval(exp_to_eval, context)
1385
+ return true
1386
+ else
1387
+ return nil
1388
+ end
1389
+ end
1390
+ end
1391
+
1392
+ return nil
1393
+ end
1394
+
1395
+ def check_eval(target_name, packet_name, item_name, comparison_to_eval, value)
1396
+ string = "value " + comparison_to_eval
1397
+ if eval(string)
1398
+ Logger.info "CHECK: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} #{comparison_to_eval} success with value == #{value}"
1399
+ else
1400
+ message = "CHECK: #{target_name.upcase} #{packet_name.upcase} #{item_name.upcase} #{comparison_to_eval} failed with value == #{value}"
1401
+ if $cmd_tlm_disconnect
1402
+ Logger.error message
1403
+ else
1404
+ raise CheckError, message
1405
+ end
1406
+ end
1407
+ end
1408
+
1409
+ def build_cmd_output_string(target_name, cmd_name, cmd_params, raw = false)
1410
+ if raw
1411
+ output_string = 'cmd_raw("'
1412
+ else
1413
+ output_string = 'cmd("'
1414
+ end
1415
+ output_string << target_name + ' ' + cmd_name
1416
+ if cmd_params.nil? or cmd_params.empty?
1417
+ output_string += '")'
1418
+ else
1419
+ params = []
1420
+ cmd_params.each do |key, value|
1421
+ if value.class == String
1422
+ if value.convert_to_value.class == String
1423
+ value = value.inspect
1424
+ if value.length > 256
1425
+ value = value[0..255] + "...'"
1426
+ end
1427
+ value.gsub!('"',"'")
1428
+ end
1429
+ end
1430
+ params << "#{key} #{value}"
1431
+ end
1432
+ params = params.join(", ")
1433
+ output_string += ' with ' + params + '")'
1434
+ end
1435
+ return output_string
1436
+ end
1437
+
1438
+ def prompt_for_hazardous(target_name, cmd_name, hazardous_description)
1439
+ message = "Warning: Command #{target_name} #{cmd_name} is Hazardous. "
1440
+ message << "\n#{hazardous_description}\n" if hazardous_description
1441
+ message << "Send? (y,n): "
1442
+ print message
1443
+ answer = gets.chomp
1444
+ if answer.downcase == 'y'
1445
+ return true
1446
+ else
1447
+ return false
1448
+ end
1449
+ end
1450
+
1451
+ def prompt_for_script_abort
1452
+ print "Stop running script? (y,n): "
1453
+ answer = gets.chomp
1454
+ if answer.downcase == 'y'
1455
+ exit
1456
+ else
1457
+ return false
1458
+ end
1459
+ end
1460
+
1461
+ def prompt_to_continue(string)
1462
+ print "#{string}: "
1463
+ gets.chomp
1464
+ end
1465
+
1466
+ def prompt_message_box(string, buttons)
1467
+ print "#{string} (#{buttons.join(", ")}): "
1468
+ gets.chomp
1469
+ end
1470
+
1471
+ ################################
1472
+ # Module setup and config
1473
+ ################################
1474
+
1475
+ def set_cmd_tlm_disconnect(disconnect = false, config_file = CmdTlmServer::DEFAULT_CONFIG_FILE)
1476
+ if disconnect != $cmd_tlm_disconnect
1477
+ $cmd_tlm_disconnect = disconnect
1478
+ initialize_script_module(config_file)
1479
+ end
1480
+ end
1481
+
1482
+ def get_cmd_tlm_disconnect
1483
+ return $cmd_tlm_disconnect
1484
+ end
1485
+
1486
+ def initialize_script_module(config_file = CmdTlmServer::DEFAULT_CONFIG_FILE)
1487
+ if $cmd_tlm_disconnect
1488
+ # Start up a standalone CTS in disconnected mode
1489
+ $cmd_tlm_server = CmdTlmServer.new(config_file, false, true)
1490
+ else
1491
+ # Start a Json connect to the real CTS server
1492
+ $cmd_tlm_server = JsonDRbObject.new('127.0.0.1', System.ports['CTS_API'])
1493
+ end
1494
+ end
1495
+
1496
+ def self.included(base)
1497
+ $cmd_tlm_disconnect = false
1498
+ $cmd_tlm_server = nil
1499
+ initialize_script_module()
1500
+ end
1501
+
1502
+ def script_disconnect
1503
+ $cmd_tlm_server.disconnect if $cmd_tlm_server && !$cmd_tlm_disconnect
1504
+ end
1505
+
1506
+ def shutdown_cmd_tlm
1507
+ script_disconnect()
1508
+ $cmd_tlm_server = nil
1509
+ end
1510
+
1511
+ end # module Script
1512
+
1513
+ end # module Cosmos