cosmos 4.2.4 → 4.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.dockerignore +2 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +30 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +19 -0
- data/.github/ISSUE_TEMPLATE/help---usage---general-question.md +12 -0
- data/.gitignore +2 -0
- data/.travis.yml +6 -6
- data/Dockerfile +69 -0
- data/Gemfile +1 -1
- data/Manifest.txt +130 -46
- data/README.md +9 -0
- data/Rakefile +57 -0
- data/appveyor.yml +18 -7
- data/autohotkey/config/targets/INST/cmd_tlm/inst_cmds.txt +1 -1
- data/autohotkey/config/targets/INST/cmd_tlm/inst_tlm.txt +5 -5
- data/autohotkey/config/targets/INST/lib/sim_inst.rb +3 -1
- data/autohotkey/config/tools/cmd_sequence/cmd_sequence.txt +2 -0
- data/autohotkey/config/tools/handbook_creator/assets/css/bootstrap-theme.css +397 -0
- data/autohotkey/config/tools/handbook_creator/assets/css/bootstrap-theme.min.css +7 -0
- data/autohotkey/config/tools/handbook_creator/assets/css/bootstrap.css +7118 -0
- data/autohotkey/config/tools/handbook_creator/assets/css/bootstrap.min.css +7 -0
- data/autohotkey/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.eot +0 -0
- data/autohotkey/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.svg +229 -0
- data/autohotkey/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/autohotkey/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.woff +0 -0
- data/autohotkey/config/tools/handbook_creator/assets/js/bootstrap.js +2006 -0
- data/autohotkey/config/tools/handbook_creator/assets/js/bootstrap.min.js +7 -0
- data/autohotkey/config/tools/table_manager/ConfigTables_def.txt +2 -4
- data/autohotkey/config/tools/table_manager/SubTables/OneDimensionalSubTable_def.txt +31 -0
- data/autohotkey/config/tools/table_manager/SubTables/TwoDimensionalSubTable_def.txt +28 -0
- data/autohotkey/config/tools/test_runner/test_runner.txt +1 -1
- data/autohotkey/config/tools/test_runner/test_runner2.txt +1 -1
- data/autohotkey/config/tools/test_runner/test_runner3.txt +1 -1
- data/autohotkey/config/tools/test_runner/test_runner4.txt +1 -1
- data/autohotkey/lib/cmd_sequence_exporter.rb +52 -0
- data/autohotkey/procedures/collect.rb +2 -2
- data/autohotkey/procedures/collect_util.rb +1 -1
- data/autohotkey/procedures/script_test.rb +1 -1
- data/autohotkey/tools/CmdSenderAHK2 +18 -0
- data/autohotkey/tools/cmd_sender.ahk +34 -6
- data/autohotkey/tools/cmd_sender2.ahk +4 -0
- data/autohotkey/tools/cmd_sequence.ahk +36 -22
- data/autohotkey/tools/cmd_sequence2.ahk +1 -1
- data/autohotkey/tools/config_editor.ahk +5 -5
- data/autohotkey/tools/launcher.ahk +1 -0
- data/autohotkey/tools/limits_monitor.ahk +1 -1
- data/autohotkey/tools/packet_viewer.ahk +7 -6
- data/autohotkey/tools/script_runner.ahk +16 -4
- data/autohotkey/tools/test_runner.ahk +8 -8
- data/bin/cosmos +38 -1
- data/bin/cstol_converter +1 -1
- data/bin/dart_util +0 -0
- data/bin/rubysloc +73 -28
- data/bin/xtce_converter +1 -1
- data/cosmos.gemspec +7 -9
- data/data/config/_interfaces.yaml +4 -0
- data/data/config/cmd_sequence.yaml +14 -0
- data/data/config/command_modifiers.yaml +16 -1
- data/data/config/housekeeping_params.yaml +14 -0
- data/data/config/interface_modifiers.yaml +14 -2
- data/data/config/item_modifiers.yaml +11 -1
- data/data/config/launcher.yaml +12 -2
- data/data/config/param_item_modifiers.yaml +7 -2
- data/data/config/parameter_modifiers.yaml +20 -0
- data/data/config/screen.yaml +2 -0
- data/data/config/script_runner.yaml +9 -0
- data/data/config/system.yaml +152 -28
- data/data/config/table_manager.yaml +7 -0
- data/data/config/target.yaml +12 -0
- data/data/config/telemetry_modifiers.yaml +19 -2
- data/data/config/test_runner.yaml +10 -9
- data/data/config/widgets.yaml +174 -11
- data/data/crc.txt +428 -415
- data/demo/Gemfile +1 -1
- data/demo/Launcher.bat +1 -9
- data/demo/Launcher2.bat +1 -0
- data/demo/LauncherMini.bat +1 -0
- data/demo/Rakefile +2 -0
- data/demo/config/dart/Gemfile +2 -7
- data/demo/config/data/crc.txt +243 -219
- data/demo/config/system/system.txt +42 -3
- data/demo/config/system/system2.txt +34 -5
- data/demo/config/system/system_alt_ports.txt +80 -0
- data/demo/config/targets/EXAMPLE/cmd_tlm_server.txt +1 -0
- data/demo/config/targets/INST/cmd_tlm/inst_cmds.txt +5 -4
- data/demo/config/targets/INST/cmd_tlm/inst_tlm.txt +12 -7
- data/demo/config/targets/INST/cmd_tlm/inst_tlm_override.txt +12 -0
- data/demo/config/targets/INST/cmd_tlm_server.txt +2 -0
- data/demo/config/targets/INST/lib/sim_inst.rb +15 -3
- data/demo/config/targets/INST/screens/adcs.txt +2 -2
- data/demo/config/targets/INST/screens/block.txt +1 -1
- data/demo/config/targets/INST/screens/commanding.txt +1 -1
- data/demo/config/targets/INST/screens/ground.txt +27 -5
- data/demo/config/targets/INST/screens/ground_error.gif +0 -0
- data/demo/config/{data/groundoff.gif → targets/INST/screens/ground_off.gif} +0 -0
- data/demo/config/{data/groundon.gif → targets/INST/screens/ground_on.gif} +0 -0
- data/demo/config/targets/INST/screens/limits.txt +69 -31
- data/demo/config/targets/INST/screens/other.txt +13 -3
- data/demo/config/targets/INST/screens/params.txt +54 -0
- data/demo/config/targets/INST/screens/satellite.gif +0 -0
- data/demo/config/targets/INST/target.txt +1 -0
- data/demo/config/tools/cmd_tlm_server/cmd_tlm_server_chain.txt +18 -0
- data/demo/config/tools/data_viewer/data_viewer.txt +3 -0
- data/demo/config/tools/handbook_creator/assets/css/bootstrap-theme.css +397 -0
- data/demo/config/tools/handbook_creator/assets/css/bootstrap-theme.min.css +7 -0
- data/demo/config/tools/handbook_creator/assets/css/bootstrap.css +7118 -0
- data/demo/config/tools/handbook_creator/assets/css/bootstrap.min.css +7 -0
- data/demo/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.eot +0 -0
- data/demo/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.svg +229 -0
- data/demo/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/demo/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.woff +0 -0
- data/demo/config/tools/handbook_creator/assets/img/ball_logo.bmp +0 -0
- data/demo/config/tools/handbook_creator/assets/img/ball_logo.gif +0 -0
- data/demo/config/tools/handbook_creator/assets/img/ball_logo.jpg +0 -0
- data/demo/config/tools/handbook_creator/assets/js/bootstrap.js +2006 -0
- data/demo/config/tools/handbook_creator/assets/js/bootstrap.min.js +7 -0
- data/demo/config/tools/handbook_creator/assets/js/html5shiv.js +8 -0
- data/demo/config/tools/handbook_creator/assets/js/jquery-1.10.2.min.js +6 -0
- data/demo/config/tools/handbook_creator/assets/js/respond.min.js +6 -0
- data/demo/config/tools/handbook_creator/default_toc.xsl +59 -59
- data/demo/config/tools/script_runner/script_runner.txt +1 -2
- data/demo/config/tools/test_runner/test_runner.txt +3 -1
- data/demo/lib/example_background_task.rb +1 -0
- data/demo/procedures/cosmos_api_test.rb +26 -22
- data/demo/procedures/interactive.rb +22 -0
- data/demo/procedures/local_screen_example.rb +51 -0
- data/ext/cosmos/ext/cosmos_io/cosmos_io.c +32 -4
- data/ext/cosmos/ext/packet/packet.c +6 -77
- data/ext/mkrf_conf.rb +2 -2
- data/extensions/vscode/.gitignore +4 -0
- data/extensions/vscode/.vscode/launch.json +32 -0
- data/extensions/vscode/.vscode/settings.json +13 -0
- data/extensions/vscode/.vscode/tasks.json +79 -0
- data/extensions/vscode/License.txt +879 -0
- data/extensions/vscode/README.md +9 -0
- data/extensions/vscode/client/License.txt +879 -0
- data/extensions/vscode/client/README.md +39 -0
- data/extensions/vscode/client/cosmos.configuration.json +23 -0
- data/extensions/vscode/client/images/icon.png +0 -0
- data/extensions/vscode/client/package-lock.json +414 -0
- data/extensions/vscode/client/package.json +105 -0
- data/extensions/vscode/client/src/extension.ts +132 -0
- data/extensions/vscode/client/src/screen_preview.rb +25 -0
- data/extensions/vscode/client/syntaxes/cosmos.tmLanguage.json +219 -0
- data/extensions/vscode/client/tsconfig.json +17 -0
- data/extensions/vscode/package-lock.json +26 -0
- data/extensions/vscode/package.json +35 -0
- data/extensions/vscode/server/License.txt +879 -0
- data/extensions/vscode/server/package-lock.json +236 -0
- data/extensions/vscode/server/package.json +29 -0
- data/extensions/vscode/server/src/server.ts +59 -0
- data/extensions/vscode/server/tsconfig.json +16 -0
- data/install/Gemfile +1 -1
- data/install/Launcher.bat +1 -9
- data/install/config/dart/Gemfile +3 -8
- data/install/config/data/crc.txt +148 -132
- data/install/config/system/system.txt +36 -3
- data/install/config/tools/handbook_creator/assets/css/bootstrap-theme.css +397 -0
- data/install/config/tools/handbook_creator/assets/css/bootstrap-theme.min.css +7 -0
- data/install/config/tools/handbook_creator/assets/css/bootstrap.css +7118 -0
- data/install/config/tools/handbook_creator/assets/css/bootstrap.min.css +7 -0
- data/install/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.eot +0 -0
- data/install/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.svg +229 -0
- data/install/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/install/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.woff +0 -0
- data/install/config/tools/handbook_creator/assets/img/ball_logo.bmp +0 -0
- data/install/config/tools/handbook_creator/assets/img/ball_logo.gif +0 -0
- data/install/config/tools/handbook_creator/assets/img/ball_logo.jpg +0 -0
- data/install/config/tools/handbook_creator/assets/js/bootstrap.js +2006 -0
- data/install/config/tools/handbook_creator/assets/js/bootstrap.min.js +7 -0
- data/install/config/tools/handbook_creator/assets/js/html5shiv.js +8 -0
- data/install/config/tools/handbook_creator/assets/js/jquery-1.10.2.min.js +6 -0
- data/install/config/tools/handbook_creator/assets/js/respond.min.js +6 -0
- data/install/config/tools/handbook_creator/default_toc.xsl +59 -59
- data/lib/cosmos/config/config_parser.rb +4 -5
- data/lib/cosmos/conversions.rb +2 -0
- data/lib/cosmos/conversions/packet_time_formatted_conversion.rb +38 -0
- data/lib/cosmos/conversions/packet_time_seconds_conversion.rb +38 -0
- data/lib/cosmos/core_ext/cosmos_io.rb +2 -1
- data/lib/cosmos/core_ext/time.rb +3 -1
- data/lib/cosmos/dart/config/boot.rb +1 -1
- data/lib/cosmos/dart/config/database.yml +2 -0
- data/lib/cosmos/dart/examples/dart_decom_client.rb +1 -1
- data/lib/cosmos/dart/examples/dart_stream_client.rb +6 -2
- data/lib/cosmos/dart/lib/dart_common.rb +13 -6
- data/lib/cosmos/dart/lib/dart_constants.rb +15 -0
- data/lib/cosmos/dart/lib/dart_database_cleaner.rb +2 -2
- data/lib/cosmos/dart/lib/dart_decom_query.rb +5 -6
- data/lib/cosmos/dart/lib/dart_decommutator.rb +64 -54
- data/lib/cosmos/dart/lib/dart_importer.rb +3 -3
- data/lib/cosmos/dart/lib/dart_master_query.rb +71 -0
- data/lib/cosmos/dart/lib/dart_packet_log_writer.rb +2 -2
- data/lib/cosmos/dart/lib/dart_reducer_worker_thread.rb +165 -134
- data/lib/cosmos/dart/processes/dart.rb +4 -2
- data/lib/cosmos/dart/processes/dart_decom_server.rb +3 -3
- data/lib/cosmos/dart/processes/dart_ingester.rb +40 -1
- data/lib/cosmos/dart/processes/dart_master.rb +44 -0
- data/lib/cosmos/dart/processes/dart_util.rb +119 -4
- data/lib/cosmos/dart/spec/dart/dart_reducer_manager_spec.rb +3 -3
- data/lib/cosmos/gui/dialogs/cmd_tlm_raw_dialog.rb +9 -5
- data/lib/cosmos/gui/dialogs/details_dialog.rb +44 -29
- data/lib/cosmos/gui/dialogs/exception_list_dialog.rb +1 -1
- data/lib/cosmos/gui/dialogs/find_replace_dialog.rb +3 -3
- data/lib/cosmos/gui/dialogs/interface_raw_dialog.rb +2 -2
- data/lib/cosmos/gui/dialogs/set_tlm_dialog.rb +1 -1
- data/lib/cosmos/gui/dialogs/tlm_details_dialog.rb +11 -10
- data/lib/cosmos/gui/dialogs/tlm_graph_dialog.rb +4 -2
- data/lib/cosmos/gui/opengl/earth_model.rb +1 -1
- data/lib/cosmos/gui/qt.rb +13 -2
- data/lib/cosmos/gui/qt_tool.rb +71 -43
- data/lib/cosmos/gui/text/ruby_editor.rb +91 -49
- data/lib/cosmos/gui/utilities/classification_banner.rb +60 -0
- data/lib/cosmos/gui/utilities/screenshot.rb +1 -1
- data/lib/cosmos/gui/utilities/script_module_gui.rb +117 -91
- data/lib/cosmos/gui/widgets/dart_meta_frame.rb +22 -3
- data/lib/cosmos/interfaces.rb +2 -0
- data/lib/cosmos/interfaces/dart_status_interface.rb +1 -1
- data/lib/cosmos/interfaces/interface.rb +9 -1
- data/lib/cosmos/interfaces/linc_interface.rb +3 -3
- data/lib/cosmos/interfaces/protocols/burst_protocol.rb +1 -1
- data/lib/cosmos/interfaces/protocols/crc_protocol.rb +1 -1
- data/lib/cosmos/interfaces/protocols/fixed_protocol.rb +40 -18
- data/lib/cosmos/interfaces/protocols/ignore_packet_protocol.rb +46 -0
- data/lib/cosmos/interfaces/protocols/length_protocol.rb +5 -0
- data/lib/cosmos/interfaces/protocols/preidentified_protocol.rb +68 -23
- data/lib/cosmos/interfaces/protocols/template_protocol.rb +9 -4
- data/lib/cosmos/interfaces/serial_interface.rb +7 -1
- data/lib/cosmos/interfaces/simulated_target_interface.rb +14 -5
- data/lib/cosmos/interfaces/stream_interface.rb +1 -1
- data/lib/cosmos/interfaces/tcpip_server_interface.rb +13 -13
- data/lib/cosmos/io/json_drb.rb +16 -12
- data/lib/cosmos/io/json_drb_object.rb +7 -2
- data/lib/cosmos/io/json_drb_rack.rb +25 -5
- data/lib/cosmos/io/json_rpc.rb +1 -1
- data/lib/cosmos/io/posix_serial_driver.rb +60 -22
- data/lib/cosmos/io/serial_driver.rb +11 -8
- data/lib/cosmos/io/win32_serial_driver.rb +31 -3
- data/lib/cosmos/packet_logs/packet_log_reader.rb +71 -28
- data/lib/cosmos/packet_logs/packet_log_writer.rb +13 -1
- data/lib/cosmos/packets/commands.rb +30 -9
- data/lib/cosmos/packets/packet.rb +105 -34
- data/lib/cosmos/packets/packet_config.rb +60 -10
- data/lib/cosmos/packets/parsers/format_string_parser.rb +0 -1
- data/lib/cosmos/packets/parsers/state_parser.rb +0 -1
- data/lib/cosmos/packets/parsers/xtce_converter.rb +2 -0
- data/lib/cosmos/packets/parsers/xtce_parser.rb +5 -4
- data/lib/cosmos/packets/structure.rb +32 -4
- data/lib/cosmos/packets/structure_item.rb +5 -1
- data/lib/cosmos/packets/telemetry.rb +30 -4
- data/lib/cosmos/script/api_shared.rb +22 -10
- data/lib/cosmos/script/extract.rb +1 -1
- data/lib/cosmos/script/limits.rb +4 -0
- data/lib/cosmos/script/script.rb +29 -20
- data/lib/cosmos/script/scripting.rb +16 -14
- data/lib/cosmos/script/telemetry.rb +3 -1
- data/lib/cosmos/script/tools.rb +18 -8
- data/lib/cosmos/streams/serial_stream.rb +11 -6
- data/lib/cosmos/system/system.rb +214 -76
- data/lib/cosmos/system/target.rb +39 -9
- data/lib/cosmos/tools/cmd_extractor/cmd_extractor.rb +116 -55
- data/lib/cosmos/tools/cmd_sender/cmd_param_table_item_delegate.rb +15 -0
- data/lib/cosmos/tools/cmd_sender/cmd_params.rb +382 -0
- data/lib/cosmos/tools/cmd_sender/cmd_sender.rb +54 -340
- data/lib/cosmos/tools/cmd_sequence/cmd_sequence.rb +74 -52
- data/lib/cosmos/tools/cmd_sequence/sequence_item.rb +40 -333
- data/lib/cosmos/tools/cmd_sequence/sequence_list.rb +16 -11
- data/lib/cosmos/tools/cmd_tlm_server/api.rb +13 -0
- data/lib/cosmos/tools/cmd_tlm_server/background_tasks.rb +2 -0
- data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server.rb +44 -15
- data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_config.rb +8 -1
- data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb +18 -20
- data/lib/cosmos/tools/cmd_tlm_server/commanding.rb +13 -2
- data/lib/cosmos/tools/cmd_tlm_server/gui/interfaces_tab.rb +2 -2
- data/lib/cosmos/tools/cmd_tlm_server/gui/logging_tab.rb +13 -13
- data/lib/cosmos/tools/cmd_tlm_server/gui/packets_tab.rb +9 -6
- data/lib/cosmos/tools/cmd_tlm_server/gui/status_tab.rb +8 -8
- data/lib/cosmos/tools/cmd_tlm_server/gui/targets_tab.rb +5 -5
- data/lib/cosmos/tools/cmd_tlm_server/interface_thread.rb +35 -20
- data/lib/cosmos/tools/cmd_tlm_server/replay_backend.rb +15 -11
- data/lib/cosmos/tools/cmd_tlm_server/router_thread.rb +5 -0
- data/lib/cosmos/tools/cmd_tlm_server/routers.rb +2 -0
- data/lib/cosmos/tools/config_editor/config_editor.rb +181 -94
- data/lib/cosmos/tools/config_editor/config_editor_frame.rb +10 -9
- data/lib/cosmos/tools/config_editor/system_config_dialog.rb +158 -0
- data/lib/cosmos/tools/data_viewer/data_viewer.rb +57 -47
- data/lib/cosmos/tools/data_viewer/data_viewer_component.rb +1 -0
- data/lib/cosmos/tools/data_viewer/dump_component.rb +3 -9
- data/lib/cosmos/tools/data_viewer/text_component.rb +77 -0
- data/lib/cosmos/tools/handbook_creator/handbook_creator.rb +68 -42
- data/lib/cosmos/tools/handbook_creator/handbook_creator_config.rb +1 -1
- data/lib/cosmos/tools/launcher/launcher.rb +2 -1
- data/lib/cosmos/tools/limits_monitor/limits_monitor.rb +59 -41
- data/lib/cosmos/tools/opengl_builder/opengl_builder.rb +42 -42
- data/lib/cosmos/tools/packet_viewer/packet_viewer.rb +64 -59
- data/lib/cosmos/tools/script_runner/script_runner.rb +198 -123
- data/lib/cosmos/tools/script_runner/script_runner_config.rb +14 -0
- data/lib/cosmos/tools/script_runner/script_runner_frame.rb +87 -35
- data/lib/cosmos/tools/table_manager/table_config.rb +5 -3
- data/lib/cosmos/tools/table_manager/table_manager.rb +48 -45
- data/lib/cosmos/tools/test_runner/test.rb +5 -2
- data/lib/cosmos/tools/test_runner/test_runner.rb +61 -38
- data/lib/cosmos/tools/test_runner/test_runner_chooser.rb +24 -12
- data/lib/cosmos/tools/tlm_extractor/tlm_extractor.rb +48 -48
- data/lib/cosmos/tools/tlm_extractor/tlm_extractor_config.rb +5 -8
- data/lib/cosmos/tools/tlm_extractor/tlm_extractor_processor.rb +20 -16
- data/lib/cosmos/tools/tlm_grapher/data_object_adders/xy_data_object_adder.rb +3 -3
- data/lib/cosmos/tools/tlm_grapher/data_object_editors/housekeeping_data_object_editor.rb +7 -7
- data/lib/cosmos/tools/tlm_grapher/data_object_editors/xy_data_object_editor.rb +10 -10
- data/lib/cosmos/tools/tlm_grapher/data_objects/housekeeping_data_object.rb +10 -3
- data/lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb +6 -6
- data/lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb +14 -14
- data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_dart_thread.rb +21 -17
- data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_realtime_thread.rb +5 -8
- data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_tool.rb +94 -91
- data/lib/cosmos/tools/tlm_grapher/tlm_grapher.rb +27 -26
- data/lib/cosmos/tools/tlm_viewer/screen.rb +76 -14
- data/lib/cosmos/tools/tlm_viewer/tlm_viewer.rb +51 -34
- data/lib/cosmos/tools/tlm_viewer/widgets.rb +3 -0
- data/lib/cosmos/tools/tlm_viewer/widgets/aging_widget.rb +4 -5
- data/lib/cosmos/tools/tlm_viewer/widgets/array_widget.rb +3 -4
- data/lib/cosmos/tools/tlm_viewer/widgets/block_widget.rb +4 -5
- data/lib/cosmos/tools/tlm_viewer/widgets/canvas_clickable.rb +16 -2
- data/lib/cosmos/tools/tlm_viewer/widgets/canvas_widget.rb +17 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/canvasdot_widget.rb +1 -2
- data/lib/cosmos/tools/tlm_viewer/widgets/canvasellipse_widget.rb +40 -0
- data/lib/cosmos/tools/tlm_viewer/widgets/canvasimage_widget.rb +12 -7
- data/lib/cosmos/tools/tlm_viewer/widgets/canvasimagevalue_widget.rb +79 -29
- data/lib/cosmos/tools/tlm_viewer/widgets/canvaslabel_widget.rb +1 -0
- data/lib/cosmos/tools/tlm_viewer/widgets/canvaslabelvalue_widget.rb +2 -1
- data/lib/cosmos/tools/tlm_viewer/widgets/canvasline_widget.rb +2 -0
- data/lib/cosmos/tools/tlm_viewer/widgets/canvaslinevalue_widget.rb +4 -0
- data/lib/cosmos/tools/tlm_viewer/widgets/canvasvalue_widget.rb +33 -25
- data/lib/cosmos/tools/tlm_viewer/widgets/checkbutton_widget.rb +5 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/combobox_widget.rb +5 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/formatfontvalue_widget.rb +1 -1
- data/lib/cosmos/tools/tlm_viewer/widgets/formatvalue_widget.rb +4 -7
- data/lib/cosmos/tools/tlm_viewer/widgets/horizontal_widget.rb +5 -5
- data/lib/cosmos/tools/tlm_viewer/widgets/horizontalbox_widget.rb +6 -7
- data/lib/cosmos/tools/tlm_viewer/widgets/horizontalline_widget.rb +2 -4
- data/lib/cosmos/tools/tlm_viewer/widgets/label_widget.rb +10 -8
- data/lib/cosmos/tools/tlm_viewer/widgets/labelformatvalue_widget.rb +2 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/labelled_widget.rb +58 -0
- data/lib/cosmos/tools/tlm_viewer/widgets/labelprogressbar_widget.rb +3 -4
- data/lib/cosmos/tools/tlm_viewer/widgets/labeltrendlimitsbar_widget.rb +2 -4
- data/lib/cosmos/tools/tlm_viewer/widgets/labelvalue_widget.rb +2 -1
- data/lib/cosmos/tools/tlm_viewer/widgets/labelvaluedesc_widget.rb +3 -5
- data/lib/cosmos/tools/tlm_viewer/widgets/labelvaluelimitsbar_widget.rb +2 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/labelvaluelimitscolumn_widget.rb +2 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/labelvaluerangebar_widget.rb +2 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/labelvaluerangecolumn_widget.rb +2 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/layout_widget.rb +3 -5
- data/lib/cosmos/tools/tlm_viewer/widgets/led_widget.rb +108 -0
- data/lib/cosmos/tools/tlm_viewer/widgets/limits_widget.rb +60 -10
- data/lib/cosmos/tools/tlm_viewer/widgets/limitsbar_widget.rb +22 -8
- data/lib/cosmos/tools/tlm_viewer/widgets/limitscolor_widget.rb +19 -13
- data/lib/cosmos/tools/tlm_viewer/widgets/limitscolumn_widget.rb +22 -8
- data/lib/cosmos/tools/tlm_viewer/widgets/linegraph_widget.rb +2 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/matrixbycolumns_widget.rb +4 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/multi_widget.rb +1 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/progressbar_widget.rb +10 -5
- data/lib/cosmos/tools/tlm_viewer/widgets/radiobutton_widget.rb +7 -4
- data/lib/cosmos/tools/tlm_viewer/widgets/rangebar_widget.rb +4 -6
- data/lib/cosmos/tools/tlm_viewer/widgets/rangecolumn_widget.rb +3 -5
- data/lib/cosmos/tools/tlm_viewer/widgets/screenshotbutton_widget.rb +4 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/scrollwindow_widget.rb +2 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/sectionheader_widget.rb +2 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/spacer_widget.rb +4 -6
- data/lib/cosmos/tools/tlm_viewer/widgets/tabbook_widget.rb +2 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/tabitem_widget.rb +2 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/textbox_widget.rb +13 -4
- data/lib/cosmos/tools/tlm_viewer/widgets/textfield_widget.rb +3 -4
- data/lib/cosmos/tools/tlm_viewer/widgets/timegraph_widget.rb +3 -8
- data/lib/cosmos/tools/tlm_viewer/widgets/title_widget.rb +6 -12
- data/lib/cosmos/tools/tlm_viewer/widgets/trendbar_widget.rb +5 -10
- data/lib/cosmos/tools/tlm_viewer/widgets/trendlimitsbar_widget.rb +5 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/value_widget.rb +4 -4
- data/lib/cosmos/tools/tlm_viewer/widgets/valuelimitsbar_widget.rb +2 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/valuelimitscolumn_widget.rb +2 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/valuerangebar_widget.rb +3 -4
- data/lib/cosmos/tools/tlm_viewer/widgets/valuerangecolumn_widget.rb +2 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/vertical_widget.rb +8 -7
- data/lib/cosmos/tools/tlm_viewer/widgets/verticalbox_widget.rb +9 -7
- data/lib/cosmos/tools/tlm_viewer/widgets/widget.rb +60 -47
- data/lib/cosmos/top_level.rb +37 -13
- data/lib/cosmos/utilities/ruby_lex_utils.rb +34 -30
- data/lib/cosmos/version.rb +5 -5
- data/lib/cosmos/win32/excel.rb +81 -24
- data/make_gems.sh +10 -0
- data/run_gui_tests.bat +1 -0
- data/spec/conversions/packet_time_formatted_conversion_spec.rb +58 -0
- data/spec/conversions/packet_time_seconds_conversion_spec.rb +60 -0
- data/spec/core_ext/socket_spec.rb +1 -1
- data/spec/core_ext/time_spec.rb +4 -0
- data/spec/gui/utilities/script_module_gui_spec.rb +44 -63
- data/spec/install/config/targets/INST/cmd_tlm/inst_cmds.txt +1 -1
- data/spec/install/config/targets/INST/cmd_tlm/inst_tlm.txt +5 -5
- data/spec/install/yaml_docs_spec.rb +132 -0
- data/spec/interfaces/linc_interface_spec.rb +1 -1
- data/spec/interfaces/protocols/fixed_protocol_spec.rb +20 -9
- data/spec/interfaces/protocols/ignore_packet_protocol_spec.rb +243 -0
- data/spec/interfaces/protocols/length_protocol_spec.rb +39 -0
- data/spec/interfaces/protocols/preidentified_protocol_spec.rb +227 -4
- data/spec/interfaces/protocols/template_protocol_spec.rb +78 -25
- data/spec/io/json_drb_rack_spec.rb +166 -0
- data/spec/io/json_drb_spec.rb +14 -0
- data/spec/io/json_rpc_spec.rb +4 -5
- data/spec/io/posix_serial_driver_spec.rb +81 -0
- data/spec/io/serial_driver_spec.rb +15 -13
- data/spec/io/win32_serial_driver_spec.rb +33 -3
- data/spec/packet_logs/packet_log_reader_spec.rb +106 -52
- data/spec/packets/commands_spec.rb +22 -0
- data/spec/packets/packet_config_spec.rb +29 -16
- data/spec/packets/packet_item_spec.rb +2 -2
- data/spec/packets/packet_spec.rb +39 -6
- data/spec/packets/parsers/format_string_parser_spec.rb +0 -11
- data/spec/packets/parsers/macro_parser_spec.rb +36 -36
- data/spec/packets/parsers/state_parser_spec.rb +69 -11
- data/spec/packets/structure_spec.rb +93 -2
- data/spec/packets/telemetry_spec.rb +63 -10
- data/spec/script/extract_spec.rb +4 -1
- data/spec/script/script_spec.rb +2 -3
- data/spec/script/scripting_spec.rb +2 -1
- data/spec/script/tools_spec.rb +0 -1
- data/spec/streams/tcpip_socket_stream_spec.rb +32 -27
- data/spec/system/system_spec.rb +187 -4
- data/spec/system/target_spec.rb +62 -1
- data/spec/tools/cmd_tlm_server/api_spec.rb +29 -21
- data/spec/tools/cmd_tlm_server/background_tasks_spec.rb +15 -7
- data/spec/tools/cmd_tlm_server/cmd_tlm_server_config_spec.rb +33 -0
- data/spec/tools/cmd_tlm_server/commanding_spec.rb +25 -1
- data/spec/tools/cmd_tlm_server/interface_thread_spec.rb +15 -0
- data/spec/tools/cmd_tlm_server/router_thread_spec.rb +2 -3
- data/spec/top_level/top_level_spec.rb +29 -5
- data/spec/utilities/message_log_spec.rb +6 -3
- data/tasks/gemfile_stats.rake +38 -14
- data/test/performance/config/system/system.txt +0 -0
- data/test/performance/config/targets/PACKET/cmd_tlm/packet_tlm.txt +5 -5
- data/test/performance/config/tools/handbook_creator/assets/css/bootstrap-theme.css +397 -0
- data/test/performance/config/tools/handbook_creator/assets/css/bootstrap-theme.min.css +7 -0
- data/test/performance/config/tools/handbook_creator/assets/css/bootstrap.css +7118 -0
- data/test/performance/config/tools/handbook_creator/assets/css/bootstrap.min.css +7 -0
- data/test/performance/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.eot +0 -0
- data/test/performance/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.svg +229 -0
- data/test/performance/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/test/performance/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.woff +0 -0
- data/test/performance/config/tools/handbook_creator/assets/img/ball_logo.bmp +0 -0
- data/test/performance/config/tools/handbook_creator/assets/img/ball_logo.gif +0 -0
- data/test/performance/config/tools/handbook_creator/assets/img/ball_logo.jpg +0 -0
- data/test/performance/config/tools/handbook_creator/assets/js/bootstrap.js +2006 -0
- data/test/performance/config/tools/handbook_creator/assets/js/bootstrap.min.js +7 -0
- data/test/performance/config/tools/handbook_creator/assets/js/html5shiv.js +8 -0
- data/test/performance/config/tools/handbook_creator/assets/js/jquery-1.10.2.min.js +6 -0
- data/test/performance/config/tools/handbook_creator/assets/js/respond.min.js +6 -0
- data/test/performance/config/tools/test_runner/test_runner.txt +1 -1
- data/test/performance/procedures/cosmos_api_test.rb +1 -1
- data/test/performance/tools/identify_performance.rb +82 -0
- metadata +154 -64
- data/lib/cosmos/dart/Gemfile +0 -69
@@ -42,6 +42,9 @@ module Cosmos
|
|
42
42
|
def paint(painter, option, index)
|
43
43
|
packet_item, _, _ = @widgets[index.row]
|
44
44
|
if index.column == 1 and packet_item and packet_item.states
|
45
|
+
painter.save
|
46
|
+
option = Qt::StyleOptionViewItemV4.new(option)
|
47
|
+
initStyleOption(option, index)
|
45
48
|
# This code simply draws the current combo box text inside a button to
|
46
49
|
# give the user an idea that they have to click it to activate it
|
47
50
|
opt = Qt::StyleOptionButton.new
|
@@ -49,6 +52,18 @@ module Cosmos
|
|
49
52
|
opt.text = @table.item(index.row, index.column).text.to_s
|
50
53
|
Qt::Application.style.drawControl(Qt::Style::CE_PushButton, opt, painter)
|
51
54
|
opt.dispose
|
55
|
+
painter.restore
|
56
|
+
# Not sure why but once we re-implement paint() the word wrapping
|
57
|
+
# doesn't work when we simply call super(painter, option, index)
|
58
|
+
# Thus we implement this to support word wrapping on the description
|
59
|
+
elsif index.column == 4
|
60
|
+
painter.save
|
61
|
+
option = Qt::StyleOptionViewItemV4.new(option)
|
62
|
+
initStyleOption(option, index)
|
63
|
+
option.text = index.data().toString()
|
64
|
+
option.features = Qt::StyleOptionViewItemV2::WrapText
|
65
|
+
self.parent().style().drawControl(Qt::Style.CE_ItemViewItem, option, painter)
|
66
|
+
painter.restore
|
52
67
|
else
|
53
68
|
super(painter, option, index)
|
54
69
|
end
|
@@ -0,0 +1,382 @@
|
|
1
|
+
# encoding: ascii-8bit
|
2
|
+
|
3
|
+
# Copyright 2014 Ball Aerospace & Technologies Corp.
|
4
|
+
# All Rights Reserved.
|
5
|
+
#
|
6
|
+
# This program is free software; you can modify and/or redistribute it
|
7
|
+
# under the terms of the GNU General Public License
|
8
|
+
# as published by the Free Software Foundation; version 3 with
|
9
|
+
# attribution addendums as found in the LICENSE.txt
|
10
|
+
|
11
|
+
require 'cosmos'
|
12
|
+
Cosmos.catch_fatal_exception do
|
13
|
+
require 'cosmos/tools/cmd_sender/cmd_param_table_item_delegate'
|
14
|
+
require 'cosmos/gui/dialogs/cmd_details_dialog'
|
15
|
+
end
|
16
|
+
|
17
|
+
module Cosmos
|
18
|
+
# Builds a command parameter widget for use in Command Sender and Command Sequence.
|
19
|
+
# The main method is update_cmd_params which builds all the widgets. It can take
|
20
|
+
# existing values for use in populating the command parameter widgets.
|
21
|
+
class CmdParams < Qt::Widget
|
22
|
+
# Class instance variables which apply to all command parameters
|
23
|
+
@states_in_hex = false
|
24
|
+
@show_ignored = false
|
25
|
+
class << self
|
26
|
+
attr_accessor :states_in_hex, :show_ignored
|
27
|
+
end
|
28
|
+
MANUALLY = CmdParamTableItemDelegate::MANUALLY
|
29
|
+
# Emit the modified signal to allow changes to propagate upwards
|
30
|
+
signals 'modified()'
|
31
|
+
|
32
|
+
def initialize
|
33
|
+
super()
|
34
|
+
@param_widgets = []
|
35
|
+
@table = nil
|
36
|
+
@packet = nil
|
37
|
+
@file_dir = System.paths['LOGS']
|
38
|
+
end
|
39
|
+
|
40
|
+
# Changes the display of items with states to hex if checked is true.
|
41
|
+
# Otherwise state values are displayed as decimal.
|
42
|
+
# @param checked [Boolean] Whether to display state values in hex
|
43
|
+
def states_in_hex(checked)
|
44
|
+
CmdParams.states_in_hex = checked
|
45
|
+
@param_widgets.each do |_, _, state_value_item|
|
46
|
+
next unless state_value_item
|
47
|
+
text = state_value_item.text
|
48
|
+
quotes_removed = text.remove_quotes
|
49
|
+
if text == quotes_removed
|
50
|
+
if checked
|
51
|
+
if text.is_int?
|
52
|
+
@table.blockSignals(true)
|
53
|
+
state_value_item.text = sprintf("0x%X", text.to_i)
|
54
|
+
@table.blockSignals(false)
|
55
|
+
end
|
56
|
+
else
|
57
|
+
if text.is_hex?
|
58
|
+
@table.blockSignals(true)
|
59
|
+
state_value_item.text = Integer(text).to_s
|
60
|
+
@table.blockSignals(false)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# @return [Hash] Hash keyed by parameter name with String formatted value
|
68
|
+
def params_text(raw = false)
|
69
|
+
params = {}
|
70
|
+
Qt.execute_in_main_thread do
|
71
|
+
@param_widgets.each do |packet_item, value_item, state_value_item|
|
72
|
+
text = value_item.text
|
73
|
+
text = state_value_item.text if state_value_item && (text == MANUALLY or raw)
|
74
|
+
quotes_removed = text.remove_quotes
|
75
|
+
if text == quotes_removed
|
76
|
+
if (packet_item.data_type == :STRING or packet_item.data_type == :BLOCK) and text.upcase.start_with?("0X")
|
77
|
+
params[packet_item.name] = text.hex_to_byte_string
|
78
|
+
else
|
79
|
+
params[packet_item.name] = text.convert_to_value
|
80
|
+
end
|
81
|
+
else
|
82
|
+
params[packet_item.name] = quotes_removed
|
83
|
+
end
|
84
|
+
Kernel.raise "#{packet_item.name} is required." if quotes_removed == '' && packet_item.required
|
85
|
+
end
|
86
|
+
end
|
87
|
+
params
|
88
|
+
end
|
89
|
+
|
90
|
+
# Primary method which builds the command parameter table. The passed in command packet
|
91
|
+
# is used to get all the command parameters to build. Existing parameters can be passed
|
92
|
+
# in to set the initial values for all command parameters. You can also specify whether
|
93
|
+
# to display the ignored parameters when building the command parameter table. Note that
|
94
|
+
# each time this method is called the TableWidget is disposed and rebuilt.
|
95
|
+
#
|
96
|
+
# @param packet [Packet] The command packet to build a parameter list for
|
97
|
+
# @param existing [Hash] Hash keyed by parameter name with text values.
|
98
|
+
# These values will be used as the defaults for all command parameters.
|
99
|
+
# @param show_ignored [Boolean] Whether to display the ignored
|
100
|
+
# parameters. Pass nil (the default) to keep the existing setting.
|
101
|
+
def update_cmd_params(packet, existing: nil, show_ignored: nil)
|
102
|
+
@packet = packet
|
103
|
+
old_params = {}
|
104
|
+
old_params = get_params(show_ignored) if !show_ignored.nil?
|
105
|
+
old_params = set_existing(packet, existing) if existing
|
106
|
+
|
107
|
+
# Determine which items to display
|
108
|
+
target = System.targets[packet.target_name]
|
109
|
+
packet_items = packet.sorted_items
|
110
|
+
shown_packet_items = []
|
111
|
+
packet_items.each do |packet_item|
|
112
|
+
next if target && target.ignored_parameters.include?(packet_item.name) && !CmdParams.show_ignored
|
113
|
+
shown_packet_items << packet_item
|
114
|
+
end
|
115
|
+
|
116
|
+
# Destroy the old table widget and parameters
|
117
|
+
@table.dispose if @table
|
118
|
+
@table = nil
|
119
|
+
@param_widgets = []
|
120
|
+
row = 0
|
121
|
+
shown_packet_items.each do |packet_item|
|
122
|
+
value_item = nil
|
123
|
+
state_value_item = nil
|
124
|
+
@table = create_table(shown_packet_items.length) unless @table
|
125
|
+
|
126
|
+
# Parameter Name
|
127
|
+
item = Qt::TableWidgetItem.new("#{packet_item.name}:")
|
128
|
+
item.setTextAlignment(Qt::AlignRight | Qt::AlignVCenter)
|
129
|
+
item.setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled)
|
130
|
+
@table.setItem(row, 0, item)
|
131
|
+
|
132
|
+
# Parameter Value
|
133
|
+
if packet_item.states
|
134
|
+
value_item, state_value_item = create_state_item(packet_item, old_params, row)
|
135
|
+
else
|
136
|
+
value_item = create_item(packet_item, old_params, row)
|
137
|
+
end
|
138
|
+
|
139
|
+
# Units
|
140
|
+
item = Qt::TableWidgetItem.new(packet_item.units.to_s)
|
141
|
+
item.setTextAlignment(Qt::AlignRight | Qt::AlignVCenter)
|
142
|
+
item.setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled)
|
143
|
+
@table.setItem(row, 3, item)
|
144
|
+
|
145
|
+
# Description
|
146
|
+
item = Qt::TableWidgetItem.new(packet_item.description.to_s)
|
147
|
+
item.setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter)
|
148
|
+
item.setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled)
|
149
|
+
@table.setItem(row, 4, item)
|
150
|
+
|
151
|
+
@param_widgets << [packet_item, value_item, state_value_item]
|
152
|
+
row += 1
|
153
|
+
end
|
154
|
+
|
155
|
+
connect_table_item_changed() if @table
|
156
|
+
@table
|
157
|
+
end
|
158
|
+
|
159
|
+
# If the user right clicks over a table item, this method displays a context
|
160
|
+
# menu with various options.
|
161
|
+
# @param point [Qt::Point] Point to display the context menu
|
162
|
+
def context_menu(point)
|
163
|
+
item = @table.itemAt(point)
|
164
|
+
if item
|
165
|
+
target_name = @packet.target_name
|
166
|
+
packet_name = @packet.packet_name
|
167
|
+
item_name = @table.item(item.row, 0).text[0..-2] # Remove :
|
168
|
+
if target_name.length > 0 && packet_name.length > 0 && item_name.length > 0
|
169
|
+
menu = Qt::Menu.new()
|
170
|
+
|
171
|
+
details_action = Qt::Action.new("Details #{target_name} #{packet_name} #{item_name}", self)
|
172
|
+
details_action.statusTip = "Popup details about #{target_name} #{packet_name} #{item_name}"
|
173
|
+
details_action.connect(SIGNAL('triggered()')) do
|
174
|
+
CmdDetailsDialog.new(nil, target_name, packet_name, item_name)
|
175
|
+
end
|
176
|
+
menu.addAction(details_action)
|
177
|
+
|
178
|
+
file_chooser_action = Qt::Action.new("Insert Filename", self)
|
179
|
+
file_chooser_action.statusTip = "Select a file and place its name into this parameter"
|
180
|
+
file_chooser_action.connect(SIGNAL('triggered()')) do
|
181
|
+
filename = Qt::FileDialog::getOpenFileName(self, "Insert Filename:", @file_dir, "All Files (*)")
|
182
|
+
if filename && !filename.empty?
|
183
|
+
@file_dir = File.dirname(filename)
|
184
|
+
_, value_item, state_value_item = @param_widgets[item.row]
|
185
|
+
if state_value_item
|
186
|
+
state_value_item.setText(filename)
|
187
|
+
elsif value_item
|
188
|
+
value_item.setText(filename)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
menu.addAction(file_chooser_action)
|
193
|
+
|
194
|
+
menu.exec(@table.mapToGlobal(point))
|
195
|
+
menu.dispose
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
private
|
201
|
+
|
202
|
+
def get_params(show_ignored)
|
203
|
+
params = {}
|
204
|
+
CmdParams.show_ignored = show_ignored
|
205
|
+
# Save parameter values
|
206
|
+
@param_widgets.each do |packet_item, value_item, state_value_item|
|
207
|
+
text = value_item.text
|
208
|
+
if state_value_item
|
209
|
+
params[packet_item.name] = [text, state_value_item.text]
|
210
|
+
else
|
211
|
+
params[packet_item.name] = text
|
212
|
+
end
|
213
|
+
end
|
214
|
+
params
|
215
|
+
end
|
216
|
+
|
217
|
+
def set_existing(packet, existing)
|
218
|
+
params = {}
|
219
|
+
existing.each do |param_name, param_value|
|
220
|
+
packet_item = packet.items[param_name]
|
221
|
+
if packet_item.states
|
222
|
+
state_value = packet_item.states[param_value]
|
223
|
+
unless state_value # If we couldn't lookup the value by the name it's manual
|
224
|
+
state_value = param_value
|
225
|
+
param_value = MANUALLY
|
226
|
+
end
|
227
|
+
params[param_name] = [param_value.to_s, state_value.to_s]
|
228
|
+
else
|
229
|
+
params[param_name] = param_value.to_s
|
230
|
+
end
|
231
|
+
end
|
232
|
+
params
|
233
|
+
end
|
234
|
+
|
235
|
+
def create_table(length)
|
236
|
+
table = Qt::TableWidget.new()
|
237
|
+
table.setSizePolicy(Qt::SizePolicy::Expanding, Qt::SizePolicy::Expanding)
|
238
|
+
table.setWordWrap(true)
|
239
|
+
table.setRowCount(length)
|
240
|
+
table.setColumnCount(5)
|
241
|
+
table.setHorizontalHeaderLabels(['Name', ' Value or State ', ' ', 'Units', 'Description'])
|
242
|
+
table.horizontalHeader.setStretchLastSection(true)
|
243
|
+
table.verticalHeader.setVisible(false)
|
244
|
+
table.setItemDelegate(CmdParamTableItemDelegate.new(table, @param_widgets, @production))
|
245
|
+
table.setContextMenuPolicy(Qt::CustomContextMenu)
|
246
|
+
table.verticalHeader.setResizeMode(Qt::HeaderView::ResizeToContents)
|
247
|
+
table.setEditTriggers(Qt::AbstractItemView::DoubleClicked | Qt::AbstractItemView::SelectedClicked | Qt::AbstractItemView::AnyKeyPressed)
|
248
|
+
table.setSelectionMode(Qt::AbstractItemView::NoSelection)
|
249
|
+
table.connect(SIGNAL('customContextMenuRequested(const QPoint&)')) {|point| context_menu(point) }
|
250
|
+
table.connect(SIGNAL('itemClicked(QTableWidgetItem*)')) do |item|
|
251
|
+
table.editItem(item) if (item.flags & Qt::ItemIsEditable) != 0
|
252
|
+
end
|
253
|
+
return table
|
254
|
+
end
|
255
|
+
|
256
|
+
def create_state_item(packet_item, old_params, row)
|
257
|
+
default_state = packet_item.states.key(packet_item.default)
|
258
|
+
if old_params[packet_item.name]
|
259
|
+
value_item = Qt::TableWidgetItem.new(old_params[packet_item.name][0])
|
260
|
+
else
|
261
|
+
if default_state
|
262
|
+
value_item = Qt::TableWidgetItem.new(default_state.to_s)
|
263
|
+
elsif @production
|
264
|
+
value_item = Qt::TableWidgetItem.new(packet_item.states.keys[0])
|
265
|
+
else
|
266
|
+
value_item = Qt::TableWidgetItem.new(MANUALLY)
|
267
|
+
end
|
268
|
+
end
|
269
|
+
value_item.setTextAlignment(Qt::AlignRight | Qt::AlignVCenter)
|
270
|
+
value_item.setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable)
|
271
|
+
@table.setItem(row, 1, value_item)
|
272
|
+
|
273
|
+
state_value = packet_item.default.to_s
|
274
|
+
if old_params[packet_item.name]
|
275
|
+
state_value = old_params[packet_item.name][1]
|
276
|
+
end
|
277
|
+
is_integer = Integer(state_value) rescue false
|
278
|
+
if CmdParams.states_in_hex && is_integer
|
279
|
+
state_value_item = Qt::TableWidgetItem.new(sprintf("0x%X", state_value))
|
280
|
+
else
|
281
|
+
if state_value.is_printable?
|
282
|
+
state_value_item = Qt::TableWidgetItem.new(state_value)
|
283
|
+
else
|
284
|
+
state_value_item = Qt::TableWidgetItem.new("0x" + state_value.simple_formatted)
|
285
|
+
end
|
286
|
+
end
|
287
|
+
state_value_item.setTextAlignment(Qt::AlignRight | Qt::AlignVCenter)
|
288
|
+
if @production
|
289
|
+
state_value_item.setFlags(Qt::NoItemFlags)
|
290
|
+
else
|
291
|
+
state_value_item.setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable)
|
292
|
+
end
|
293
|
+
@table.setItem(row, 2, state_value_item)
|
294
|
+
|
295
|
+
# If the parameter is required clear the combobox and
|
296
|
+
# clear the value field so they have to choose something
|
297
|
+
if packet_item.required && !old_params[packet_item.name]
|
298
|
+
value_item.setText('')
|
299
|
+
state_value_item.setText('')
|
300
|
+
end
|
301
|
+
return [value_item, state_value_item]
|
302
|
+
end
|
303
|
+
|
304
|
+
def create_item(packet_item, old_params, row)
|
305
|
+
if old_params[packet_item.name]
|
306
|
+
value_text = old_params[packet_item.name]
|
307
|
+
elsif packet_item.required
|
308
|
+
value_text = ''
|
309
|
+
else
|
310
|
+
if packet_item.format_string
|
311
|
+
begin
|
312
|
+
value_text = sprintf(packet_item.format_string, packet_item.default)
|
313
|
+
rescue
|
314
|
+
# Oh well - Don't use the format string
|
315
|
+
value_text = packet_item.default.to_s
|
316
|
+
end
|
317
|
+
else
|
318
|
+
value_text = packet_item.default.to_s
|
319
|
+
end
|
320
|
+
end
|
321
|
+
if !value_text.is_printable?
|
322
|
+
value_text = "0x" + value_text.simple_formatted
|
323
|
+
# Add quotes around STRING or BLOCK defaults so they are interpreted correctly
|
324
|
+
elsif (packet_item.data_type == :STRING or packet_item.data_type == :BLOCK)
|
325
|
+
value_text = "'#{value_text}'"
|
326
|
+
end
|
327
|
+
value_item = Qt::TableWidgetItem.new(value_text)
|
328
|
+
value_item.setTextAlignment(Qt::AlignRight | Qt::AlignVCenter)
|
329
|
+
value_item.setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable)
|
330
|
+
@table.setItem(row, 1, value_item)
|
331
|
+
@table.setSpan(row, 1, 1, 2)
|
332
|
+
return value_item
|
333
|
+
end
|
334
|
+
|
335
|
+
def connect_table_item_changed
|
336
|
+
@table.connect(SIGNAL('itemChanged(QTableWidgetItem*)')) do |item|
|
337
|
+
packet_item, value_item, state_value_item = @param_widgets[item.row]
|
338
|
+
if item.column == 1
|
339
|
+
if packet_item.states
|
340
|
+
value = packet_item.states[value_item.text]
|
341
|
+
if packet_item.hazardous && packet_item.hazardous.key?(value_item.text)
|
342
|
+
desc = packet_item.hazardous[value]
|
343
|
+
# Hazardous states aren't required to have a description so use the item description
|
344
|
+
desc = packet_item.description unless desc
|
345
|
+
@table.item(item.row, 4).setText("(Hazardous) #{desc}")
|
346
|
+
else
|
347
|
+
@table.item(item.row, 4).setText(packet_item.description)
|
348
|
+
end
|
349
|
+
@table.blockSignals(true)
|
350
|
+
if CmdParams.states_in_hex && value.kind_of?(Integer)
|
351
|
+
state_value_item.setText(sprintf("0x%X", value))
|
352
|
+
else
|
353
|
+
state_value_item.setText(value.to_s)
|
354
|
+
end
|
355
|
+
@table.blockSignals(false)
|
356
|
+
end
|
357
|
+
elsif item.column == 2
|
358
|
+
@table.blockSignals(true)
|
359
|
+
@table.item(item.row, 1).setText(MANUALLY)
|
360
|
+
@table.blockSignals(false)
|
361
|
+
end
|
362
|
+
calculate_height()
|
363
|
+
emit modified()
|
364
|
+
end
|
365
|
+
calculate_height()
|
366
|
+
end
|
367
|
+
|
368
|
+
def calculate_height
|
369
|
+
@table.resizeColumnsToContents()
|
370
|
+
@table.resizeRowsToContents()
|
371
|
+
height = @table.horizontalHeader.height + 2 # 2 = Header frame?
|
372
|
+
@table.rowCount.times do |i|
|
373
|
+
# TODO: rowHeight does not reflect word wrapping ... it's always 37
|
374
|
+
height += @table.rowHeight(i)
|
375
|
+
# NOTE: Checking the fontMetrics boundingRect also does not refect word wrapping
|
376
|
+
# e.g. Cosmos.getFontMetrics(@table.font).boundingRect(@table.item(x,y).text).height
|
377
|
+
end
|
378
|
+
@table.setMaximumHeight(height)
|
379
|
+
@table.setMinimumHeight(height)
|
380
|
+
end
|
381
|
+
end
|
382
|
+
end
|
@@ -10,16 +10,17 @@
|
|
10
10
|
|
11
11
|
require 'cosmos'
|
12
12
|
Cosmos.catch_fatal_exception do
|
13
|
-
require 'cosmos/script'
|
14
13
|
require 'cosmos/gui/qt_tool'
|
15
|
-
require 'cosmos/config/config_parser'
|
16
14
|
require 'cosmos/gui/text/completion'
|
17
15
|
require 'cosmos/gui/utilities/script_module_gui'
|
18
16
|
require 'cosmos/gui/dialogs/splash'
|
19
17
|
require 'cosmos/gui/dialogs/cmd_details_dialog'
|
18
|
+
require 'cosmos/gui/widgets/full_text_search_line_edit'
|
20
19
|
require 'cosmos/tools/cmd_sender/cmd_sender_text_edit'
|
20
|
+
require 'cosmos/tools/cmd_sender/cmd_params'
|
21
21
|
require 'cosmos/tools/cmd_sender/cmd_param_table_item_delegate'
|
22
|
-
require 'cosmos/
|
22
|
+
require 'cosmos/config/config_parser'
|
23
|
+
require 'cosmos/script'
|
23
24
|
end
|
24
25
|
|
25
26
|
module Cosmos
|
@@ -27,7 +28,7 @@ module Cosmos
|
|
27
28
|
module Script
|
28
29
|
def prompt_for_script_abort
|
29
30
|
window = get_cmd_tlm_gui_window()
|
30
|
-
window.statusBar.showMessage(
|
31
|
+
window.statusBar.showMessage("Hazardous command not sent")
|
31
32
|
return true # Aborted - Don't retry
|
32
33
|
end
|
33
34
|
end
|
@@ -41,15 +42,6 @@ module Cosmos
|
|
41
42
|
# command is sent it is added to the command history window which allows the
|
42
43
|
# user to resend the command or copy it for use in a script.
|
43
44
|
class CmdSender < QtTool
|
44
|
-
slots 'file_send_raw()'
|
45
|
-
slots 'update_cmd_params(bool)'
|
46
|
-
slots 'menu_states_in_hex(bool)'
|
47
|
-
slots 'target_changed(const QString&)'
|
48
|
-
slots 'cmd_changed(const QString&)'
|
49
|
-
slots 'send_button()'
|
50
|
-
slots 'context_menu(const QPoint&)'
|
51
|
-
slots 'click_callback(QTableWidgetItem*)'
|
52
|
-
|
53
45
|
MANUALLY = CmdParamTableItemDelegate::MANUALLY
|
54
46
|
|
55
47
|
# @return [Integer] Number of commands sent
|
@@ -62,20 +54,6 @@ module Cosmos
|
|
62
54
|
@@send_count = val
|
63
55
|
end
|
64
56
|
|
65
|
-
# @return [Array<PacketItem, Qt::TableWidgetItem, Qt::TableWidgetItem>]
|
66
|
-
# Array of the packet item, the table widget item representing the value,
|
67
|
-
# and the table widget item representing states if the packet item has
|
68
|
-
# states.
|
69
|
-
def self.param_widgets
|
70
|
-
@@param_widgets
|
71
|
-
end
|
72
|
-
|
73
|
-
# @return [Qt::TableWidget] Table holding the command parameters. Each
|
74
|
-
# parameter is a separate row in the table.
|
75
|
-
def self.table
|
76
|
-
@@table
|
77
|
-
end
|
78
|
-
|
79
57
|
# Create the application by building the GUI and loading an initial target
|
80
58
|
# and command packet. This can be passed on the command line or the first
|
81
59
|
# target and packet will be loaded.
|
@@ -85,13 +63,11 @@ module Cosmos
|
|
85
63
|
super(options)
|
86
64
|
Cosmos.load_cosmos_icon("cmd_sender.png")
|
87
65
|
|
88
|
-
@file_dir = System.paths['LOGS']
|
89
66
|
@message_log = MessageLog.new('cmdsender')
|
90
67
|
@production = options.production
|
91
68
|
@send_raw_dir = nil
|
92
69
|
@@send_count = 0
|
93
|
-
|
94
|
-
@@table = nil
|
70
|
+
@cmd_params = CmdParams.new
|
95
71
|
|
96
72
|
initialize_actions()
|
97
73
|
initialize_menus()
|
@@ -137,59 +113,63 @@ module Cosmos
|
|
137
113
|
super()
|
138
114
|
# File menu actions
|
139
115
|
@send_raw_action = Qt::Action.new(Cosmos.get_icon('send_file.png'),
|
140
|
-
|
116
|
+
'&Send Raw',
|
141
117
|
self)
|
142
|
-
@send_raw_action.shortcut = Qt::KeySequence.new(
|
118
|
+
@send_raw_action.shortcut = Qt::KeySequence.new('Ctrl+S')
|
143
119
|
tip = 'Send raw data from a file'
|
144
120
|
if @production
|
145
121
|
tip += ' - Disabled in Production Mode'
|
146
122
|
@send_raw_action.setEnabled(false)
|
147
123
|
end
|
148
|
-
@send_raw_action.statusTip =
|
149
|
-
connect(
|
124
|
+
@send_raw_action.statusTip = tip
|
125
|
+
@send_raw_action.connect(SIGNAL('triggered()')) { file_send_raw }
|
150
126
|
|
151
127
|
# Mode menu actions
|
152
|
-
@ignore_range = Qt::Action.new(
|
128
|
+
@ignore_range = Qt::Action.new('&Ignore Range Checks', self)
|
153
129
|
tip = 'Ignore range checks when processing command'
|
154
130
|
if @production
|
155
131
|
tip += ' - Disabled in Production Mode'
|
156
132
|
@ignore_range.setEnabled(false)
|
157
133
|
end
|
158
|
-
@ignore_range.statusTip =
|
134
|
+
@ignore_range.statusTip = tip
|
159
135
|
@ignore_range.setCheckable(true)
|
160
136
|
@ignore_range.setChecked(false)
|
161
137
|
|
162
|
-
@states_in_hex = Qt::Action.new(
|
163
|
-
@states_in_hex.statusTip =
|
138
|
+
@states_in_hex = Qt::Action.new('&Display State Values in Hex', self)
|
139
|
+
@states_in_hex.statusTip = 'Display states values in hex instead of decimal'
|
164
140
|
@states_in_hex.setCheckable(true)
|
165
|
-
@states_in_hex.setChecked(
|
166
|
-
connect(
|
141
|
+
@states_in_hex.setChecked(CmdParams.states_in_hex)
|
142
|
+
@states_in_hex.connect(SIGNAL('toggled(bool)')) do |checked|
|
143
|
+
@cmd_params.states_in_hex(checked)
|
144
|
+
end
|
167
145
|
|
168
|
-
@show_ignored = Qt::Action.new(
|
169
|
-
@show_ignored.statusTip =
|
146
|
+
@show_ignored = Qt::Action.new('&Show Ignored Parameters', self)
|
147
|
+
@show_ignored.statusTip = 'Show ignored parameters which are normally hidden'
|
170
148
|
@show_ignored.setCheckable(true)
|
171
|
-
@show_ignored.setChecked(
|
172
|
-
connect(
|
149
|
+
@show_ignored.setChecked(CmdParams.show_ignored)
|
150
|
+
@show_ignored.connect(SIGNAL('toggled(bool)')) do |checked|
|
151
|
+
update_cmd_params(checked)
|
152
|
+
end
|
173
153
|
|
174
|
-
@cmd_raw = Qt::Action.new(
|
154
|
+
@cmd_raw = Qt::Action.new('Disable &Parameter Conversions', self)
|
175
155
|
tip = 'Send the command without running write or state conversions'
|
176
156
|
if @production
|
177
157
|
tip += ' - Disabled in Production Mode'
|
178
158
|
@cmd_raw.setEnabled(false)
|
179
159
|
end
|
180
|
-
@cmd_raw.statusTip =
|
160
|
+
@cmd_raw.statusTip = tip
|
181
161
|
@cmd_raw.setCheckable(true)
|
182
162
|
@cmd_raw.setChecked(false)
|
183
163
|
end
|
184
164
|
|
185
165
|
# Create the File and Mode menus and initialize the help menu
|
186
166
|
def initialize_menus
|
187
|
-
file_menu = menuBar.addMenu(
|
167
|
+
file_menu = menuBar.addMenu('&File')
|
188
168
|
file_menu.addAction(@send_raw_action)
|
189
169
|
file_menu.addAction(@exit_action)
|
190
170
|
file_menu.insertSeparator(@exit_action)
|
191
171
|
|
192
|
-
mode_menu = menuBar.addMenu(
|
172
|
+
mode_menu = menuBar.addMenu('&Mode')
|
193
173
|
mode_menu.addAction(@ignore_range)
|
194
174
|
mode_menu.addAction(@states_in_hex)
|
195
175
|
mode_menu.addAction(@show_ignored)
|
@@ -243,20 +223,23 @@ module Cosmos
|
|
243
223
|
# Set the target combobox selection
|
244
224
|
@target_select = Qt::ComboBox.new
|
245
225
|
@target_select.setMaxVisibleItems(6)
|
246
|
-
connect(
|
247
|
-
|
226
|
+
@target_select.connect(SIGNAL('activated(const QString&)')) do |target|
|
227
|
+
update_commands()
|
228
|
+
update_cmd_params()
|
229
|
+
end
|
230
|
+
target_label = Qt::Label.new("&Target:")
|
248
231
|
target_label.setBuddy(@target_select)
|
249
232
|
|
250
233
|
# Set the comamnd combobox selection
|
251
234
|
@cmd_select = Qt::ComboBox.new
|
252
235
|
@cmd_select.setMaxVisibleItems(20)
|
253
|
-
connect(
|
254
|
-
cmd_label = Qt::Label.new(
|
236
|
+
@cmd_select.connect(SIGNAL('activated(const QString&)')) {|command| update_cmd_params }
|
237
|
+
cmd_label = Qt::Label.new("&Command:")
|
255
238
|
cmd_label.setBuddy(@cmd_select)
|
256
239
|
|
257
240
|
# Button to send command
|
258
241
|
send = Qt::PushButton.new("Send")
|
259
|
-
connect(
|
242
|
+
send.connect(SIGNAL('clicked()')) { send_button }
|
260
243
|
|
261
244
|
# Layout the top level selection
|
262
245
|
select_layout = Qt::HBoxLayout.new
|
@@ -273,7 +256,7 @@ module Cosmos
|
|
273
256
|
top_layout.addWidget(sep1)
|
274
257
|
|
275
258
|
# Command Description Label
|
276
|
-
dec_label = Qt::Label.new(
|
259
|
+
dec_label = Qt::Label.new("Description:")
|
277
260
|
@description = Qt::Label.new('')
|
278
261
|
@description.setWordWrap(true)
|
279
262
|
desc_layout = Qt::HBoxLayout.new
|
@@ -287,7 +270,7 @@ module Cosmos
|
|
287
270
|
top_layout.addWidget(sep2)
|
288
271
|
|
289
272
|
# Parameters Label
|
290
|
-
param_label = Qt::Label.new(
|
273
|
+
param_label = Qt::Label.new("Parameters:")
|
291
274
|
top_layout.addWidget(param_label)
|
292
275
|
|
293
276
|
# Grid Layout for Parameters
|
@@ -326,32 +309,6 @@ module Cosmos
|
|
326
309
|
history
|
327
310
|
end
|
328
311
|
|
329
|
-
# Changes the display of items with states to hex if checked is true.
|
330
|
-
# Otherwise state values are displayed as decimal.
|
331
|
-
# @param checked [Boolean] Whether to display state values in hex
|
332
|
-
def menu_states_in_hex(checked)
|
333
|
-
@@param_widgets.each do |_, _, state_value_item|
|
334
|
-
next unless state_value_item
|
335
|
-
text = state_value_item.text
|
336
|
-
quotes_removed = text.remove_quotes
|
337
|
-
if text == quotes_removed
|
338
|
-
if checked
|
339
|
-
if text.is_int?
|
340
|
-
@@table.blockSignals(true)
|
341
|
-
state_value_item.text = sprintf("0x%X", text.to_i)
|
342
|
-
@@table.blockSignals(false)
|
343
|
-
end
|
344
|
-
else
|
345
|
-
if text.is_hex?
|
346
|
-
@@table.blockSignals(true)
|
347
|
-
state_value_item.text = Integer(text).to_s
|
348
|
-
@@table.blockSignals(false)
|
349
|
-
end
|
350
|
-
end
|
351
|
-
end
|
352
|
-
end
|
353
|
-
end
|
354
|
-
|
355
312
|
# Opens a dialog which allows the user to select a file to read and send
|
356
313
|
# directly over the interface.
|
357
314
|
def file_send_raw
|
@@ -362,13 +319,13 @@ module Cosmos
|
|
362
319
|
interfaces.addItems(get_interface_names())
|
363
320
|
interfaces.setMaxVisibleItems(30)
|
364
321
|
layout.addWidget(interfaces, 0, 1)
|
365
|
-
int_label = Qt::Label.new(
|
322
|
+
int_label = Qt::Label.new("&Interface:")
|
366
323
|
int_label.setBuddy(interfaces)
|
367
324
|
layout.addWidget(int_label, 0, 0)
|
368
325
|
|
369
326
|
file_line = Qt::LineEdit.new(@send_raw_dir)
|
370
327
|
file_line.setMinimumSize(250, 0)
|
371
|
-
file_label = Qt::Label.new(
|
328
|
+
file_label = Qt::Label.new("&Filename:")
|
372
329
|
file_label.setBuddy(file_line)
|
373
330
|
get_file = Qt::PushButton.new("Select")
|
374
331
|
file_layout = Qt::BoxLayout.new(Qt::Horizontal)
|
@@ -376,7 +333,7 @@ module Cosmos
|
|
376
333
|
file_layout.addWidget(file_line)
|
377
334
|
get_file.connect(SIGNAL('clicked()')) do
|
378
335
|
Cosmos.set_working_dir do
|
379
|
-
file_line.text = Qt::FileDialog::getOpenFileName(self, "Select File", @send_raw_dir,
|
336
|
+
file_line.text = Qt::FileDialog::getOpenFileName(self, "Select File", @send_raw_dir, "Binary Files (*.bin);;All Files (*)")
|
380
337
|
end
|
381
338
|
end
|
382
339
|
|
@@ -417,17 +374,6 @@ module Cosmos
|
|
417
374
|
super(event)
|
418
375
|
end
|
419
376
|
|
420
|
-
# Updates the commands combobox and command parameters table
|
421
|
-
def target_changed(_)
|
422
|
-
update_commands()
|
423
|
-
update_cmd_params()
|
424
|
-
end
|
425
|
-
|
426
|
-
# Updates the command parameters table
|
427
|
-
def cmd_changed(_)
|
428
|
-
update_cmd_params()
|
429
|
-
end
|
430
|
-
|
431
377
|
# Sends the current command and parameters to the target
|
432
378
|
def send_button
|
433
379
|
target_name = @target_select.text
|
@@ -470,26 +416,8 @@ module Cosmos
|
|
470
416
|
|
471
417
|
# @return [String, Hash] Command as it would appear in a ScriptRunner script
|
472
418
|
def view_as_script
|
473
|
-
params = {}
|
474
|
-
|
475
|
-
@@param_widgets.each do |packet_item, value_item, state_value_item|
|
476
|
-
text = value_item.text
|
477
|
-
|
478
|
-
text = state_value_item.text if state_value_item && (text == MANUALLY or @cmd_raw.checked?)
|
479
|
-
quotes_removed = text.remove_quotes
|
480
|
-
if text == quotes_removed
|
481
|
-
if (packet_item.data_type == :STRING or packet_item.data_type == :BLOCK) and text.upcase.start_with?("0X")
|
482
|
-
params[packet_item.name] = text.hex_to_byte_string
|
483
|
-
else
|
484
|
-
params[packet_item.name] = text.convert_to_value
|
485
|
-
end
|
486
|
-
else
|
487
|
-
params[packet_item.name] = quotes_removed
|
488
|
-
end
|
489
|
-
raise "#{packet_item.name} is required." if quotes_removed == '' && packet_item.required
|
490
|
-
end
|
491
419
|
statusBar.clearMessage()
|
492
|
-
|
420
|
+
params = @cmd_params.params_text(@cmd_raw.checked?)
|
493
421
|
output_string = System.commands.build_cmd_output_string(@target_select.text, @cmd_select.text, params, @cmd_raw.checked?)
|
494
422
|
if output_string =~ /[\x00-\x08\x0B-\x0C\x0E-\x1F\x7F-\xFF]/
|
495
423
|
output_string = output_string.inspect.remove_quotes
|
@@ -552,243 +480,29 @@ module Cosmos
|
|
552
480
|
|
553
481
|
# Updates the command parameters table based on the selected target and
|
554
482
|
# packet comboboxes
|
555
|
-
# @param
|
556
|
-
#
|
557
|
-
def update_cmd_params(
|
558
|
-
old_params = {}
|
559
|
-
if !ignored_toggle.nil?
|
560
|
-
# Save parameter values
|
561
|
-
@@param_widgets.each do |packet_item, value_item, state_value_item|
|
562
|
-
text = value_item.text
|
563
|
-
if state_value_item
|
564
|
-
old_params[packet_item.name] = [text, state_value_item.text]
|
565
|
-
else
|
566
|
-
old_params[packet_item.name] = text
|
567
|
-
end
|
568
|
-
end
|
569
|
-
end
|
570
|
-
|
483
|
+
# @param checked [Boolean] Whether the show ignored parameters option
|
484
|
+
# is checked. Pass nil (the default) to keep the existing setting.
|
485
|
+
def update_cmd_params(checked = nil)
|
571
486
|
# Clear Status Bar
|
572
|
-
statusBar.showMessage(
|
487
|
+
statusBar.showMessage("")
|
573
488
|
|
574
489
|
target_name = @target_select.text
|
575
490
|
target = System.targets[target_name]
|
576
491
|
packet_name = @cmd_select.text
|
577
492
|
if target_name && packet_name
|
578
493
|
packet = System.commands.packet(target_name, packet_name)
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
# Update Command Description
|
587
|
-
@description.text = packet.description.to_s
|
588
|
-
|
589
|
-
# Destroy the old table widget
|
590
|
-
@@table.dispose if @@table
|
591
|
-
@@table = nil
|
592
|
-
|
593
|
-
# Update Parameters
|
594
|
-
@@param_widgets = []
|
595
|
-
drawn_header = false
|
596
|
-
|
597
|
-
row = 0
|
598
|
-
shown_packet_items.each do |packet_item|
|
599
|
-
next if target && target.ignored_parameters.include?(packet_item.name) && !@show_ignored.checked?
|
600
|
-
value_item = nil
|
601
|
-
state_value_item = nil
|
602
|
-
|
603
|
-
unless drawn_header
|
604
|
-
@@table = Qt::TableWidget.new()
|
605
|
-
@@table.setSizePolicy(Qt::SizePolicy::Expanding, Qt::SizePolicy::Expanding)
|
606
|
-
@@table.setWordWrap(true)
|
607
|
-
@@table.setRowCount(shown_packet_items.length)
|
608
|
-
@@table.setColumnCount(5)
|
609
|
-
@@table.setHorizontalHeaderLabels(['Name', ' Value or State ', ' ', 'Units', 'Description'])
|
610
|
-
@@table.horizontalHeader.setStretchLastSection(true)
|
611
|
-
@@table.verticalHeader.setVisible(false)
|
612
|
-
@@table.setItemDelegate(CmdParamTableItemDelegate.new(@@table, @@param_widgets, @production))
|
613
|
-
@@table.setContextMenuPolicy(Qt::CustomContextMenu)
|
614
|
-
@@table.verticalHeader.setResizeMode(Qt::HeaderView::ResizeToContents)
|
615
|
-
@@table.setEditTriggers(Qt::AbstractItemView::DoubleClicked | Qt::AbstractItemView::SelectedClicked | Qt::AbstractItemView::AnyKeyPressed)
|
616
|
-
@@table.setSelectionMode(Qt::AbstractItemView::NoSelection)
|
617
|
-
connect(@@table, SIGNAL('customContextMenuRequested(const QPoint&)'), self, SLOT('context_menu(const QPoint&)'))
|
618
|
-
connect(@@table, SIGNAL('itemClicked(QTableWidgetItem*)'), self, SLOT('click_callback(QTableWidgetItem*)'))
|
619
|
-
drawn_header = true
|
620
|
-
end
|
621
|
-
|
622
|
-
# Parameter Name
|
623
|
-
item = Qt::TableWidgetItem.new("#{packet_item.name}:")
|
624
|
-
item.setTextAlignment(Qt::AlignRight | Qt::AlignVCenter)
|
625
|
-
item.setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled)
|
626
|
-
@@table.setItem(row, 0, item)
|
627
|
-
|
628
|
-
if packet_item.states
|
629
|
-
default_state = packet_item.states.key(packet_item.default)
|
630
|
-
if old_params[packet_item.name]
|
631
|
-
value_item = Qt::TableWidgetItem.new(old_params[packet_item.name][0])
|
632
|
-
else
|
633
|
-
if default_state
|
634
|
-
value_item = Qt::TableWidgetItem.new(default_state.to_s)
|
635
|
-
elsif @production
|
636
|
-
value_item = Qt::TableWidgetItem.new(packet_item.states.keys[0])
|
637
|
-
else
|
638
|
-
value_item = Qt::TableWidgetItem.new(MANUALLY)
|
639
|
-
end
|
640
|
-
end
|
641
|
-
value_item.setTextAlignment(Qt::AlignRight | Qt::AlignVCenter)
|
642
|
-
value_item.setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable)
|
643
|
-
@@table.setItem(row, 1, value_item)
|
644
|
-
|
645
|
-
if old_params[packet_item.name]
|
646
|
-
state_value_item = Qt::TableWidgetItem.new(old_params[packet_item.name][1])
|
647
|
-
else
|
648
|
-
if @states_in_hex.checked? && packet_item.default.kind_of?(Integer)
|
649
|
-
state_value_item = Qt::TableWidgetItem.new(sprintf("0x%X", packet_item.default))
|
650
|
-
else
|
651
|
-
default_str = packet_item.default.to_s
|
652
|
-
if default_str.is_printable?
|
653
|
-
state_value_item = Qt::TableWidgetItem.new(default_str)
|
654
|
-
else
|
655
|
-
state_value_item = Qt::TableWidgetItem.new("0x" + default_str.simple_formatted)
|
656
|
-
end
|
657
|
-
end
|
658
|
-
end
|
659
|
-
state_value_item.setTextAlignment(Qt::AlignRight | Qt::AlignVCenter)
|
660
|
-
if @production
|
661
|
-
state_value_item.setFlags(Qt::NoItemFlags)
|
662
|
-
else
|
663
|
-
state_value_item.setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable)
|
664
|
-
end
|
665
|
-
@@table.setItem(row, 2, state_value_item)
|
666
|
-
|
667
|
-
# If the parameter is required clear the combobox and
|
668
|
-
# clear the value field so they have to choose something
|
669
|
-
if packet_item.required && !old_params[packet_item.name]
|
670
|
-
value_item.setText('')
|
671
|
-
state_value_item.setText('')
|
672
|
-
end
|
673
|
-
else
|
674
|
-
# Parameter Value
|
675
|
-
if old_params[packet_item.name]
|
676
|
-
value_item = Qt::TableWidgetItem.new(old_params[packet_item.name])
|
677
|
-
else
|
678
|
-
if packet_item.required
|
679
|
-
value_text = ''
|
680
|
-
else
|
681
|
-
if packet_item.format_string
|
682
|
-
begin
|
683
|
-
value_text = sprintf(packet_item.format_string, packet_item.default)
|
684
|
-
rescue
|
685
|
-
# Oh well - Don't use the format string
|
686
|
-
value_text = packet_item.default.to_s
|
687
|
-
end
|
688
|
-
else
|
689
|
-
value_text = packet_item.default.to_s
|
690
|
-
end
|
691
|
-
if !value_text.is_printable?
|
692
|
-
value_text = "0x" + value_text.simple_formatted
|
693
|
-
end
|
694
|
-
end
|
695
|
-
value_item = Qt::TableWidgetItem.new(value_text)
|
696
|
-
end
|
697
|
-
value_item.setTextAlignment(Qt::AlignRight | Qt::AlignVCenter)
|
698
|
-
value_item.setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable)
|
699
|
-
@@table.setItem(row, 1, value_item)
|
700
|
-
@@table.setSpan(row, 1, 1, 2)
|
701
|
-
end
|
702
|
-
|
703
|
-
# Units
|
704
|
-
item = Qt::TableWidgetItem.new(packet_item.units.to_s)
|
705
|
-
item.setTextAlignment(Qt::AlignRight | Qt::AlignVCenter)
|
706
|
-
item.setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled)
|
707
|
-
@@table.setItem(row, 3, item)
|
708
|
-
|
709
|
-
# Description
|
710
|
-
item = Qt::TableWidgetItem.new(packet_item.description.to_s)
|
711
|
-
item.setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter)
|
712
|
-
item.setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled)
|
713
|
-
@@table.setItem(row, 4, item)
|
714
|
-
|
715
|
-
@@param_widgets << [packet_item, value_item, state_value_item]
|
716
|
-
row += 1
|
717
|
-
end
|
718
|
-
|
719
|
-
if @@table
|
720
|
-
@@table.connect(SIGNAL('itemChanged(QTableWidgetItem*)')) do |item|
|
721
|
-
packet_item, value_item, state_value_item = @@param_widgets[item.row]
|
722
|
-
if item.column == 1
|
723
|
-
if packet_item.states
|
724
|
-
value = packet_item.states[value_item.text]
|
725
|
-
@@table.blockSignals(true)
|
726
|
-
if @states_in_hex.checked? && value.kind_of?(Integer)
|
727
|
-
state_value_item.setText(sprintf("0x%X", value))
|
728
|
-
else
|
729
|
-
state_value_item.setText(value.to_s)
|
730
|
-
end
|
731
|
-
@@table.blockSignals(false)
|
732
|
-
end
|
733
|
-
elsif item.column == 2
|
734
|
-
@@table.blockSignals(true)
|
735
|
-
@@table.item(item.row, 1).setText(MANUALLY)
|
736
|
-
@@table.blockSignals(false)
|
737
|
-
end
|
738
|
-
end
|
739
|
-
@table_layout.addWidget(@@table, 500)
|
740
|
-
@@table.resizeColumnsToContents()
|
741
|
-
@@table.resizeRowsToContents()
|
742
|
-
end
|
743
|
-
end # if target_name && packet_name
|
744
|
-
end
|
745
|
-
|
746
|
-
# If the user right clicks over a table item, this method displays a context
|
747
|
-
# menu with various options.
|
748
|
-
# @param point [Qt::Point] Point to display the context menu
|
749
|
-
def context_menu(point)
|
750
|
-
target_name = @target_select.text
|
751
|
-
packet_name = @cmd_select.text
|
752
|
-
item = @@table.itemAt(point)
|
753
|
-
if item
|
754
|
-
item_name = @@table.item(item.row, 0).text[0..-2] # Remove :
|
755
|
-
if target_name.length > 0 && packet_name.length > 0 && item_name.length > 0
|
756
|
-
menu = Qt::Menu.new()
|
757
|
-
|
758
|
-
details_action = Qt::Action.new(tr("Details #{target_name} #{packet_name} #{item_name}"), self)
|
759
|
-
details_action.statusTip = tr("Popup details about #{target_name} #{packet_name} #{item_name}")
|
760
|
-
details_action.connect(SIGNAL('triggered()')) do
|
761
|
-
CmdDetailsDialog.new(nil, target_name, packet_name, item_name)
|
762
|
-
end
|
763
|
-
menu.addAction(details_action)
|
764
|
-
|
765
|
-
file_chooser_action = Qt::Action.new(tr("Insert Filename"), self)
|
766
|
-
file_chooser_action.statusTip = tr("Select a file and place its name into this parameter")
|
767
|
-
file_chooser_action.connect(SIGNAL('triggered()')) do
|
768
|
-
filename = Qt::FileDialog::getOpenFileName(self, "Insert Filename:", @file_dir, "All Files (*)")
|
769
|
-
if filename && !filename.empty?
|
770
|
-
@file_dir = File.dirname(filename)
|
771
|
-
_, value_item, state_value_item = @@param_widgets[item.row]
|
772
|
-
if state_value_item
|
773
|
-
state_value_item.setText(filename)
|
774
|
-
elsif value_item
|
775
|
-
value_item.setText(filename)
|
776
|
-
end
|
777
|
-
end
|
778
|
-
end
|
779
|
-
menu.addAction(file_chooser_action)
|
780
|
-
|
781
|
-
menu.exec(@@table.mapToGlobal(point))
|
782
|
-
menu.dispose
|
494
|
+
# Directly update packet description ... safe because always in GUI thread
|
495
|
+
hazardous, _ = System.commands.cmd_hazardous?(target_name, packet_name)
|
496
|
+
if hazardous
|
497
|
+
@description.text = "(Hazardous) #{packet.description}"
|
498
|
+
else
|
499
|
+
@description.text = packet.description
|
783
500
|
end
|
501
|
+
table = @cmd_params.update_cmd_params(packet, show_ignored: checked)
|
502
|
+
@table_layout.addWidget(table, 500) if table
|
784
503
|
end
|
785
504
|
end
|
786
505
|
|
787
|
-
# @param item [Qt::TableWidgetItem] Item which was left clicked
|
788
|
-
def click_callback(item)
|
789
|
-
@@table.editItem(item) if (item.flags & Qt::ItemIsEditable) != 0
|
790
|
-
end
|
791
|
-
|
792
506
|
# (see QtTool.run)
|
793
507
|
def self.run(option_parser = nil, options = nil)
|
794
508
|
Cosmos.catch_fatal_exception do
|