cosmos 3.9.2 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +23 -0
- data/.travis.yml +1 -0
- data/.yardopts +3 -0
- data/Gemfile +1 -1
- data/Manifest.txt +137 -52
- data/Rakefile +50 -44
- data/autohotkey/config/system/system.txt +0 -5
- data/autohotkey/config/targets/INST/cmd_tlm/inst_cmds.txt +6 -1
- data/autohotkey/config/targets/INST/screens/extra.txt +19 -0
- data/autohotkey/config/targets/INST/sequences/run_sequence.txt +1 -0
- data/autohotkey/config/targets/META/screens/data.txt +12 -0
- data/autohotkey/config/targets/SYSTEM/cmd_tlm/meta_cmd_tlm.txt +16 -0
- data/autohotkey/config/targets/{COSMOS/cmd_tlm/cosmos_server_cmds.txt → SYSTEM/cmd_tlm/system_cmds.txt} +8 -8
- data/autohotkey/config/targets/SYSTEM/cmd_tlm/system_tlm.txt +7 -0
- data/autohotkey/config/targets/SYSTEM/screens/limits_change.txt +14 -0
- data/autohotkey/config/targets/SYSTEM/screens/meta.txt +14 -0
- data/autohotkey/config/targets/SYSTEM/target.txt +12 -0
- data/autohotkey/config/tools/cmd_tlm_server/cmd_tlm_server.txt +2 -2
- data/autohotkey/config/tools/test_runner/test_runner2.txt +1 -1
- data/autohotkey/tools/CmdSequence +14 -0
- data/autohotkey/tools/CmdSequenceAHK +23 -0
- data/autohotkey/tools/CmdSequenceAHK2 +16 -0
- data/autohotkey/tools/cmd_extractor.ahk +2 -2
- data/autohotkey/tools/cmd_sender.ahk +4 -6
- data/autohotkey/tools/cmd_sequence.ahk +215 -0
- data/autohotkey/tools/cmd_sequence2.ahk +23 -0
- data/autohotkey/tools/data_viewer.ahk +2 -3
- data/autohotkey/tools/limits_monitor.ahk +9 -11
- data/autohotkey/tools/open_gl_builder.ahk +1 -2
- data/autohotkey/tools/packet_viewer.ahk +51 -35
- data/autohotkey/tools/replay.ahk +1 -2
- data/autohotkey/tools/script_runner.ahk +1 -2
- data/autohotkey/tools/script_runner2.ahk +1 -2
- data/autohotkey/tools/test_runner2.ahk +1 -5
- data/autohotkey/tools/test_runner3.ahk +1 -3
- data/autohotkey/tools/tlm_grapher.ahk +1 -3
- data/autohotkey/tools/tlm_grapher3.ahk +1 -2
- data/autohotkey/tools/tlm_viewer.ahk +8 -3
- data/autohotkey/tools/tlm_viewer2.ahk +2 -3
- data/autohotkey/tools/tlm_viewer5.ahk +1 -2
- data/cosmos.gemspec +26 -20
- data/data/cmd_sequence.png +0 -0
- data/data/config/_array_params.yaml +23 -0
- data/data/config/_id_items.yaml +24 -0
- data/data/config/_id_params.yaml +58 -0
- data/data/config/_interfaces.yaml +206 -0
- data/data/config/_items.yaml +20 -0
- data/data/config/_params.yaml +58 -0
- data/data/config/cmd_tlm_server.yaml +110 -0
- data/data/config/command.yaml +38 -0
- data/data/config/command_modifiers.yaml +127 -0
- data/data/config/command_telemetry.yaml +3 -0
- data/data/config/data_viewer.yaml +43 -0
- data/data/config/handbook_creator.yaml +23 -0
- data/data/config/housekeeping_params.yaml +71 -0
- data/data/config/interface_modifiers.yaml +44 -0
- data/data/config/item_modifiers.yaml +172 -0
- data/data/config/launcher.yaml +117 -0
- data/data/config/limits_monitor.yaml +53 -0
- data/data/config/linegraph_params.yaml +30 -0
- data/data/config/linegraph_plot.yaml +106 -0
- data/data/config/page_modifiers.yaml +128 -0
- data/data/config/param_item_modifiers.yaml +41 -0
- data/data/config/parameter_modifiers.yaml +144 -0
- data/data/config/protocols.yaml +257 -0
- data/data/config/screen.yaml +151 -0
- data/data/config/script_runner.yaml +15 -0
- data/data/config/system.yaml +153 -0
- data/data/config/table_manager.yaml +76 -0
- data/data/config/table_parameter_modifiers.yaml +9 -0
- data/data/config/target.yaml +71 -0
- data/data/config/telemetry.yaml +73 -0
- data/data/config/telemetry_modifiers.yaml +129 -0
- data/data/config/test_runner.yaml +118 -0
- data/data/config/tlm_extractor.yaml +109 -0
- data/data/config/tlm_grapher.yaml +78 -0
- data/data/config/tlm_viewer.yaml +107 -0
- data/data/config/unknown.yaml +3 -0
- data/data/config/widgets.yaml +1339 -0
- data/data/config/xy_params.yaml +50 -0
- data/data/config/xy_plot.yaml +12 -0
- data/data/config_editor.png +0 -0
- data/data/crc.txt +172 -161
- data/data/delete.png +0 -0
- data/demo/config/data/crc.txt +56 -36
- data/demo/config/data/meta_init.txt +1 -4
- data/demo/config/system/system.txt +15 -3
- data/demo/config/system/system2.txt +13 -3
- data/demo/config/targets/EXAMPLE/lib/example_interface.rb +2 -6
- data/demo/config/targets/EXAMPLE/target.txt +3 -1
- data/demo/config/targets/INST/cmd_tlm/inst_cmds.txt +1 -0
- data/demo/config/targets/INST/lib/inst_dump_component.rb +34 -0
- data/demo/config/targets/INST/screens/adcs.txt +39 -15
- data/demo/config/targets/INST/screens/commanding.txt +26 -19
- data/demo/config/targets/INST/screens/spacing_box.txt +44 -0
- data/demo/config/targets/INST/screens/spacing_grid.txt +78 -0
- data/demo/config/targets/INST/screens/tabs.txt +0 -2
- data/demo/config/targets/INST/sequences/sequence.tsv +3 -0
- data/demo/config/targets/INST/tables/EventAction.csv +9 -0
- data/demo/config/targets/INST/tables/EventAction.dat +0 -0
- data/demo/config/targets/INST/tables/McConfigTable.csv +20 -0
- data/demo/config/targets/INST/tables/McConfigTable.dat +0 -0
- data/demo/config/targets/INST/target.txt +4 -0
- data/demo/config/targets/INST/tools/data_viewer/data_viewer.txt +2 -0
- data/demo/config/targets/INST/tools/data_viewer/data_viewer2.txt +2 -0
- data/demo/config/targets/INST/tools/table_manager/EventAction_def.txt +6 -0
- data/demo/config/targets/INST/tools/table_manager/McConfigTable_def.txt +38 -0
- data/demo/config/targets/SYSTEM/cmd_tlm/limits_groups.txt +7 -3
- data/demo/config/targets/SYSTEM/cmd_tlm/meta_cmd_tlm.txt +16 -0
- data/demo/config/targets/{COSMOS/cmd_tlm/cosmos_server_cmds.txt → SYSTEM/cmd_tlm/system_cmds.txt} +8 -8
- data/demo/config/targets/SYSTEM/cmd_tlm/system_tlm.txt +7 -0
- data/demo/config/targets/{COSMOS → SYSTEM}/cmd_tlm_server.txt +2 -2
- data/demo/config/targets/SYSTEM/lib/limits_groups.rb +39 -0
- data/demo/config/targets/SYSTEM/screens/status.txt +1 -1
- data/demo/config/targets/SYSTEM/target.txt +12 -0
- data/demo/config/targets/TEMPLATED/cmd_tlm_server.txt +1 -1
- data/demo/config/targets/TEMPLATED/lib/templated_interface.rb +8 -5
- data/demo/config/targets/TEMPLATED/target.txt +2 -0
- data/demo/config/tools/cmd_tlm_server/cmd_tlm_server.txt +15 -6
- data/demo/config/tools/cmd_tlm_server/cmd_tlm_server2.txt +13 -5
- data/demo/config/tools/data_viewer/data_viewer.txt +9 -0
- data/demo/config/tools/launcher/launcher.txt +9 -6
- data/demo/config/tools/launcher/launcher2.txt +16 -13
- data/demo/config/tools/launcher/launcher_mini.txt +45 -0
- data/demo/config/tools/table_manager/MCConfigurationTable_fsw1_def.txt +12 -11
- data/demo/config/tools/table_manager/MCConfigurationTable_fsw2_def.txt +12 -11
- data/demo/config/tools/test_runner/test_runner.txt +1 -1
- data/demo/config/tools/tlm_viewer/tlm_viewer.txt +5 -5
- data/demo/lib/example_background_task.rb +9 -5
- data/demo/lib/example_target.rb +5 -15
- data/demo/lib/scpi_target.rb +4 -10
- data/demo/procedures/cosmos_api_test.rb +17 -0
- data/demo/tools/CmdSequence +16 -0
- data/demo/tools/CmdSequence.bat +9 -0
- data/demo/tools/ConfigEditor +16 -0
- data/demo/tools/ConfigEditor.bat +9 -0
- data/demo/tools/mac/CmdSequence.app/Contents/Info.plist +38 -0
- data/demo/tools/mac/CmdSequence.app/Contents/MacOS/CmdSequence.rb +16 -0
- data/demo/tools/mac/CmdSequence.app/Contents/MacOS/main.sh +10 -0
- data/demo/tools/mac/CmdSequence.app/Contents/MacOS/tool_launch.rb +38 -0
- data/demo/tools/mac/CmdSequence.app/Contents/Resources/appIcon.icns +0 -0
- data/ext/cosmos/ext/packet/packet.c +5 -5
- data/install/config/data/crc.txt +12 -8
- data/install/config/system/system.txt +13 -3
- data/install/config/targets/SYSTEM/cmd_tlm/meta_cmd_tlm.txt +14 -0
- data/install/config/targets/SYSTEM/target.txt +12 -0
- data/install/tools/CmdSequence +16 -0
- data/install/tools/CmdSequence.bat +9 -0
- data/install/tools/ConfigEditor +16 -0
- data/install/tools/ConfigEditor.bat +9 -0
- data/install/tools/mac/CmdSequence.app/Contents/Info.plist +38 -0
- data/install/tools/mac/CmdSequence.app/Contents/MacOS/CmdSequence.rb +16 -0
- data/install/tools/mac/CmdSequence.app/Contents/MacOS/main.sh +10 -0
- data/install/tools/mac/CmdSequence.app/Contents/MacOS/tool_launch.rb +38 -0
- data/install/tools/mac/CmdSequence.app/Contents/Resources/appIcon.icns +0 -0
- data/lib/cosmos.rb +1 -1
- data/lib/cosmos/config/config_parser.rb +147 -59
- data/lib/cosmos/config/meta_config_parser.rb +57 -0
- data/lib/cosmos/conversions/polynomial_conversion.rb +20 -4
- data/lib/cosmos/conversions/unix_time_conversion.rb +4 -4
- data/lib/cosmos/core_ext/array.rb +45 -5
- data/lib/cosmos/core_ext/cosmos_io.rb +31 -15
- data/lib/cosmos/core_ext/file.rb +2 -2
- data/lib/cosmos/core_ext/kernel.rb +1 -6
- data/lib/cosmos/core_ext/objectspace.rb +0 -2
- data/lib/cosmos/core_ext/string.rb +27 -4
- data/lib/cosmos/core_ext/time.rb +39 -10
- data/lib/cosmos/gui/choosers/combobox_chooser.rb +37 -26
- data/lib/cosmos/gui/choosers/file_chooser.rb +23 -6
- data/lib/cosmos/gui/choosers/float_chooser.rb +13 -11
- data/lib/cosmos/gui/choosers/integer_chooser.rb +13 -11
- data/lib/cosmos/gui/choosers/string_chooser.rb +18 -36
- data/lib/cosmos/gui/choosers/telemetry_chooser.rb +64 -64
- data/lib/cosmos/gui/choosers/value_chooser.rb +15 -15
- data/lib/cosmos/gui/dialogs/about_dialog.rb +18 -13
- data/lib/cosmos/gui/dialogs/calendar_dialog.rb +11 -3
- data/lib/cosmos/gui/dialogs/cmd_tlm_raw_dialog.rb +1 -1
- data/lib/cosmos/gui/dialogs/details_dialog.rb +1 -1
- data/lib/cosmos/gui/dialogs/exception_dialog.rb +7 -7
- data/lib/cosmos/gui/dialogs/find_replace_dialog.rb +20 -15
- data/lib/cosmos/gui/dialogs/interface_raw_dialog.rb +143 -0
- data/lib/cosmos/gui/dialogs/legal_dialog.rb +6 -5
- data/lib/cosmos/gui/dialogs/packet_log_dialog.rb +5 -2
- data/lib/cosmos/gui/dialogs/progress_dialog.rb +1 -1
- data/lib/cosmos/gui/dialogs/pry_dialog.rb +4 -4
- data/lib/cosmos/gui/dialogs/scroll_text_dialog.rb +3 -0
- data/lib/cosmos/gui/dialogs/set_tlm_dialog.rb +7 -6
- data/lib/cosmos/gui/dialogs/splash.rb +1 -1
- data/lib/cosmos/gui/dialogs/tlm_details_dialog.rb +1 -1
- data/lib/cosmos/gui/dialogs/tlm_graph_dialog.rb +114 -0
- data/lib/cosmos/gui/line_graph/line_graph.rb +9 -10
- data/lib/cosmos/gui/line_graph/line_graph_dialog.rb +7 -5
- data/lib/cosmos/gui/line_graph/line_graph_drawing.rb +3 -7
- data/lib/cosmos/gui/line_graph/line_graph_popups.rb +3 -8
- data/lib/cosmos/gui/line_graph/line_graph_scaling.rb +2 -7
- data/lib/cosmos/gui/line_graph/overview_graph.rb +6 -1
- data/lib/cosmos/gui/opengl/earth_model.rb +6 -3
- data/lib/cosmos/gui/opengl/gl_bounds.rb +11 -23
- data/lib/cosmos/gui/opengl/gl_light.rb +3 -4
- data/lib/cosmos/gui/opengl/gl_material.rb +3 -4
- data/lib/cosmos/gui/opengl/gl_scene.rb +10 -4
- data/lib/cosmos/gui/opengl/gl_shape.rb +6 -2
- data/lib/cosmos/gui/opengl/gl_viewer.rb +5 -5
- data/lib/cosmos/gui/opengl/gl_viewport.rb +11 -12
- data/lib/cosmos/gui/opengl/moon_model.rb +6 -3
- data/lib/cosmos/gui/opengl/stl_reader.rb +8 -9
- data/lib/cosmos/gui/opengl/stl_shape.rb +4 -5
- data/lib/cosmos/gui/opengl/texture_mapped_sphere.rb +7 -7
- data/lib/cosmos/gui/qt.rb +1 -1
- data/lib/cosmos/gui/qt_tool.rb +21 -10
- data/lib/cosmos/gui/text/completion.rb +23 -2
- data/lib/cosmos/gui/text/completion_text_edit.rb +38 -23
- data/lib/cosmos/gui/utilities/analyze_log.rb +1 -1
- data/lib/cosmos/gui/utilities/screenshot.rb +2 -2
- data/lib/cosmos/gui/widgets/full_text_search_line_edit.rb +11 -1
- data/lib/cosmos/gui/widgets/packet_log_frame.rb +19 -6
- data/lib/cosmos/interfaces.rb +10 -0
- data/lib/cosmos/interfaces/cmd_tlm_server_interface.rb +28 -47
- data/lib/cosmos/interfaces/interface.rb +240 -22
- data/lib/cosmos/interfaces/linc_interface.rb +3 -5
- data/lib/cosmos/interfaces/protocols/burst_protocol.rb +173 -0
- data/lib/cosmos/interfaces/protocols/crc_protocol.rb +141 -0
- data/lib/cosmos/{streams/fixed_stream_protocol.rb → interfaces/protocols/fixed_protocol.rb} +40 -37
- data/lib/cosmos/{streams/length_stream_protocol.rb → interfaces/protocols/length_protocol.rb} +55 -48
- data/lib/cosmos/interfaces/protocols/override_protocol.rb +52 -0
- data/lib/cosmos/interfaces/protocols/preidentified_protocol.rb +141 -0
- data/lib/cosmos/interfaces/protocols/protocol.rb +60 -0
- data/lib/cosmos/interfaces/protocols/template_protocol.rb +209 -0
- data/lib/cosmos/interfaces/protocols/terminated_protocol.rb +81 -0
- data/lib/cosmos/interfaces/serial_interface.rb +28 -23
- data/lib/cosmos/interfaces/simulated_target_interface.rb +27 -16
- data/lib/cosmos/interfaces/stream_interface.rb +36 -108
- data/lib/cosmos/interfaces/tcpip_client_interface.rb +21 -21
- data/lib/cosmos/interfaces/tcpip_server_interface.rb +555 -94
- data/lib/cosmos/interfaces/udp_interface.rb +51 -83
- data/lib/cosmos/io/buffered_file.rb +92 -2
- data/lib/cosmos/io/json_drb.rb +2 -2
- data/lib/cosmos/io/posix_serial_driver.rb +3 -1
- data/lib/cosmos/io/raw_logger.rb +3 -3
- data/lib/cosmos/io/serial_driver.rb +14 -5
- data/lib/cosmos/io/win32_serial_driver.rb +16 -4
- data/lib/cosmos/packet_logs.rb +0 -1
- data/lib/cosmos/packet_logs/packet_log_reader.rb +11 -1
- data/lib/cosmos/packet_logs/packet_log_writer.rb +31 -13
- data/lib/cosmos/packets/binary_accessor.rb +599 -32
- data/lib/cosmos/packets/commands.rb +48 -24
- data/lib/cosmos/packets/packet.rb +140 -54
- data/lib/cosmos/packets/packet_config.rb +0 -2
- data/lib/cosmos/packets/parsers/packet_item_parser.rb +10 -2
- data/lib/cosmos/packets/structure.rb +81 -33
- data/lib/cosmos/packets/structure_item.rb +45 -5
- data/lib/cosmos/packets/telemetry.rb +149 -55
- data/lib/cosmos/script/api_shared.rb +1000 -0
- data/lib/cosmos/script/commands.rb +2 -2
- data/lib/cosmos/script/extract.rb +19 -4
- data/lib/cosmos/script/limits.rb +2 -0
- data/lib/cosmos/script/script.rb +1 -1
- data/lib/cosmos/script/scripting.rb +4 -784
- data/lib/cosmos/script/telemetry.rb +44 -23
- data/lib/cosmos/script/tools.rb +15 -69
- data/lib/cosmos/streams/serial_stream.rb +12 -19
- data/lib/cosmos/streams/stream.rb +2 -11
- data/lib/cosmos/streams/tcpip_socket_stream.rb +3 -13
- data/lib/cosmos/system/system.rb +187 -31
- data/lib/cosmos/system/target.rb +11 -2
- data/lib/cosmos/tools/cmd_extractor/cmd_extractor.rb +12 -11
- data/lib/cosmos/tools/cmd_sender/{cmd_sender_item_delegate.rb → cmd_param_table_item_delegate.rb} +11 -10
- data/lib/cosmos/tools/cmd_sender/cmd_sender.rb +209 -164
- data/lib/cosmos/tools/cmd_sequence/cmd_sequence.rb +652 -0
- data/lib/cosmos/tools/cmd_sequence/sequence_item.rb +510 -0
- data/lib/cosmos/tools/cmd_sequence/sequence_list.rb +194 -0
- data/lib/cosmos/tools/cmd_tlm_server/api.rb +179 -5
- data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server.rb +31 -14
- data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_config.rb +23 -16
- data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb +92 -20
- data/lib/cosmos/tools/cmd_tlm_server/commanding.rb +1 -1
- data/lib/cosmos/tools/cmd_tlm_server/gui/interfaces_tab.rb +17 -4
- data/lib/cosmos/tools/cmd_tlm_server/gui/targets_tab.rb +0 -5
- data/lib/cosmos/tools/cmd_tlm_server/interface_thread.rb +1 -2
- data/lib/cosmos/tools/cmd_tlm_server/interfaces.rb +4 -4
- data/lib/cosmos/tools/cmd_tlm_server/limits_groups_background_task.rb +121 -0
- data/lib/cosmos/tools/cmd_tlm_server/routers.rb +8 -4
- data/lib/cosmos/tools/config_editor/config_editor.rb +720 -0
- data/lib/cosmos/tools/config_editor/config_editor_frame.rb +675 -0
- data/lib/cosmos/tools/data_viewer/data_viewer.rb +44 -27
- data/lib/cosmos/tools/data_viewer/data_viewer_component.rb +8 -22
- data/lib/cosmos/tools/launcher/launcher.rb +29 -12
- data/lib/cosmos/tools/launcher/launcher_config.rb +1 -1
- data/lib/cosmos/tools/limits_monitor/limits_monitor.rb +153 -42
- data/lib/cosmos/tools/packet_viewer/packet_viewer.rb +44 -6
- data/lib/cosmos/tools/replay/replay.rb +36 -20
- data/lib/cosmos/tools/replay/replay_server.rb +1 -1
- data/lib/cosmos/tools/script_runner/script_runner_config.rb +1 -1
- data/lib/cosmos/tools/script_runner/script_runner_frame.rb +31 -21
- data/lib/cosmos/tools/table_manager/table_config.rb +9 -3
- data/lib/cosmos/tools/table_manager/table_manager.rb +27 -7
- data/lib/cosmos/tools/test_runner/results_writer.rb +6 -6
- data/lib/cosmos/tools/test_runner/test_runner.rb +4 -6
- data/lib/cosmos/tools/tlm_extractor/tlm_extractor.rb +4 -5
- data/lib/cosmos/tools/tlm_extractor/tlm_extractor_config.rb +1 -1
- data/lib/cosmos/tools/tlm_extractor/tlm_extractor_processor.rb +1 -1
- data/lib/cosmos/tools/tlm_grapher/data_object_adders/housekeeping_data_object_adder.rb +23 -6
- data/lib/cosmos/tools/tlm_grapher/data_object_editors/housekeeping_data_object_editor.rb +44 -3
- data/lib/cosmos/tools/tlm_grapher/data_objects/housekeeping_data_object.rb +20 -7
- data/lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb +1 -1
- data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_config.rb +11 -4
- data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_plot_editor.rb +2 -2
- data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_realtime_thread.rb +1 -1
- data/lib/cosmos/tools/tlm_grapher/tlm_grapher.rb +16 -0
- data/lib/cosmos/tools/tlm_viewer/screen.rb +36 -32
- data/lib/cosmos/tools/tlm_viewer/tlm_viewer.rb +59 -50
- data/lib/cosmos/tools/tlm_viewer/tlm_viewer_config.rb +2 -2
- data/lib/cosmos/tools/tlm_viewer/widgets.rb +1 -0
- data/lib/cosmos/tools/tlm_viewer/widgets/canvasvalue_widget.rb +1 -0
- data/lib/cosmos/tools/tlm_viewer/widgets/labelvalue_widget.rb +22 -4
- data/lib/cosmos/tools/tlm_viewer/widgets/matrixbycolumns_widget.rb +9 -0
- data/lib/cosmos/tools/tlm_viewer/widgets/spacer_widget.rb +55 -0
- data/lib/cosmos/tools/tlm_viewer/widgets/vertical_widget.rb +3 -2
- data/lib/cosmos/tools/tlm_viewer/widgets/verticalbox_widget.rb +3 -2
- data/lib/cosmos/tools/tlm_viewer/widgets/widget.rb +12 -12
- data/lib/cosmos/top_level.rb +34 -24
- data/lib/cosmos/utilities/crc.rb +108 -6
- data/lib/cosmos/utilities/csv.rb +68 -14
- data/lib/cosmos/utilities/logger.rb +2 -2
- data/lib/cosmos/utilities/low_fragmentation_array.rb +9 -1
- data/lib/cosmos/version.rb +6 -6
- data/lib/cosmos/win32/win32_main.rb +50 -46
- data/run_gui_tests.bat +3 -1
- data/spec/conversions/unix_time_formatted_conversion_spec.rb +2 -2
- data/spec/conversions/unix_time_seconds_conversion_spec.rb +2 -2
- data/spec/core_ext/file_spec.rb +1 -1
- data/spec/core_ext/objectspace_spec.rb +12 -9
- data/spec/core_ext/string_spec.rb +6 -0
- data/spec/core_ext/time_spec.rb +10 -0
- data/spec/gui/line_graph/line_clip_spec.rb +226 -224
- data/spec/gui/qt_spec.rb +81 -79
- data/spec/install/config/system/system.txt +0 -6
- data/spec/install/config/targets/INST/cmd_tlm/inst_cmd_linc.txt +5 -5
- data/spec/install/config/targets/INST/cmd_tlm/inst_tlm_linc.txt +8 -8
- data/spec/install/config/targets/SYSTEM/cmd_tlm/meta_cmd_tlm.txt +16 -0
- data/{install/config/targets/COSMOS/cmd_tlm/cosmos_server_cmds.txt → spec/install/config/targets/SYSTEM/cmd_tlm/system_cmds.txt} +8 -8
- data/spec/install/config/targets/SYSTEM/cmd_tlm/system_tlm.txt +7 -0
- data/spec/install/config/targets/{COSMOS → SYSTEM}/cmd_tlm_server.txt +2 -2
- data/spec/install/config/targets/SYSTEM/screens/status.txt +12 -0
- data/spec/install/config/targets/SYSTEM/target.txt +12 -0
- data/spec/interfaces/cmd_tlm_server_interface_spec.rb +9 -13
- data/spec/interfaces/interface_spec.rb +402 -18
- data/spec/interfaces/linc_interface_spec.rb +37 -39
- data/spec/interfaces/protocols/burst_protocol_spec.rb +300 -0
- data/spec/interfaces/protocols/crc_protocol_spec.rb +709 -0
- data/spec/interfaces/protocols/fixed_protocol_spec.rb +119 -0
- data/spec/interfaces/protocols/length_protocol_spec.rb +499 -0
- data/spec/interfaces/protocols/override_protocol_spec.rb +158 -0
- data/spec/interfaces/protocols/preidentified_protocol_spec.rb +149 -0
- data/spec/interfaces/protocols/template_protocol_spec.rb +218 -0
- data/spec/interfaces/protocols/terminated_protocol_spec.rb +174 -0
- data/spec/interfaces/serial_interface_spec.rb +35 -34
- data/spec/interfaces/simulated_target_interface_spec.rb +13 -13
- data/spec/interfaces/tcpip_client_interface_spec.rb +21 -16
- data/spec/interfaces/tcpip_server_interface_spec.rb +66 -69
- data/spec/interfaces/udp_interface_spec.rb +120 -55
- data/spec/io/serial_driver_spec.rb +41 -39
- data/spec/io/udp_sockets_spec.rb +13 -8
- data/spec/io/win32_serial_driver_spec.rb +62 -59
- data/spec/packet_logs/packet_log_reader_spec.rb +68 -47
- data/spec/packet_logs/packet_log_writer_spec.rb +7 -5
- data/spec/packets/commands_spec.rb +5 -5
- data/spec/packets/packet_spec.rb +2 -14
- data/spec/script/extract_spec.rb +21 -7
- data/spec/script/scripting_spec.rb +261 -6
- data/spec/script/telemetry_spec.rb +17 -9
- data/spec/spec_helper.rb +26 -10
- data/spec/streams/serial_stream_spec.rb +87 -82
- data/spec/streams/tcpip_client_stream_spec.rb +12 -4
- data/spec/streams/tcpip_socket_stream_spec.rb +5 -0
- data/spec/system/system_spec.rb +66 -50
- data/spec/system/target_spec.rb +33 -11
- data/spec/tools/cmd_tlm_server/api_spec.rb +5 -5
- data/spec/tools/cmd_tlm_server/background_tasks_spec.rb +75 -15
- data/spec/tools/cmd_tlm_server/cmd_tlm_server_config_spec.rb +125 -5
- data/spec/tools/cmd_tlm_server/cmd_tlm_server_spec.rb +244 -232
- data/spec/tools/cmd_tlm_server/commanding_spec.rb +18 -18
- data/spec/tools/cmd_tlm_server/interface_thread_spec.rb +124 -29
- data/spec/tools/cmd_tlm_server/interfaces_spec.rb +2 -2
- data/spec/tools/cmd_tlm_server/limits_groups_background_task_spec.rb +145 -0
- data/spec/tools/cmd_tlm_server/router_thread_spec.rb +50 -10
- data/spec/tools/table_manager/tablemanager_core_spec.rb +0 -1
- data/spec/top_level/top_level_spec.rb +39 -11
- data/spec/utilities/csv_spec.rb +62 -20
- data/tasks/gemfile_stats.rake +6 -3
- data/test/performance/config/system/system_packets.txt +0 -1
- data/test/performance/config/system/system_threads.txt +0 -1
- metadata +177 -92
- data/autohotkey/config/targets/COSMOS/cmd_tlm/cosmos_server_tlm.txt +0 -15
- data/autohotkey/config/targets/COSMOS/cmd_tlm_server.txt +0 -6
- data/autohotkey/config/targets/COSMOS/target.txt +0 -5
- data/autohotkey/userpath.txt +0 -1
- data/demo/config/targets/COSMOS/cmd_tlm/cosmos_server_tlm.txt +0 -15
- data/demo/config/targets/COSMOS/screens/limits_change.txt +0 -20
- data/demo/config/targets/COSMOS/screens/version.txt +0 -19
- data/demo/config/targets/COSMOS/target.txt +0 -11
- data/demo/config/targets/META/cmd_tlm/meta_cmd.txt +0 -10
- data/demo/config/targets/META/cmd_tlm/meta_tlm.txt +0 -13
- data/demo/userpath.txt +0 -1
- data/install/config/targets/COSMOS/cmd_tlm/cosmos_server_tlm.txt +0 -15
- data/install/config/targets/COSMOS/cmd_tlm_server.txt +0 -6
- data/install/config/targets/COSMOS/screens/limits_change.txt +0 -20
- data/install/config/targets/COSMOS/screens/version.txt +0 -19
- data/install/config/targets/COSMOS/target.txt +0 -9
- data/install/config/targets/SYSTEM/README.txt +0 -1
- data/install/userpath.txt +0 -1
- data/lib/cosmos/io/tcpip_server.rb +0 -571
- data/lib/cosmos/packet_logs/meta_packet_log_writer.rb +0 -107
- data/lib/cosmos/streams/burst_stream_protocol.rb +0 -25
- data/lib/cosmos/streams/preidentified_stream_protocol.rb +0 -118
- data/lib/cosmos/streams/stream_protocol.rb +0 -373
- data/lib/cosmos/streams/template_stream_protocol.rb +0 -140
- data/lib/cosmos/streams/terminated_stream_protocol.rb +0 -85
- data/spec/install/config/targets/COSMOS/cmd_tlm/cosmos_server_cmds.txt +0 -41
- data/spec/install/config/targets/COSMOS/cmd_tlm/cosmos_server_tlm.txt +0 -15
- data/spec/install/config/targets/COSMOS/screens/limits_change.txt +0 -20
- data/spec/install/config/targets/COSMOS/screens/version.txt +0 -19
- data/spec/install/config/targets/COSMOS/target.txt +0 -5
- data/spec/install/config/targets/META/cmd_tlm/meta_cmd.txt +0 -4
- data/spec/install/config/targets/META/cmd_tlm/meta_tlm.txt +0 -4
- data/spec/install/userpath.txt +0 -1
- data/spec/interfaces/stream_interface_spec.rb +0 -157
- data/spec/io/tcpip_server_spec.rb +0 -338
- data/spec/packet_logs/meta_packet_log_writer_spec.rb +0 -170
- data/spec/streams/burst_stream_protocol_spec.rb +0 -32
- data/spec/streams/fixed_stream_protocol_spec.rb +0 -113
- data/spec/streams/length_stream_protocol_spec.rb +0 -300
- data/spec/streams/preidentified_stream_protocol_spec.rb +0 -121
- data/spec/streams/stream_protocol_spec.rb +0 -346
- data/spec/streams/template_stream_protocol_spec.rb +0 -156
- data/spec/streams/terminated_stream_protocol_spec.rb +0 -127
- data/test/performance/userpath.txt +0 -1
|
@@ -17,7 +17,7 @@ module Cosmos
|
|
|
17
17
|
@parent = parent
|
|
18
18
|
@packet_log_frame = packet_log_frame
|
|
19
19
|
@input_filenames = []
|
|
20
|
-
@packet_log_reader = System.default_packet_log_reader.new
|
|
20
|
+
@packet_log_reader = System.default_packet_log_reader.new(*System.default_packet_log_reader_params)
|
|
21
21
|
@time_start = nil
|
|
22
22
|
@time_end = nil
|
|
23
23
|
@cancel = false
|
|
@@ -17,8 +17,8 @@ module Cosmos
|
|
|
17
17
|
def self.screenshot_window (window, filename)
|
|
18
18
|
if !Kernel.is_windows?()
|
|
19
19
|
# Delay for one second to allow any dialogs to fully clear first
|
|
20
|
-
start_time = Time.now
|
|
21
|
-
while ((Time.now - start_time) < 1.0)
|
|
20
|
+
start_time = Time.now.sys
|
|
21
|
+
while ((Time.now.sys - start_time) < 1.0)
|
|
22
22
|
Qt::CoreApplication.processEvents(Qt::EventLoop::AllEvents, 1000)
|
|
23
23
|
end
|
|
24
24
|
end
|
|
@@ -9,13 +9,23 @@
|
|
|
9
9
|
# attribution addendums as found in the LICENSE.txt
|
|
10
10
|
|
|
11
11
|
module Cosmos
|
|
12
|
+
# Provides a text completion LineEdit which pops up values as the user types.
|
|
13
|
+
# Hitting Return completes the currently selected popup item and calls the
|
|
14
|
+
# registered callback method.
|
|
12
15
|
class FullTextSearchLineEdit < Qt::LineEdit
|
|
13
|
-
|
|
14
16
|
attr_accessor :completion_list
|
|
15
17
|
attr_accessor :callback
|
|
16
18
|
|
|
17
19
|
def initialize(parent)
|
|
18
20
|
super(parent)
|
|
21
|
+
# Add the magnifying glass to the box
|
|
22
|
+
setStyleSheet(
|
|
23
|
+
"padding-right: 20px;"\
|
|
24
|
+
"padding-left: 5px;"\
|
|
25
|
+
"background: url(#{File.join(Cosmos::PATH, 'data', 'search-14.png')});"\
|
|
26
|
+
"background-position: right;"\
|
|
27
|
+
"background-repeat: no-repeat;"
|
|
28
|
+
)
|
|
19
29
|
@listView = Qt::ListWidget.new(parent)
|
|
20
30
|
@listView.setWindowFlags(0xc | 0x1) # Qt::ToolTip
|
|
21
31
|
@completion_list = []
|
|
@@ -52,6 +52,8 @@ module Cosmos
|
|
|
52
52
|
# selecting input log files with the FileDialog
|
|
53
53
|
# @param output_filename_filter [String] File filter to apply when
|
|
54
54
|
# selecting an output filename with the FileDialog
|
|
55
|
+
# @param multiple_file_select [Boolean] Whether to allow multiple file
|
|
56
|
+
# selections when browsing for files
|
|
55
57
|
def initialize(parent,
|
|
56
58
|
log_directory,
|
|
57
59
|
packet_log_reader,
|
|
@@ -61,12 +63,14 @@ module Cosmos
|
|
|
61
63
|
show_time = true,
|
|
62
64
|
show_log_reader = true,
|
|
63
65
|
input_filename_filter = Cosmos::BIN_FILE_PATTERN,
|
|
64
|
-
output_filename_filter = Cosmos::BIN_FILE_PATTERN
|
|
66
|
+
output_filename_filter = Cosmos::BIN_FILE_PATTERN,
|
|
67
|
+
multiple_file_select = true)
|
|
65
68
|
super(parent)
|
|
66
69
|
|
|
67
70
|
@output_select = :FILE
|
|
68
71
|
@input_filename_filter = input_filename_filter
|
|
69
72
|
@output_filename_filter = output_filename_filter
|
|
73
|
+
@multiple_file_select = multiple_file_select
|
|
70
74
|
@log_directory = log_directory
|
|
71
75
|
if initial_output_filename
|
|
72
76
|
@output_directory = File.dirname(initial_output_filename)
|
|
@@ -223,11 +227,20 @@ module Cosmos
|
|
|
223
227
|
# Handles browsing for log files
|
|
224
228
|
def handle_browse_button
|
|
225
229
|
Cosmos.set_working_dir do
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
230
|
+
if @multiple_file_select
|
|
231
|
+
filenames = Qt::FileDialog::getOpenFileNames(
|
|
232
|
+
self, "Select Log File(s):", @log_directory, @input_filename_filter)
|
|
233
|
+
if filenames and not filenames.empty?
|
|
234
|
+
@log_directory.replace(File.dirname(filenames[0]) + '/')
|
|
235
|
+
filenames.each {|filename| @filenames.addItem(filename) if @filenames.findItems(filename, Qt::MatchExactly).empty? }
|
|
236
|
+
end
|
|
237
|
+
else
|
|
238
|
+
filename = Qt::FileDialog::getOpenFileName(
|
|
239
|
+
self, "Select Log File:", @log_directory, @input_filename_filter)
|
|
240
|
+
if filename
|
|
241
|
+
@log_directory.replace(File.dirname(filename) + '/')
|
|
242
|
+
@filenames.addItem(filename)
|
|
243
|
+
end
|
|
231
244
|
end
|
|
232
245
|
@change_callback.call(:INPUT_FILES) if @change_callback
|
|
233
246
|
end
|
data/lib/cosmos/interfaces.rb
CHANGED
|
@@ -9,3 +9,13 @@ require 'cosmos/interfaces/tcpip_client_interface'
|
|
|
9
9
|
require 'cosmos/interfaces/tcpip_server_interface'
|
|
10
10
|
require 'cosmos/interfaces/udp_interface'
|
|
11
11
|
require 'cosmos/interfaces/linc_interface'
|
|
12
|
+
|
|
13
|
+
require 'cosmos/interfaces/protocols/protocol'
|
|
14
|
+
require 'cosmos/interfaces/protocols/burst_protocol'
|
|
15
|
+
require 'cosmos/interfaces/protocols/fixed_protocol'
|
|
16
|
+
require 'cosmos/interfaces/protocols/length_protocol'
|
|
17
|
+
require 'cosmos/interfaces/protocols/preidentified_protocol'
|
|
18
|
+
require 'cosmos/interfaces/protocols/template_protocol'
|
|
19
|
+
require 'cosmos/interfaces/protocols/terminated_protocol'
|
|
20
|
+
|
|
21
|
+
require 'cosmos/interfaces/protocols/override_protocol'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# encoding: ascii-8bit
|
|
2
2
|
|
|
3
|
-
# Copyright
|
|
3
|
+
# Copyright 2017 Ball Aerospace & Technologies Corp.
|
|
4
4
|
# All Rights Reserved.
|
|
5
5
|
#
|
|
6
6
|
# This program is free software; you can modify and/or redistribute it
|
|
@@ -11,11 +11,9 @@
|
|
|
11
11
|
require 'cosmos/interfaces/interface'
|
|
12
12
|
|
|
13
13
|
module Cosmos
|
|
14
|
-
|
|
15
14
|
# Allows commands to be sent and telemetry received from the the
|
|
16
15
|
# CmdTlmServer.
|
|
17
16
|
class CmdTlmServerInterface < Interface
|
|
18
|
-
|
|
19
17
|
# Create the interface and disallow raw writes
|
|
20
18
|
def initialize
|
|
21
19
|
super()
|
|
@@ -29,44 +27,31 @@ module Cosmos
|
|
|
29
27
|
@limit_id = CmdTlmServer.instance.subscribe_limits_events
|
|
30
28
|
end
|
|
31
29
|
|
|
32
|
-
# @return [Boolean]
|
|
30
|
+
# @return [Boolean] Returns whether subscribed to limits events
|
|
33
31
|
def connected?
|
|
34
|
-
if @limit_id
|
|
35
|
-
|
|
36
|
-
else
|
|
37
|
-
return false
|
|
38
|
-
end
|
|
32
|
+
return true if @limit_id
|
|
33
|
+
false
|
|
39
34
|
end
|
|
40
35
|
|
|
41
|
-
#
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
# Unsubscribe from the limits events
|
|
37
|
+
def disconnect
|
|
38
|
+
CmdTlmServer.instance.unsubscribe_limits_events(@limit_id) if @limit_id
|
|
39
|
+
@limit_id = nil
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Continuously wait for limits events and returning
|
|
43
|
+
# SYSTEM LIMITS_CHANGE packets.
|
|
44
44
|
#
|
|
45
|
-
# @return [Packet]
|
|
46
|
-
# returns COSMOS LIMITS_CHANGE packets as limits events are generated.
|
|
45
|
+
# @return [Packet] returns SYSTEM LIMITS_CHANGE packets as limits events are generated.
|
|
47
46
|
def read
|
|
48
|
-
if @read_count == 0
|
|
49
|
-
begin
|
|
50
|
-
packet = System.telemetry.packet("COSMOS","VERSION")
|
|
51
|
-
packet.write('PKT_ID',1)
|
|
52
|
-
packet.write('COSMOS', Cosmos::VERSION)
|
|
53
|
-
packet.write('RUBY', "#{RUBY_VERSION}p#{RUBY_PATCHLEVEL}")
|
|
54
|
-
packet.write('CTDB', System.cmd_tlm_version)
|
|
55
|
-
packet.write('USER', USER_VERSION) if defined? USER_VERSION
|
|
56
|
-
@read_count += 1
|
|
57
|
-
return packet
|
|
58
|
-
rescue # if they haven't defined COSMOS VERSION we just fall through
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
47
|
while connected?
|
|
63
48
|
begin
|
|
64
49
|
event = CmdTlmServer.instance.get_limits_event(@limit_id)
|
|
65
50
|
if event
|
|
66
51
|
if event[0] == :LIMITS_CHANGE
|
|
67
52
|
data = event[1]
|
|
68
|
-
packet ||= System.telemetry.packet("
|
|
69
|
-
packet.received_time = Time.now
|
|
53
|
+
packet ||= System.telemetry.packet("SYSTEM","LIMITS_CHANGE")
|
|
54
|
+
packet.received_time = Time.now.sys
|
|
70
55
|
packet.write('PKT_ID',2)
|
|
71
56
|
packet.write('TARGET', data[0])
|
|
72
57
|
packet.write('PACKET', data[1])
|
|
@@ -77,6 +62,8 @@ module Cosmos
|
|
|
77
62
|
packet.write('OLD_STATE', data[3])
|
|
78
63
|
packet.write('NEW_STATE', data[4])
|
|
79
64
|
@read_count += 1
|
|
65
|
+
@read_raw_data_time = Time.now
|
|
66
|
+
@read_raw_data = packet.buffer
|
|
80
67
|
return packet
|
|
81
68
|
end
|
|
82
69
|
else
|
|
@@ -84,7 +71,7 @@ module Cosmos
|
|
|
84
71
|
end
|
|
85
72
|
rescue => error
|
|
86
73
|
puts error.formatted
|
|
87
|
-
# if they haven't defined
|
|
74
|
+
# if they haven't defined SYSTEM LIMITS_CHANGE we fall through
|
|
88
75
|
# and break the loop because nothing will work
|
|
89
76
|
break
|
|
90
77
|
end
|
|
@@ -95,14 +82,16 @@ module Cosmos
|
|
|
95
82
|
|
|
96
83
|
# Write a packet to the CmdTlmServer to change various settings.
|
|
97
84
|
#
|
|
98
|
-
# @param packet [Packet] Must be one of
|
|
85
|
+
# @param packet [Packet] Must be one of SYSTEM SETLOGLABEL, STARTLOGGING,
|
|
99
86
|
# STARTCMDLOG, STARTTLMLOG, STOPLOGGING, STOPCMDLOG or STOPTLMLOG.
|
|
100
87
|
def write(packet)
|
|
101
88
|
@write_count += 1
|
|
102
89
|
command_data = packet.buffer
|
|
103
90
|
@bytes_written += command_data.length
|
|
91
|
+
@written_raw_data_time = Time.now
|
|
92
|
+
@written_raw_data = command_data
|
|
104
93
|
|
|
105
|
-
identified_command = System.commands.identify(command_data, ['
|
|
94
|
+
identified_command = System.commands.identify(command_data, ['SYSTEM'])
|
|
106
95
|
if identified_command
|
|
107
96
|
case identified_command.packet_name
|
|
108
97
|
when 'STARTLOGGING'
|
|
@@ -125,29 +114,21 @@ module Cosmos
|
|
|
125
114
|
interface_name = identified_command.read('interface')
|
|
126
115
|
CmdTlmServer.instance.stop_tlm_log(interface_name)
|
|
127
116
|
else
|
|
128
|
-
raise "Command unhandled at
|
|
117
|
+
raise "Command unhandled at SYSTEM interface. : #{identifed_command.packet_name}"
|
|
129
118
|
end
|
|
130
119
|
else
|
|
131
|
-
raise "Unknown command received at
|
|
120
|
+
raise "Unknown command received at SYSTEM Interface."
|
|
132
121
|
end
|
|
133
122
|
end
|
|
134
123
|
|
|
135
124
|
# Raise an error because this method is not implemented for this interface
|
|
136
|
-
def write_raw(
|
|
125
|
+
def write_raw(_data)
|
|
137
126
|
raise "write_raw not implemented for CmdTlmServerInterface"
|
|
138
127
|
end
|
|
139
128
|
|
|
140
129
|
# Raise an error because raw logging is not supported for this interface
|
|
141
|
-
def raw_logger_pair=(
|
|
130
|
+
def raw_logger_pair=(_raw_logger_pair)
|
|
142
131
|
raise "Raw logging not supported for CmdTlmServerInterface"
|
|
143
132
|
end
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
def disconnect
|
|
147
|
-
CmdTlmServer.instance.unsubscribe_limits_events(@limit_id) if @limit_id
|
|
148
|
-
@limit_id = nil
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
end # end class CmdTlmServerInterface
|
|
152
|
-
|
|
153
|
-
end # module Cosmos
|
|
133
|
+
end
|
|
134
|
+
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# encoding: ascii-8bit
|
|
2
2
|
|
|
3
|
-
# Copyright
|
|
3
|
+
# Copyright 2017 Ball Aerospace & Technologies Corp.
|
|
4
4
|
# All Rights Reserved.
|
|
5
5
|
#
|
|
6
6
|
# This program is free software; you can modify and/or redistribute it
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
|
|
11
11
|
require 'cosmos/tools/cmd_tlm_server/api'
|
|
12
12
|
require 'cosmos/io/raw_logger_pair'
|
|
13
|
+
require 'thread'
|
|
13
14
|
|
|
14
15
|
module Cosmos
|
|
15
16
|
|
|
16
17
|
# Defines all the attributes and methods common to all interface classes
|
|
17
18
|
# used by COSMOS.
|
|
18
19
|
class Interface
|
|
19
|
-
|
|
20
20
|
include Api
|
|
21
21
|
|
|
22
22
|
# @return [String] Name of the interface
|
|
@@ -88,9 +88,33 @@ module Cosmos
|
|
|
88
88
|
# @return [Hash<option name, option values>] Hash of options supplied to interface/router
|
|
89
89
|
attr_accessor :options
|
|
90
90
|
|
|
91
|
+
# @return [Array<Protocol>] Array of protocols for reading
|
|
92
|
+
attr_accessor :read_protocols
|
|
93
|
+
|
|
94
|
+
# @return [Array<Protocol>] Array of protocols for writing
|
|
95
|
+
attr_accessor :write_protocols
|
|
96
|
+
|
|
97
|
+
# @return [Array<[Protocol Class, Protocol Args, Protocol kind (:READ, :WRITE, :READ_WRITE)>] Info to recreate protocols
|
|
98
|
+
attr_accessor :protocol_info
|
|
99
|
+
|
|
100
|
+
# @return [Hash or nil] Hash of overridden telemetry points
|
|
101
|
+
attr_accessor :override_tlm
|
|
102
|
+
|
|
103
|
+
# @return [String] Most recently read raw data
|
|
104
|
+
attr_accessor :read_raw_data
|
|
105
|
+
|
|
106
|
+
# @return [String] Most recently written raw data
|
|
107
|
+
attr_accessor :written_raw_data
|
|
108
|
+
|
|
109
|
+
# @return [Time] Most recent read raw data time
|
|
110
|
+
attr_accessor :read_raw_data_time
|
|
111
|
+
|
|
112
|
+
# @return [Time] Most recent written raw data time
|
|
113
|
+
attr_accessor :written_raw_data_time
|
|
114
|
+
|
|
91
115
|
# Initialize default attribute values
|
|
92
116
|
def initialize
|
|
93
|
-
@name = self.class.to_s
|
|
117
|
+
@name = self.class.to_s.split("::")[-1] # Remove namespacing if present
|
|
94
118
|
@target_names = []
|
|
95
119
|
@thread = nil
|
|
96
120
|
@connect_on_startup = true
|
|
@@ -108,47 +132,158 @@ module Cosmos
|
|
|
108
132
|
@num_clients = 0
|
|
109
133
|
@read_queue_size = 0
|
|
110
134
|
@write_queue_size = 0
|
|
135
|
+
@write_mutex = Mutex.new
|
|
111
136
|
@interfaces = []
|
|
112
137
|
@read_allowed = true
|
|
113
138
|
@write_allowed = true
|
|
114
139
|
@write_raw_allowed = true
|
|
115
140
|
@options = {}
|
|
141
|
+
@read_protocols = []
|
|
142
|
+
@write_protocols = []
|
|
143
|
+
@protocol_info = []
|
|
144
|
+
@override_tlm = nil
|
|
145
|
+
@read_raw_data = ''
|
|
146
|
+
@written_raw_data = ''
|
|
147
|
+
@read_raw_data_time = nil
|
|
148
|
+
@written_raw_data_time = nil
|
|
116
149
|
end
|
|
117
150
|
|
|
118
151
|
# Connects the interface to its target(s). Must be implemented by a
|
|
119
152
|
# subclass.
|
|
120
153
|
def connect
|
|
121
|
-
|
|
154
|
+
(@read_protocols | @write_protocols).each {|protocol| protocol.connect_reset}
|
|
122
155
|
end
|
|
123
156
|
|
|
124
157
|
# Indicates if the interface is connected to its target(s) or not. Must be
|
|
125
158
|
# implemented by a subclass.
|
|
126
159
|
def connected?
|
|
127
|
-
raise "
|
|
160
|
+
raise "connected? not defined by Interface"
|
|
128
161
|
end
|
|
129
162
|
|
|
130
163
|
# Disconnects the interface from its target(s). Must be implemented by a
|
|
131
164
|
# subclass.
|
|
132
165
|
def disconnect
|
|
133
|
-
|
|
166
|
+
(@read_protocols | @write_protocols).each {|protocol| protocol.disconnect_reset}
|
|
134
167
|
end
|
|
135
168
|
|
|
136
|
-
|
|
137
|
-
|
|
169
|
+
def read_interface
|
|
170
|
+
raise "read_interface not defined by Interface"
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def write_interface
|
|
174
|
+
raise "write_interface not defined by Interface"
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
# Retrieves the next packet from the interface.
|
|
178
|
+
# @return [Packet] Packet constructed from the data. Packet will be
|
|
179
|
+
# unidentified (nil target and packet names)
|
|
138
180
|
def read
|
|
139
|
-
raise "Interface read
|
|
181
|
+
raise "Interface not connected for read: #{@name}" unless connected? && read_allowed?
|
|
182
|
+
|
|
183
|
+
first = true
|
|
184
|
+
loop do
|
|
185
|
+
# Protocols may have cached data for a packet, so initially just inject a blank string
|
|
186
|
+
# Otherwise we can hold off outputing other packets where all the data has already
|
|
187
|
+
# been received
|
|
188
|
+
if !first or @read_protocols.length <= 0
|
|
189
|
+
# Read data for a packet
|
|
190
|
+
data = read_interface()
|
|
191
|
+
return nil unless data
|
|
192
|
+
else
|
|
193
|
+
data = ''
|
|
194
|
+
first = false
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
@read_protocols.each do |protocol|
|
|
198
|
+
data = protocol.read_data(data)
|
|
199
|
+
return nil if data == :DISCONNECT # Disconnect handled by thread
|
|
200
|
+
break if data == :STOP
|
|
201
|
+
end
|
|
202
|
+
next if data == :STOP
|
|
203
|
+
|
|
204
|
+
packet = convert_data_to_packet(data)
|
|
205
|
+
|
|
206
|
+
# Potentially modify packet
|
|
207
|
+
@read_protocols.each do |protocol|
|
|
208
|
+
packet = protocol.read_packet(packet)
|
|
209
|
+
return nil if packet == :DISCONNECT # Disconnect handled by thread
|
|
210
|
+
break if packet == :STOP
|
|
211
|
+
end
|
|
212
|
+
next if packet == :STOP
|
|
213
|
+
|
|
214
|
+
# Return packet
|
|
215
|
+
@read_count += 1
|
|
216
|
+
return packet
|
|
217
|
+
end
|
|
218
|
+
rescue Exception => err
|
|
219
|
+
Logger.instance.error("Error reading from interface : #{@name}")
|
|
220
|
+
disconnect()
|
|
221
|
+
raise err
|
|
140
222
|
end
|
|
141
223
|
|
|
142
|
-
# Method to send a packet on the interface.
|
|
143
|
-
#
|
|
224
|
+
# Method to send a packet on the interface.
|
|
225
|
+
# @param packet [Packet] The Packet to send out the interface
|
|
144
226
|
def write(packet)
|
|
145
|
-
raise "Interface write
|
|
227
|
+
raise "Interface not connected for write: #{@name}" unless connected? && write_allowed?
|
|
228
|
+
_write do
|
|
229
|
+
@write_count += 1
|
|
230
|
+
|
|
231
|
+
# Potentially modify packet
|
|
232
|
+
@write_protocols.each do |protocol|
|
|
233
|
+
packet = protocol.write_packet(packet)
|
|
234
|
+
if packet == :DISCONNECT
|
|
235
|
+
disconnect()
|
|
236
|
+
return
|
|
237
|
+
end
|
|
238
|
+
return if packet == :STOP
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
data = convert_packet_to_data(packet)
|
|
242
|
+
|
|
243
|
+
# Potentially modify packet data
|
|
244
|
+
@write_protocols.each do |protocol|
|
|
245
|
+
data = protocol.write_data(data)
|
|
246
|
+
if data == :DISCONNECT
|
|
247
|
+
disconnect()
|
|
248
|
+
return
|
|
249
|
+
end
|
|
250
|
+
return if data == :STOP
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
# Actually write out data if not handled by protocol
|
|
254
|
+
write_interface(data)
|
|
255
|
+
|
|
256
|
+
# Potentially block and wait for response
|
|
257
|
+
@write_protocols.each do |protocol|
|
|
258
|
+
packet, data = protocol.post_write_interface(packet, data)
|
|
259
|
+
if packet == :DISCONNECT
|
|
260
|
+
disconnect()
|
|
261
|
+
return
|
|
262
|
+
end
|
|
263
|
+
return if packet == :STOP
|
|
264
|
+
end
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
return nil
|
|
146
268
|
end
|
|
147
269
|
|
|
148
270
|
# Writes preformatted data onto the interface. Malformed data may cause
|
|
149
|
-
# problems.
|
|
271
|
+
# problems.
|
|
272
|
+
# @param data [String] The raw data to send out the interface
|
|
150
273
|
def write_raw(data)
|
|
151
|
-
raise "Interface write_raw
|
|
274
|
+
raise "Interface not connected for write_raw : #{@name}" unless connected? && write_raw_allowed?
|
|
275
|
+
_write do
|
|
276
|
+
write_interface(data)
|
|
277
|
+
end
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
# Wrap all writes in a mutex and handle errors
|
|
281
|
+
def _write
|
|
282
|
+
@write_mutex.synchronize { yield }
|
|
283
|
+
rescue Exception => err
|
|
284
|
+
Logger.instance.error("Error writing to interface : #{@name}")
|
|
285
|
+
disconnect()
|
|
286
|
+
raise err
|
|
152
287
|
end
|
|
153
288
|
|
|
154
289
|
# @return [Boolean] Whether reading is allowed
|
|
@@ -203,12 +338,18 @@ module Cosmos
|
|
|
203
338
|
other_interface.write_count = self.write_count
|
|
204
339
|
other_interface.bytes_read = self.bytes_read
|
|
205
340
|
other_interface.bytes_written = self.bytes_written
|
|
206
|
-
other_interface.raw_logger_pair = self.raw_logger_pair.clone if
|
|
341
|
+
other_interface.raw_logger_pair = self.raw_logger_pair.clone if @raw_logger_pair
|
|
207
342
|
# num_clients is per interface so don't copy
|
|
208
343
|
# read_queue_size is the number of packets in the queue so don't copy
|
|
209
344
|
# write_queue_size is the number of packets in the queue so don't copy
|
|
210
345
|
other_interface.interfaces = self.interfaces.clone
|
|
211
346
|
other_interface.options = self.options.clone
|
|
347
|
+
other_interface.protocol_info = []
|
|
348
|
+
self.protocol_info.each do |protocol_class, protocol_args, read_write|
|
|
349
|
+
other_interface.add_protocol(protocol_class, protocol_args, read_write)
|
|
350
|
+
end
|
|
351
|
+
other_interface.override_tlm = nil
|
|
352
|
+
other_interface.override_tlm = self.override_tlm.clone if self.override_tlm
|
|
212
353
|
end
|
|
213
354
|
|
|
214
355
|
# Set an interface or router specific option
|
|
@@ -218,14 +359,91 @@ module Cosmos
|
|
|
218
359
|
@options[option_name.upcase] = option_values.clone
|
|
219
360
|
end
|
|
220
361
|
|
|
221
|
-
#
|
|
222
|
-
# identified. It can be used to perform custom processing/monitoring as
|
|
223
|
-
# each packet is received by the CmdTlmServer.
|
|
362
|
+
# Called to convert the read data into a COSMOS Packet object
|
|
224
363
|
#
|
|
225
|
-
# @param
|
|
226
|
-
|
|
364
|
+
# @param data [String] Raw packet data
|
|
365
|
+
# @return [Packet] COSMOS Packet with buffer filled with data
|
|
366
|
+
def convert_data_to_packet(data)
|
|
367
|
+
Packet.new(nil, nil, :BIG_ENDIAN, nil, data)
|
|
227
368
|
end
|
|
228
369
|
|
|
229
|
-
|
|
370
|
+
# Called to convert a packet into the data to send
|
|
371
|
+
#
|
|
372
|
+
# @param packet [Packet] Packet to extract data from
|
|
373
|
+
# @return data
|
|
374
|
+
def convert_packet_to_data(packet)
|
|
375
|
+
packet.buffer(false)
|
|
376
|
+
end
|
|
230
377
|
|
|
231
|
-
|
|
378
|
+
# Called to read data and manipulate it until enough data is
|
|
379
|
+
# returned. The definition of 'enough data' changes depending on the
|
|
380
|
+
# protocol used which is why this method exists. This method is also used
|
|
381
|
+
# to perform operations on the data before it can be interpreted as packet
|
|
382
|
+
# data such as decryption. After this method is called the post_read_data
|
|
383
|
+
# method is called. Subclasses must implement this method.
|
|
384
|
+
#
|
|
385
|
+
# @return [String] Raw packet data
|
|
386
|
+
def read_interface_base(data)
|
|
387
|
+
@read_raw_data_time = Time.now
|
|
388
|
+
@read_raw_data = data.clone
|
|
389
|
+
@bytes_read += data.length
|
|
390
|
+
@raw_logger_pair.read_logger.write(data) if @raw_logger_pair
|
|
391
|
+
end
|
|
392
|
+
|
|
393
|
+
# Called to write data to the underlying interface. Subclasses must
|
|
394
|
+
# implement this method and call super to count the raw bytes and allow raw
|
|
395
|
+
# logging.
|
|
396
|
+
#
|
|
397
|
+
#
|
|
398
|
+
# @param data [String] Raw packet data
|
|
399
|
+
# @return data [String] The exact data written
|
|
400
|
+
def write_interface_base(data)
|
|
401
|
+
@written_raw_data_time = Time.now
|
|
402
|
+
@written_raw_data = data.clone
|
|
403
|
+
@bytes_written += data.length
|
|
404
|
+
@raw_logger_pair.write_logger.write(data) if @raw_logger_pair
|
|
405
|
+
end
|
|
406
|
+
|
|
407
|
+
def add_protocol(protocol_class, protocol_args, read_write)
|
|
408
|
+
protocol_args = protocol_args.clone
|
|
409
|
+
protocol = protocol_class.new(*protocol_args)
|
|
410
|
+
case read_write
|
|
411
|
+
when :READ
|
|
412
|
+
@read_protocols << protocol
|
|
413
|
+
when :WRITE
|
|
414
|
+
@write_protocols.unshift(protocol)
|
|
415
|
+
when :READ_WRITE
|
|
416
|
+
@read_protocols << protocol
|
|
417
|
+
@write_protocols.unshift(protocol)
|
|
418
|
+
else
|
|
419
|
+
raise "Unknown protocol descriptor: #{read_write}. Must be :READ, :WRITE, or :READ_WRITE."
|
|
420
|
+
end
|
|
421
|
+
@protocol_info << [protocol_class, protocol_args, read_write]
|
|
422
|
+
protocol.interface = self
|
|
423
|
+
end
|
|
424
|
+
|
|
425
|
+
def _override_tlm(target_name, packet_name, item_name, value)
|
|
426
|
+
_override(target_name, packet_name, item_name, value, :CONVERTED)
|
|
427
|
+
end
|
|
428
|
+
|
|
429
|
+
def _override_tlm_raw(target_name, packet_name, item_name, value)
|
|
430
|
+
_override(target_name, packet_name, item_name, value, :RAW)
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
def _normalize_tlm(target_name, packet_name, item_name)
|
|
434
|
+
@override_tlm ||= {}
|
|
435
|
+
pkt = @override_tlm[target_name]
|
|
436
|
+
if pkt
|
|
437
|
+
items = @override_tlm[target_name][packet_name]
|
|
438
|
+
items.delete(item_name) if items
|
|
439
|
+
end
|
|
440
|
+
end
|
|
441
|
+
|
|
442
|
+
def _override(target_name, packet_name, item_name, value, type)
|
|
443
|
+
@override_tlm ||= {}
|
|
444
|
+
@override_tlm[target_name] ||= {}
|
|
445
|
+
@override_tlm[target_name][packet_name] ||= {}
|
|
446
|
+
@override_tlm[target_name][packet_name][item_name] = [value, type]
|
|
447
|
+
end
|
|
448
|
+
end
|
|
449
|
+
end
|