cosmos 4.1.1 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (336) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -2
  3. data/.travis.yml +2 -0
  4. data/.yardopts +1 -0
  5. data/Gemfile +1 -0
  6. data/Manifest.txt +130 -0
  7. data/autohotkey/tools/ConfigEditorAHK +19 -0
  8. data/autohotkey/tools/cmd_extractor.ahk +4 -4
  9. data/autohotkey/tools/cmd_sequence.ahk +9 -5
  10. data/autohotkey/tools/config_editor.ahk +197 -0
  11. data/autohotkey/tools/packet_viewer.ahk +12 -6
  12. data/autohotkey/tools/replay.ahk +29 -29
  13. data/autohotkey/tools/script_runner.ahk +10 -2
  14. data/autohotkey/tools/tlm_extractor.ahk +7 -8
  15. data/autohotkey/tools/tlm_grapher.ahk +21 -9
  16. data/bin/dart_import +2 -0
  17. data/cosmos.gemspec +18 -16
  18. data/data/config/cmd_tlm_server.yaml +9 -0
  19. data/data/config/interface_modifiers.yaml +17 -0
  20. data/data/config/item_modifiers.yaml +3 -3
  21. data/data/crc.txt +184 -90
  22. data/data/dart.png +0 -0
  23. data/demo/Gemfile +1 -0
  24. data/demo/Rakefile +4 -0
  25. data/demo/config/dart/Gemfile +54 -0
  26. data/demo/config/data/crc.txt +28 -21
  27. data/demo/config/system/system.txt +3 -0
  28. data/demo/config/system/system2.txt +3 -0
  29. data/demo/config/targets/INST/cmd_tlm/inst_cmds.txt +3 -3
  30. data/demo/config/targets/INST/cmd_tlm/inst_tlm.txt +1 -1
  31. data/demo/config/targets/INST/lib/sim_inst.rb +1 -1
  32. data/demo/config/targets/INST/screens/adcs.txt +2 -1
  33. data/demo/config/targets/INST/screens/array.txt +1 -1
  34. data/demo/config/targets/INST/screens/block.txt +1 -1
  35. data/demo/config/targets/INST/screens/commanding.txt +7 -2
  36. data/demo/config/targets/INST/screens/graphs.txt +1 -1
  37. data/demo/config/targets/INST/screens/ground.txt +1 -1
  38. data/demo/config/targets/INST/screens/hs.txt +2 -1
  39. data/demo/config/targets/INST/screens/latest.txt +1 -1
  40. data/demo/config/targets/INST/screens/limits.txt +1 -1
  41. data/demo/config/targets/INST/screens/other.txt +1 -1
  42. data/demo/config/targets/INST/screens/tabs.txt +1 -1
  43. data/demo/config/tools/cmd_tlm_server/cmd_tlm_server.txt +2 -2
  44. data/demo/config/tools/cmd_tlm_server/cmd_tlm_server2.txt +3 -1
  45. data/demo/config/tools/launcher/launcher.txt +3 -2
  46. data/demo/tools/Dart +16 -0
  47. data/demo/tools/Dart.bat +9 -0
  48. data/demo/tools/mac/CmdSequence.app/Contents/MacOS/main.sh +0 -0
  49. data/demo/tools/mac/ConfigEditor.app/Contents/MacOS/main.sh +0 -0
  50. data/install/Gemfile +1 -0
  51. data/install/Rakefile +4 -0
  52. data/install/config/dart/Gemfile +54 -0
  53. data/install/config/data/crc.txt +6 -3
  54. data/install/config/system/system.txt +3 -0
  55. data/install/config/tools/launcher/launcher.txt +3 -2
  56. data/install/tools/Dart +16 -0
  57. data/install/tools/Dart.bat +9 -0
  58. data/install/tools/mac/CmdSequence.app/Contents/MacOS/main.sh +0 -0
  59. data/install/tools/mac/ConfigEditor.app/Contents/MacOS/main.sh +0 -0
  60. data/lib/cosmos/core_ext/time.rb +8 -8
  61. data/lib/cosmos/dart/.rspec +1 -0
  62. data/lib/cosmos/dart/Gemfile +69 -0
  63. data/lib/cosmos/dart/Rakefile +7 -0
  64. data/lib/cosmos/dart/app/assets/config/manifest.js +4 -0
  65. data/lib/cosmos/dart/app/assets/images/.keep +0 -0
  66. data/lib/cosmos/dart/app/assets/javascripts/application.js +13 -0
  67. data/lib/cosmos/dart/app/assets/javascripts/cable.js +13 -0
  68. data/lib/cosmos/dart/app/assets/stylesheets/application.css.scss +15 -0
  69. data/lib/cosmos/dart/app/channels/application_cable/channel.rb +4 -0
  70. data/lib/cosmos/dart/app/channels/application_cable/connection.rb +4 -0
  71. data/lib/cosmos/dart/app/controllers/application_controller.rb +3 -0
  72. data/lib/cosmos/dart/app/helpers/application_helper.rb +2 -0
  73. data/lib/cosmos/dart/app/jobs/application_job.rb +2 -0
  74. data/lib/cosmos/dart/app/mailers/application_mailer.rb +4 -0
  75. data/lib/cosmos/dart/app/models/application_record.rb +3 -0
  76. data/lib/cosmos/dart/app/models/item.rb +6 -0
  77. data/lib/cosmos/dart/app/models/item_to_decom_table_mapping.rb +9 -0
  78. data/lib/cosmos/dart/app/models/packet.rb +4 -0
  79. data/lib/cosmos/dart/app/models/packet_config.rb +7 -0
  80. data/lib/cosmos/dart/app/models/packet_log.rb +3 -0
  81. data/lib/cosmos/dart/app/models/packet_log_entry.rb +41 -0
  82. data/lib/cosmos/dart/app/models/system_config.rb +2 -0
  83. data/lib/cosmos/dart/app/models/target.rb +4 -0
  84. data/lib/cosmos/dart/app/views/layouts/application.html.erb +14 -0
  85. data/lib/cosmos/dart/app/views/layouts/mailer.html.erb +13 -0
  86. data/lib/cosmos/dart/app/views/layouts/mailer.text.erb +1 -0
  87. data/lib/cosmos/dart/bin/bundle +3 -0
  88. data/lib/cosmos/dart/bin/rails +4 -0
  89. data/lib/cosmos/dart/bin/rake +4 -0
  90. data/lib/cosmos/dart/bin/setup +34 -0
  91. data/lib/cosmos/dart/bin/update +29 -0
  92. data/lib/cosmos/dart/config.ru +5 -0
  93. data/lib/cosmos/dart/config/application.rb +29 -0
  94. data/lib/cosmos/dart/config/boot.rb +3 -0
  95. data/lib/cosmos/dart/config/cable.yml +9 -0
  96. data/lib/cosmos/dart/config/database.yml +23 -0
  97. data/lib/cosmos/dart/config/environment.rb +5 -0
  98. data/lib/cosmos/dart/config/environments/development.rb +62 -0
  99. data/lib/cosmos/dart/config/environments/production.rb +84 -0
  100. data/lib/cosmos/dart/config/environments/test.rb +42 -0
  101. data/lib/cosmos/dart/config/initializers/application_controller_renderer.rb +6 -0
  102. data/lib/cosmos/dart/config/initializers/assets.rb +12 -0
  103. data/lib/cosmos/dart/config/initializers/backtrace_silencers.rb +7 -0
  104. data/lib/cosmos/dart/config/initializers/cookies_serializer.rb +5 -0
  105. data/lib/cosmos/dart/config/initializers/filter_parameter_logging.rb +4 -0
  106. data/lib/cosmos/dart/config/initializers/inflections.rb +16 -0
  107. data/lib/cosmos/dart/config/initializers/mime_types.rb +4 -0
  108. data/lib/cosmos/dart/config/initializers/new_framework_defaults.rb +25 -0
  109. data/lib/cosmos/dart/config/initializers/session_store.rb +3 -0
  110. data/lib/cosmos/dart/config/initializers/wrap_parameters.rb +14 -0
  111. data/lib/cosmos/dart/config/locales/en.yml +23 -0
  112. data/lib/cosmos/dart/config/puma.rb +47 -0
  113. data/lib/cosmos/dart/config/routes.rb +3 -0
  114. data/lib/cosmos/dart/config/secrets.yml +22 -0
  115. data/lib/cosmos/dart/db/migrate/20170406172907_create_targets.rb +8 -0
  116. data/lib/cosmos/dart/db/migrate/20170406172927_create_packets.rb +10 -0
  117. data/lib/cosmos/dart/db/migrate/20170406172937_create_packet_logs.rb +9 -0
  118. data/lib/cosmos/dart/db/migrate/20170406172943_create_packet_log_entries.rb +16 -0
  119. data/lib/cosmos/dart/db/migrate/20170406183500_change_packet_log_entries_primary_key.rb +5 -0
  120. data/lib/cosmos/dart/db/migrate/20170407153618_add_unique_requirements.rb +7 -0
  121. data/lib/cosmos/dart/db/migrate/20170511155447_add_meta_id_to_packet_log_entries.rb +6 -0
  122. data/lib/cosmos/dart/db/migrate/20170523185056_rename_received_time_and_add_is_tlm_to_packet_log_entries.rb +7 -0
  123. data/lib/cosmos/dart/db/migrate/20170525201157_create_items.rb +10 -0
  124. data/lib/cosmos/dart/db/migrate/20170525201315_create_system_configs.rb +9 -0
  125. data/lib/cosmos/dart/db/migrate/20170525201624_create_packet_configs.rb +11 -0
  126. data/lib/cosmos/dart/db/migrate/20170525201745_create_item_to_decom_table_mappings.rb +12 -0
  127. data/lib/cosmos/dart/db/migrate/20170525201939_create_decom_tables.rb +12 -0
  128. data/lib/cosmos/dart/db/migrate/20170525202051_add_decom_state_to_packet_log_entry.rb +5 -0
  129. data/lib/cosmos/dart/db/migrate/20170913160409_update_items.rb +6 -0
  130. data/lib/cosmos/dart/db/migrate/20170913160558_update_item_to_decom_table_mapping.rb +11 -0
  131. data/lib/cosmos/dart/db/migrate/20170913160916_udpate_decom_table.rb +6 -0
  132. data/lib/cosmos/dart/db/migrate/20170913212026_add_ready_to_packet_configs.rb +5 -0
  133. data/lib/cosmos/dart/db/migrate/20170913223556_modify_tables.rb +9 -0
  134. data/lib/cosmos/dart/db/migrate/20170914215744_modify_mapping_table.rb +6 -0
  135. data/lib/cosmos/dart/db/migrate/20170919201433_add_system_config_id_to_packet_config.rb +11 -0
  136. data/lib/cosmos/dart/db/migrate/20170919210307_add_max_table_index_to_packet_configs.rb +5 -0
  137. data/lib/cosmos/dart/db/migrate/20171215225546_add_ready_to_packet_log_entries.rb +5 -0
  138. data/lib/cosmos/dart/db/migrate/20180116214338_add_index_for_ple_ready_to_packet_log_entries.rb +5 -0
  139. data/lib/cosmos/dart/db/schema.rb +103 -0
  140. data/lib/cosmos/dart/db/seeds.rb +7 -0
  141. data/lib/cosmos/dart/examples/dart_decom_client.rb +45 -0
  142. data/lib/cosmos/dart/examples/dart_stream_client.rb +93 -0
  143. data/lib/cosmos/dart/lib/dart_common.rb +749 -0
  144. data/lib/cosmos/dart/lib/dart_database_cleaner.rb +172 -0
  145. data/lib/cosmos/dart/lib/dart_decom_query.rb +184 -0
  146. data/lib/cosmos/dart/lib/dart_decommutator.rb +235 -0
  147. data/lib/cosmos/dart/lib/dart_importer.rb +154 -0
  148. data/lib/cosmos/dart/lib/dart_logging.rb +50 -0
  149. data/lib/cosmos/dart/lib/dart_packet_log_writer.rb +139 -0
  150. data/lib/cosmos/dart/lib/dart_reducer_manager.rb +85 -0
  151. data/lib/cosmos/dart/lib/dart_reducer_worker_thread.rb +263 -0
  152. data/lib/cosmos/dart/lib/dart_tcpip_server_interface.rb +142 -0
  153. data/lib/cosmos/dart/processes/dart.rb +145 -0
  154. data/lib/cosmos/dart/processes/dart_decom_server.rb +39 -0
  155. data/lib/cosmos/dart/processes/dart_import.rb +63 -0
  156. data/lib/cosmos/dart/processes/dart_ingester.rb +92 -0
  157. data/lib/cosmos/dart/processes/dart_reducer.rb +27 -0
  158. data/lib/cosmos/dart/processes/dart_stream_server.rb +31 -0
  159. data/lib/cosmos/dart/processes/dart_worker.rb +37 -0
  160. data/lib/cosmos/dart/spec/dart/dart_common_spec.rb +333 -0
  161. data/lib/cosmos/dart/spec/dart/dart_database_cleaner_spec.rb +455 -0
  162. data/lib/cosmos/dart/spec/dart/dart_decom_query_spec.rb +153 -0
  163. data/lib/cosmos/dart/spec/dart/dart_decommutator_spec.rb +336 -0
  164. data/lib/cosmos/dart/spec/dart/dart_importer_spec.rb +83 -0
  165. data/lib/cosmos/dart/spec/dart/dart_logging_spec.rb +30 -0
  166. data/lib/cosmos/dart/spec/dart/dart_packet_log_writer_spec.rb +149 -0
  167. data/lib/cosmos/dart/spec/dart/dart_reducer_manager_spec.rb +289 -0
  168. data/lib/cosmos/dart/spec/dart/dart_tcpip_server_interface_spec.rb +241 -0
  169. data/lib/cosmos/dart/spec/rails_helper.rb +60 -0
  170. data/lib/cosmos/dart/spec/spec_helper.rb +139 -0
  171. data/lib/cosmos/gui/dialogs/about_dialog.rb +1 -1
  172. data/lib/cosmos/gui/dialogs/dart_dialog.rb +60 -0
  173. data/lib/cosmos/gui/dialogs/legal_dialog.rb +1 -0
  174. data/lib/cosmos/gui/dialogs/scroll_text_dialog.rb +0 -3
  175. data/lib/cosmos/gui/qt.rb +10 -1
  176. data/lib/cosmos/gui/text/completion.rb +10 -9
  177. data/lib/cosmos/gui/text/completion_text_edit.rb +16 -14
  178. data/lib/cosmos/gui/text/ruby_editor.rb +2 -2
  179. data/lib/cosmos/gui/widgets/dart_frame.rb +142 -0
  180. data/lib/cosmos/gui/widgets/dart_meta_frame.rb +119 -0
  181. data/lib/cosmos/gui/widgets/packet_log_frame.rb +42 -12
  182. data/lib/cosmos/interfaces/interface.rb +1 -2
  183. data/lib/cosmos/interfaces/protocols/crc_protocol.rb +26 -8
  184. data/lib/cosmos/interfaces/protocols/fixed_protocol.rb +8 -2
  185. data/lib/cosmos/interfaces/protocols/protocol.rb +2 -1
  186. data/lib/cosmos/interfaces/protocols/template_protocol.rb +1 -1
  187. data/lib/cosmos/interfaces/stream_interface.rb +1 -0
  188. data/lib/cosmos/interfaces/tcpip_server_interface.rb +2 -3
  189. data/lib/cosmos/io/json_drb_object.rb +1 -1
  190. data/lib/cosmos/io/json_rpc.rb +2 -1
  191. data/lib/cosmos/io/win32_serial_driver.rb +2 -9
  192. data/lib/cosmos/packet_logs/packet_log_writer.rb +1 -1
  193. data/lib/cosmos/packets/packet.rb +22 -12
  194. data/lib/cosmos/packets/packet_config.rb +2 -1
  195. data/lib/cosmos/packets/packet_item.rb +26 -24
  196. data/lib/cosmos/packets/parsers/macro_parser.rb +5 -2
  197. data/lib/cosmos/packets/parsers/packet_item_parser.rb +35 -17
  198. data/lib/cosmos/packets/parsers/packet_parser.rb +3 -10
  199. data/lib/cosmos/packets/parsers/xtce_converter.rb +21 -35
  200. data/lib/cosmos/packets/parsers/xtce_parser.rb +54 -46
  201. data/lib/cosmos/packets/structure.rb +10 -2
  202. data/lib/cosmos/packets/structure_item.rb +22 -8
  203. data/lib/cosmos/processors/statistics_processor.rb +2 -0
  204. data/lib/cosmos/script/api_shared.rb +13 -12
  205. data/lib/cosmos/script/cmd_tlm_server.rb +4 -0
  206. data/lib/cosmos/script/commands.rb +3 -15
  207. data/lib/cosmos/script/script.rb +69 -23
  208. data/lib/cosmos/streams/tcpip_client_stream.rb +2 -2
  209. data/lib/cosmos/system/system.rb +42 -25
  210. data/lib/cosmos/system/target.rb +6 -2
  211. data/lib/cosmos/tools/cmd_extractor/cmd_extractor.rb +177 -36
  212. data/lib/cosmos/tools/cmd_sender/cmd_param_table_item_delegate.rb +3 -2
  213. data/lib/cosmos/tools/cmd_sender/cmd_sender.rb +34 -8
  214. data/lib/cosmos/tools/cmd_sequence/cmd_sequence.rb +80 -25
  215. data/lib/cosmos/tools/cmd_tlm_server/api.rb +19 -4
  216. data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server.rb +15 -14
  217. data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb +15 -9
  218. data/lib/cosmos/tools/cmd_tlm_server/gui/interfaces_tab.rb +1 -9
  219. data/lib/cosmos/tools/cmd_tlm_server/gui/logging_tab.rb +1 -6
  220. data/lib/cosmos/tools/cmd_tlm_server/gui/packets_tab.rb +1 -3
  221. data/lib/cosmos/tools/cmd_tlm_server/gui/replay_tab.rb +84 -7
  222. data/lib/cosmos/tools/cmd_tlm_server/gui/status_tab.rb +0 -1
  223. data/lib/cosmos/tools/cmd_tlm_server/gui/targets_tab.rb +1 -5
  224. data/lib/cosmos/tools/cmd_tlm_server/limits_groups_background_task.rb +3 -2
  225. data/lib/cosmos/tools/cmd_tlm_server/replay_backend.rb +159 -27
  226. data/lib/cosmos/tools/cmd_tlm_server/routers.rb +1 -1
  227. data/lib/cosmos/tools/config_editor/config_editor.rb +17 -52
  228. data/lib/cosmos/tools/config_editor/config_editor_frame.rb +0 -5
  229. data/lib/cosmos/tools/data_viewer/data_viewer.rb +111 -0
  230. data/lib/cosmos/tools/limits_monitor/limits_monitor.rb +31 -18
  231. data/lib/cosmos/tools/packet_viewer/packet_viewer.rb +12 -3
  232. data/lib/cosmos/tools/script_runner/script_runner.rb +27 -14
  233. data/lib/cosmos/tools/script_runner/script_runner_frame.rb +104 -37
  234. data/lib/cosmos/tools/table_manager/table_config.rb +1 -1
  235. data/lib/cosmos/tools/table_manager/table_item_parser.rb +4 -2
  236. data/lib/cosmos/tools/table_manager/table_manager.rb +0 -5
  237. data/lib/cosmos/tools/table_manager/table_manager_core.rb +0 -1
  238. data/lib/cosmos/tools/test_runner/test.rb +1 -3
  239. data/lib/cosmos/tools/test_runner/test_runner.rb +26 -15
  240. data/lib/cosmos/tools/tlm_extractor/tlm_extractor.rb +290 -137
  241. data/lib/cosmos/tools/tlm_extractor/tlm_extractor_config.rb +122 -25
  242. data/lib/cosmos/tools/tlm_extractor/tlm_extractor_processor.rb +67 -0
  243. data/lib/cosmos/tools/tlm_grapher/data_object_editors/housekeeping_data_object_editor.rb +28 -0
  244. data/lib/cosmos/tools/tlm_grapher/data_object_editors/xy_data_object_editor.rb +36 -0
  245. data/lib/cosmos/tools/tlm_grapher/data_objects/data_object.rb +42 -3
  246. data/lib/cosmos/tools/tlm_grapher/data_objects/housekeeping_data_object.rb +88 -14
  247. data/lib/cosmos/tools/tlm_grapher/data_objects/linegraph_data_object.rb +2 -5
  248. data/lib/cosmos/tools/tlm_grapher/data_objects/singlexy_data_object.rb +2 -6
  249. data/lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb +74 -18
  250. data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_config.rb +3 -7
  251. data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_dart_thread.rb +159 -0
  252. data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_tool.rb +49 -2
  253. data/lib/cosmos/tools/tlm_viewer/screen.rb +3 -0
  254. data/lib/cosmos/tools/tlm_viewer/tlm_viewer_config.rb +0 -2
  255. data/lib/cosmos/tools/tlm_viewer/widgets.rb +1 -0
  256. data/lib/cosmos/tools/tlm_viewer/widgets/backgroundbutton_widget.rb +54 -0
  257. data/lib/cosmos/tools/tlm_viewer/widgets/button_widget.rb +5 -5
  258. data/lib/cosmos/top_level.rb +1 -0
  259. data/lib/cosmos/utilities/crc.rb +3 -0
  260. data/lib/cosmos/utilities/csv.rb +1 -0
  261. data/lib/cosmos/utilities/message_log.rb +2 -1
  262. data/lib/cosmos/utilities/simulated_target.rb +8 -8
  263. data/lib/cosmos/version.rb +5 -5
  264. data/lib/cosmos/win32/win32.rb +4 -10
  265. data/run_gui_tests.bat +2 -1
  266. data/spec/config/config_parser_spec.rb +4 -4
  267. data/spec/core_ext/array_spec.rb +1 -1
  268. data/spec/core_ext/exception_spec.rb +12 -12
  269. data/spec/core_ext/file_spec.rb +6 -6
  270. data/spec/core_ext/hash_spec.rb +1 -1
  271. data/spec/core_ext/socket_spec.rb +2 -2
  272. data/spec/core_ext/string_spec.rb +13 -13
  273. data/spec/core_ext/time_spec.rb +0 -2
  274. data/spec/gui/utilities/script_module_gui_spec.rb +3 -3
  275. data/spec/install/config/targets/INST/cmd_tlm/inst_tlm.txt +6 -6
  276. data/spec/install/config/tools/cmd_tlm_server/cmd_tlm_server.txt +4 -0
  277. data/spec/interfaces/cmd_tlm_server_interface_spec.rb +6 -2
  278. data/spec/interfaces/interface_spec.rb +0 -1
  279. data/spec/interfaces/linc_interface_spec.rb +0 -5
  280. data/spec/interfaces/protocols/crc_protocol_spec.rb +201 -85
  281. data/spec/interfaces/protocols/fixed_protocol_spec.rb +33 -9
  282. data/spec/interfaces/protocols/length_protocol_spec.rb +1 -1
  283. data/spec/interfaces/protocols/override_protocol_spec.rb +6 -2
  284. data/spec/interfaces/protocols/preidentified_protocol_spec.rb +1 -5
  285. data/spec/interfaces/protocols/template_protocol_spec.rb +0 -1
  286. data/spec/interfaces/simulated_target_interface_spec.rb +5 -5
  287. data/spec/interfaces/udp_interface_spec.rb +2 -4
  288. data/spec/io/buffered_file_spec.rb +8 -12
  289. data/spec/io/json_drb_spec.rb +9 -9
  290. data/spec/io/json_rpc_spec.rb +4 -4
  291. data/spec/io/raw_logger_spec.rb +4 -3
  292. data/spec/packet_logs/packet_log_reader_spec.rb +3 -6
  293. data/spec/packet_logs/packet_log_writer_spec.rb +4 -4
  294. data/spec/packets/binary_accessor_spec.rb +5 -8
  295. data/spec/packets/commands_spec.rb +2 -2
  296. data/spec/packets/limits_spec.rb +2 -2
  297. data/spec/packets/packet_config_spec.rb +12 -0
  298. data/spec/packets/packet_item_limits_spec.rb +1 -1
  299. data/spec/packets/packet_item_spec.rb +9 -9
  300. data/spec/packets/packet_spec.rb +15 -5
  301. data/spec/packets/parsers/packet_item_parser_spec.rb +27 -0
  302. data/spec/packets/parsers/xtce_parser_spec.rb +27 -30
  303. data/spec/packets/structure_spec.rb +2 -1
  304. data/spec/packets/telemetry_spec.rb +3 -5
  305. data/spec/processors/statistics_processor_spec.rb +35 -0
  306. data/spec/script/cmd_tlm_server_spec.rb +4 -21
  307. data/spec/script/commands_disconnect_spec.rb +46 -58
  308. data/spec/script/commands_spec.rb +40 -61
  309. data/spec/script/limits_spec.rb +1 -21
  310. data/spec/script/script_spec.rb +32 -41
  311. data/spec/script/scripting_spec.rb +166 -185
  312. data/spec/script/telemetry_spec.rb +10 -5
  313. data/spec/script/tools_spec.rb +2 -24
  314. data/spec/spec_helper.rb +11 -5
  315. data/spec/system/system_spec.rb +17 -12
  316. data/spec/tools/cmd_tlm_server/api_spec.rb +21 -10
  317. data/spec/tools/cmd_tlm_server/background_tasks_spec.rb +15 -16
  318. data/spec/tools/cmd_tlm_server/cmd_tlm_server_config_spec.rb +0 -1
  319. data/spec/tools/cmd_tlm_server/cmd_tlm_server_spec.rb +16 -27
  320. data/spec/tools/cmd_tlm_server/commanding_spec.rb +2 -6
  321. data/spec/tools/cmd_tlm_server/connections_spec.rb +0 -4
  322. data/spec/tools/cmd_tlm_server/interface_thread_spec.rb +13 -13
  323. data/spec/tools/cmd_tlm_server/interfaces_spec.rb +5 -9
  324. data/spec/tools/cmd_tlm_server/limits_groups_background_task_spec.rb +11 -3
  325. data/spec/tools/cmd_tlm_server/packet_logging_spec.rb +0 -4
  326. data/spec/tools/cmd_tlm_server/router_thread_spec.rb +5 -5
  327. data/spec/tools/cmd_tlm_server/routers_spec.rb +5 -9
  328. data/spec/tools/table_manager/table_config_spec.rb +0 -1
  329. data/spec/tools/table_manager/tablemanager_core_spec.rb +23 -23
  330. data/spec/tools/tlm_viewer/tlm_viewer_config_spec.rb +6 -4
  331. data/spec/top_level/top_level_spec.rb +9 -9
  332. data/spec/utilities/csv_spec.rb +2 -12
  333. data/spec/utilities/logger_spec.rb +6 -6
  334. data/spec/utilities/message_log_spec.rb +3 -11
  335. data/tasks/gemfile_stats.rake +2 -2
  336. metadata +198 -63
@@ -94,7 +94,6 @@ module Cosmos
94
94
  build_unknown_help()
95
95
 
96
96
  # Configure Variables
97
- @key_press_callback = nil
98
97
  @output_time = Time.now.sys
99
98
  initialize_variables()
100
99
 
@@ -152,10 +151,6 @@ module Cosmos
152
151
  display_keyword_help()
153
152
  end
154
153
 
155
- def key_press_callback=(callback)
156
- @editor.keyPressCallback = callback
157
- end
158
-
159
154
  def setFocus
160
155
  @editor.setFocus
161
156
  end
@@ -18,6 +18,7 @@ Cosmos.catch_fatal_exception do
18
18
  require 'cosmos/gui/dialogs/exception_dialog'
19
19
  require 'cosmos/gui/dialogs/packet_log_dialog'
20
20
  require 'cosmos/gui/dialogs/find_replace_dialog'
21
+ require 'cosmos/gui/dialogs/dart_dialog'
21
22
  require 'cosmos/gui/widgets/realtime_button_bar'
22
23
  require 'cosmos/tools/data_viewer/data_viewer_component'
23
24
  require 'cosmos/tools/data_viewer/dump_component'
@@ -51,6 +52,11 @@ module Cosmos
51
52
  @log_filenames = []
52
53
  @cancel_thread = false
53
54
  @sleeper = Sleeper.new
55
+ @interface = Cosmos::TcpipClientInterface.new(
56
+ Cosmos::System.connect_hosts['DART_STREAM'],
57
+ Cosmos::System.ports['DART_STREAM'],
58
+ Cosmos::System.ports['DART_STREAM'],
59
+ 10, 30, 'PREIDENTIFIED')
54
60
 
55
61
  # Process config file and create a tab for each data viewer component
56
62
  @component_mutex = Mutex.new
@@ -97,6 +103,12 @@ module Cosmos
97
103
  @open_log.statusTip = tr('Open telemetry log file for processing')
98
104
  @open_log.connect(SIGNAL('triggered()')) { handle_open_log_file() }
99
105
 
106
+ @query_dart = Qt::Action.new(tr('&Query DART Database'), self)
107
+ @query_dart_keyseq = Qt::KeySequence.new(tr('Ctrl+D'))
108
+ @query_dart.shortcut = @query_dart_keyseq
109
+ @query_dart.statusTip = tr('Query DART Database')
110
+ @query_dart.connect(SIGNAL('triggered()')) { handle_query_dart() }
111
+
100
112
  @handle_reset = Qt::Action.new(tr('&Reset'), self)
101
113
  @handle_reset_keyseq = Qt::KeySequence.new(tr('Ctrl+R'))
102
114
  @handle_reset.shortcut = @handle_reset_keyseq
@@ -142,6 +154,7 @@ module Cosmos
142
154
  # File Menu
143
155
  file_menu = menuBar.addMenu(tr('&File'))
144
156
  file_menu.addAction(@open_log)
157
+ file_menu.addAction(@query_dart)
145
158
  file_menu.addAction(@handle_reset)
146
159
  file_menu.addAction(@replay_action)
147
160
  file_menu.addSeparator()
@@ -498,6 +511,104 @@ module Cosmos
498
511
  end
499
512
  end
500
513
 
514
+ def handle_query_dart
515
+ dart_dialog = DartDialog.new(self, 'Query DART Database:')
516
+ dart_dialog.time_start = @time_start
517
+ dart_dialog.time_end = @time_end
518
+ case dart_dialog.exec
519
+ when Qt::Dialog::Accepted
520
+ @time_start = dart_dialog.time_start
521
+ @time_end = dart_dialog.time_end
522
+ @meta_filters = dart_dialog.meta_filters
523
+
524
+ self.setWindowTitle("Data Viewer : DART Database Query")
525
+
526
+ handle_stop() # Stop realtime collection
527
+ handle_reset() # Reset
528
+
529
+ @cancel_progress = false
530
+
531
+ begin
532
+ ProgressDialog.execute(self, 'Querying DART Database', 500, 200, true, false, true, true, true) do |progress_dialog|
533
+ progress_dialog.cancel_callback = method(:cancel_callback)
534
+ progress_dialog.enable_cancel_button
535
+
536
+ begin
537
+ @interface.disconnect
538
+ request_packet = Cosmos::Packet.new('DART', 'DART')
539
+ request_packet.define_item('REQUEST', 0, 0, :BLOCK)
540
+
541
+ @time_start ||= Time.utc(1970, 1, 1)
542
+ @time_end ||= Time.now
543
+ @time_delta = @time_end - @time_start
544
+ request = {}
545
+ request['start_time_sec'] = @time_start.tv_sec
546
+ request['start_time_usec'] = @time_start.tv_usec
547
+ request['end_time_sec'] = @time_end.tv_sec
548
+ request['end_time_usec'] = @time_end.tv_usec
549
+ request['cmd_tlm'] = 'TLM'
550
+ request['packets'] = @packets
551
+ request['meta_filters'] = @meta_filters unless @meta_filters.empty?
552
+ request_packet.write('REQUEST', JSON.dump(request))
553
+
554
+ progress_dialog.append_text("Connecting to DART Database...")
555
+ @interface.connect
556
+ progress_dialog.append_text("Sending DART Database Query...")
557
+ @interface.write(request_packet)
558
+ progress_dialog.append_text("Receiving Packets...")
559
+
560
+ first = true
561
+ while true
562
+ break if @cancel_progress
563
+ packet = @interface.read
564
+ unless packet
565
+ progress_dialog.append_text("Done!")
566
+ progress_dialog.set_overall_progress(1.0)
567
+ @interface.disconnect
568
+ break
569
+ end
570
+
571
+ # Switch to correct configuration from SYSTEM META when needed
572
+ if packet.target_name == 'SYSTEM'.freeze and packet.packet_name == 'META'.freeze
573
+ meta_packet = System.telemetry.update!('SYSTEM', 'META', packet.buffer)
574
+ Cosmos::System.load_configuration(meta_packet.read('CONFIG'))
575
+ elsif first
576
+ first = false
577
+ @time_start = packet.received_time
578
+ @time_delta = @time_end - @time_start
579
+ end
580
+
581
+ defined_packet = System.telemetry.update!(packet.target_name, packet.packet_name, packet.buffer)
582
+ defined_packet.received_time = packet.received_time
583
+
584
+ break if @cancel_progress
585
+ # Route packet to its component(s)
586
+ index = defined_packet.target_name + ' ' + defined_packet.packet_name
587
+ components = @packet_to_components_mapping[index]
588
+ if components
589
+ @component_mutex.synchronize do
590
+ components.each do |component|
591
+ component.process_packet(defined_packet)
592
+ end
593
+ end
594
+ end
595
+
596
+ progress = ((@time_delta - (@time_end - defined_packet.received_time)).to_f / @time_delta.to_f)
597
+ progress_dialog.set_overall_progress(progress) if !@cancel_progress
598
+ end
599
+ ensure
600
+ progress_dialog.append_text("Canceled!") if @cancel_progress
601
+ progress_dialog.complete
602
+ end
603
+ end
604
+ rescue => error
605
+ Qt::MessageBox.critical(self, 'Error!', "Error Querying DART Database\n#{error.formatted}")
606
+ ensure
607
+ @interface.disconnect
608
+ end
609
+ end
610
+ end
611
+
501
612
  def cancel_callback(progress_dialog = nil)
502
613
  @cancel_progress = true
503
614
  return true, false
@@ -107,13 +107,14 @@ module Cosmos
107
107
  @initialized = false
108
108
  end
109
109
 
110
- # Ignore an item. Don't display it in the GUI if it goes out of limits
111
- # and don't have it count towards the overall limit state. Still display
112
- # its limits transitions in the log.
110
+ # Remove an item and optionally ignore it which means don't display it
111
+ # again if it goes out of limits and don't have it count towards the
112
+ # overall limit state. Still display its limits transitions in the log.
113
113
  #
114
114
  # @param item [Array<String,String,String>] Target name, packet name,
115
115
  # item name to ignore
116
- def ignore(item)
116
+ # @param ignore [Boolean] Whether to ignore future limits events
117
+ def remove(item, ignore)
117
118
  if item[2]
118
119
  items_to_delete = [item]
119
120
  else
@@ -124,8 +125,10 @@ module Cosmos
124
125
  widget = @items.delete("#{item_to_delete[0]} #{item_to_delete[1]} #{item_to_delete[2]}") if index
125
126
  @remove_item_callback.call(widget) if widget
126
127
  end
127
- unless @ignored.includes_item?(item)
128
- @ignored << item
128
+ if ignore
129
+ unless @ignored.includes_item?(item)
130
+ @ignored << item
131
+ end
129
132
  end
130
133
  end
131
134
 
@@ -133,7 +136,7 @@ module Cosmos
133
136
  # count towards the overall limit state.
134
137
  #
135
138
  # @param item [Array<String,String>] Target name, packet name
136
- def ignore_stale(item)
139
+ def remove_stale(item)
137
140
  index = @stale.delete_item(item)
138
141
  widget = @items.delete("#{item[0]} #{item[1]}") if index
139
142
  @remove_item_callback.call(widget) if widget
@@ -459,18 +462,24 @@ module Cosmos
459
462
  @value.set_setting('COLORBLIND', [parent.limits_items.colorblind])
460
463
  @value.process_settings
461
464
  @ignore_button = Qt::PushButton.new('Ignore Item')
462
- @ignore_button.connect(SIGNAL('clicked()')) { parent.ignore(self, item) }
465
+ @ignore_button.connect(SIGNAL('clicked()')) { parent.remove(self, item) }
463
466
  @layout.addWidget(@ignore_button)
464
467
 
465
468
  @ignore_packet_button = Qt::PushButton.new('Ignore Packet')
466
- @ignore_packet_button.connect(SIGNAL('clicked()')) { parent.ignore(self, packet) }
469
+ @ignore_packet_button.connect(SIGNAL('clicked()')) { parent.remove(self, packet) }
467
470
  @layout.addWidget(@ignore_packet_button)
471
+
472
+ @delete_button = Qt::PushButton.new()
473
+ @delete_button.setFixedSize(25, 25)
474
+ @delete_button.setIcon(Cosmos.get_icon('delete.png'))
475
+ @delete_button.connect(SIGNAL('clicked()')) { parent.remove(self, item, ignore: false) }
476
+ @layout.addWidget(@delete_button)
468
477
  else
469
478
  @type = :STALE
470
479
  @value = LabelWidget.new(@layout, "#{target_name} #{packet_name} is STALE")
471
480
  @layout.addStretch(1)
472
481
  @ignore_button = Qt::PushButton.new('Ignore Stale Packet')
473
- @ignore_button.connect(SIGNAL('clicked()')) { parent.ignore(self, packet) }
482
+ @ignore_button.connect(SIGNAL('clicked()')) { parent.remove(self, packet) }
474
483
  @layout.addWidget(@ignore_button)
475
484
  end
476
485
  end
@@ -601,7 +610,7 @@ module Cosmos
601
610
  widget = Qt::Widget.new
602
611
  layout = Qt::VBoxLayout.new(widget)
603
612
  setCentralWidget(widget)
604
-
613
+
605
614
  @replay_flag = Qt::Label.new("Replay Mode")
606
615
  @replay_flag.setStyleSheet("background:green;color:white;padding:5px;font-weight:bold;")
607
616
  layout.addWidget(@replay_flag)
@@ -860,22 +869,26 @@ module Cosmos
860
869
  else
861
870
  @replay_flag.hide
862
871
  end
863
- @scroll_layout.removeAll
872
+ @scroll_layout.removeAll
864
873
  end
865
874
  end
866
875
 
867
- # Update front panel to ignore an item when the corresponding button is pressed.
876
+ # Remove a limits item from the list and optionally ignore
868
877
  #
878
+ # @param widget [Qt::Widget] Widget to remove
869
879
  # @param item [Array<String,String,String] Array containing the target name,
870
880
  # packet name, and item name of the item to ignore.
871
- def ignore(widget, item)
881
+ # @param ignore [Boolean] Whether to ignore the item
882
+ def remove(widget, item, ignore: true)
872
883
  if widget.type == :ITEM
873
- @limits_items.ignore(item)
884
+ @limits_items.remove(item, ignore)
874
885
  else
875
- @limits_items.ignore_stale(item)
886
+ @limits_items.remove_stale(item)
876
887
  end
877
- Qt.execute_in_main_thread(true) do
878
- statusBar.showMessage('Warning: Some Telemetry Items are Ignored')
888
+ if ignore
889
+ Qt.execute_in_main_thread(true) do
890
+ statusBar.showMessage('Warning: Some Telemetry Items are Ignored')
891
+ end
879
892
  end
880
893
  end
881
894
 
@@ -411,9 +411,10 @@ module Cosmos
411
411
  @descriptions = []
412
412
 
413
413
  row = 0
414
- featured_item = nil
414
+ featured_row = -1
415
415
  @ignored_rows = []
416
416
  tlm_items.each do |tlm_name, states, description, derived|
417
+ featured_row = row if featured_item_name == tlm_name
417
418
  @ignored_rows << row if System.targets[target_name].ignored_items.include?(tlm_name)
418
419
  tlm_name = "*#{tlm_name}" if derived
419
420
  item = Qt::TableWidgetItem.new(tr("#{tlm_name}:"))
@@ -428,12 +429,20 @@ module Cosmos
428
429
  @descriptions[row][0] = description
429
430
  @descriptions[row][1] = description
430
431
  row += 1
431
- featured_item = item if featured_item_name == tlm_name
432
432
  end
433
433
 
434
434
  @table.resizeColumnsToContents()
435
435
  @table.resizeRowsToContents()
436
- @table.scrollToItem(featured_item) if featured_item
436
+ if featured_row != -1
437
+ # Selecting the row also scrolls to it so the item is displayed
438
+ @table.selectRow(featured_row)
439
+ # Fire up a thread to clear the selection cuz it's kind of annoying
440
+ Thread.new do
441
+ sleep 1
442
+ Qt.execute_in_main_thread { @table.clearSelection }
443
+ end
444
+ end
445
+
437
446
  @frame.addWidget(@table)
438
447
 
439
448
  # Handle Table Clicks
@@ -76,6 +76,10 @@ module Cosmos
76
76
  initial_tabs.each {|filename| create_tab(filename)}
77
77
  end
78
78
 
79
+ if options.disconnect_mode
80
+ script_toggle_disconnect(false)
81
+ end
82
+
79
83
  if options.run_procedure
80
84
  run_procedure(options.run_procedure)
81
85
  end
@@ -340,6 +344,12 @@ module Cosmos
340
344
  SLOT('handle_tab_change(int)'))
341
345
  setCentralWidget(@tab_book)
342
346
 
347
+ next_child = Qt::Shortcut.new(Qt::KeySequence.new(Qt::CTRL + Qt::Key_Tab), self)
348
+ self.connect(next_child, SIGNAL('activated()')) { next_child() }
349
+ # Note using Qt::KeySequence::PreviousChild does not work due to QT bug
350
+ previous_child = Qt::Shortcut.new(Qt::KeySequence.new(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab), self)
351
+ self.connect(previous_child, SIGNAL('activated()')) { previous_child() }
352
+
343
353
  # Display a blank message to force the statusBar to show
344
354
  statusBar.showMessage("")
345
355
  end
@@ -622,8 +632,8 @@ module Cosmos
622
632
  end
623
633
 
624
634
  # Script->Toggle Disconnect
625
- def script_toggle_disconnect
626
- @server_config_file = active_script_runner_frame().toggle_disconnect(@server_config_file)
635
+ def script_toggle_disconnect(ask_for_config_file = true)
636
+ @server_config_file = active_script_runner_frame().toggle_disconnect(@server_config_file, ask_for_config_file)
627
637
  end
628
638
 
629
639
  ###########################################
@@ -749,17 +759,18 @@ module Cosmos
749
759
  update_title()
750
760
  end
751
761
 
752
- def handle_script_keypress(event)
762
+ def next_child
763
+ index = @tab_book.currentIndex + 1
764
+ index = 0 if index >= @tab_book.count
765
+ @tab_book.setCurrentIndex(index)
766
+ update_title()
767
+ end
768
+
769
+ def previous_child
770
+ index = @tab_book.currentIndex - 1
771
+ index = @tab_book.count - 1 if index < 0
772
+ @tab_book.setCurrentIndex(index)
753
773
  update_title()
754
- if event.matches(Qt::KeySequence::NextChild)
755
- index = @tab_book.currentIndex + 1
756
- index = 0 if index >= @tab_book.count
757
- @tab_book.setCurrentIndex(index)
758
- elsif event.matches(Qt::KeySequence::PreviousChild)
759
- index = @tab_book.currentIndex - 1
760
- index = @tab_book.count - 1 if index < 0
761
- @tab_book.setCurrentIndex(index)
762
- end
763
774
  end
764
775
 
765
776
  def context_menu(point)
@@ -849,8 +860,6 @@ module Cosmos
849
860
  script_runner_frame.stop_callback = method(:stop_callback)
850
861
  script_runner_frame.set_text_from_file(filename) unless filename.empty?
851
862
  script_runner_frame.filename = filename
852
- # Register a keypress handler so we can Ctrl-Tab our way through the tabs
853
- script_runner_frame.key_press_callback = method(:handle_script_keypress)
854
863
  # Update the title if the frame changes so we can add/remove the asterix
855
864
  script_runner_frame.connect(SIGNAL('modificationChanged(bool)')) { update_title() }
856
865
 
@@ -957,6 +966,7 @@ module Cosmos
957
966
  options.auto_size = false
958
967
  options.server_config_file = CmdTlmServer::DEFAULT_CONFIG_FILE
959
968
  options.run_procedure = nil
969
+ options.disconnect_mode = false
960
970
 
961
971
  option_parser.separator "Script Runner Specific Options:"
962
972
  option_parser.on("-c", "--config FILE", "Use the specified configuration file") do |arg|
@@ -968,6 +978,9 @@ module Cosmos
968
978
  option_parser.on("-r", "--run FILE", "Open and run the specified procedure") do |arg|
969
979
  options.run_procedure = arg
970
980
  end
981
+ option_parser.on("-d", "--disconnect", "Start in disconnect mode") do |arg|
982
+ options.disconnect_mode = true
983
+ end
971
984
  end
972
985
 
973
986
  super(option_parser, options)
@@ -34,6 +34,8 @@ module Cosmos
34
34
  end
35
35
  end
36
36
 
37
+ # Create a dialog with an embedded ScriptRunnerFrame used to execute
38
+ # a snippet of code while the main script is paused.
37
39
  class ScriptRunnerDialog < Qt::Dialog
38
40
  attr_reader :script_runner_frame
39
41
 
@@ -65,8 +67,11 @@ module Cosmos
65
67
  return if @script_runner_frame.running?
66
68
  super
67
69
  end
68
- end # class ScriptRunnerDialog
70
+ end
69
71
 
72
+ # Frame within ScriptRunner and TestRunner that handles instrumenting the
73
+ # script and running it. This includes handling all the user interation and
74
+ # how to run, step, pause, and stop a script.
70
75
  class ScriptRunnerFrame < Qt::Widget
71
76
  slots 'context_menu(const QPoint&)'
72
77
  slots 'undo_available(bool)'
@@ -146,6 +151,16 @@ module Cosmos
146
151
  @realtime_button_bar.stop_callback = method(:handle_stop_button)
147
152
  @layout.addWidget(@realtime_button_bar)
148
153
 
154
+ # Create shortcuts to activate the RealtimeButtonBar actions
155
+ step = Qt::Shortcut.new(Qt::KeySequence.new(Qt::Key_F10), self)
156
+ self.connect(step, SIGNAL('activated()')) { handle_step_button() }
157
+ start_go = Qt::Shortcut.new(Qt::KeySequence.new(Qt::Key_F5), self)
158
+ self.connect(start_go, SIGNAL('activated()')) { handle_start_go_button() }
159
+ pause_retry = Qt::Shortcut.new(Qt::KeySequence.new(Qt::Key_F6), self)
160
+ self.connect(pause_retry, SIGNAL('activated()')) { handle_pause_retry_button() }
161
+ stop = Qt::Shortcut.new(Qt::KeySequence.new(Qt::Key_F7), self)
162
+ self.connect(stop, SIGNAL('activated()')) { handle_stop_button() }
163
+
149
164
  # Create a splitter to hold the script text area and the script output text area.
150
165
  @splitter = Qt::Splitter.new(Qt::Vertical, self)
151
166
  @layout.addWidget(@splitter)
@@ -197,7 +212,6 @@ module Cosmos
197
212
  @stop_callback = nil
198
213
  @error_callback = nil
199
214
  @pause_callback = nil
200
- @key_press_callback = nil
201
215
  @allow_start = true
202
216
  @continue_after_error = true
203
217
  @debug_text = nil
@@ -297,10 +311,6 @@ module Cosmos
297
311
  emit undoAvailable(bool)
298
312
  end
299
313
 
300
- def key_press_callback=(callback)
301
- @script.keyPressCallback = callback
302
- end
303
-
304
314
  def setFocus
305
315
  @script.setFocus
306
316
  end
@@ -695,9 +705,9 @@ module Cosmos
695
705
  # There are other un-instrumentable lines which don't support breakpoints
696
706
  # but this is the most common and is an easy check.
697
707
  # Note: line is 1 based but @script.get_line is zero based so subtract 1
698
- text = @script.get_line(line - 1)
699
- if text.strip.empty? || text.strip[0] == '#'
700
- @script.clear_breakpoint(line) # Immediately clear it
708
+ text = @active_script.get_line(line - 1)
709
+ if text && (text.strip.empty? || text.strip[0] == '#')
710
+ @active_script.clear_breakpoint(line) # Immediately clear it
701
711
  else
702
712
  ScriptRunnerFrame.set_breakpoint(current_tab_filename(), line)
703
713
  end
@@ -908,7 +918,7 @@ module Cosmos
908
918
  @debug_frame.addWidget(@debug_frame_label)
909
919
  @debug_text = CompletionLineEdit.new(self)
910
920
  @debug_text.setFocus(Qt::OtherFocusReason)
911
- @debug_text.keyPressCallback = lambda { |event|
921
+ @debug_text.connect(SIGNAL('key_pressed(QKeyEvent*)')) do |event|
912
922
  case event.key
913
923
  when Qt::Key_Return, Qt::Key_Enter
914
924
  begin
@@ -961,7 +971,7 @@ module Cosmos
961
971
  when Qt::Key_Escape
962
972
  @debug_text.setPlainText("")
963
973
  end
964
- }
974
+ end
965
975
 
966
976
  @debug_frame.addWidget(@debug_text)
967
977
 
@@ -1048,49 +1058,106 @@ module Cosmos
1048
1058
  end
1049
1059
  end
1050
1060
 
1051
- def toggle_disconnect(config_file)
1052
- if get_cmd_tlm_disconnect
1053
- set_cmd_tlm_disconnect(false)
1054
- self.parent.setPalette(Cosmos::DEFAULT_PALETTE)
1055
- else
1056
- dialog = Qt::Dialog.new(self, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
1057
- dialog.setWindowTitle(tr("Server Config File"))
1058
- dialog_layout = Qt::VBoxLayout.new
1061
+ def toggle_disconnect(config_file, ask_for_config_file = true)
1062
+ dialog = Qt::Dialog.new(self, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
1063
+ dialog.setWindowTitle(tr("Disconnect Settings"))
1064
+ dialog_layout = Qt::VBoxLayout.new
1065
+ dialog_layout.addWidget(Qt::Label.new("Targets checked will be disconnected."))
1059
1066
 
1067
+ all_targets = {}
1068
+ set_clear_layout = Qt::HBoxLayout.new
1069
+ check_all = Qt::PushButton.new("Check All")
1070
+ check_all.setAutoDefault(false)
1071
+ check_all.setDefault(false)
1072
+ check_all.connect(SIGNAL('clicked()')) do
1073
+ all_targets.each do |target, checkbox|
1074
+ checkbox.setChecked(true)
1075
+ end
1076
+ end
1077
+ set_clear_layout.addWidget(check_all)
1078
+ clear_all = Qt::PushButton.new("Clear All")
1079
+ clear_all.connect(SIGNAL('clicked()')) do
1080
+ all_targets.each do |target, checkbox|
1081
+ checkbox.setChecked(false)
1082
+ end
1083
+ end
1084
+ set_clear_layout.addWidget(clear_all)
1085
+ dialog_layout.addLayout(set_clear_layout)
1086
+
1087
+ scroll = Qt::ScrollArea.new
1088
+ target_widget = Qt::Widget.new
1089
+ scroll.setWidget(target_widget)
1090
+ target_layout = Qt::VBoxLayout.new(target_widget)
1091
+ target_layout.setSizeConstraint(Qt::Layout::SetMinAndMaxSize)
1092
+ scroll.setSizePolicy(Qt::SizePolicy::Preferred, Qt::SizePolicy::Expanding)
1093
+ scroll.setWidgetResizable(true)
1094
+
1095
+ existing = get_disconnected_targets()
1096
+ System.targets.keys.each do |target|
1097
+ check_layout = Qt::HBoxLayout.new
1098
+ check_label = Qt::CheckboxLabel.new(target)
1099
+ checkbox = Qt::CheckBox.new
1100
+ all_targets[target] = checkbox
1101
+ if existing
1102
+ checkbox.setChecked(existing && existing.include?(target))
1103
+ else
1104
+ checkbox.setChecked(true)
1105
+ end
1106
+ check_label.setCheckbox(checkbox)
1107
+ check_layout.addWidget(checkbox)
1108
+ check_layout.addWidget(check_label)
1109
+ check_layout.addStretch
1110
+ target_layout.addLayout(check_layout)
1111
+ end
1112
+ dialog_layout.addWidget(scroll)
1113
+
1114
+ if ask_for_config_file
1060
1115
  chooser = FileChooser.new(self, "Config File", config_file, 'Select',
1061
1116
  File.dirname(config_file))
1062
1117
  chooser.callback = lambda do |filename|
1063
1118
  chooser.filename = filename
1064
1119
  end
1065
1120
  dialog_layout.addWidget(chooser)
1121
+ end
1066
1122
 
1067
- button_layout = Qt::HBoxLayout.new
1068
- ok = Qt::PushButton.new("Ok")
1069
- ok.setDefault(true)
1070
- ok.connect(SIGNAL('clicked()')) do
1071
- dialog.accept()
1123
+ button_layout = Qt::HBoxLayout.new
1124
+ ok = Qt::PushButton.new("Ok")
1125
+ ok.setAutoDefault(true)
1126
+ ok.setDefault(true)
1127
+ targets = []
1128
+ ok.connect(SIGNAL('clicked()')) do
1129
+ all_targets.each do |target, checkbox|
1130
+ targets << target if checkbox.isChecked
1072
1131
  end
1073
- button_layout.addWidget(ok)
1074
- cancel = Qt::PushButton.new("Cancel")
1075
- cancel.connect(SIGNAL('clicked()')) do
1076
- dialog.reject()
1077
- end
1078
- button_layout.addWidget(cancel)
1079
- dialog_layout.addLayout(button_layout)
1080
-
1081
- dialog.setLayout(dialog_layout)
1082
- if dialog.exec == Qt::Dialog::Accepted
1132
+ dialog.accept()
1133
+ end
1134
+ button_layout.addWidget(ok)
1135
+ cancel = Qt::PushButton.new("Cancel")
1136
+ cancel.connect(SIGNAL('clicked()')) do
1137
+ dialog.reject()
1138
+ end
1139
+ button_layout.addWidget(cancel)
1140
+ dialog_layout.addLayout(button_layout)
1141
+
1142
+ dialog.setLayout(dialog_layout)
1143
+ if dialog.exec == Qt::Dialog::Accepted
1144
+ if targets.empty?
1145
+ clear_disconnected_targets()
1146
+ self.parent.parent.parent.statusBar.showMessage("")
1147
+ self.setPalette(Qt::Palette.new(Cosmos::DEFAULT_PALETTE))
1148
+ else
1083
1149
  config_file = chooser.filename
1084
- self.parent.setPalette(Cosmos::RED_PALETTE)
1150
+ self.parent.parent.parent.statusBar.showMessage("Targets disconnected: #{targets.join(" ")}")
1151
+ self.setPalette(Qt::Palette.new(Cosmos::RED_PALETTE))
1085
1152
  Splash.execute(self) do |splash|
1086
1153
  ConfigParser.splash = splash
1087
1154
  splash.message = "Initializing Command and Telemetry Server"
1088
- set_cmd_tlm_disconnect(true, config_file)
1155
+ set_disconnected_targets(targets, config_file)
1089
1156
  ConfigParser.splash = nil
1090
1157
  end
1091
1158
  end
1092
- dialog.dispose
1093
1159
  end
1160
+ dialog.dispose
1094
1161
  config_file
1095
1162
  end
1096
1163