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,38 +1,38 @@
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 implements a class to handle responses to limits state changes.
12
-
13
- require 'cosmos/tools/cmd_tlm_server/api'
14
-
15
- module Cosmos
16
- # This class defines a #call method which is called when a PacketItem
17
- # goes out of limits. This class must be subclassed and the call method
18
- # implemented. Do NOT use this class directly.
19
- class LimitsResponse
20
-
21
- include Api
22
-
23
- # @param packet [Packet] Packet the limits response is assigned to
24
- # @param item [PacketItem] PacketItem the limits response is assigned to
25
- # @param old_limits_state [Symbol] Previous value of the limit. One of nil,
26
- # :GREEN_HIGH, :GREEN_LOW, :YELLOW, :YELLOW_HIGH, :YELLOW_LOW,
27
- # :RED, :RED_HIGH, :RED_LOW. nil if the previous limit state has not yet
28
- # been established.
29
- def call(packet, item, old_limits_state)
30
- raise "call method must be defined by subclass"
31
- end
32
-
33
- def to_s
34
- self.class.to_s.split('::')[-1]
35
- end
36
-
37
- end # class LimitsResponse
38
- end
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 implements a class to handle responses to limits state changes.
12
+
13
+ require 'cosmos/tools/cmd_tlm_server/api'
14
+
15
+ module Cosmos
16
+ # This class defines a #call method which is called when a PacketItem
17
+ # goes out of limits. This class must be subclassed and the call method
18
+ # implemented. Do NOT use this class directly.
19
+ class LimitsResponse
20
+
21
+ include Api
22
+
23
+ # @param packet [Packet] Packet the limits response is assigned to
24
+ # @param item [PacketItem] PacketItem the limits response is assigned to
25
+ # @param old_limits_state [Symbol] Previous value of the limit. One of nil,
26
+ # :GREEN_HIGH, :GREEN_LOW, :YELLOW, :YELLOW_HIGH, :YELLOW_LOW,
27
+ # :RED, :RED_HIGH, :RED_LOW. nil if the previous limit state has not yet
28
+ # been established.
29
+ def call(packet, item, old_limits_state)
30
+ raise "call method must be defined by subclass"
31
+ end
32
+
33
+ def to_s
34
+ self.class.to_s.split('::')[-1]
35
+ end
36
+
37
+ end # class LimitsResponse
38
+ end
@@ -1,699 +1,714 @@
1
- # encoding: ascii-8bit
2
-
3
- # Copyright 2014 Ball Aerospace & Technologies Corp.
4
- # All Rights Reserved.
5
- #
6
- # This program is free software; you can modify and/or redistribute it
7
- # under the terms of the GNU General Public License
8
- # as published by the Free Software Foundation; version 3 with
9
- # attribution addendums as found in the LICENSE.txt
10
-
11
- require 'cosmos/packets/structure'
12
- require 'cosmos/packets/packet_item'
13
- require 'cosmos/ext/packet'
14
-
15
- module Cosmos
16
-
17
- # Adds features common to all COSMOS packets of data to the Structure class.
18
- # This includes the additional attributes listed below. The primary behavior
19
- # Packet adds is the ability to apply formatting to PacketItem values as well
20
- # as managing PacketItem's limit states.
21
- class Packet < Structure
22
-
23
- # @return [String] Name of the target this packet is associated with
24
- attr_reader :target_name
25
-
26
- # @return [String] Name of the packet
27
- attr_reader :packet_name
28
-
29
- # @return [String] Description of the packet
30
- attr_reader :description
31
-
32
- # @return [Time] Time at which the packet was received
33
- attr_reader :received_time
34
-
35
- # @return [Integer] Number of times the packet has been received
36
- attr_reader :received_count
37
-
38
- # @return [Boolean] Flag indicating if the packet is hazardous (typically for commands)
39
- attr_accessor :hazardous
40
-
41
- # @return [String] Description of why the packet is hazardous
42
- attr_reader :hazardous_description
43
-
44
- # Containst the values given by the user for a command (distinguished from defaults)
45
- # These values should be used within command conversions if present because the order
46
- # that values are written into the actual packet can vary
47
- # @return [Hash<Item Name, Value>] Given values when constructing the packet
48
- attr_reader :given_values
49
-
50
- # @return [Boolean] Flag indicating if the packet is stale (hasn't been received recently)
51
- attr_reader :stale
52
-
53
- # @return [Boolean] Whether or not this is a 'raw' packet
54
- attr_accessor :raw
55
-
56
- # @return [Boolean] Whether or not this is a 'hidden' packet
57
- attr_accessor :hidden
58
-
59
- # @return [Boolean] Whether or not this is a 'disabled' packet
60
- attr_accessor :disabled
61
-
62
- # @return [Boolean] Whether or not messages should be printed for this packet
63
- attr_accessor :messages_disabled
64
-
65
- # Valid format types
66
- VALUE_TYPES = [:RAW, :CONVERTED, :FORMATTED, :WITH_UNITS]
67
-
68
- # Creates a new packet by initalizing the attributes.
69
- #
70
- # @param target_name [String] Name of the target this packet is associated with
71
- # @param packet_name [String] Name of the packet
72
- # @param default_endianness [Symbol] One of {BinaryAccessor::ENDIANNESS}
73
- # @param description [String] Description of the packet
74
- # @param buffer [String] String buffer to hold the packet data
75
- # @param item_class [Class] Class used to instantiate items (Must be a
76
- # subclass of PacketItem)
77
- # def initialize(target_name, packet_name, default_endianness = :BIG_ENDIAN, description = nil, buffer = '', item_class = PacketItem)
78
-
79
- # (see Structure#buffer=)
80
- def buffer=(buffer)
81
- synchronize() do
82
- begin
83
- internal_buffer_equals(buffer)
84
- rescue RuntimeError
85
- Logger.instance.error "#{@target_name} #{@packet_name} received with actual packet length of #{buffer.length} but defined length of #{@defined_length}"
86
- end
87
- @read_conversion_cache.clear if @read_conversion_cache
88
- process()
89
- end
90
- end
91
-
92
- # Sets the target name this packet is associated with. Unidentified packets
93
- # will have target name set to nil.
94
- #
95
- # @param target_name [String] Name of the target this packet is associated with
96
- # def target_name=(target_name)
97
-
98
- # Sets the packet name. Unidentified packets will have packet name set to
99
- # nil.
100
- #
101
- # @param packet_name [String] Name of the packet
102
- # def packet_name=(packet_name)
103
-
104
- # Sets the description of the packet
105
- #
106
- # @param description [String] Description of the packet
107
- # def description=(description)
108
-
109
- # Sets the received time of the packet
110
- #
111
- # @param received_time [Time] Time this packet was received
112
- # def received_time=(received_time)
113
-
114
- # Sets the received time of the packet (without cloning)
115
- #
116
- # @param received_time [Time] Time this packet was received
117
- def set_received_time_fast(received_time)
118
- @received_time = received_time
119
- @received_time.freeze if @received_time
120
- end
121
-
122
- # Sets the received count of the packet
123
- #
124
- # @param received_count [Integer] Number of times this packet has been
125
- # received
126
- # def received_count=(received_count)
127
-
128
- # Sets the hazardous description of the packet
129
- #
130
- # @param hazardous_description [String] Hazardous description of the packet
131
- def hazardous_description=(hazardous_description)
132
- if hazardous_description
133
- raise ArgumentError, "hazardous_description must be a String but is a #{hazardous_description.class}" unless String === hazardous_description
134
- @hazardous_description = hazardous_description.clone.freeze
135
- else
136
- @hazardous_description = nil
137
- end
138
- end
139
-
140
- # Saves a hash of the values given by a user when constructing a command
141
- #
142
- # @param given_values [Hash<Item Name, Value>] Hash of given command parameters
143
- def given_values=(given_values)
144
- if given_values
145
- raise ArgumentError, "given_values must be a Hash but is a #{given_values.class}" unless Hash === given_values
146
- @given_values = given_values.clone
147
- else
148
- @given_values = nil
149
- end
150
- end
151
-
152
- # Sets the callback object called when a limits state changes
153
- #
154
- # @param limits_change_callback [#call] Object must respond to the call
155
- # method and take the following arguments: packet (Packet), item (PacketItem),
156
- # old_limits_state (Symbol), item_value (Object), log_change (Boolean). The
157
- # current item state can be found by querying the item object:
158
- # item.limits.state.
159
- def limits_change_callback=(limits_change_callback)
160
- if limits_change_callback
161
- raise ArgumentError, "limits_change_callback must respond to call" unless limits_change_callback.respond_to?(:call)
162
- @limits_change_callback = limits_change_callback
163
- else
164
- @limits_change_callback = nil
165
- end
166
- end
167
-
168
- # Id items are used by the identify? method to determine if a raw buffer of
169
- # data represents this packet.
170
- # @return [Array<PacketItem>] Packet item identifiers
171
- def id_items
172
- @id_items ||= []
173
- end
174
-
175
- # @return [Array<PacketItem>] All items with defined limits
176
- def limits_items
177
- @limits_items ||= []
178
- end
179
-
180
- # @return [Hash] Hash of processors associated with this packet
181
- def processors
182
- @processors ||= {}
183
- end
184
-
185
- # Returns packet specific metadata
186
- # @return [Hash<Meta Name, Meta Values>]
187
- def meta
188
- @meta ||= {}
189
- end
190
-
191
- # Indicates if the packet has been identified
192
- # @return [TrueClass or FalseClass]
193
- def identified?
194
- !@target_name.nil? && !@packet_name.nil?
195
- end
196
-
197
- # Define an item in the packet. This creates a new instance of the
198
- # item_class as given in the constructor and adds it to the items hash. It
199
- # also resizes the buffer to accomodate the new item.
200
- #
201
- # @param name [String] Name of the item. Used by the items hash to retrieve
202
- # the item.
203
- # @param bit_offset [Integer] Bit offset of the item in the raw buffer
204
- # @param bit_size [Integer] Bit size of the item in the raw buffer
205
- # @param data_type [Symbol] Type of data contained by the item. This is
206
- # dependant on the item_class but by default see StructureItem.
207
- # @param array_size [Integer] Set to a non nil value if the item is to
208
- # represented as an array.
209
- # @param endianness [Symbol] Endianness of this item. By default the
210
- # endianness as set in the constructure is used.
211
- # @param overflow [Symbol] How to handle value overflows. This is
212
- # dependant on the item_class but by default see StructureItem.
213
- # @param format_string [String] String to pass to Kernel#sprintf
214
- # @param read_conversion [Conversion] Conversion to apply when reading the
215
- # item from the packet buffer
216
- # @param write_conversion [Conversion] Conversion to apply before writing
217
- # the item to the packet buffer
218
- # @param id_value [Object] Set to something other than nil to indicate that
219
- # this item should be used to identify a buffer as this packet. The
220
- # id_value should make sense according to the data_type.
221
- def define_item(name, bit_offset, bit_size, data_type, array_size = nil, endianness = @default_endianness, overflow = :ERROR, format_string = nil, read_conversion = nil, write_conversion = nil, id_value = nil)
222
- item = super(name, bit_offset, bit_size, data_type, array_size, endianness, overflow)
223
- packet_define_item(item, format_string, read_conversion, write_conversion, id_value)
224
- end
225
-
226
- # Define an item at the end of the packet. This creates a new instance of the
227
- # item_class as given in the constructor and adds it to the items hash. It
228
- # also resizes the buffer to accomodate the new item.
229
- #
230
- # @param name (see #define_item)
231
- # @param bit_size (see #define_item)
232
- # @param data_type (see #define_item)
233
- # @param array_size (see #define_item)
234
- # @param endianness (see #define_item)
235
- # @param overflow (see #define_item)
236
- # @param format_string (see #define_item)
237
- # @param read_conversion (see #define_item)
238
- # @param write_conversion (see #define_item)
239
- # @param id_value (see #define_item)
240
- def append_item(name, bit_size, data_type, array_size = nil, endianness = @default_endianness, overflow = :ERROR, format_string = nil, read_conversion = nil, write_conversion = nil, id_value = nil)
241
- item = super(name, bit_size, data_type, array_size, endianness, overflow)
242
- packet_define_item(item, format_string, read_conversion, write_conversion, id_value)
243
- end
244
-
245
- # (see Structure#get_item)
246
- def get_item(name)
247
- super(name)
248
- rescue ArgumentError
249
- raise "Packet item '#{@target_name} #{@packet_name} #{name.upcase}' does not exist"
250
- end
251
-
252
- # Read an item in the packet
253
- #
254
- # @param item [PacketItem] Instance of PacketItem or one of its subclasses
255
- # @param value_type [Symbol] How to convert the item before returning it.
256
- # Must be one of {VALUE_TYPES}
257
- # @param buffer (see Structure#read_item)
258
- # @return The value. :FORMATTED and :WITH_UNITS values are always returned
259
- # as Strings. :RAW values will match their data_type. :CONVERTED values
260
- # can be any type.
261
- def read_item(item, value_type = :CONVERTED, buffer = @buffer)
262
- value = super(item, :RAW, buffer)
263
- case value_type
264
- when :RAW
265
- # Done above
266
- when :CONVERTED, :FORMATTED, :WITH_UNITS
267
- if item.read_conversion
268
- use_cache = buffer.equal?(@buffer)
269
- if use_cache and @read_conversion_cache and @read_conversion_cache[item]
270
- value = @read_conversion_cache[item]
271
- else
272
- if item.array_size
273
- value.map! do |val, index|
274
- item.read_conversion.call(val, self, buffer)
275
- end
276
- else
277
- value = item.read_conversion.call(value, self, buffer)
278
- end
279
- @read_conversion_cache ||= {}
280
- @read_conversion_cache[item] = value if use_cache
281
- end
282
- end
283
-
284
- # Convert from value to state if possible
285
- if item.states
286
- if item.array_size
287
- value = value.map do |val, index|
288
- if item.states.key(val)
289
- item.states.key(val)
290
- else
291
- apply_format_string_and_units(item, val, value_type)
292
- end
293
- end
294
- else
295
- state_value = item.states.key(value)
296
- if state_value
297
- value = state_value
298
- else
299
- value = apply_format_string_and_units(item, value, value_type)
300
- end
301
- end
302
- else
303
- if item.array_size
304
- value = value.map do |val, index|
305
- apply_format_string_and_units(item, val, value_type)
306
- end
307
- else
308
- value = apply_format_string_and_units(item, value, value_type)
309
- end
310
- end
311
- else
312
- raise ArgumentError, "Unknown value type on read: #{value_type}"
313
- end
314
- return value
315
- end
316
-
317
- # Write an item in the packet
318
- #
319
- # @param item [PacketItem] Instance of PacketItem or one of its subclasses
320
- # @param value (see Structure#write_item)
321
- # @param value_type (see #read_item)
322
- # @param buffer (see Structure#write_item)
323
- def write_item(item, value, value_type = :CONVERTED, buffer = @buffer)
324
- @read_conversion_cache.clear if @read_conversion_cache
325
- case value_type
326
- when :RAW
327
- super(item, value, value_type, buffer)
328
- when :CONVERTED
329
- if item.states
330
- # Convert from state to value if possible
331
- state_value = item.states[value.to_s.upcase]
332
- value = state_value if state_value
333
- end
334
- if item.write_conversion
335
- value = item.write_conversion.call(value, self, buffer)
336
- else
337
- raise "Cannot write DERIVED item without a write conversion" if item.data_type == :DERIVED
338
- end
339
- begin
340
- super(item, value, :RAW, buffer) unless item.data_type == :DERIVED
341
- rescue ArgumentError => err
342
- if item.states and String === value and err.message =~ /invalid value for/
343
- raise "Unknown state #{value} for #{item.name}"
344
- else
345
- raise err
346
- end
347
- end
348
- when :FORMATTED, :WITH_UNITS
349
- raise ArgumentError, "Invalid value type on write: #{value_type}"
350
- else
351
- raise ArgumentError, "Unknown value type on write: #{value_type}"
352
- end
353
- end
354
-
355
- # Read an item in the packet by name
356
- #
357
- # @param name [String] Name of the item to read
358
- # @param value_type (see #read_item)
359
- # @param buffer (see #read_item)
360
- # @return (see #read_item)
361
- def read(name, value_type = :CONVERTED, buffer = @buffer)
362
- return super(name, value_type, buffer)
363
- end
364
-
365
- # Write an item in the packet by name
366
- #
367
- # @param name [String] Name of the item to write
368
- # @param value (see #write_item)
369
- # @param value_type (see #write_item)
370
- # @param buffer (see #write_item)
371
- def write(name, value, value_type = :CONVERTED, buffer = @buffer)
372
- super(name, value, value_type, buffer)
373
- end
374
-
375
- # Read all items in the packet into an array of arrays
376
- # [[item name, item value], ...]
377
- #
378
- # @param value_type (see #read_item)
379
- # @param buffer (see Structure#read_all)
380
- # @return (see Structure#read_all)
381
- def read_all(value_type = :CONVERTED, buffer = @buffer)
382
- return super(value_type, buffer)
383
- end
384
-
385
- # Read all items in the packet into an array of arrays
386
- # [[item name, item value], [item limits state], ...]
387
- #
388
- # @param value_type (see #read_all)
389
- # @param buffer (see #read_all)
390
- # @return [Array<String, Object, Symbol|nil>] Returns an Array consisting
391
- # of [item name, item value, item limits state] where the item limits
392
- # state can be one of {Cosmos::Limits::LIMITS_STATES}
393
- def read_all_with_limits_states(value_type = :CONVERTED, buffer = @buffer)
394
- return read_all(value_type, buffer).map! do |array|
395
- array << @items[array[0]].limits.state
396
- end
397
- end
398
-
399
- # Create a string that shows the name and value of each item in the packet
400
- #
401
- # @param value_type (see #read_item)
402
- # @param indent (see Structure#formatted)
403
- # @param buffer (see Structure#formatted)
404
- # @return (see Structure#formatted)
405
- def formatted(value_type = :CONVERTED, indent = 0, buffer = @buffer)
406
- return super(value_type, indent, buffer)
407
- end
408
-
409
- # Tries to identify if a buffer represents the currently defined packet. It
410
- # does this by iterating over all the packet items that were created with
411
- # an ID value and checking whether that ID value is present at the correct
412
- # location in the buffer.
413
- #
414
- # Incorrectly sized buffers will still positively identify if there is
415
- # enough data to match the ID values. This is to allow incorrectly sized
416
- # packets to still be processed as well as possible given the incorrectly
417
- # sized data.
418
- #
419
- # @param buffer [String] Raw buffer of binary data
420
- # @return [Boolean] Whether or not the buffer of data is this packet
421
- # def identify?(buffer)
422
-
423
- # Restore all items in the packet to their default value
424
- #
425
- # @param buffer [String] Raw buffer of binary data
426
- def restore_defaults(buffer = @buffer)
427
- @sorted_items.each do |item|
428
- write_item(item, item.default, :CONVERTED, buffer)
429
- end
430
- end
431
-
432
- # Enable limits on an item by name
433
- #
434
- # @param name [String] Name of the item to enable limits
435
- def enable_limits(name)
436
- get_item(name).limits.enabled = true
437
- end
438
-
439
- # Disable limits on an item by name
440
- #
441
- # @param name [String] Name of the item to disable limits
442
- def disable_limits(name)
443
- item = get_item(name)
444
- item.limits.enabled = false
445
- unless item.limits.state == :STALE
446
- old_limits_state = item.limits.state
447
- item.limits.state = nil
448
- @limits_change_callback.call(self, item, old_limits_state, nil, false) if @limits_change_callback
449
- end
450
- end
451
-
452
- # Force the packet to update its knowledge of items with limits. This is an
453
- # optimization so we don't have to iterate through all the items when
454
- # checking for limits.
455
- def update_limits_items_cache
456
- # Collect only the items who have limits values or states and then
457
- # compact the array to remove all the nil values
458
- @limits_items = @sorted_items.collect do |item|
459
- item if item.limits.values || item.state_colors
460
- end
461
- @limits_items.compact!
462
- end
463
-
464
- # Return an array of arrays indicating all items in the packet that are out of limits
465
- # [[target name, packet name, item name, item limits state], ...]
466
- #
467
- # @return [Array<Array<String, String, String, Symbol>>]
468
- def out_of_limits
469
- items = []
470
- return items unless @limits_items
471
- @limits_items.each do |item|
472
- if (item.limits.enabled && item.limits.state &&
473
- PacketItemLimits::OUT_OF_LIMITS_STATES.include?(item.limits.state))
474
- items << [@target_name, @packet_name, item.name, item.limits.state]
475
- end
476
- end
477
- return items
478
- end
479
-
480
- # Set the limits state for all items to the given state
481
- #
482
- # @param state [Symbol] Must be one of PacketItemLimits::LIMITS_STATES
483
- def set_all_limits_states(state)
484
- @sorted_items.each {|item| item.limits.state = state}
485
- end
486
-
487
- # Check all the items in the packet against their defined limits. Update
488
- # their internal limits state and persistence and call the
489
- # limits_change_callback as necessary.
490
- #
491
- # @param limits_set [Symbol] Which limits set to check the item values
492
- # against.
493
- # @param ignore_persistence [Boolean] Whether to ignore persistence when
494
- # checking for out of limits
495
- def check_limits(limits_set = :DEFAULT, ignore_persistence = false)
496
- # If check_limits is being called, then a new packet has arrived and
497
- # this packet is no longer stale
498
- if @stale
499
- @stale = false
500
- set_all_limits_states(nil)
501
- end
502
-
503
- return unless @limits_items
504
- @limits_items.each do |item|
505
- # Verify limits monitoring is enabled for this item
506
- if item.limits.enabled
507
- value = read_item(item)
508
-
509
- # Handle state monitoring and value monitoring differently
510
- if item.states
511
- handle_limits_states(item, value)
512
- elsif item.limits.values
513
- handle_limits_values(item, value, limits_set, ignore_persistence)
514
- end
515
- end
516
- end
517
- end
518
-
519
- # Sets the overall packet stale state to true and sets each packet item
520
- # limits state to :STALE.
521
- def set_stale
522
- @stale = true
523
- set_all_limits_states(:STALE)
524
- end
525
-
526
- # Reset temporary packet data
527
- # This includes packet received time, received count, and processor state
528
- def reset
529
- @received_time = nil
530
- @received_count = 0
531
- @read_conversion_cache.clear if @read_conversion_cache
532
- return unless @processors
533
- @processors.each do |processor_name, processor|
534
- processor.reset
535
- end
536
- end
537
-
538
- # Make a light weight clone of this packet. This only creates a new buffer
539
- # of data and clones the processors. The defined packet items are the same.
540
- #
541
- # @return [Packet] A copy of the current packet with a new underlying
542
- # buffer of data and processors
543
- def clone
544
- packet = super()
545
- if packet.instance_variable_get("@processors")
546
- packet.processors.each do |processor_name, processor|
547
- packet.processors[processor_name] = processor.clone
548
- end
549
- end
550
- packet
551
- end
552
- alias dup clone
553
-
554
- protected
555
-
556
- # Performs packet specific processing on the packet. Intended to only be run once for each packet received
557
- def process(buffer = @buffer)
558
- return unless @processors
559
- @processors.each do |processor_name, processor|
560
- processor.call(self, buffer)
561
- end
562
- end
563
-
564
- def handle_limits_states(item, value)
565
- # Retrieve limits state for the given value
566
- limits_state = item.state_colors[value]
567
-
568
- if item.limits.state != limits_state # PacketItemLimits state has changed
569
- # Save old limits state
570
- old_limits_state = item.limits.state
571
- # Update to new limits state
572
- item.limits.state = limits_state
573
-
574
- if old_limits_state == nil # Changing from nil
575
- if limits_state != :GREEN && limits_state != :BLUE # Warnings are needed
576
- @limits_change_callback.call(self, item, old_limits_state, value, true) if @limits_change_callback
577
- end
578
- else # Changing from a state other than nil so always call the callback
579
- if @limits_change_callback
580
- if item.limits.state.nil?
581
- @limits_change_callback.call(self, item, old_limits_state, value, false)
582
- else
583
- @limits_change_callback.call(self, item, old_limits_state, value, true)
584
- end
585
- end
586
- end
587
- end
588
- end
589
-
590
- def handle_limits_values(item, value, limits_set, ignore_persistence)
591
- # Retrieve limits settings for the specified limits_set
592
- limits = item.limits.values[limits_set]
593
-
594
- # Use the default limits set if limits aren't specified for the
595
- # particular limits set
596
- limits = item.limits.values[:DEFAULT] unless limits
597
-
598
- # Extract limits from array
599
- red_low = limits[0]
600
- yellow_low = limits[1]
601
- yellow_high = limits[2]
602
- red_high = limits[3]
603
- green_low = limits[4]
604
- green_high = limits[5]
605
- limits_state = nil
606
-
607
- # Determine the limits_state based on the limits values and the current
608
- # value of the item
609
- if (value > yellow_low)
610
- if (value < yellow_high)
611
- if green_low
612
- if value < green_high
613
- if value > green_low
614
- limits_state = :BLUE
615
- else
616
- limits_state = :GREEN_LOW
617
- end
618
- else
619
- limits_state = :GREEN_HIGH
620
- end
621
- else
622
- limits_state = :GREEN
623
- end
624
- elsif (value < red_high)
625
- limits_state = :YELLOW_HIGH
626
- else
627
- limits_state = :RED_HIGH
628
- end
629
- else # value <= yellow_low
630
- if (value > red_low)
631
- limits_state = :YELLOW_LOW
632
- else
633
- limits_state = :RED_LOW
634
- end
635
- end
636
-
637
- if item.limits.state != limits_state # limits state has changed
638
- # Save old limits state
639
- old_limits_state = item.limits.state
640
-
641
- if old_limits_state == nil # Changing from nil
642
- # Persistence is ignored when changing from nil.
643
- # Immediately update limits state
644
- item.limits.state = limits_state
645
-
646
- if @limits_change_callback && PacketItemLimits::OUT_OF_LIMITS_STATES.include?(limits_state)
647
- @limits_change_callback.call(self, item, old_limits_state, value, true)
648
- end
649
-
650
- # Clear the persistence since we've entered a new state
651
- item.limits.persistence_count = 0
652
-
653
- else # changing from a current state (:GREEN, :YELLOW, :RED, etc)
654
- item.limits.persistence_count += 1
655
-
656
- # Check for item to achieve its persistence which means we
657
- # have to update the state and call the callback
658
- if (item.limits.persistence_count >= item.limits.persistence_setting) or ignore_persistence
659
- item.limits.state = limits_state
660
-
661
- # Additional actions for limits change
662
- @limits_change_callback.call(self, item, old_limits_state, value, true) if @limits_change_callback
663
-
664
- # Clear Persistence since we've entered a new state
665
- item.limits.persistence_count = 0
666
- end
667
- end
668
- end # limits state has not changed
669
- end
670
-
671
- def apply_format_string_and_units(item, value, value_type)
672
- if value_type == :FORMATTED or value_type == :WITH_UNITS
673
- if item.format_string && value
674
- value = sprintf(item.format_string, value)
675
- else
676
- value = value.to_s
677
- end
678
- end
679
- value << ' ' << item.units if value_type == :WITH_UNITS and item.units
680
- value
681
- end
682
-
683
- def packet_define_item(item, format_string, read_conversion, write_conversion, id_value)
684
- item.format_string = format_string
685
- item.read_conversion = read_conversion
686
- item.write_conversion = write_conversion
687
-
688
- # Change id_value to the correct type
689
- if id_value
690
- item.id_value = id_value
691
- @id_items ||= []
692
- @id_items << item
693
- end
694
-
695
- item
696
- end
697
- end # class Packet
698
-
699
- end # module Cosmos
1
+ # encoding: ascii-8bit
2
+
3
+ # Copyright 2014 Ball Aerospace & Technologies Corp.
4
+ # All Rights Reserved.
5
+ #
6
+ # This program is free software; you can modify and/or redistribute it
7
+ # under the terms of the GNU General Public License
8
+ # as published by the Free Software Foundation; version 3 with
9
+ # attribution addendums as found in the LICENSE.txt
10
+
11
+ require 'cosmos/packets/structure'
12
+ require 'cosmos/packets/packet_item'
13
+ require 'cosmos/ext/packet'
14
+
15
+ module Cosmos
16
+
17
+ # Adds features common to all COSMOS packets of data to the Structure class.
18
+ # This includes the additional attributes listed below. The primary behavior
19
+ # Packet adds is the ability to apply formatting to PacketItem values as well
20
+ # as managing PacketItem's limit states.
21
+ class Packet < Structure
22
+
23
+ # @return [String] Name of the target this packet is associated with
24
+ attr_reader :target_name
25
+
26
+ # @return [String] Name of the packet
27
+ attr_reader :packet_name
28
+
29
+ # @return [String] Description of the packet
30
+ attr_reader :description
31
+
32
+ # @return [Time] Time at which the packet was received
33
+ attr_reader :received_time
34
+
35
+ # @return [Integer] Number of times the packet has been received
36
+ attr_reader :received_count
37
+
38
+ # @return [Boolean] Flag indicating if the packet is hazardous (typically for commands)
39
+ attr_accessor :hazardous
40
+
41
+ # @return [String] Description of why the packet is hazardous
42
+ attr_reader :hazardous_description
43
+
44
+ # Containst the values given by the user for a command (distinguished from defaults)
45
+ # These values should be used within command conversions if present because the order
46
+ # that values are written into the actual packet can vary
47
+ # @return [Hash<Item Name, Value>] Given values when constructing the packet
48
+ attr_reader :given_values
49
+
50
+ # @return [Boolean] Flag indicating if the packet is stale (hasn't been received recently)
51
+ attr_reader :stale
52
+
53
+ # @return [Boolean] Whether or not this is a 'raw' packet
54
+ attr_accessor :raw
55
+
56
+ # @return [Boolean] Whether or not this is a 'hidden' packet
57
+ attr_accessor :hidden
58
+
59
+ # @return [Boolean] Whether or not this is a 'disabled' packet
60
+ attr_accessor :disabled
61
+
62
+ # @return [Boolean] Whether or not messages should be printed for this packet
63
+ attr_accessor :messages_disabled
64
+
65
+ # Valid format types
66
+ VALUE_TYPES = [:RAW, :CONVERTED, :FORMATTED, :WITH_UNITS]
67
+
68
+ # Creates a new packet by initalizing the attributes.
69
+ #
70
+ # @param target_name [String] Name of the target this packet is associated with
71
+ # @param packet_name [String] Name of the packet
72
+ # @param default_endianness [Symbol] One of {BinaryAccessor::ENDIANNESS}
73
+ # @param description [String] Description of the packet
74
+ # @param buffer [String] String buffer to hold the packet data
75
+ # @param item_class [Class] Class used to instantiate items (Must be a
76
+ # subclass of PacketItem)
77
+ # def initialize(target_name, packet_name, default_endianness = :BIG_ENDIAN, description = nil, buffer = '', item_class = PacketItem)
78
+
79
+ # (see Structure#buffer=)
80
+ def buffer=(buffer)
81
+ synchronize() do
82
+ begin
83
+ internal_buffer_equals(buffer)
84
+ rescue RuntimeError
85
+ Logger.instance.error "#{@target_name} #{@packet_name} received with actual packet length of #{buffer.length} but defined length of #{@defined_length}"
86
+ end
87
+ @read_conversion_cache.clear if @read_conversion_cache
88
+ process()
89
+ end
90
+ end
91
+
92
+ # Sets the target name this packet is associated with. Unidentified packets
93
+ # will have target name set to nil.
94
+ #
95
+ # @param target_name [String] Name of the target this packet is associated with
96
+ # def target_name=(target_name)
97
+
98
+ # Sets the packet name. Unidentified packets will have packet name set to
99
+ # nil.
100
+ #
101
+ # @param packet_name [String] Name of the packet
102
+ # def packet_name=(packet_name)
103
+
104
+ # Sets the description of the packet
105
+ #
106
+ # @param description [String] Description of the packet
107
+ # def description=(description)
108
+
109
+ # Sets the received time of the packet
110
+ #
111
+ # @param received_time [Time] Time this packet was received
112
+ # def received_time=(received_time)
113
+
114
+ # Sets the received time of the packet (without cloning)
115
+ #
116
+ # @param received_time [Time] Time this packet was received
117
+ def set_received_time_fast(received_time)
118
+ @received_time = received_time
119
+ @received_time.freeze if @received_time
120
+ end
121
+
122
+ # Sets the received count of the packet
123
+ #
124
+ # @param received_count [Integer] Number of times this packet has been
125
+ # received
126
+ # def received_count=(received_count)
127
+
128
+ # Sets the hazardous description of the packet
129
+ #
130
+ # @param hazardous_description [String] Hazardous description of the packet
131
+ def hazardous_description=(hazardous_description)
132
+ if hazardous_description
133
+ raise ArgumentError, "hazardous_description must be a String but is a #{hazardous_description.class}" unless String === hazardous_description
134
+ @hazardous_description = hazardous_description.clone.freeze
135
+ else
136
+ @hazardous_description = nil
137
+ end
138
+ end
139
+
140
+ # Saves a hash of the values given by a user when constructing a command
141
+ #
142
+ # @param given_values [Hash<Item Name, Value>] Hash of given command parameters
143
+ def given_values=(given_values)
144
+ if given_values
145
+ raise ArgumentError, "given_values must be a Hash but is a #{given_values.class}" unless Hash === given_values
146
+ @given_values = given_values.clone
147
+ else
148
+ @given_values = nil
149
+ end
150
+ end
151
+
152
+ # Sets the callback object called when a limits state changes
153
+ #
154
+ # @param limits_change_callback [#call] Object must respond to the call
155
+ # method and take the following arguments: packet (Packet), item (PacketItem),
156
+ # old_limits_state (Symbol), item_value (Object), log_change (Boolean). The
157
+ # current item state can be found by querying the item object:
158
+ # item.limits.state.
159
+ def limits_change_callback=(limits_change_callback)
160
+ if limits_change_callback
161
+ raise ArgumentError, "limits_change_callback must respond to call" unless limits_change_callback.respond_to?(:call)
162
+ @limits_change_callback = limits_change_callback
163
+ else
164
+ @limits_change_callback = nil
165
+ end
166
+ end
167
+
168
+ # Id items are used by the identify? method to determine if a raw buffer of
169
+ # data represents this packet.
170
+ # @return [Array<PacketItem>] Packet item identifiers
171
+ def id_items
172
+ @id_items ||= []
173
+ end
174
+
175
+ # @return [Array<PacketItem>] All items with defined limits
176
+ def limits_items
177
+ @limits_items ||= []
178
+ end
179
+
180
+ # @return [Hash] Hash of processors associated with this packet
181
+ def processors
182
+ @processors ||= {}
183
+ end
184
+
185
+ # Returns packet specific metadata
186
+ # @return [Hash<Meta Name, Meta Values>]
187
+ def meta
188
+ @meta ||= {}
189
+ end
190
+
191
+ # Indicates if the packet has been identified
192
+ # @return [TrueClass or FalseClass]
193
+ def identified?
194
+ !@target_name.nil? && !@packet_name.nil?
195
+ end
196
+
197
+ # Define an item in the packet. This creates a new instance of the
198
+ # item_class as given in the constructor and adds it to the items hash. It
199
+ # also resizes the buffer to accomodate the new item.
200
+ #
201
+ # @param name [String] Name of the item. Used by the items hash to retrieve
202
+ # the item.
203
+ # @param bit_offset [Integer] Bit offset of the item in the raw buffer
204
+ # @param bit_size [Integer] Bit size of the item in the raw buffer
205
+ # @param data_type [Symbol] Type of data contained by the item. This is
206
+ # dependant on the item_class but by default see StructureItem.
207
+ # @param array_size [Integer] Set to a non nil value if the item is to
208
+ # represented as an array.
209
+ # @param endianness [Symbol] Endianness of this item. By default the
210
+ # endianness as set in the constructure is used.
211
+ # @param overflow [Symbol] How to handle value overflows. This is
212
+ # dependant on the item_class but by default see StructureItem.
213
+ # @param format_string [String] String to pass to Kernel#sprintf
214
+ # @param read_conversion [Conversion] Conversion to apply when reading the
215
+ # item from the packet buffer
216
+ # @param write_conversion [Conversion] Conversion to apply before writing
217
+ # the item to the packet buffer
218
+ # @param id_value [Object] Set to something other than nil to indicate that
219
+ # this item should be used to identify a buffer as this packet. The
220
+ # id_value should make sense according to the data_type.
221
+ def define_item(name, bit_offset, bit_size, data_type, array_size = nil, endianness = @default_endianness, overflow = :ERROR, format_string = nil, read_conversion = nil, write_conversion = nil, id_value = nil)
222
+ item = super(name, bit_offset, bit_size, data_type, array_size, endianness, overflow)
223
+ packet_define_item(item, format_string, read_conversion, write_conversion, id_value)
224
+ end
225
+
226
+ # Define an item at the end of the packet. This creates a new instance of the
227
+ # item_class as given in the constructor and adds it to the items hash. It
228
+ # also resizes the buffer to accomodate the new item.
229
+ #
230
+ # @param name (see #define_item)
231
+ # @param bit_size (see #define_item)
232
+ # @param data_type (see #define_item)
233
+ # @param array_size (see #define_item)
234
+ # @param endianness (see #define_item)
235
+ # @param overflow (see #define_item)
236
+ # @param format_string (see #define_item)
237
+ # @param read_conversion (see #define_item)
238
+ # @param write_conversion (see #define_item)
239
+ # @param id_value (see #define_item)
240
+ def append_item(name, bit_size, data_type, array_size = nil, endianness = @default_endianness, overflow = :ERROR, format_string = nil, read_conversion = nil, write_conversion = nil, id_value = nil)
241
+ item = super(name, bit_size, data_type, array_size, endianness, overflow)
242
+ packet_define_item(item, format_string, read_conversion, write_conversion, id_value)
243
+ end
244
+
245
+ # (see Structure#get_item)
246
+ def get_item(name)
247
+ super(name)
248
+ rescue ArgumentError
249
+ raise "Packet item '#{@target_name} #{@packet_name} #{name.upcase}' does not exist"
250
+ end
251
+
252
+ # Read an item in the packet
253
+ #
254
+ # @param item [PacketItem] Instance of PacketItem or one of its subclasses
255
+ # @param value_type [Symbol] How to convert the item before returning it.
256
+ # Must be one of {VALUE_TYPES}
257
+ # @param buffer (see Structure#read_item)
258
+ # @return The value. :FORMATTED and :WITH_UNITS values are always returned
259
+ # as Strings. :RAW values will match their data_type. :CONVERTED values
260
+ # can be any type.
261
+ def read_item(item, value_type = :CONVERTED, buffer = @buffer)
262
+ value = super(item, :RAW, buffer)
263
+ case value_type
264
+ when :RAW
265
+ # Done above
266
+ when :CONVERTED, :FORMATTED, :WITH_UNITS
267
+ if item.read_conversion
268
+ using_cached_value = false
269
+
270
+ check_cache = buffer.equal?(@buffer)
271
+ if check_cache and @read_conversion_cache
272
+ synchronize_allow_reads() do
273
+ if @read_conversion_cache[item]
274
+ value = @read_conversion_cache[item]
275
+ using_cached_value = true
276
+ end
277
+ end
278
+ end
279
+
280
+ unless using_cached_value
281
+ if item.array_size
282
+ value.map! do |val, index|
283
+ item.read_conversion.call(val, self, buffer)
284
+ end
285
+ else
286
+ value = item.read_conversion.call(value, self, buffer)
287
+ end
288
+ if check_cache
289
+ synchronize_allow_reads() do
290
+ @read_conversion_cache ||= {}
291
+ @read_conversion_cache[item] = value
292
+ end
293
+ end
294
+ end
295
+ end
296
+
297
+ # Convert from value to state if possible
298
+ if item.states
299
+ if item.array_size
300
+ value = value.map do |val, index|
301
+ if item.states.key(val)
302
+ item.states.key(val)
303
+ else
304
+ apply_format_string_and_units(item, val, value_type)
305
+ end
306
+ end
307
+ else
308
+ state_value = item.states.key(value)
309
+ if state_value
310
+ value = state_value
311
+ else
312
+ value = apply_format_string_and_units(item, value, value_type)
313
+ end
314
+ end
315
+ else
316
+ if item.array_size
317
+ value = value.map do |val, index|
318
+ apply_format_string_and_units(item, val, value_type)
319
+ end
320
+ else
321
+ value = apply_format_string_and_units(item, value, value_type)
322
+ end
323
+ end
324
+ else
325
+ raise ArgumentError, "Unknown value type on read: #{value_type}"
326
+ end
327
+ return value
328
+ end
329
+
330
+ # Write an item in the packet
331
+ #
332
+ # @param item [PacketItem] Instance of PacketItem or one of its subclasses
333
+ # @param value (see Structure#write_item)
334
+ # @param value_type (see #read_item)
335
+ # @param buffer (see Structure#write_item)
336
+ def write_item(item, value, value_type = :CONVERTED, buffer = @buffer)
337
+ if @read_conversion_cache
338
+ synchronize() do
339
+ @read_conversion_cache.clear
340
+ end
341
+ end
342
+ case value_type
343
+ when :RAW
344
+ super(item, value, value_type, buffer)
345
+ when :CONVERTED
346
+ if item.states
347
+ # Convert from state to value if possible
348
+ state_value = item.states[value.to_s.upcase]
349
+ value = state_value if state_value
350
+ end
351
+ if item.write_conversion
352
+ value = item.write_conversion.call(value, self, buffer)
353
+ else
354
+ raise "Cannot write DERIVED item without a write conversion" if item.data_type == :DERIVED
355
+ end
356
+ begin
357
+ super(item, value, :RAW, buffer) unless item.data_type == :DERIVED
358
+ rescue ArgumentError => err
359
+ if item.states and String === value and err.message =~ /invalid value for/
360
+ raise "Unknown state #{value} for #{item.name}"
361
+ else
362
+ raise err
363
+ end
364
+ end
365
+ when :FORMATTED, :WITH_UNITS
366
+ raise ArgumentError, "Invalid value type on write: #{value_type}"
367
+ else
368
+ raise ArgumentError, "Unknown value type on write: #{value_type}"
369
+ end
370
+ end
371
+
372
+ # Read an item in the packet by name
373
+ #
374
+ # @param name [String] Name of the item to read
375
+ # @param value_type (see #read_item)
376
+ # @param buffer (see #read_item)
377
+ # @return (see #read_item)
378
+ def read(name, value_type = :CONVERTED, buffer = @buffer)
379
+ return super(name, value_type, buffer)
380
+ end
381
+
382
+ # Write an item in the packet by name
383
+ #
384
+ # @param name [String] Name of the item to write
385
+ # @param value (see #write_item)
386
+ # @param value_type (see #write_item)
387
+ # @param buffer (see #write_item)
388
+ def write(name, value, value_type = :CONVERTED, buffer = @buffer)
389
+ super(name, value, value_type, buffer)
390
+ end
391
+
392
+ # Read all items in the packet into an array of arrays
393
+ # [[item name, item value], ...]
394
+ #
395
+ # @param value_type (see #read_item)
396
+ # @param buffer (see Structure#read_all)
397
+ # @param top (See Structure#read_all)
398
+ # @return (see Structure#read_all)
399
+ def read_all(value_type = :CONVERTED, buffer = @buffer, top = true)
400
+ return super(value_type, buffer, top)
401
+ end
402
+
403
+ # Read all items in the packet into an array of arrays
404
+ # [[item name, item value], [item limits state], ...]
405
+ #
406
+ # @param value_type (see #read_all)
407
+ # @param buffer (see #read_all)
408
+ # @return [Array<String, Object, Symbol|nil>] Returns an Array consisting
409
+ # of [item name, item value, item limits state] where the item limits
410
+ # state can be one of {Cosmos::Limits::LIMITS_STATES}
411
+ def read_all_with_limits_states(value_type = :CONVERTED, buffer = @buffer)
412
+ result = nil
413
+ synchronize_allow_reads(true) do
414
+ result = read_all(value_type, buffer, false).map! do |array|
415
+ array << @items[array[0]].limits.state
416
+ end
417
+ end
418
+ return result
419
+ end
420
+
421
+ # Create a string that shows the name and value of each item in the packet
422
+ #
423
+ # @param value_type (see #read_item)
424
+ # @param indent (see Structure#formatted)
425
+ # @param buffer (see Structure#formatted)
426
+ # @return (see Structure#formatted)
427
+ def formatted(value_type = :CONVERTED, indent = 0, buffer = @buffer)
428
+ return super(value_type, indent, buffer)
429
+ end
430
+
431
+ # Tries to identify if a buffer represents the currently defined packet. It
432
+ # does this by iterating over all the packet items that were created with
433
+ # an ID value and checking whether that ID value is present at the correct
434
+ # location in the buffer.
435
+ #
436
+ # Incorrectly sized buffers will still positively identify if there is
437
+ # enough data to match the ID values. This is to allow incorrectly sized
438
+ # packets to still be processed as well as possible given the incorrectly
439
+ # sized data.
440
+ #
441
+ # @param buffer [String] Raw buffer of binary data
442
+ # @return [Boolean] Whether or not the buffer of data is this packet
443
+ # def identify?(buffer)
444
+
445
+ # Restore all items in the packet to their default value
446
+ #
447
+ # @param buffer [String] Raw buffer of binary data
448
+ def restore_defaults(buffer = @buffer)
449
+ @sorted_items.each do |item|
450
+ write_item(item, item.default, :CONVERTED, buffer)
451
+ end
452
+ end
453
+
454
+ # Enable limits on an item by name
455
+ #
456
+ # @param name [String] Name of the item to enable limits
457
+ def enable_limits(name)
458
+ get_item(name).limits.enabled = true
459
+ end
460
+
461
+ # Disable limits on an item by name
462
+ #
463
+ # @param name [String] Name of the item to disable limits
464
+ def disable_limits(name)
465
+ item = get_item(name)
466
+ item.limits.enabled = false
467
+ unless item.limits.state == :STALE
468
+ old_limits_state = item.limits.state
469
+ item.limits.state = nil
470
+ @limits_change_callback.call(self, item, old_limits_state, nil, false) if @limits_change_callback
471
+ end
472
+ end
473
+
474
+ # Force the packet to update its knowledge of items with limits. This is an
475
+ # optimization so we don't have to iterate through all the items when
476
+ # checking for limits.
477
+ def update_limits_items_cache
478
+ # Collect only the items who have limits values or states and then
479
+ # compact the array to remove all the nil values
480
+ @limits_items = @sorted_items.collect do |item|
481
+ item if item.limits.values || item.state_colors
482
+ end
483
+ @limits_items.compact!
484
+ end
485
+
486
+ # Return an array of arrays indicating all items in the packet that are out of limits
487
+ # [[target name, packet name, item name, item limits state], ...]
488
+ #
489
+ # @return [Array<Array<String, String, String, Symbol>>]
490
+ def out_of_limits
491
+ items = []
492
+ return items unless @limits_items
493
+ @limits_items.each do |item|
494
+ if (item.limits.enabled && item.limits.state &&
495
+ PacketItemLimits::OUT_OF_LIMITS_STATES.include?(item.limits.state))
496
+ items << [@target_name, @packet_name, item.name, item.limits.state]
497
+ end
498
+ end
499
+ return items
500
+ end
501
+
502
+ # Set the limits state for all items to the given state
503
+ #
504
+ # @param state [Symbol] Must be one of PacketItemLimits::LIMITS_STATES
505
+ def set_all_limits_states(state)
506
+ @sorted_items.each {|item| item.limits.state = state}
507
+ end
508
+
509
+ # Check all the items in the packet against their defined limits. Update
510
+ # their internal limits state and persistence and call the
511
+ # limits_change_callback as necessary.
512
+ #
513
+ # @param limits_set [Symbol] Which limits set to check the item values
514
+ # against.
515
+ # @param ignore_persistence [Boolean] Whether to ignore persistence when
516
+ # checking for out of limits
517
+ def check_limits(limits_set = :DEFAULT, ignore_persistence = false)
518
+ # If check_limits is being called, then a new packet has arrived and
519
+ # this packet is no longer stale
520
+ if @stale
521
+ @stale = false
522
+ set_all_limits_states(nil)
523
+ end
524
+
525
+ return unless @limits_items
526
+ @limits_items.each do |item|
527
+ # Verify limits monitoring is enabled for this item
528
+ if item.limits.enabled
529
+ value = read_item(item)
530
+
531
+ # Handle state monitoring and value monitoring differently
532
+ if item.states
533
+ handle_limits_states(item, value)
534
+ elsif item.limits.values
535
+ handle_limits_values(item, value, limits_set, ignore_persistence)
536
+ end
537
+ end
538
+ end
539
+ end
540
+
541
+ # Sets the overall packet stale state to true and sets each packet item
542
+ # limits state to :STALE.
543
+ def set_stale
544
+ @stale = true
545
+ set_all_limits_states(:STALE)
546
+ end
547
+
548
+ # Reset temporary packet data
549
+ # This includes packet received time, received count, and processor state
550
+ def reset
551
+ @received_time = nil
552
+ @received_count = 0
553
+ if @read_conversion_cache
554
+ synchronize() do
555
+ @read_conversion_cache.clear
556
+ end
557
+ end
558
+ return unless @processors
559
+ @processors.each do |processor_name, processor|
560
+ processor.reset
561
+ end
562
+ end
563
+
564
+ # Make a light weight clone of this packet. This only creates a new buffer
565
+ # of data and clones the processors. The defined packet items are the same.
566
+ #
567
+ # @return [Packet] A copy of the current packet with a new underlying
568
+ # buffer of data and processors
569
+ def clone
570
+ packet = super()
571
+ if packet.instance_variable_get("@processors")
572
+ packet.processors.each do |processor_name, processor|
573
+ packet.processors[processor_name] = processor.clone
574
+ end
575
+ end
576
+ packet
577
+ end
578
+ alias dup clone
579
+
580
+ protected
581
+
582
+ # Performs packet specific processing on the packet. Intended to only be run once for each packet received
583
+ def process(buffer = @buffer)
584
+ return unless @processors
585
+ @processors.each do |processor_name, processor|
586
+ processor.call(self, buffer)
587
+ end
588
+ end
589
+
590
+ def handle_limits_states(item, value)
591
+ # Retrieve limits state for the given value
592
+ limits_state = item.state_colors[value]
593
+
594
+ if item.limits.state != limits_state # PacketItemLimits state has changed
595
+ # Save old limits state
596
+ old_limits_state = item.limits.state
597
+ # Update to new limits state
598
+ item.limits.state = limits_state
599
+
600
+ if old_limits_state == nil # Changing from nil
601
+ if limits_state != :GREEN && limits_state != :BLUE # Warnings are needed
602
+ @limits_change_callback.call(self, item, old_limits_state, value, true) if @limits_change_callback
603
+ end
604
+ else # Changing from a state other than nil so always call the callback
605
+ if @limits_change_callback
606
+ if item.limits.state.nil?
607
+ @limits_change_callback.call(self, item, old_limits_state, value, false)
608
+ else
609
+ @limits_change_callback.call(self, item, old_limits_state, value, true)
610
+ end
611
+ end
612
+ end
613
+ end
614
+ end
615
+
616
+ def handle_limits_values(item, value, limits_set, ignore_persistence)
617
+ # Retrieve limits settings for the specified limits_set
618
+ limits = item.limits.values[limits_set]
619
+
620
+ # Use the default limits set if limits aren't specified for the
621
+ # particular limits set
622
+ limits = item.limits.values[:DEFAULT] unless limits
623
+
624
+ # Extract limits from array
625
+ red_low = limits[0]
626
+ yellow_low = limits[1]
627
+ yellow_high = limits[2]
628
+ red_high = limits[3]
629
+ green_low = limits[4]
630
+ green_high = limits[5]
631
+ limits_state = nil
632
+
633
+ # Determine the limits_state based on the limits values and the current
634
+ # value of the item
635
+ if (value > yellow_low)
636
+ if (value < yellow_high)
637
+ if green_low
638
+ if value < green_high
639
+ if value > green_low
640
+ limits_state = :BLUE
641
+ else
642
+ limits_state = :GREEN_LOW
643
+ end
644
+ else
645
+ limits_state = :GREEN_HIGH
646
+ end
647
+ else
648
+ limits_state = :GREEN
649
+ end
650
+ elsif (value < red_high)
651
+ limits_state = :YELLOW_HIGH
652
+ else
653
+ limits_state = :RED_HIGH
654
+ end
655
+ else # value <= yellow_low
656
+ if (value > red_low)
657
+ limits_state = :YELLOW_LOW
658
+ else
659
+ limits_state = :RED_LOW
660
+ end
661
+ end
662
+
663
+ if item.limits.state != limits_state # limits state has changed
664
+ # Save old limits state for use in the callback
665
+ old_limits_state = item.limits.state
666
+
667
+ item.limits.persistence_count += 1
668
+
669
+ # Check for item to achieve its persistence which means we
670
+ # have to update the state and call the callback
671
+ # Note when going back to green (or blue) persistence is ignored
672
+ if (item.limits.persistence_count >= item.limits.persistence_setting) || ignore_persistence
673
+ item.limits.state = limits_state
674
+
675
+ # Additional actions for limits change
676
+ @limits_change_callback.call(self, item, old_limits_state, value, true) if @limits_change_callback
677
+
678
+ # Clear persistence since we've entered a new state
679
+ item.limits.persistence_count = 0
680
+ end
681
+ else # limits state has not changed so clear persistence
682
+ item.limits.persistence_count = 0
683
+ end
684
+ end
685
+
686
+ def apply_format_string_and_units(item, value, value_type)
687
+ if value_type == :FORMATTED or value_type == :WITH_UNITS
688
+ if item.format_string && value
689
+ value = sprintf(item.format_string, value)
690
+ else
691
+ value = value.to_s
692
+ end
693
+ end
694
+ value << ' ' << item.units if value_type == :WITH_UNITS and item.units
695
+ value
696
+ end
697
+
698
+ def packet_define_item(item, format_string, read_conversion, write_conversion, id_value)
699
+ item.format_string = format_string
700
+ item.read_conversion = read_conversion
701
+ item.write_conversion = write_conversion
702
+
703
+ # Change id_value to the correct type
704
+ if id_value
705
+ item.id_value = id_value
706
+ @id_items ||= []
707
+ @id_items << item
708
+ end
709
+
710
+ item
711
+ end
712
+ end # class Packet
713
+
714
+ end # module Cosmos