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,786 +1,813 @@
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
- # This file require QT for use by COSMOS. It exists to provide a location for
12
- # adding workarounds should they be needed to work through problems with
13
- # interacting with QT from Ruby.
14
-
15
- require 'cosmos'
16
- check_filename = File.join(Cosmos::USERPATH, "#{File.basename($0, File.extname($0))}_qt_check.txt")
17
- qt_in_system_folder = false
18
-
19
- # Check for Qt dlls in Window system folders
20
- if Kernel.is_windows?
21
- windir = ENV['SystemRoot']
22
- if windir
23
- # Check Windows system folders for existing Qt dll files
24
- ['system', 'SysWOW64', 'System32'].each do |folder|
25
- break if qt_in_system_folder
26
- ['libgcc_s_dw2-1.dll',
27
- 'mingwm10.dll',
28
- 'phonon4.dll',
29
- 'Qt3Support4.dll',
30
- 'QtCLucene4.dll',
31
- 'QtCore4.dll',
32
- 'QtDeclarative4.dll',
33
- 'QtDesigner4.dll',
34
- 'QtDesignerComponents4.dll',
35
- 'QtGui4.dll',
36
- 'QtHelp4.dll',
37
- 'QtMultimedia4.dll',
38
- 'QtNetwork4.dll',
39
- 'QtOpenGL4.dll',
40
- 'QtScript4.dll',
41
- 'QtScriptTools4.dll',
42
- 'QtSql4.dll',
43
- 'QtSvg4.dll',
44
- 'QtTest4.dll',
45
- 'QtWebKit4.dll',
46
- 'QtXml4.dll',
47
- 'QtXmlPatterns4.dll'].each do |qtfilename|
48
- break if qt_in_system_folder
49
- filename = File.join(windir, folder, qtfilename)
50
- if File.exist?(filename)
51
- qt_in_system_folder = true
52
-
53
- # Is this the first time we've detected this?
54
- if File.exist?(check_filename)
55
- # We tried before and failed
56
- File.delete(check_filename)
57
-
58
- if $0 =~ /Launcher/
59
- require 'cosmos/win32/win32'
60
- Cosmos::Win32.message_box("Found conflicting Qt dll file at: #{filename}\nPlease overwrite all Qt dlls in the Windows system folders with the newest Qt4 version (or delete them).")
61
- end
62
- raise "Found conflicting Qt dll file at: #{filename}. Please overwrite all Qt dlls in the Windows system folders with the newest Qt4 version (or delete them)."
63
- else
64
- # First Time we've detected this - We'll create it and risk just requiring Qt once
65
- File.open(check_filename, 'w') {|file| file.write("Qt Dll Check In Progress")}
66
- end
67
- end
68
- end
69
- end
70
- end
71
- end
72
-
73
- # This will either lock up or raise an error if older Qt dlls are present in the Windows system folders
74
- require 'Qt'
75
- File.delete(check_filename) if Kernel.is_windows? and File.exist?(check_filename)
76
-
77
- module Cosmos
78
- BIN_FILE_PATTERN = "Bin Files (*.bin);;All Files (*)"
79
- TXT_FILE_PATTERN = "Txt Files (*.txt);;All Files (*)"
80
- CSV_FILE_PATTERN = "Csv Files (*.csv);;All Files (*)"
81
- CMD_FILE_PATTERN = "Cmd Log Files (*cmd*.bin);;Bin Files (*.bin);;All Files (*)"
82
- TLM_FILE_PATTERN = "Tlm Log Files (*tlm*.bin);;Bin Files (*.bin);;All Files (*)"
83
- COLORS = {}
84
- BRUSHES = {}
85
- PALETTES = {}
86
- PENS = {}
87
- FONTS = {}
88
- FONT_METRICS = {}
89
- CURSORS = {}
90
-
91
- def self.getColor(color_r, color_g = nil, color_b = nil)
92
- return color_r if (color_r.is_a? Qt::Color) || (color_r.is_a? Qt::Pen) || (color_r.is_a? Qt::LinearGradient)
93
-
94
- color = nil
95
- key = color_r
96
- key = key.to_i if key.is_a? Qt::Enum
97
- if color_r && color_g && color_b
98
- key = (color_r.to_i << 24) + (color_g.to_i << 16) + (color_b.to_i << 8)
99
- end
100
-
101
- if Cosmos::COLORS[key]
102
- color = Cosmos::COLORS[key]
103
- else
104
- if color_r && color_g && color_b
105
- color = Qt::Color.new(color_r.to_i, color_g.to_i, color_b.to_i)
106
- else
107
- color = Qt::Color.new(color_r)
108
- end
109
- Cosmos::COLORS[key] = color
110
- end
111
- color
112
- end
113
-
114
- def self.getBrush(color)
115
- brush = nil
116
- color = Cosmos.getColor(color)
117
- brush = BRUSHES[color]
118
- unless brush
119
- if color.is_a? Qt::LinearGradient
120
- brush = Qt::Brush.new(color)
121
- else
122
- brush = Qt::Brush.new(color, Qt::SolidPattern)
123
- end
124
- BRUSHES[color] = brush
125
- end
126
- brush
127
- end
128
-
129
- def self.getPalette(foreground, background)
130
- foreground = Cosmos.getColor(foreground)
131
- background = Cosmos.getColor(background)
132
- PALETTES[foreground] ||= {}
133
- p = PALETTES[foreground][background]
134
- unless p
135
- p = Qt::Palette.new
136
- p.setColor(Qt::Palette::Text, foreground)
137
- p.setColor(Qt::Palette::Base, background)
138
- p.setColor(Qt::Palette::Window, background)
139
- PALETTES[foreground][background] = p
140
- end
141
- p
142
- end
143
-
144
- def self.getPen(color = nil)
145
- color = Cosmos.getColor(color) if color
146
- pen = nil
147
- pen = PENS[color]
148
- unless pen
149
- if color
150
- pen = Qt::Pen.new(color)
151
- else
152
- pen = Qt::Pen.new
153
- end
154
- PENS[color] = pen
155
- end
156
- pen
157
- end
158
-
159
- def self.getFont(font_face, font_size, font_attrs = nil, font_italics = false)
160
- FONTS[font_face] ||= {}
161
- FONTS[font_face][font_size] ||= {}
162
- FONTS[font_face][font_size][font_attrs] ||= {}
163
- font = FONTS[font_face][font_size][font_attrs][font_italics]
164
- unless font
165
- if font_attrs and font_italics
166
- font = Qt::Font.new(font_face, font_size, font_attrs, font_italics)
167
- else
168
- font = Qt::Font.new(font_face, font_size)
169
- end
170
- FONTS[font_face][font_size][font_attrs][font_italics] = font
171
- end
172
- font
173
- end
174
-
175
- def self.getFontMetrics(font)
176
- font_metrics = FONT_METRICS[font]
177
- unless font_metrics
178
- font_metrics = Qt::FontMetrics.new(font)
179
- FONT_METRICS[font] = font_metrics
180
- end
181
- font_metrics
182
- end
183
-
184
- def self.getCursor(shape)
185
- key = shape
186
- key = shape.to_i if shape.is_a? Qt::Enum
187
- cursor = CURSORS[key]
188
- unless cursor
189
- cursor = Qt::Cursor.new(shape)
190
- CURSORS[key] = cursor
191
- end
192
- cursor
193
- end
194
-
195
- GREEN = getColor(0, 150, 0)
196
- YELLOW = getColor(190, 135, 0)
197
- RED = getColor(Qt::red)
198
- BLUE = getColor(0, 100, 255)
199
- PURPLE = getColor(200, 0, 200)
200
- BLACK = getColor(Qt::black)
201
- WHITE = getColor(Qt::white)
202
- BLACK_NO_BRUSH = Qt::Brush.new(Cosmos::BLACK, Qt::NoBrush)
203
- DEFAULT_PALETTE = Qt::Palette.new
204
- RED_PALETTE = Qt::Palette.new(Qt::red)
205
- DASHLINE_PEN = Qt::Pen.new(Qt::DashLine)
206
-
207
- # Load the applications icon
208
- def self.load_cosmos_icon(name='COSMOS_64x64.png')
209
- icon = Cosmos.get_icon(name, false)
210
- icon = Cosmos.get_icon('COSMOS_64x64.png', false) unless icon
211
- Qt::Application.instance.setWindowIcon(icon) if icon
212
- return icon
213
- end
214
-
215
- # Load the applications icon
216
- def self.get_icon(name, fail_blank = true)
217
- icon = nil
218
- filename = File.join(::Cosmos::USERPATH, 'config', 'data', name)
219
- begin
220
- raise unless File.exist? filename
221
- icon = Qt::Icon.new(filename)
222
- raise if icon.isNull
223
- rescue
224
- begin
225
- filename = File.join(::Cosmos::PATH, 'data', name)
226
- raise unless File.exist? filename
227
- icon = Qt::Icon.new(filename)
228
- raise if icon.isNull
229
- rescue
230
- # Return a blank icon if we couldn't find an icon in either the user path or cosmos path
231
- if fail_blank
232
- icon = Qt::Icon.new
233
- else
234
- icon = nil
235
- end
236
- end
237
- end
238
- return icon
239
- end
240
- end
241
-
242
- #### TEMPORARY UNTIL INCLUDED IN QTBINDINGS ####
243
- class Qt::Application
244
- def exec
245
- begin
246
- method_missing(:exec)
247
- ensure
248
- disable_threading()
249
- self.dispose
250
- Qt::Internal.application_terminated = true
251
- end
252
- end
253
- end
254
-
255
- class Qt::CoreApplication
256
- def exec
257
- begin
258
- method_missing(:exec)
259
- ensure
260
- disable_threading()
261
- self.dispose
262
- Qt::Internal.application_terminated = true
263
- end
264
- end
265
- end
266
- #### END TEMPORARY UNTIL INCLUDED IN QTBINDINGS ####
267
-
268
- class Qt::Dialog
269
- def initialize(parent = Qt::Application.activeWindow,
270
- flags = (Qt::WindowTitleHint | Qt::WindowSystemMenuHint))
271
- super(parent, flags)
272
- end
273
- end
274
-
275
- class Qt::TableWidget
276
- # Resizes the table, turns off scroll bars, and sets the minimum and maximum sizes
277
- # to the full size of the table with all the elements in view
278
- def displayFullSize
279
- resizeColumnsToContents()
280
- resizeRowsToContents()
281
- setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff)
282
- setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff)
283
- setMinimumSize(2*frameWidth() + horizontalHeader.length + verticalHeader.width,
284
- 2*frameWidth() + verticalHeader.length + horizontalHeader.height)
285
- setMaximumSize(2*frameWidth() + horizontalHeader.length + verticalHeader.width,
286
- 2*frameWidth() + verticalHeader.length + horizontalHeader.height)
287
- end
288
- end
289
-
290
- class Qt::TableWidgetItem
291
- def initialize(string = "")
292
- super(string)
293
- setFlags(Qt::ItemIsEnabled)
294
- end
295
-
296
- def textColor=(color)
297
- setForeground(Cosmos.getBrush(color))
298
- end
299
- end
300
-
301
- class Qt::TreeWidget
302
- def initialize(parent = Qt::Application.activeWindow)
303
- super(parent)
304
-
305
- # Create a sensible default handler for clicking the checkboxes
306
- # of a tree. If you check a node all the lower nodes get checked.
307
- # If you uncheck a node all the lower nodes get unchecked.
308
- # If you check a lower node all the parent nodes get checked.
309
- connect(SIGNAL('itemClicked(QTreeWidgetItem*, int)')) do |node, col|
310
- if node.checkState == Qt::Checked
311
- # Set all nodes below this to checked
312
- node.setCheckStateAll(Qt::Checked)
313
-
314
- # Set all the nodes above this to checked
315
- while node.parent
316
- node = node.parent
317
- node.setCheckState(0, Qt::Checked)
318
- end
319
- else
320
- # Set all nodes below this to unchecked
321
- node.setCheckStateAll(Qt::Unchecked)
322
- end
323
- end
324
- end
325
-
326
- # Yields each of the top level items (those without a parent).
327
- def topLevelItems
328
- topLevelItemCount.times do |index|
329
- yield topLevelItem(index)
330
- end
331
- end
332
- end
333
-
334
- class Qt::TreeWidgetItem
335
- # Sets the check state of this TreeWidgetItem as well as all its children
336
- # recursively.
337
- #
338
- # @param state [Integer] Must be Qt::Checked or Qt::Unchecked
339
- def setCheckStateAll(state = Qt::Checked)
340
- children() do |child|
341
- child.setCheckStateAll(state)
342
- end
343
- setCheckState(0, state)
344
- end
345
-
346
- # @return [Qt::TreeWidgetItem] The top level item for this TreeWidgetItem.
347
- # The top level item does not have a parent. Note that this could return
348
- # itself.
349
- def topLevel
350
- top = self
351
- if !top.parent.nil?
352
- while true
353
- top = top.parent
354
- break if top.parent.nil?
355
- end
356
- end
357
- top
358
- end
359
-
360
- # Yields the children of the current node
361
- def children
362
- childCount.times do |index|
363
- yield child(index)
364
- end
365
- end
366
-
367
- # Define the default column to be 0
368
- def background(column = 0)
369
- super(column)
370
- end
371
- def checkState(column = 0)
372
- super(column)
373
- end
374
- def font(column = 0)
375
- super(column)
376
- end
377
- def foreground(column = 0)
378
- super(column)
379
- end
380
- def icon(column = 0)
381
- super(column)
382
- end
383
- def statusTip(column = 0)
384
- super(column)
385
- end
386
- def sizeHint(column = 0)
387
- super(column)
388
- end
389
- def text(column = 0)
390
- super(column)
391
- end
392
- def toolTip(column = 0)
393
- super(column)
394
- end
395
- def whatsThis(column = 0)
396
- super(column)
397
- end
398
- end
399
-
400
- class Qt::TabWidget
401
- def tab(index)
402
- widget(index)
403
- end
404
-
405
- def widgets
406
- all = []
407
- (0...self.count()).each do |index|
408
- all << self.widget(index)
409
- end
410
- all
411
- end
412
- alias :tabs :widgets
413
-
414
- def currentWidget
415
- self.widget(self.currentIndex)
416
- end
417
- alias :currentTab :currentWidget
418
- end
419
-
420
- class Qt::LineEdit
421
- def setColors(foreground, background)
422
- setPalette(Cosmos.getPalette(foreground, background))
423
- end
424
-
425
- def text=(value)
426
- setText(value)
427
- end
428
- end
429
-
430
- class Qt::PlainTextEdit
431
- def add_formatted_text(text, color = nil)
432
- if text =~ /[\x00-\x08\x0B-\x0C\x0E-\x1F\x7F-\xFF]/
433
- text.chomp!
434
- text = text.inspect.remove_quotes
435
- text << "\n"
436
- end
437
- if text =~ /<G>/ or color == Cosmos::GREEN
438
- text.gsub!('<G>', '')
439
- addText(text, Cosmos::GREEN)
440
- elsif text =~ /<Y>/ or color == Cosmos::YELLOW
441
- text.gsub!('<Y>', '')
442
- addText(text, Cosmos::YELLOW)
443
- elsif text =~ /<R>/ or color == Cosmos::RED
444
- text.gsub!('<R>', '')
445
- addText(text, Cosmos::RED)
446
- elsif text =~ /<B>/ or color == Cosmos::BLUE
447
- text.gsub!('<B>', '')
448
- addText(text, Cosmos::BLUE)
449
- else
450
- addText(text) # default is Cosmos::BLACK
451
- end
452
- end
453
-
454
- def addText(text, color = Cosmos::BLACK)
455
- @current_text = "" if !defined? @current_text or @current_text.nil?
456
- text = text.gsub("&", "&amp;")
457
- text.gsub!("\n", '')
458
- text.gsub!(' ', '&nbsp;')
459
- text.gsub!(">", "&gt;")
460
- text.gsub!("<", "&lt;")
461
- rgb_color = "#%02X%02X%02X" % [color.red, color.green, color.blue]
462
- @current_text +="<font color=\"#{rgb_color}\">#{text}</font><br/>"
463
- end
464
-
465
- def flush
466
- appendHtml(@current_text)
467
- @current_text = nil
468
- end
469
-
470
- def appendText(text, color = Cosmos::BLACK)
471
- text = text.chomp
472
- text.gsub!(/\n/, '<br/>') # replace newlines with html breaks
473
- text.gsub!("&", "&amp;")
474
- text.gsub!(' ', '&nbsp;')
475
- text.gsub!(">", "&gt;")
476
- text.gsub!("<", "&lt;")
477
- rgb_color = "#%02X%02X%02X" % [color.red, color.green, color.blue]
478
- appendHtml("<font color=\"#{rgb_color}\">#{text}</font>")
479
- end
480
-
481
- # Return the selected lines. If a partial line is selected the entire line will be returned.
482
- # If there is no selection the line with the cursor will be returned
483
- def selected_lines
484
- cursor = textCursor
485
- selection_end = cursor.selectionEnd
486
- # Initially place the cursor at the beginning of the selection
487
- # If nothing is selected this will just put the cursor at the beginning of the current line
488
- cursor.setPosition(textCursor.selectionStart)
489
- cursor.movePosition(Qt::TextCursor::StartOfLine)
490
- # Move the cursor to the end of the selection while keeping the anchor
491
- cursor.setPosition(selection_end, Qt::TextCursor::KeepAnchor)
492
- # Normally we want to select the entire line where the end of selection is
493
- # However if the user selects an exact number of lines
494
- # the cursor will be at the beginning of the following line
495
- # Therefore if the cursor is at the beginning of the line and we have a selection
496
- # we'll skip moving to the end of the line
497
- unless (cursor.atBlockStart and textCursor.hasSelection)
498
- cursor.movePosition(Qt::TextCursor::EndOfLine, Qt::TextCursor::KeepAnchor)
499
- end
500
- # If there is no selection then just return nil
501
- return nil if cursor.selectedText.nil?
502
-
503
- cursor.selection.toPlainText
504
-
505
- # The selectedText function returns the Unicode U+2029 paragraph separator character
506
- # instead of newline \n. Thus we have to unpack as Unicode, covert to newlines, and then repack
507
- #text = cursor.selectedText.unpack("U*")
508
- #text.collect! {|letter| if letter == 63 then 10 else letter end }
509
- #text.pack("U*")
510
- end
511
-
512
- # Return the line number (0 based) of the selection start
513
- def selection_start_line
514
- cursor = textCursor
515
- cursor.setPosition(textCursor.selectionStart)
516
- cursor.blockNumber
517
- end
518
-
519
- # Return the line number (0 based) of the selection end
520
- def selection_end_line
521
- cursor = textCursor
522
- cursor.setPosition(textCursor.selectionEnd)
523
- cursor.blockNumber
524
- end
525
- end
526
-
527
- class Qt::TextEdit
528
- def setColors(foreground, background)
529
- setPalette(Cosmos.getPalette(foreground, background))
530
- end
531
- end
532
-
533
- class Qt::ComboBox
534
- # Helper method to remove all items from a ComboBox
535
- def clearItems
536
- (0...count).to_a.reverse.each do |index|
537
- removeItem(index)
538
- end
539
- end
540
-
541
- # Alias currentText as text to make it more compatible with LineEdit which uses text
542
- def text
543
- currentText
544
- end
545
-
546
- # Helper method to set the current item using a text String instead of the index
547
- def setCurrentText(arg)
548
- setCurrentIndex(findText(arg.to_s))
549
- end
550
-
551
- def each
552
- (0...count).each do |index|
553
- yield self.itemText(index), self.itemData(index)
554
- end
555
- end
556
- end
557
-
558
- class Qt::ListWidget
559
- # Helper method to remove all items from a ListWidget
560
- def clearItems
561
- (0...count).each do
562
- takeItem(0).dispose
563
- end
564
- end
565
-
566
- def each
567
- (0...count).each do |index|
568
- yield self.item(index)
569
- end
570
- end
571
-
572
- def remove_selected_items
573
- # Take the selected items and call row on each to get an array of the item indexes
574
- # Sort that array because selectedItems is returned in the order selected, not numerical order
575
- # Reverse this array of indices so we remove the last item first,
576
- # this allows all the indexes to remain constant
577
- # Call takeItem of each of the indices and then dispose the resulting ListWidgetItem that is returned
578
- selectedItems.map {|x| row(x)}.sort.reverse.each { |index| takeItem(index).dispose }
579
- end
580
- end
581
-
582
- # This class attempts to duplicate Fox's FXColorList
583
- # by adding a colored icon to each item in the ListWidget
584
- class Qt::ColorListWidget < Qt::ListWidget
585
- attr_reader :original_parent
586
-
587
- def initialize(parent, enable_key_delete = true)
588
- super(parent)
589
- # When a layout adds this widget it automatically gets re-parented so
590
- # store the original parent in case someone needs it
591
- @original_parent = parent
592
- @enable_key_delete = enable_key_delete
593
- @colors = []
594
- @maps = []
595
- @icons = []
596
- setUniformItemSizes(true)
597
- end
598
-
599
- def resize_to_contents
600
- return if count == 0
601
- #setResizeMode(Qt::ListView::Adjust)
602
- # Disable the vertical scrollbar and don't display it
603
- verticalScrollBar.setDisabled(true)
604
- setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff)
605
- # Get the height of an item and multiply by the number of items
606
- setFixedHeight(visualItemRect(item(0)).height * (count + 1))
607
- end
608
-
609
- def set_read_only
610
- setSelectionMode(Qt::AbstractItemView::NoSelection)
611
- filter = Qt::Object.new
612
- filter.define_singleton_method(:eventFilter) do |obj, event|
613
- if event.type == Qt::Event::KeyPress &&
614
- (event.key == Qt::Key_Delete || event.key == Qt::Key_Backspace)
615
- return true
616
- end
617
- return false
618
- end
619
- installEventFilter(filter)
620
- end
621
-
622
- def keyPressEvent(event)
623
- if @enable_key_delete
624
- if (event.key == Qt::Key_Delete || event.key == Qt::Key_Backspace)
625
- takeItemColor(currentRow)
626
- end
627
- end
628
- super(event)
629
- end
630
-
631
- def addItemColor(text, color = Cosmos::BLACK)
632
- @colors << color
633
- @maps << Qt::Pixmap.new(20,14)
634
- color = Cosmos::getColor(color)
635
- @maps[-1].fill(color)
636
- icon = Qt::Icon.new
637
- icon.addPixmap(@maps[-1], Qt::Icon::Normal)
638
- icon.addPixmap(@maps[-1], Qt::Icon::Selected)
639
- @icons << icon
640
- item = Qt::ListWidgetItem.new(@icons[-1], text.to_s)
641
- addItem(item)
642
- end
643
-
644
- def getItemColor(index)
645
- @colors[index]
646
- end
647
-
648
- def takeItemColor(row)
649
- item = takeItem(row)
650
- if item
651
- @colors.delete_at(row)
652
- @maps.delete_at(row).dispose
653
- @icons.delete_at(row).dispose
654
- item.dispose
655
- end
656
- end
657
-
658
- def clearItems
659
- (0...count).each do
660
- takeItemColor(0)
661
- end
662
- end
663
-
664
- def dispose
665
- super()
666
- @maps.each {|map| map.dispose}
667
- @icons.each {|icon| icon.dispose}
668
- end
669
- end
670
-
671
- class Qt::Painter
672
- def addLineColor(x, y, w, h, color = Cosmos::BLACK)
673
- color = Cosmos::getColor(color)
674
- setPen(color)
675
- drawLine(x,y,w,h)
676
- end
677
-
678
- def addRectColor(x, y, w, h, color = Cosmos::BLACK)
679
- color = Cosmos::getColor(color)
680
- setPen(color)
681
- setBrush(nil)
682
- drawRect(x,y,w,h)
683
- end
684
-
685
- def addRectColorFill(x, y, w, h, color = Cosmos::BLACK)
686
- color = Cosmos::getColor(color)
687
- setPen(color)
688
- setBrush(Cosmos.getBrush(color))
689
- drawRect(x,y,w,h)
690
- end
691
-
692
- def addSimpleTextAt(text, x, y, color = Cosmos::BLACK)
693
- color = Cosmos::getColor(color)
694
- setPen(color)
695
- drawText(x, y, text)
696
- end
697
-
698
- def addEllipseColor(x, y, w, h, color = Cosmos::BLACK)
699
- color = Cosmos::getColor(color)
700
- setPen(color)
701
- setBrush(nil)
702
- drawEllipse(x,y,w,h)
703
- end
704
-
705
- def addEllipseColorFill(x, y, w, h, color = Cosmos::BLACK)
706
- color = Cosmos::getColor(color)
707
- setPen(color)
708
- setBrush(Cosmos.getBrush(color))
709
- drawEllipse(x,y,w,h)
710
- end
711
- end
712
-
713
- class Qt::MatrixLayout < Qt::GridLayout
714
- def initialize(num_columns)
715
- super(nil)
716
- @num_columns = num_columns
717
- @row = 0
718
- @col = 0
719
- end
720
-
721
- def addWidget(widget)
722
- super(widget, @row, @col)
723
- @col += 1 if @col < @num_columns
724
- if @col == @num_columns
725
- @row += 1
726
- @col = 0
727
- end
728
- end
729
-
730
- def addLayout(layout)
731
- super(layout, @row, @col)
732
- @col += 1 if @col < @num_columns
733
- if @col == @num_columns
734
- @row += 1
735
- @col = 0
736
- end
737
- end
738
- end
739
-
740
- class Qt::AdaptiveGridLayout < Qt::GridLayout
741
- def addWidget(widget)
742
- case (count() + 1)
743
- when 3 # reorder things to add a second column
744
- old = takeAt(1)
745
- addItem(old, 0, 1)
746
- super(widget)
747
- when 7 # reorder everything to add a third column
748
- items = []
749
- # Take the items in reverse order because taking an item changes the indexes
750
- 5.downto(2).each {|index| items << takeAt(index)}
751
- # Reverse the items to get them back into insertion order
752
- items.reverse!
753
- addItem(items[0], 0, 2)
754
- addItem(items[1], 1, 0)
755
- addItem(items[2], 1, 1)
756
- addItem(items[3], 1, 2)
757
- super(widget)
758
- # When we have established the desired number of rows we can add things and GridLayout does the right thing
759
- else
760
- super(widget)
761
- end
762
- end
763
- # removeWidget is not implemented. If you want to remove widgets, transfer the existing to a new layout like so:
764
- # (0...old_layout.count).each do |index|
765
- # new_layout.addWidget(old_layout.takeAt(0).widget)
766
- # end
767
- end
768
-
769
- # Implement removeAll on all the layout managers.
770
- # It would be easier to add this method on Qt::Layout which is the parent class to all but
771
- # that doesn't work due to the way method_missing is used to call the actual method
772
- %w(GridLayout BoxLayout VBoxLayout HBoxLayout FormLayout StackedLayout).each do |klass|
773
- "Qt::#{klass}".to_class.class_eval do
774
- def removeAll
775
- (0...count).each do |index|
776
- item = takeAt(0)
777
- if item.layout
778
- item.removeAll
779
- else
780
- item.widget.dispose
781
- end
782
- end
783
- end
784
- end
785
- end
786
-
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
+ # This file require QT for use by COSMOS. It exists to provide a location for
12
+ # adding workarounds should they be needed to work through problems with
13
+ # interacting with QT from Ruby.
14
+
15
+ require 'cosmos'
16
+ check_filename = File.join(Cosmos::USERPATH, "#{File.basename($0, File.extname($0))}_qt_check.txt")
17
+ qt_in_system_folder = false
18
+
19
+ # Check for Qt dlls in Window system folders
20
+ if Kernel.is_windows?
21
+ windir = ENV['SystemRoot']
22
+ if windir
23
+ # Check Windows system folders for existing Qt dll files
24
+ ['system', 'SysWOW64', 'System32'].each do |folder|
25
+ break if qt_in_system_folder
26
+ ['libgcc_s_dw2-1.dll',
27
+ 'mingwm10.dll',
28
+ 'phonon4.dll',
29
+ 'Qt3Support4.dll',
30
+ 'QtCLucene4.dll',
31
+ 'QtCore4.dll',
32
+ 'QtDeclarative4.dll',
33
+ 'QtDesigner4.dll',
34
+ 'QtDesignerComponents4.dll',
35
+ 'QtGui4.dll',
36
+ 'QtHelp4.dll',
37
+ 'QtMultimedia4.dll',
38
+ 'QtNetwork4.dll',
39
+ 'QtOpenGL4.dll',
40
+ 'QtScript4.dll',
41
+ 'QtScriptTools4.dll',
42
+ 'QtSql4.dll',
43
+ 'QtSvg4.dll',
44
+ 'QtTest4.dll',
45
+ 'QtWebKit4.dll',
46
+ 'QtXml4.dll',
47
+ 'QtXmlPatterns4.dll'].each do |qtfilename|
48
+ break if qt_in_system_folder
49
+ filename = File.join(windir, folder, qtfilename)
50
+ if File.exist?(filename)
51
+ qt_in_system_folder = true
52
+
53
+ # Is this the first time we've detected this?
54
+ if File.exist?(check_filename)
55
+ # We tried before and failed
56
+ File.delete(check_filename)
57
+
58
+ if $0 =~ /Launcher/
59
+ require 'cosmos/win32/win32'
60
+ Cosmos::Win32.message_box("Found conflicting Qt dll file at: #{filename}\nPlease overwrite all Qt dlls in the Windows system folders with the newest Qt4 version (or delete them).")
61
+ end
62
+ raise "Found conflicting Qt dll file at: #{filename}. Please overwrite all Qt dlls in the Windows system folders with the newest Qt4 version (or delete them)."
63
+ else
64
+ # First Time we've detected this - We'll create it and risk just requiring Qt once
65
+ File.open(check_filename, 'w') {|file| file.write("Qt Dll Check In Progress")}
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+
73
+ # This will either lock up or raise an error if older Qt dlls are present in the Windows system folders
74
+ require 'Qt'
75
+ File.delete(check_filename) if Kernel.is_windows? and File.exist?(check_filename)
76
+
77
+ module Cosmos
78
+ BIN_FILE_PATTERN = "Bin Files (*.bin);;All Files (*)"
79
+ TXT_FILE_PATTERN = "Txt Files (*.txt);;All Files (*)"
80
+ CSV_FILE_PATTERN = "Csv Files (*.csv);;All Files (*)"
81
+ CMD_FILE_PATTERN = "Cmd Log Files (*cmd*.bin);;Bin Files (*.bin);;All Files (*)"
82
+ TLM_FILE_PATTERN = "Tlm Log Files (*tlm*.bin);;Bin Files (*.bin);;All Files (*)"
83
+ COLORS = {}
84
+ BRUSHES = {}
85
+ PALETTES = {}
86
+ PENS = {}
87
+ FONTS = {}
88
+ FONT_METRICS = {}
89
+ CURSORS = {}
90
+
91
+ def self.getColor(color_r, color_g = nil, color_b = nil)
92
+ return color_r if (color_r.is_a? Qt::Color) || (color_r.is_a? Qt::Pen) || (color_r.is_a? Qt::LinearGradient)
93
+
94
+ color = nil
95
+ key = color_r
96
+ key = key.to_i if key.is_a? Qt::Enum
97
+ if color_r && color_g && color_b
98
+ key = (color_r.to_i << 24) + (color_g.to_i << 16) + (color_b.to_i << 8)
99
+ end
100
+
101
+ if Cosmos::COLORS[key]
102
+ color = Cosmos::COLORS[key]
103
+ else
104
+ if color_r && color_g && color_b
105
+ color = Qt::Color.new(color_r.to_i, color_g.to_i, color_b.to_i)
106
+ else
107
+ color = Qt::Color.new(color_r)
108
+ end
109
+ Cosmos::COLORS[key] = color
110
+ end
111
+ color
112
+ end
113
+
114
+ def self.getBrush(color)
115
+ brush = nil
116
+ color = Cosmos.getColor(color)
117
+ brush = BRUSHES[color]
118
+ unless brush
119
+ if color.is_a? Qt::LinearGradient
120
+ brush = Qt::Brush.new(color)
121
+ else
122
+ brush = Qt::Brush.new(color, Qt::SolidPattern)
123
+ end
124
+ BRUSHES[color] = brush
125
+ end
126
+ brush
127
+ end
128
+
129
+ def self.getPalette(foreground, background)
130
+ foreground = Cosmos.getColor(foreground)
131
+ background = Cosmos.getColor(background)
132
+ PALETTES[foreground] ||= {}
133
+ p = PALETTES[foreground][background]
134
+ unless p
135
+ p = Qt::Palette.new
136
+ p.setColor(Qt::Palette::Text, foreground)
137
+ p.setColor(Qt::Palette::Base, background)
138
+ p.setColor(Qt::Palette::Window, background)
139
+ PALETTES[foreground][background] = p
140
+ end
141
+ p
142
+ end
143
+
144
+ def self.getPen(color = nil)
145
+ color = Cosmos.getColor(color) if color
146
+ pen = nil
147
+ pen = PENS[color]
148
+ unless pen
149
+ if color
150
+ pen = Qt::Pen.new(color)
151
+ else
152
+ pen = Qt::Pen.new
153
+ end
154
+ PENS[color] = pen
155
+ end
156
+ pen
157
+ end
158
+
159
+ def self.getFont(font_face, font_size, font_attrs = nil, font_italics = false)
160
+ FONTS[font_face] ||= {}
161
+ FONTS[font_face][font_size] ||= {}
162
+ FONTS[font_face][font_size][font_attrs] ||= {}
163
+ font = FONTS[font_face][font_size][font_attrs][font_italics]
164
+ unless font
165
+ if font_attrs and font_italics
166
+ font = Qt::Font.new(font_face, font_size, font_attrs, font_italics)
167
+ else
168
+ font = Qt::Font.new(font_face, font_size)
169
+ end
170
+ FONTS[font_face][font_size][font_attrs][font_italics] = font
171
+ end
172
+ font
173
+ end
174
+
175
+ def self.getFontMetrics(font)
176
+ font_metrics = FONT_METRICS[font]
177
+ unless font_metrics
178
+ font_metrics = Qt::FontMetrics.new(font)
179
+ FONT_METRICS[font] = font_metrics
180
+ end
181
+ font_metrics
182
+ end
183
+
184
+ def self.getCursor(shape)
185
+ key = shape
186
+ key = shape.to_i if shape.is_a? Qt::Enum
187
+ cursor = CURSORS[key]
188
+ unless cursor
189
+ cursor = Qt::Cursor.new(shape)
190
+ CURSORS[key] = cursor
191
+ end
192
+ cursor
193
+ end
194
+
195
+ GREEN = getColor(0, 150, 0)
196
+ YELLOW = getColor(190, 135, 0)
197
+ RED = getColor(Qt::red)
198
+ BLUE = getColor(0, 100, 255)
199
+ PURPLE = getColor(200, 0, 200)
200
+ BLACK = getColor(Qt::black)
201
+ WHITE = getColor(Qt::white)
202
+ BLACK_NO_BRUSH = Qt::Brush.new(Cosmos::BLACK, Qt::NoBrush)
203
+ DEFAULT_PALETTE = Qt::Palette.new
204
+ RED_PALETTE = Qt::Palette.new(Qt::red)
205
+ DASHLINE_PEN = Qt::Pen.new(Qt::DashLine)
206
+
207
+ # Load the applications icon
208
+ def self.load_cosmos_icon(name='COSMOS_64x64.png')
209
+ icon = Cosmos.get_icon(name, false)
210
+ icon = Cosmos.get_icon('COSMOS_64x64.png', false) unless icon
211
+ Qt::Application.instance.setWindowIcon(icon) if icon
212
+ return icon
213
+ end
214
+
215
+ # Load the applications icon
216
+ def self.get_icon(name, fail_blank = true)
217
+ icon = nil
218
+ filename = File.join(::Cosmos::USERPATH, 'config', 'data', name)
219
+ begin
220
+ raise unless File.exist? filename
221
+ icon = Qt::Icon.new(filename)
222
+ raise if icon.isNull
223
+ rescue
224
+ begin
225
+ filename = File.join(::Cosmos::PATH, 'data', name)
226
+ raise unless File.exist? filename
227
+ icon = Qt::Icon.new(filename)
228
+ raise if icon.isNull
229
+ rescue
230
+ # Return a blank icon if we couldn't find an icon in either the user path or cosmos path
231
+ if fail_blank
232
+ icon = Qt::Icon.new
233
+ else
234
+ icon = nil
235
+ end
236
+ end
237
+ end
238
+ return icon
239
+ end
240
+ end
241
+
242
+ #### TEMPORARY UNTIL INCLUDED IN QTBINDINGS ####
243
+ class Qt::Application
244
+ def exec
245
+ begin
246
+ method_missing(:exec)
247
+ ensure
248
+ disable_threading()
249
+ self.dispose
250
+ Qt::Internal.application_terminated = true
251
+ end
252
+ end
253
+ end
254
+
255
+ class Qt::CoreApplication
256
+ def exec
257
+ begin
258
+ method_missing(:exec)
259
+ ensure
260
+ disable_threading()
261
+ self.dispose
262
+ Qt::Internal.application_terminated = true
263
+ end
264
+ end
265
+ end
266
+ #### END TEMPORARY UNTIL INCLUDED IN QTBINDINGS ####
267
+
268
+ class Qt::Dialog
269
+ def initialize(parent = Qt::Application.activeWindow,
270
+ flags = (Qt::WindowTitleHint | Qt::WindowSystemMenuHint))
271
+ super(parent, flags)
272
+ end
273
+ end
274
+
275
+ class Qt::TableWidget
276
+ # Resizes the table, turns off scroll bars, and sets the minimum and maximum sizes
277
+ # to the full size of the table with all the elements in view
278
+ def displayFullSize
279
+ resizeColumnsToContents()
280
+ resizeRowsToContents()
281
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff)
282
+ setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff)
283
+ setMinimumSize(2*frameWidth() + horizontalHeader.length + verticalHeader.width,
284
+ 2*frameWidth() + verticalHeader.length + horizontalHeader.height)
285
+ setMaximumSize(2*frameWidth() + horizontalHeader.length + verticalHeader.width,
286
+ 2*frameWidth() + verticalHeader.length + horizontalHeader.height)
287
+ end
288
+ end
289
+
290
+ class Qt::TableWidgetItem
291
+ def initialize(string = "")
292
+ super(string)
293
+ setFlags(Qt::ItemIsEnabled)
294
+ end
295
+
296
+ def textColor=(color)
297
+ setForeground(Cosmos.getBrush(color))
298
+ end
299
+ end
300
+
301
+ class Qt::TreeWidget
302
+ def initialize(parent = Qt::Application.activeWindow)
303
+ super(parent)
304
+
305
+ # Create a sensible default handler for clicking the checkboxes
306
+ # of a tree. If you check a node all the lower nodes get checked.
307
+ # If you uncheck a node all the lower nodes get unchecked.
308
+ # If you check a lower node all the parent nodes get checked.
309
+ connect(SIGNAL('itemClicked(QTreeWidgetItem*, int)')) do |node, col|
310
+ if node.checkState == Qt::Checked
311
+ # Set all nodes below this to checked
312
+ node.setCheckStateAll(Qt::Checked)
313
+
314
+ # Set all the nodes above this to checked
315
+ while node.parent
316
+ node = node.parent
317
+ node.setCheckState(0, Qt::Checked)
318
+ end
319
+ else
320
+ # Set all nodes below this to unchecked
321
+ node.setCheckStateAll(Qt::Unchecked)
322
+ end
323
+ end
324
+ end
325
+
326
+ # Yields each of the top level items (those without a parent).
327
+ def topLevelItems
328
+ topLevelItemCount.times do |index|
329
+ yield topLevelItem(index)
330
+ end
331
+ end
332
+ end
333
+
334
+ class Qt::TreeWidgetItem
335
+ # Sets the check state of this TreeWidgetItem as well as all its children
336
+ # recursively.
337
+ #
338
+ # @param state [Integer] Must be Qt::Checked or Qt::Unchecked
339
+ def setCheckStateAll(state = Qt::Checked)
340
+ children() do |child|
341
+ child.setCheckStateAll(state)
342
+ end
343
+ setCheckState(0, state)
344
+ end
345
+
346
+ # @return [Qt::TreeWidgetItem] The top level item for this TreeWidgetItem.
347
+ # The top level item does not have a parent. Note that this could return
348
+ # itself.
349
+ def topLevel
350
+ top = self
351
+ if !top.parent.nil?
352
+ while true
353
+ top = top.parent
354
+ break if top.parent.nil?
355
+ end
356
+ end
357
+ top
358
+ end
359
+
360
+ # Yields the children of the current node
361
+ def children
362
+ childCount.times do |index|
363
+ yield child(index)
364
+ end
365
+ end
366
+
367
+ # Define the default column to be 0
368
+ def background(column = 0)
369
+ super(column)
370
+ end
371
+ def checkState(column = 0)
372
+ super(column)
373
+ end
374
+ def font(column = 0)
375
+ super(column)
376
+ end
377
+ def foreground(column = 0)
378
+ super(column)
379
+ end
380
+ def icon(column = 0)
381
+ super(column)
382
+ end
383
+ def statusTip(column = 0)
384
+ super(column)
385
+ end
386
+ def sizeHint(column = 0)
387
+ super(column)
388
+ end
389
+ def text(column = 0)
390
+ super(column)
391
+ end
392
+ def toolTip(column = 0)
393
+ super(column)
394
+ end
395
+ def whatsThis(column = 0)
396
+ super(column)
397
+ end
398
+ end
399
+
400
+ class Qt::TabWidget
401
+ def tab(index)
402
+ widget(index)
403
+ end
404
+
405
+ def widgets
406
+ all = []
407
+ (0...self.count()).each do |index|
408
+ all << self.widget(index)
409
+ end
410
+ all
411
+ end
412
+ alias :tabs :widgets
413
+
414
+ def currentWidget
415
+ self.widget(self.currentIndex)
416
+ end
417
+ alias :currentTab :currentWidget
418
+ end
419
+
420
+ class Qt::LineEdit
421
+ def setColors(foreground, background)
422
+ setPalette(Cosmos.getPalette(foreground, background))
423
+ end
424
+
425
+ def text=(value)
426
+ setText(value)
427
+ end
428
+ end
429
+
430
+ class Qt::PlainTextEdit
431
+ def add_formatted_text(text, color = nil)
432
+ if text =~ /[\x00-\x08\x0B-\x0C\x0E-\x1F\x7F-\xFF]/
433
+ text.chomp!
434
+ text = text.inspect.remove_quotes
435
+ text << "\n"
436
+ end
437
+ if text =~ /<G>/ or color == Cosmos::GREEN
438
+ text.gsub!('<G>', '')
439
+ addText(text, Cosmos::GREEN)
440
+ elsif text =~ /<Y>/ or color == Cosmos::YELLOW
441
+ text.gsub!('<Y>', '')
442
+ addText(text, Cosmos::YELLOW)
443
+ elsif text =~ /<R>/ or color == Cosmos::RED
444
+ text.gsub!('<R>', '')
445
+ addText(text, Cosmos::RED)
446
+ elsif text =~ /<B>/ or color == Cosmos::BLUE
447
+ text.gsub!('<B>', '')
448
+ addText(text, Cosmos::BLUE)
449
+ else
450
+ addText(text) # default is Cosmos::BLACK
451
+ end
452
+ end
453
+
454
+ def addText(text, color = Cosmos::BLACK)
455
+ @current_text = "" if !defined? @current_text or @current_text.nil?
456
+ text = text.gsub("&", "&amp;")
457
+ text.gsub!("\n", '')
458
+ text.gsub!(' ', '&nbsp;')
459
+ text.gsub!(">", "&gt;")
460
+ text.gsub!("<", "&lt;")
461
+ rgb_color = "#%02X%02X%02X" % [color.red, color.green, color.blue]
462
+ @current_text +="<font color=\"#{rgb_color}\">#{text}</font><br/>"
463
+ end
464
+
465
+ def flush
466
+ appendHtml(@current_text)
467
+ @current_text = nil
468
+ end
469
+
470
+ def appendText(text, color = Cosmos::BLACK)
471
+ text = text.chomp
472
+ text.gsub!(/\n/, '<br/>') # replace newlines with html breaks
473
+ text.gsub!("&", "&amp;")
474
+ text.gsub!(' ', '&nbsp;')
475
+ text.gsub!(">", "&gt;")
476
+ text.gsub!("<", "&lt;")
477
+ rgb_color = "#%02X%02X%02X" % [color.red, color.green, color.blue]
478
+ appendHtml("<font color=\"#{rgb_color}\">#{text}</font>")
479
+ end
480
+
481
+ # Return the selected lines. If a partial line is selected the entire line will be returned.
482
+ # If there is no selection the line with the cursor will be returned
483
+ def selected_lines
484
+ cursor = textCursor
485
+ selection_end = cursor.selectionEnd
486
+ # Initially place the cursor at the beginning of the selection
487
+ # If nothing is selected this will just put the cursor at the beginning of the current line
488
+ cursor.setPosition(textCursor.selectionStart)
489
+ cursor.movePosition(Qt::TextCursor::StartOfLine)
490
+ # Move the cursor to the end of the selection while keeping the anchor
491
+ cursor.setPosition(selection_end, Qt::TextCursor::KeepAnchor)
492
+ # Normally we want to select the entire line where the end of selection is
493
+ # However if the user selects an exact number of lines
494
+ # the cursor will be at the beginning of the following line
495
+ # Therefore if the cursor is at the beginning of the line and we have a selection
496
+ # we'll skip moving to the end of the line
497
+ unless (cursor.atBlockStart and textCursor.hasSelection)
498
+ cursor.movePosition(Qt::TextCursor::EndOfLine, Qt::TextCursor::KeepAnchor)
499
+ end
500
+ # If there is no selection then just return nil
501
+ return nil if cursor.selectedText.nil?
502
+
503
+ cursor.selection.toPlainText
504
+
505
+ # The selectedText function returns the Unicode U+2029 paragraph separator character
506
+ # instead of newline \n. Thus we have to unpack as Unicode, covert to newlines, and then repack
507
+ #text = cursor.selectedText.unpack("U*")
508
+ #text.collect! {|letter| if letter == 63 then 10 else letter end }
509
+ #text.pack("U*")
510
+ end
511
+
512
+ # Return the line number (0 based) of the selection start
513
+ def selection_start_line
514
+ cursor = textCursor
515
+ cursor.setPosition(textCursor.selectionStart)
516
+ cursor.blockNumber
517
+ end
518
+
519
+ # Return the line number (0 based) of the selection end
520
+ def selection_end_line
521
+ cursor = textCursor
522
+ cursor.setPosition(textCursor.selectionEnd)
523
+ cursor.blockNumber
524
+ end
525
+ end
526
+
527
+ class Qt::TextEdit
528
+ def setColors(foreground, background)
529
+ setPalette(Cosmos.getPalette(foreground, background))
530
+ end
531
+ end
532
+
533
+ class Qt::ComboBox
534
+ # Helper method to remove all items from a ComboBox
535
+ def clearItems
536
+ (0...count).to_a.reverse.each do |index|
537
+ removeItem(index)
538
+ end
539
+ end
540
+
541
+ # Alias currentText as text to make it more compatible with LineEdit which uses text
542
+ def text
543
+ currentText
544
+ end
545
+
546
+ # Helper method to set the current item using a text String instead of the index
547
+ def setCurrentText(arg)
548
+ setCurrentIndex(findText(arg.to_s))
549
+ end
550
+
551
+ def each
552
+ (0...count).each do |index|
553
+ yield self.itemText(index), self.itemData(index)
554
+ end
555
+ end
556
+ end
557
+
558
+ class Qt::ListWidget
559
+ # Helper method to remove all items from a ListWidget
560
+ def clearItems
561
+ (0...count).each do
562
+ takeItem(0).dispose
563
+ end
564
+ end
565
+
566
+ def each
567
+ (0...count).each do |index|
568
+ yield self.item(index)
569
+ end
570
+ end
571
+
572
+ def remove_selected_items
573
+ # Take the selected items and call row on each to get an array of the item indexes
574
+ # Sort that array because selectedItems is returned in the order selected, not numerical order
575
+ # Reverse this array of indices so we remove the last item first,
576
+ # this allows all the indexes to remain constant
577
+ # Call takeItem of each of the indices and then dispose the resulting ListWidgetItem that is returned
578
+ selectedItems.map {|x| row(x)}.sort.reverse.each { |index| takeItem(index).dispose }
579
+ end
580
+ end
581
+
582
+ # This class attempts to duplicate Fox's FXColorList
583
+ # by adding a colored icon to each item in the ListWidget
584
+ class Qt::ColorListWidget < Qt::ListWidget
585
+ attr_reader :original_parent
586
+
587
+ def initialize(parent, enable_key_delete = true)
588
+ super(parent)
589
+ # When a layout adds this widget it automatically gets re-parented so
590
+ # store the original parent in case someone needs it
591
+ @original_parent = parent
592
+ @enable_key_delete = enable_key_delete
593
+ @colors = []
594
+ @maps = []
595
+ @icons = []
596
+ setUniformItemSizes(true)
597
+ end
598
+
599
+ def resize_to_contents
600
+ return if count == 0
601
+ #setResizeMode(Qt::ListView::Adjust)
602
+ # Disable the vertical scrollbar and don't display it
603
+ verticalScrollBar.setDisabled(true)
604
+ setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff)
605
+ # Get the height of an item and multiply by the number of items
606
+ setFixedHeight(visualItemRect(item(0)).height * (count + 1))
607
+ end
608
+
609
+ def set_read_only
610
+ setSelectionMode(Qt::AbstractItemView::NoSelection)
611
+ filter = Qt::Object.new
612
+ filter.define_singleton_method(:eventFilter) do |obj, event|
613
+ if event.type == Qt::Event::KeyPress &&
614
+ (event.key == Qt::Key_Delete || event.key == Qt::Key_Backspace)
615
+ return true
616
+ end
617
+ return false
618
+ end
619
+ installEventFilter(filter)
620
+ end
621
+
622
+ def keyPressEvent(event)
623
+ if @enable_key_delete
624
+ if (event.key == Qt::Key_Delete || event.key == Qt::Key_Backspace)
625
+ takeItemColor(currentRow)
626
+ end
627
+ end
628
+ super(event)
629
+ end
630
+
631
+ def addItemColor(text, color = Cosmos::BLACK)
632
+ @colors << color
633
+ @maps << Qt::Pixmap.new(20,14)
634
+ color = Cosmos::getColor(color)
635
+ @maps[-1].fill(color)
636
+ icon = Qt::Icon.new
637
+ icon.addPixmap(@maps[-1], Qt::Icon::Normal)
638
+ icon.addPixmap(@maps[-1], Qt::Icon::Selected)
639
+ @icons << icon
640
+ item = Qt::ListWidgetItem.new(@icons[-1], text.to_s)
641
+ addItem(item)
642
+ end
643
+
644
+ def getItemColor(index)
645
+ @colors[index]
646
+ end
647
+
648
+ def takeItemColor(row)
649
+ item = takeItem(row)
650
+ if item
651
+ @colors.delete_at(row)
652
+ @maps.delete_at(row).dispose
653
+ @icons.delete_at(row).dispose
654
+ item.dispose
655
+ end
656
+ end
657
+
658
+ def clearItems
659
+ (0...count).each do
660
+ takeItemColor(0)
661
+ end
662
+ end
663
+
664
+ def dispose
665
+ super()
666
+ @maps.each {|map| map.dispose}
667
+ @icons.each {|icon| icon.dispose}
668
+ end
669
+ end
670
+
671
+ class Qt::Painter
672
+ def addLineColor(x, y, w, h, color = Cosmos::BLACK)
673
+ color = Cosmos::getColor(color)
674
+ setPen(color)
675
+ drawLine(x,y,w,h)
676
+ end
677
+
678
+ def addRectColor(x, y, w, h, color = Cosmos::BLACK)
679
+ color = Cosmos::getColor(color)
680
+ setPen(color)
681
+ setBrush(nil)
682
+ drawRect(x,y,w,h)
683
+ end
684
+
685
+ def addRectColorFill(x, y, w, h, color = Cosmos::BLACK)
686
+ color = Cosmos::getColor(color)
687
+ setPen(color)
688
+ setBrush(Cosmos.getBrush(color))
689
+ drawRect(x,y,w,h)
690
+ end
691
+
692
+ def addSimpleTextAt(text, x, y, color = Cosmos::BLACK)
693
+ color = Cosmos::getColor(color)
694
+ setPen(color)
695
+ drawText(x, y, text)
696
+ end
697
+
698
+ def addEllipseColor(x, y, w, h, color = Cosmos::BLACK)
699
+ color = Cosmos::getColor(color)
700
+ setPen(color)
701
+ setBrush(nil)
702
+ drawEllipse(x,y,w,h)
703
+ end
704
+
705
+ def addEllipseColorFill(x, y, w, h, color = Cosmos::BLACK)
706
+ color = Cosmos::getColor(color)
707
+ setPen(color)
708
+ setBrush(Cosmos.getBrush(color))
709
+ drawEllipse(x,y,w,h)
710
+ end
711
+ end
712
+
713
+ class Qt::MatrixLayout < Qt::GridLayout
714
+ def initialize(num_columns)
715
+ super(nil)
716
+ @num_columns = num_columns
717
+ @row = 0
718
+ @col = 0
719
+ end
720
+
721
+ def addWidget(widget)
722
+ super(widget, @row, @col)
723
+ @col += 1 if @col < @num_columns
724
+ if @col == @num_columns
725
+ @row += 1
726
+ @col = 0
727
+ end
728
+ end
729
+
730
+ def addLayout(layout)
731
+ super(layout, @row, @col)
732
+ @col += 1 if @col < @num_columns
733
+ if @col == @num_columns
734
+ @row += 1
735
+ @col = 0
736
+ end
737
+ end
738
+ end
739
+
740
+ class Qt::AdaptiveGridLayout < Qt::GridLayout
741
+ def addWidget(widget)
742
+ case (count() + 1)
743
+ when 3 # reorder things to add a second column
744
+ old = takeAt(1)
745
+ addItem(old, 0, 1)
746
+ super(widget)
747
+ when 7 # reorder everything to add a third column
748
+ items = []
749
+ # Take the items in reverse order because taking an item changes the indexes
750
+ 5.downto(2).each {|index| items << takeAt(index)}
751
+ # Reverse the items to get them back into insertion order
752
+ items.reverse!
753
+ addItem(items[0], 0, 2)
754
+ addItem(items[1], 1, 0)
755
+ addItem(items[2], 1, 1)
756
+ addItem(items[3], 1, 2)
757
+ super(widget)
758
+ # When we have established the desired number of rows we can add things and GridLayout does the right thing
759
+ else
760
+ super(widget)
761
+ end
762
+ end
763
+ # removeWidget is not implemented. If you want to remove widgets, transfer the existing to a new layout like so:
764
+ # (0...old_layout.count).each do |index|
765
+ # new_layout.addWidget(old_layout.takeAt(0).widget)
766
+ # end
767
+ end
768
+
769
+ # Implement removeAll on all the layout managers.
770
+ # It would be easier to add this method on Qt::Layout which is the parent class to all but
771
+ # that doesn't work due to the way method_missing is used to call the actual method
772
+ %w(GridLayout BoxLayout VBoxLayout HBoxLayout FormLayout StackedLayout).each do |klass|
773
+ "Qt::#{klass}".to_class.class_eval do
774
+ def removeAll
775
+ (0...count).each do |index|
776
+ item = takeAt(0)
777
+ if item.layout
778
+ item.removeAll
779
+ else
780
+ item.widget.dispose
781
+ end
782
+ end
783
+ end
784
+ end
785
+ end
786
+
787
+ class Qt::BoxLayout
788
+ def initialize(*args)
789
+ super(*args)
790
+ setSpacing(5) if Kernel.is_mac?
791
+ end
792
+ end
793
+
794
+ class Qt::VBoxLayout
795
+ def initialize(*args)
796
+ super(*args)
797
+ setSpacing(5) if Kernel.is_mac?
798
+ end
799
+ end
800
+
801
+ class Qt::HBoxLayout
802
+ def initialize(*args)
803
+ super(*args)
804
+ setSpacing(5) if Kernel.is_mac?
805
+ end
806
+ end
807
+
808
+ class Qt::GridLayout
809
+ def initialize(*args)
810
+ super(*args)
811
+ setSpacing(5) if Kernel.is_mac?
812
+ end
813
+ end