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
|
@@ -66,13 +66,53 @@ module Cosmos
|
|
|
66
66
|
# Set the raw value of a telemetry point to a given value. Note this will
|
|
67
67
|
# be over written in a live system by incoming new telemetry.
|
|
68
68
|
# Usage:
|
|
69
|
-
#
|
|
69
|
+
# set_tlm_raw(target_name, packet_name, item_name, value)
|
|
70
70
|
# or
|
|
71
|
-
#
|
|
71
|
+
# set_tlm_raw("target_name packet_name item_name = value")
|
|
72
72
|
def set_tlm_raw(*args)
|
|
73
73
|
return $cmd_tlm_server.set_tlm_raw(*args)
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
+
# Injects a packet into the system as if it was received from an interface
|
|
77
|
+
#
|
|
78
|
+
# @param target_name[String] Target name of the packet
|
|
79
|
+
# @param packet_name[String] Packet name of the packet
|
|
80
|
+
# @param item_hash[Hash] Hash of item_name and value for each item you want to change from the current value table
|
|
81
|
+
# @param value_type[Symbol/String] Type of the values in the item_hash (RAW or CONVERTED)
|
|
82
|
+
# @param send_routers[Boolean] Whether or not to send to routers for the target's interface
|
|
83
|
+
# @param send_packet_log_writers[Boolean] Whether or not to send to the packet log writers for the target's interface
|
|
84
|
+
# @param create_new_logs[Boolean] Whether or not to create new log files before writing this packet to logs
|
|
85
|
+
def inject_tlm(target_name, packet_name, item_hash = nil, value_type = :CONVERTED, send_routers = true, send_packet_log_writers = true, create_new_logs = false)
|
|
86
|
+
return $cmd_tlm_server.inject_tlm(target_name, packet_name, item_hash, value_type, send_routers, send_packet_log_writers, create_new_logs)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Permanently set the converted value of a telemetry point to a given value
|
|
90
|
+
# Usage:
|
|
91
|
+
# override_tlm(target_name, packet_name, item_name, value)
|
|
92
|
+
# or
|
|
93
|
+
# override_tlm("target_name packet_name item_name = value")
|
|
94
|
+
def override_tlm(*args)
|
|
95
|
+
return $cmd_tlm_server.override_tlm(*args)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Permanently set the raw value of a telemetry point to a given value
|
|
99
|
+
# Usage:
|
|
100
|
+
# override_tlm_raw(target_name, packet_name, item_name, value)
|
|
101
|
+
# or
|
|
102
|
+
# override_tlm_raw("target_name packet_name item_name = value")
|
|
103
|
+
def override_tlm_raw(*args)
|
|
104
|
+
return $cmd_tlm_server.override_tlm_raw(*args)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Clear an override of a telemetry point
|
|
108
|
+
# Usage:
|
|
109
|
+
# normalize_tlm(target_name, packet_name, item_name)
|
|
110
|
+
# or
|
|
111
|
+
# normalize_tlm("target_name packet_name item_name")
|
|
112
|
+
def normalize_tlm(*args)
|
|
113
|
+
return $cmd_tlm_server.normalize_tlm(*args)
|
|
114
|
+
end
|
|
115
|
+
|
|
76
116
|
# Gets all the values from the given packet returned in a two dimensional
|
|
77
117
|
# array containing the item_name, value, and limits state.
|
|
78
118
|
# Usage:
|
|
@@ -125,7 +165,7 @@ module Cosmos
|
|
|
125
165
|
# Returns the buffer from the telemetry packet.
|
|
126
166
|
def get_tlm_buffer(target_name, packet_name)
|
|
127
167
|
return $cmd_tlm_server.get_tlm_buffer(target_name, packet_name)
|
|
128
|
-
end
|
|
168
|
+
end
|
|
129
169
|
|
|
130
170
|
# Subscribe to one or more telemetry packets. The queue ID is returned for
|
|
131
171
|
# use in get_packet_data and unsubscribe_packet_data.
|
|
@@ -149,31 +189,12 @@ module Cosmos
|
|
|
149
189
|
def get_packet_data(id, non_block = false)
|
|
150
190
|
results = $cmd_tlm_server.get_packet_data(id, non_block)
|
|
151
191
|
if Array === results and results[3] and results[4]
|
|
152
|
-
results[3] = Time.at(results[3], results[4])
|
|
192
|
+
results[3] = Time.at(results[3], results[4]).sys
|
|
153
193
|
results.delete_at(4)
|
|
154
194
|
end
|
|
155
195
|
results
|
|
156
196
|
end
|
|
157
197
|
|
|
158
|
-
# Get a packet which was previously subscribed to by
|
|
159
|
-
# subscribe_packet_data. This method can block waiting for new packets or
|
|
160
|
-
# not based on the second parameter. It returns a single Cosmos::Packet instance
|
|
161
|
-
# and will return nil when no more packets are buffered (assuming non_block
|
|
162
|
-
# is false).
|
|
163
|
-
# Usage:
|
|
164
|
-
# get_packet(id, <true or false to block>)
|
|
165
|
-
def get_packet(id, non_block = false)
|
|
166
|
-
packet = nil
|
|
167
|
-
buffer, target_name, packet_name, received_time, received_count = get_packet_data(id, non_block)
|
|
168
|
-
if buffer
|
|
169
|
-
packet = System.telemetry.packet(target_name, packet_name).clone
|
|
170
|
-
packet.buffer = buffer
|
|
171
|
-
packet.received_time = received_time
|
|
172
|
-
packet.received_count = received_count
|
|
173
|
-
end
|
|
174
|
-
packet
|
|
175
|
-
end
|
|
176
|
-
|
|
177
198
|
end
|
|
178
199
|
end
|
|
179
200
|
|
data/lib/cosmos/script/tools.rb
CHANGED
|
@@ -13,70 +13,6 @@ module Cosmos
|
|
|
13
13
|
module Script
|
|
14
14
|
private
|
|
15
15
|
|
|
16
|
-
#######################################
|
|
17
|
-
# Methods accessing tlm_viewer
|
|
18
|
-
#######################################
|
|
19
|
-
|
|
20
|
-
def display(display_name, x_pos = nil, y_pos = nil)
|
|
21
|
-
run_tlm_viewer("display", display_name) do |tlm_viewer|
|
|
22
|
-
tlm_viewer.display(display_name, x_pos, y_pos)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def clear(display_name)
|
|
27
|
-
run_tlm_viewer("clear", display_name) do |tlm_viewer|
|
|
28
|
-
tlm_viewer.clear(display_name)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def clear_all(target = nil)
|
|
33
|
-
run_tlm_viewer("clear_all") do |tlm_viewer|
|
|
34
|
-
tlm_viewer.clear_all(target)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def run_tlm_viewer(action, display_name = '')
|
|
39
|
-
tlm_viewer = JsonDRbObject.new "localhost", System.ports['TLMVIEWER_API']
|
|
40
|
-
begin
|
|
41
|
-
yield tlm_viewer
|
|
42
|
-
tlm_viewer.disconnect
|
|
43
|
-
rescue DRb::DRbConnError
|
|
44
|
-
# No Listening Tlm Viewer - So Start One
|
|
45
|
-
start_tlm_viewer
|
|
46
|
-
max_retries = 60
|
|
47
|
-
retry_count = 0
|
|
48
|
-
begin
|
|
49
|
-
yield tlm_viewer
|
|
50
|
-
tlm_viewer.disconnect
|
|
51
|
-
rescue DRb::DRbConnError
|
|
52
|
-
retry_count += 1
|
|
53
|
-
if retry_count < max_retries
|
|
54
|
-
canceled = cosmos_script_sleep(1)
|
|
55
|
-
retry unless canceled
|
|
56
|
-
end
|
|
57
|
-
raise "Unable to Successfully Start Listening Telemetry Viewer: Could not #{action} #{display_name}"
|
|
58
|
-
rescue Errno::ENOENT
|
|
59
|
-
raise "Display Screen File: #{display_name}.txt does not exist"
|
|
60
|
-
end
|
|
61
|
-
rescue Errno::ENOENT
|
|
62
|
-
raise "Display Screen File: #{display_name}.txt does not exist"
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def start_tlm_viewer
|
|
67
|
-
system_file = File.basename(System.initial_filename)
|
|
68
|
-
mac_app = File.join(Cosmos::USERPATH, 'tools', 'mac', 'TlmViewer.app')
|
|
69
|
-
|
|
70
|
-
if Kernel.is_mac? && File.exist?(mac_app)
|
|
71
|
-
Cosmos.run_process("open '#{mac_app}' --args --system #{system_file}")
|
|
72
|
-
else
|
|
73
|
-
cmd = 'ruby'
|
|
74
|
-
cmd << 'w' if Kernel.is_windows? # Windows uses rubyw to avoid creating a DOS shell
|
|
75
|
-
Cosmos.run_process("#{cmd} '#{File.join(Cosmos::USERPATH, 'tools', 'TlmViewer')}' --system #{system_file}")
|
|
76
|
-
end
|
|
77
|
-
cosmos_script_sleep(1)
|
|
78
|
-
end
|
|
79
|
-
|
|
80
16
|
#######################################
|
|
81
17
|
# Methods accessing script runner
|
|
82
18
|
#######################################
|
|
@@ -86,11 +22,15 @@ module Cosmos
|
|
|
86
22
|
end
|
|
87
23
|
|
|
88
24
|
def set_line_delay(delay)
|
|
89
|
-
|
|
25
|
+
if defined? ScriptRunnerFrame
|
|
26
|
+
ScriptRunnerFrame.line_delay = delay if delay >= 0.0
|
|
27
|
+
end
|
|
90
28
|
end
|
|
91
29
|
|
|
92
30
|
def get_line_delay
|
|
93
|
-
|
|
31
|
+
if defined? ScriptRunnerFrame
|
|
32
|
+
ScriptRunnerFrame.line_delay
|
|
33
|
+
end
|
|
94
34
|
end
|
|
95
35
|
|
|
96
36
|
def get_scriptrunner_message_log_filename
|
|
@@ -135,15 +75,21 @@ module Cosmos
|
|
|
135
75
|
end
|
|
136
76
|
|
|
137
77
|
def step_mode
|
|
138
|
-
|
|
78
|
+
if defined? ScriptRunnerFrame
|
|
79
|
+
ScriptRunnerFrame.step_mode = true
|
|
80
|
+
end
|
|
139
81
|
end
|
|
140
82
|
|
|
141
83
|
def run_mode
|
|
142
|
-
|
|
84
|
+
if defined? ScriptRunnerFrame
|
|
85
|
+
ScriptRunnerFrame.step_mode = false
|
|
86
|
+
end
|
|
143
87
|
end
|
|
144
88
|
|
|
145
89
|
def show_backtrace(value = true)
|
|
146
|
-
|
|
90
|
+
if defined? ScriptRunnerFrame
|
|
91
|
+
ScriptRunnerFrame.show_backtrace = value
|
|
92
|
+
end
|
|
147
93
|
end
|
|
148
94
|
|
|
149
95
|
end # module Script
|
|
@@ -9,16 +9,13 @@
|
|
|
9
9
|
# attribution addendums as found in the LICENSE.txt
|
|
10
10
|
|
|
11
11
|
require 'thread' # For Mutex
|
|
12
|
-
require 'timeout' # For Timeout::Error
|
|
13
12
|
require 'cosmos/streams/stream'
|
|
14
13
|
require 'cosmos/config/config_parser'
|
|
15
14
|
require 'cosmos/io/serial_driver'
|
|
16
15
|
|
|
17
16
|
module Cosmos
|
|
18
|
-
|
|
19
17
|
# Stream that reads and writes to serial ports by using {SerialDriver}.
|
|
20
18
|
class SerialStream < Stream
|
|
21
|
-
|
|
22
19
|
# @param write_port_name [String] The name of the serial port to write.
|
|
23
20
|
# Pass nil if the stream is to be read only. On Windows the port name
|
|
24
21
|
# is typically 'COMX' where X can be any port number. On UNIX the port
|
|
@@ -38,13 +35,15 @@ module Cosmos
|
|
|
38
35
|
# complete. Pass nil to create no timeout. The {SerialDriver} will
|
|
39
36
|
# continously try to read data until it has received data or an error
|
|
40
37
|
# occurs.
|
|
38
|
+
# @param flow_control [Symbol] Currently supported :NONE and :RTSCTS
|
|
41
39
|
def initialize(write_port_name,
|
|
42
40
|
read_port_name,
|
|
43
41
|
baud_rate,
|
|
44
42
|
parity,
|
|
45
43
|
stop_bits,
|
|
46
44
|
write_timeout,
|
|
47
|
-
read_timeout
|
|
45
|
+
read_timeout,
|
|
46
|
+
flow_control = :NONE)
|
|
48
47
|
super()
|
|
49
48
|
|
|
50
49
|
# The SerialDriver class will validate the parameters
|
|
@@ -57,6 +56,7 @@ module Cosmos
|
|
|
57
56
|
@write_timeout = @write_timeout.to_f if @write_timeout
|
|
58
57
|
@read_timeout = ConfigParser.handle_nil(read_timeout)
|
|
59
58
|
@read_timeout = @read_timeout.to_f if @read_timeout
|
|
59
|
+
@flow_control = flow_control.to_s.intern
|
|
60
60
|
|
|
61
61
|
if @write_port_name
|
|
62
62
|
@write_serial_port = SerialDriver.new(@write_port_name,
|
|
@@ -64,7 +64,8 @@ module Cosmos
|
|
|
64
64
|
@parity,
|
|
65
65
|
@stop_bits,
|
|
66
66
|
@write_timeout,
|
|
67
|
-
@read_timeout
|
|
67
|
+
@read_timeout,
|
|
68
|
+
@flow_control)
|
|
68
69
|
else
|
|
69
70
|
@write_serial_port = nil
|
|
70
71
|
end
|
|
@@ -77,7 +78,8 @@ module Cosmos
|
|
|
77
78
|
@parity,
|
|
78
79
|
@stop_bits,
|
|
79
80
|
@write_timeout,
|
|
80
|
-
@read_timeout
|
|
81
|
+
@read_timeout,
|
|
82
|
+
@flow_control)
|
|
81
83
|
end
|
|
82
84
|
else
|
|
83
85
|
@read_serial_port = nil
|
|
@@ -97,21 +99,15 @@ module Cosmos
|
|
|
97
99
|
# @return [String] Returns a binary string of data from the serial port
|
|
98
100
|
def read
|
|
99
101
|
raise "Attempt to read from write only stream" unless @read_serial_port
|
|
100
|
-
# No read mutex is needed because
|
|
101
|
-
|
|
102
|
-
data = @read_serial_port.read
|
|
103
|
-
@raw_logger_pair.read_logger.write(data) if @raw_logger_pair
|
|
104
|
-
data
|
|
102
|
+
# No read mutex is needed because reads happen serially
|
|
103
|
+
@read_serial_port.read
|
|
105
104
|
end
|
|
106
105
|
|
|
107
106
|
# @return [String] Returns a binary string of data from the serial port without blocking
|
|
108
107
|
def read_nonblock
|
|
109
108
|
raise "Attempt to read from write only stream" unless @read_serial_port
|
|
110
|
-
# No read mutex is needed because
|
|
111
|
-
|
|
112
|
-
data = @read_serial_port.read_nonblock
|
|
113
|
-
@raw_logger_pair.read_logger.write(data) if @raw_logger_pair
|
|
114
|
-
data
|
|
109
|
+
# No read mutex is needed because reads happen serially
|
|
110
|
+
@read_serial_port.read_nonblock
|
|
115
111
|
end
|
|
116
112
|
|
|
117
113
|
# @param data [String] A binary string of data to write to the serial port
|
|
@@ -119,7 +115,6 @@ module Cosmos
|
|
|
119
115
|
raise "Attempt to write to read only stream" unless @write_serial_port
|
|
120
116
|
@write_mutex.synchronize do
|
|
121
117
|
@write_serial_port.write(data)
|
|
122
|
-
@raw_logger_pair.write_logger.write(data) if @raw_logger_pair
|
|
123
118
|
end
|
|
124
119
|
end
|
|
125
120
|
|
|
@@ -151,7 +146,5 @@ module Cosmos
|
|
|
151
146
|
@connected = false
|
|
152
147
|
end
|
|
153
148
|
end
|
|
154
|
-
|
|
155
149
|
end # class SerialStream
|
|
156
|
-
|
|
157
150
|
end # module Cosmos
|
|
@@ -8,20 +8,13 @@
|
|
|
8
8
|
# as published by the Free Software Foundation; version 3 with
|
|
9
9
|
# attribution addendums as found in the LICENSE.txt
|
|
10
10
|
|
|
11
|
-
require 'timeout' # For Timeout::Error
|
|
12
|
-
|
|
13
11
|
module Cosmos
|
|
14
|
-
|
|
15
12
|
# Class that implments the following methods: read, write(data),
|
|
16
13
|
# connect, connected? and disconnect. Streams are simply data sources which
|
|
17
|
-
# {
|
|
14
|
+
# {Protocol} classes read and write to. This separation of concerns
|
|
18
15
|
# allows Streams to simply focus on getting and sending raw data while the
|
|
19
|
-
# higher level processing occurs in {
|
|
16
|
+
# higher level processing occurs in {Protocol}.
|
|
20
17
|
class Stream
|
|
21
|
-
|
|
22
|
-
# @return [RawLoggerPair] Raw logger pair associated with this stream
|
|
23
|
-
attr_accessor :raw_logger_pair
|
|
24
|
-
|
|
25
18
|
# Expected to return any amount of data on success, or a blank string on
|
|
26
19
|
# closed/EOF, and may raise Timeout::Error, or other errors
|
|
27
20
|
def read
|
|
@@ -57,7 +50,5 @@ module Cosmos
|
|
|
57
50
|
def disconnect
|
|
58
51
|
raise "disconnect not defined by Stream"
|
|
59
52
|
end
|
|
60
|
-
|
|
61
53
|
end # class Stream
|
|
62
|
-
|
|
63
54
|
end # module Cosmos
|
|
@@ -49,8 +49,7 @@ module Cosmos
|
|
|
49
49
|
def read
|
|
50
50
|
raise "Attempt to read from write only stream" unless @read_socket
|
|
51
51
|
|
|
52
|
-
# No read mutex is needed because
|
|
53
|
-
# reading
|
|
52
|
+
# No read mutex is needed because reads happen serially
|
|
54
53
|
if FAST_READ
|
|
55
54
|
begin
|
|
56
55
|
while true # Loop until we get some data
|
|
@@ -77,7 +76,6 @@ module Cosmos
|
|
|
77
76
|
data = ''
|
|
78
77
|
end
|
|
79
78
|
end
|
|
80
|
-
@raw_logger_pair.read_logger.write(data) if @raw_logger_pair
|
|
81
79
|
break
|
|
82
80
|
end
|
|
83
81
|
rescue Errno::ECONNRESET, Errno::ECONNABORTED, IOError, Errno::ENOTSOCK
|
|
@@ -86,7 +84,6 @@ module Cosmos
|
|
|
86
84
|
else
|
|
87
85
|
begin
|
|
88
86
|
data = @read_socket.read_nonblock(65535)
|
|
89
|
-
@raw_logger_pair.read_logger.write(data) if @raw_logger_pair
|
|
90
87
|
rescue IO::WaitReadable
|
|
91
88
|
# Wait for the socket to be ready for reading or for the timeout
|
|
92
89
|
begin
|
|
@@ -118,20 +115,14 @@ module Cosmos
|
|
|
118
115
|
|
|
119
116
|
# @return [String] Returns a binary string of data from the socket. Always returns immediately
|
|
120
117
|
def read_nonblock
|
|
121
|
-
# No read mutex is needed because
|
|
122
|
-
# reading
|
|
118
|
+
# No read mutex is needed because reads happen serially
|
|
123
119
|
begin
|
|
124
120
|
if FAST_READ
|
|
125
121
|
data = @read_socket.read_nonblock(65535, exception: false)
|
|
126
122
|
raise EOFError, 'end of file reached' unless data
|
|
127
|
-
if data == :wait_readable
|
|
128
|
-
data = ''
|
|
129
|
-
else
|
|
130
|
-
@raw_logger_pair.read_logger.write(data) if @raw_logger_pair
|
|
131
|
-
end
|
|
123
|
+
data = '' if data == :wait_readable
|
|
132
124
|
else
|
|
133
125
|
data = @read_socket.read_nonblock(65535)
|
|
134
|
-
@raw_logger_pair.read_logger.write(data) if @raw_logger_pair
|
|
135
126
|
end
|
|
136
127
|
rescue Errno::EAGAIN, Errno::EWOULDBLOCK, Errno::ECONNRESET, Errno::ECONNABORTED, IOError
|
|
137
128
|
data = ''
|
|
@@ -153,7 +144,6 @@ module Cosmos
|
|
|
153
144
|
loop do
|
|
154
145
|
begin
|
|
155
146
|
bytes_sent = @write_socket.write_nonblock(data_to_send)
|
|
156
|
-
@raw_logger_pair.write_logger.write(data_to_send[0..(bytes_sent - 1)]) if @raw_logger_pair and bytes_sent > 0
|
|
157
147
|
rescue Errno::EAGAIN, Errno::EWOULDBLOCK
|
|
158
148
|
# Wait for the socket to be ready for writing or for the timeout
|
|
159
149
|
result = IO.fast_select(nil, [@write_socket], nil, @write_timeout)
|
data/lib/cosmos/system/system.rb
CHANGED
|
@@ -20,7 +20,6 @@ require 'drb/acl'
|
|
|
20
20
|
require 'bundler'
|
|
21
21
|
|
|
22
22
|
module Cosmos
|
|
23
|
-
|
|
24
23
|
# System is the primary entry point into the COSMOS framework. It captures
|
|
25
24
|
# system wide configuration items such as the available ports and paths to
|
|
26
25
|
# various files used by the system. The #commands, #telemetry, and #limits
|
|
@@ -32,14 +31,20 @@ module Cosmos
|
|
|
32
31
|
class System
|
|
33
32
|
# @return [Hash<String,Fixnum>] Hash of all the known ports and their values
|
|
34
33
|
instance_attr_reader :ports
|
|
34
|
+
# @return [Hash<String,String>] Hash of host names or ip addresses for tools to listen on
|
|
35
|
+
instance_attr_reader :listen_hosts
|
|
36
|
+
# @return [Hash<String,String>] Hash of host names or ip addresses for tools to connect to
|
|
37
|
+
instance_attr_reader :connect_hosts
|
|
35
38
|
# @return [Hash<String,String>] Hash of all the known paths and their values
|
|
36
39
|
instance_attr_reader :paths
|
|
37
|
-
# @return [String] Arbitrary string containing the version
|
|
38
|
-
instance_attr_reader :cmd_tlm_version
|
|
39
40
|
# @return [PacketLogWriter] Class used to create log files
|
|
40
41
|
instance_attr_reader :default_packet_log_writer
|
|
42
|
+
# @return [Array<String>] Parameters to be used with the default log writer
|
|
43
|
+
instance_attr_reader :default_packet_log_writer_params
|
|
41
44
|
# @return [PacketLogReader] Class used to read log files
|
|
42
45
|
instance_attr_reader :default_packet_log_reader
|
|
46
|
+
# @return [Array<String>] Parameters to be used with the default log reader
|
|
47
|
+
instance_attr_reader :default_packet_log_reader_params
|
|
43
48
|
# @return [Boolean] Whether to use sound for alerts
|
|
44
49
|
instance_attr_reader :sound
|
|
45
50
|
# @return [Boolean] Whether to use DNS to lookup IP addresses or not
|
|
@@ -58,11 +63,19 @@ module Cosmos
|
|
|
58
63
|
instance_attr_reader :staleness_seconds
|
|
59
64
|
# @return [Symbol] The current limits set
|
|
60
65
|
instance_attr_reader :limits_set
|
|
66
|
+
# @return [Boolean] Whether to use UTC or local times
|
|
67
|
+
instance_attr_reader :use_utc
|
|
68
|
+
# @return [Array<String>] List of files that are to be included in the MD5
|
|
69
|
+
# calculation in addition to the cmd/tlm definition files that are
|
|
70
|
+
# automatically included
|
|
71
|
+
instance_attr_reader :additional_md5_files
|
|
61
72
|
|
|
62
73
|
# Known COSMOS ports
|
|
63
74
|
KNOWN_PORTS = ['CTS_API', 'TLMVIEWER_API', 'CTS_PREIDENTIFIED', 'CTS_CMD_ROUTER']
|
|
75
|
+
# Known COSMOS hosts
|
|
76
|
+
KNOWN_HOSTS = ['CTS_API', 'TLMVIEWER_API', 'CTS_PREIDENTIFIED', 'CTS_CMD_ROUTER']
|
|
64
77
|
# Known COSMOS paths
|
|
65
|
-
KNOWN_PATHS = ['LOGS', 'TMP', 'SAVED_CONFIG', 'TABLES', 'HANDBOOKS', 'PROCEDURES']
|
|
78
|
+
KNOWN_PATHS = ['LOGS', 'TMP', 'SAVED_CONFIG', 'TABLES', 'HANDBOOKS', 'PROCEDURES', 'SEQUENCES']
|
|
66
79
|
|
|
67
80
|
@@instance = nil
|
|
68
81
|
@@instance_mutex = Mutex.new
|
|
@@ -81,14 +94,17 @@ module Cosmos
|
|
|
81
94
|
@commands = nil
|
|
82
95
|
@telemetry = nil
|
|
83
96
|
@limits = nil
|
|
84
|
-
@cmd_tlm_version = nil
|
|
85
97
|
@default_packet_log_writer = PacketLogWriter
|
|
98
|
+
@default_packet_log_writer_params = []
|
|
86
99
|
@default_packet_log_reader = PacketLogReader
|
|
100
|
+
@default_packet_log_reader_params = []
|
|
87
101
|
@sound = false
|
|
88
102
|
@use_dns = false
|
|
89
103
|
@acl = nil
|
|
90
104
|
@staleness_seconds = 30
|
|
91
105
|
@limits_set = :DEFAULT
|
|
106
|
+
@use_utc = false
|
|
107
|
+
@additional_md5_files = []
|
|
92
108
|
|
|
93
109
|
@ports = {}
|
|
94
110
|
@ports['CTS_API'] = 7777
|
|
@@ -96,6 +112,19 @@ module Cosmos
|
|
|
96
112
|
@ports['CTS_PREIDENTIFIED'] = 7779
|
|
97
113
|
@ports['CTS_CMD_ROUTER'] = 7780
|
|
98
114
|
|
|
115
|
+
@listen_hosts = {}
|
|
116
|
+
@listen_hosts['CTS_API'] = '127.0.0.1'
|
|
117
|
+
@listen_hosts['TLMVIEWER_API'] = '127.0.0.1'
|
|
118
|
+
# Localhost would be more secure but historically these are open to allow for chaining servers by default
|
|
119
|
+
@listen_hosts['CTS_PREIDENTIFIED'] = '0.0.0.0'
|
|
120
|
+
@listen_hosts['CTS_CMD_ROUTER'] = '0.0.0.0'
|
|
121
|
+
|
|
122
|
+
@connect_hosts = {}
|
|
123
|
+
@connect_hosts['CTS_API'] = '127.0.0.1'
|
|
124
|
+
@connect_hosts['TLMVIEWER_API'] = '127.0.0.1'
|
|
125
|
+
@connect_hosts['CTS_PREIDENTIFIED'] = '127.0.0.1'
|
|
126
|
+
@connect_hosts['CTS_CMD_ROUTER'] = '127.0.0.1'
|
|
127
|
+
|
|
99
128
|
@paths = {}
|
|
100
129
|
@paths['LOGS'] = File.join(USERPATH, 'outputs', 'logs')
|
|
101
130
|
@paths['TMP'] = File.join(USERPATH, 'outputs', 'tmp')
|
|
@@ -103,6 +132,7 @@ module Cosmos
|
|
|
103
132
|
@paths['TABLES'] = File.join(USERPATH, 'outputs', 'tables')
|
|
104
133
|
@paths['HANDBOOKS'] = File.join(USERPATH, 'outputs', 'handbooks')
|
|
105
134
|
@paths['PROCEDURES'] = [File.join(USERPATH, 'procedures')]
|
|
135
|
+
@paths['SEQUENCES'] = File.join(USERPATH, 'outputs', 'sequences')
|
|
106
136
|
|
|
107
137
|
unless filename
|
|
108
138
|
system_arg = false
|
|
@@ -120,6 +150,7 @@ module Cosmos
|
|
|
120
150
|
|
|
121
151
|
@initial_filename = filename
|
|
122
152
|
@initial_config = nil
|
|
153
|
+
@meta_init_filename = nil
|
|
123
154
|
@@instance = self
|
|
124
155
|
end
|
|
125
156
|
|
|
@@ -186,7 +217,7 @@ module Cosmos
|
|
|
186
217
|
if @config.limits_sets.include?(new_limits_set)
|
|
187
218
|
@limits_set = new_limits_set
|
|
188
219
|
Logger.info("Limits Set Changed to: #{@limits_set}")
|
|
189
|
-
CmdTlmServer.instance.post_limits_event(:LIMITS_SET, System.limits_set) if defined? CmdTlmServer
|
|
220
|
+
CmdTlmServer.instance.post_limits_event(:LIMITS_SET, System.limits_set) if defined? CmdTlmServer && CmdTlmServer.instance
|
|
190
221
|
else
|
|
191
222
|
raise "Unknown limits set requested: #{new_limits_set}"
|
|
192
223
|
end
|
|
@@ -218,12 +249,14 @@ module Cosmos
|
|
|
218
249
|
@targets = {}
|
|
219
250
|
# Set config to nil so things will lazy load later
|
|
220
251
|
@config = nil
|
|
252
|
+
@use_utc = false
|
|
221
253
|
acl_list = []
|
|
222
254
|
all_allowed = false
|
|
223
255
|
first_procedures_path = true
|
|
256
|
+
@additional_md5_files = []
|
|
224
257
|
|
|
225
258
|
Cosmos.set_working_dir do
|
|
226
|
-
parser = ConfigParser.new
|
|
259
|
+
parser = ConfigParser.new("http://cosmosrb.com/docs/system")
|
|
227
260
|
|
|
228
261
|
# First pass - Everything except targets
|
|
229
262
|
parser.parse_file(filename) do |keyword, parameters|
|
|
@@ -238,6 +271,19 @@ module Cosmos
|
|
|
238
271
|
@ports[port_name] = Integer(parameters[1])
|
|
239
272
|
Logger.warn("Unknown port name given: #{port_name}") unless KNOWN_PORTS.include?(port_name)
|
|
240
273
|
|
|
274
|
+
when 'LISTEN_HOST', 'CONNECT_HOST'
|
|
275
|
+
usage = "#{keyword} <HOST NAME> <HOST VALUE>"
|
|
276
|
+
parser.verify_num_parameters(2, 2, usage)
|
|
277
|
+
host_name = parameters[0].to_s.upcase
|
|
278
|
+
host = parameters[1]
|
|
279
|
+
host = '127.0.0.1' if host.to_s.upcase == 'LOCALHOST'
|
|
280
|
+
if keyword == 'LISTEN_HOST'
|
|
281
|
+
@listen_hosts[host_name] = host
|
|
282
|
+
else
|
|
283
|
+
@connect_hosts[host_name] = host
|
|
284
|
+
end
|
|
285
|
+
Logger.warn("Unknown host name given: #{host_name}") unless KNOWN_HOSTS.include?(host_name)
|
|
286
|
+
|
|
241
287
|
when 'PATH'
|
|
242
288
|
usage = "#{keyword} <PATH NAME> <PATH>"
|
|
243
289
|
parser.verify_num_parameters(2, 2, usage)
|
|
@@ -264,14 +310,16 @@ module Cosmos
|
|
|
264
310
|
Logger.warn("Unknown path name given: #{path_name}") unless KNOWN_PATHS.include?(path_name)
|
|
265
311
|
|
|
266
312
|
when 'DEFAULT_PACKET_LOG_WRITER'
|
|
267
|
-
usage = "#{keyword} <FILENAME>"
|
|
268
|
-
parser.verify_num_parameters(1,
|
|
313
|
+
usage = "#{keyword} <FILENAME> <Specific Parameters>"
|
|
314
|
+
parser.verify_num_parameters(1, nil, usage)
|
|
269
315
|
@default_packet_log_writer = Cosmos.require_class(parameters[0])
|
|
316
|
+
@default_packet_log_writer_params = parameters[1..-1] if parameters.size > 1
|
|
270
317
|
|
|
271
318
|
when 'DEFAULT_PACKET_LOG_READER'
|
|
272
|
-
usage = "#{keyword} <FILENAME>"
|
|
273
|
-
parser.verify_num_parameters(1,
|
|
319
|
+
usage = "#{keyword} <FILENAME> <Specific Parameters>"
|
|
320
|
+
parser.verify_num_parameters(1, nil, usage)
|
|
274
321
|
@default_packet_log_reader = Cosmos.require_class(parameters[0])
|
|
322
|
+
@default_packet_log_reader_params = parameters[1..-1] if parameters.size > 1
|
|
275
323
|
|
|
276
324
|
when 'ENABLE_SOUND'
|
|
277
325
|
usage = "#{keyword}"
|
|
@@ -299,7 +347,7 @@ module Cosmos
|
|
|
299
347
|
|
|
300
348
|
unless all_allowed
|
|
301
349
|
first_char = addr[0..0]
|
|
302
|
-
if !((first_char =~ /[1234567890]/)
|
|
350
|
+
if !((first_char =~ /[1234567890]/) || (first_char == '*') || (addr.upcase == 'ALL'))
|
|
303
351
|
# Try to lookup IP Address
|
|
304
352
|
info = Socket.gethostbyname(addr)
|
|
305
353
|
addr = "#{info[3].getbyte(0)}.#{info[3].getbyte(1)}.#{info[3].getbyte(2)}.#{info[3].getbyte(3)}"
|
|
@@ -327,10 +375,23 @@ module Cosmos
|
|
|
327
375
|
parser.verify_num_parameters(1, 1, "#{keyword} <Value in Seconds>")
|
|
328
376
|
@staleness_seconds = Integer(parameters[0])
|
|
329
377
|
|
|
330
|
-
when '
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
378
|
+
when 'META_INIT'
|
|
379
|
+
parser.verify_num_parameters(1, 1, "#{keyword} <Filename>")
|
|
380
|
+
@meta_init_filename = ConfigParser.handle_nil(parameters[0])
|
|
381
|
+
|
|
382
|
+
when 'TIME_ZONE_UTC'
|
|
383
|
+
parser.verify_num_parameters(0, 0, "#{keyword}")
|
|
384
|
+
@use_utc = true
|
|
385
|
+
|
|
386
|
+
when 'ADD_MD5_FILE'
|
|
387
|
+
parser.verify_num_parameters(1, 1, "#{keyword} <Filename>")
|
|
388
|
+
if File.file?(parameters[0])
|
|
389
|
+
@additional_md5_files << File.expand_path(parameters[0])
|
|
390
|
+
elsif File.file?(File.join(Cosmos::USERPATH, parameters[0]))
|
|
391
|
+
@additional_md5_files << File.expand_path(File.join(Cosmos::USERPATH, parameters[0]))
|
|
392
|
+
else
|
|
393
|
+
raise "Missing expected file: #{parameters[0]}"
|
|
394
|
+
end
|
|
334
395
|
|
|
335
396
|
else
|
|
336
397
|
# blank lines will have a nil keyword and should not raise an exception
|
|
@@ -340,6 +401,13 @@ module Cosmos
|
|
|
340
401
|
|
|
341
402
|
@acl = ACL.new(acl_list, ACL::ALLOW_DENY) unless acl_list.empty?
|
|
342
403
|
|
|
404
|
+
# Explicitly set up time to use UTC or local
|
|
405
|
+
if @use_utc
|
|
406
|
+
Time.use_utc()
|
|
407
|
+
else
|
|
408
|
+
Time.use_local()
|
|
409
|
+
end
|
|
410
|
+
|
|
343
411
|
# Second pass - Process targets
|
|
344
412
|
process_targets(parser, filename, configuration_directory)
|
|
345
413
|
|
|
@@ -362,7 +430,6 @@ module Cosmos
|
|
|
362
430
|
unless File.exist? path
|
|
363
431
|
raise parser.error("#{path} must exist", usage)
|
|
364
432
|
end
|
|
365
|
-
system_found = false
|
|
366
433
|
dirs = []
|
|
367
434
|
Dir.foreach(File.join(USERPATH, 'config', 'targets')) { |dir_filename| dirs << dir_filename }
|
|
368
435
|
dirs.sort!
|
|
@@ -373,10 +440,7 @@ module Cosmos
|
|
|
373
440
|
# current directory then it must have been already processed by
|
|
374
441
|
# DECLARE_TARGET so we skip it.
|
|
375
442
|
next if @targets.select {|name, target| target.original_name == dir_filename }.length > 0
|
|
376
|
-
if dir_filename == 'SYSTEM'
|
|
377
|
-
system_found = true
|
|
378
|
-
next
|
|
379
|
-
end
|
|
443
|
+
next if dir_filename == 'SYSTEM'
|
|
380
444
|
target = Target.new(dir_filename)
|
|
381
445
|
@targets[target.name] = target
|
|
382
446
|
else
|
|
@@ -387,10 +451,9 @@ module Cosmos
|
|
|
387
451
|
|
|
388
452
|
auto_detect_gem_based_targets()
|
|
389
453
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
end
|
|
454
|
+
# Make sure SYSTEM target is always present and added last
|
|
455
|
+
target = Target.new('SYSTEM')
|
|
456
|
+
@targets[target.name] = target
|
|
394
457
|
|
|
395
458
|
when 'DECLARE_TARGET'
|
|
396
459
|
usage = "#{keyword} <TARGET NAME> <SUBSTITUTE TARGET NAME (Optional)> <TARGET FILENAME (Optional - defaults to target.txt)>"
|
|
@@ -434,7 +497,7 @@ module Cosmos
|
|
|
434
497
|
# configuration. Pass nil to load the default configuration.
|
|
435
498
|
# @return [String, Exception/nil] The actual configuration loaded
|
|
436
499
|
def load_configuration(name = nil)
|
|
437
|
-
if name
|
|
500
|
+
if name && @config
|
|
438
501
|
# Make sure they're requesting something other than the current
|
|
439
502
|
# configuration.
|
|
440
503
|
if name != @config.name
|
|
@@ -481,7 +544,7 @@ module Cosmos
|
|
|
481
544
|
def auto_detect_gem_based_targets
|
|
482
545
|
Bundler.load.specs.each do |spec|
|
|
483
546
|
spec_name_split = spec.name.split('-')
|
|
484
|
-
if spec_name_split.length > 1
|
|
547
|
+
if spec_name_split.length > 1 && (spec_name_split[0] == 'cosmos')
|
|
485
548
|
# Filter to just targets and not tools and other extensions
|
|
486
549
|
if File.exist?(File.join(spec.gem_dir, 'cmd_tlm'))
|
|
487
550
|
target_name = spec_name_split[1..-1].join('-').to_s.upcase
|
|
@@ -514,7 +577,7 @@ module Cosmos
|
|
|
514
577
|
Cosmos.set_working_dir do
|
|
515
578
|
Dir.foreach(@paths['SAVED_CONFIG']) do |filename|
|
|
516
579
|
full_path = File.join(@paths['SAVED_CONFIG'], filename)
|
|
517
|
-
if Dir.exist?(full_path)
|
|
580
|
+
if Dir.exist?(full_path) && (filename[-32..-1] == name)
|
|
518
581
|
return full_path
|
|
519
582
|
end
|
|
520
583
|
end
|
|
@@ -573,7 +636,7 @@ module Cosmos
|
|
|
573
636
|
end
|
|
574
637
|
end
|
|
575
638
|
|
|
576
|
-
md5 = Cosmos.md5_files(cmd_tlm_files, additional_data)
|
|
639
|
+
md5 = Cosmos.md5_files(cmd_tlm_files + @additional_md5_files, additional_data)
|
|
577
640
|
md5_string = md5.hexdigest
|
|
578
641
|
|
|
579
642
|
# Build filename for marshal file
|
|
@@ -612,13 +675,106 @@ module Cosmos
|
|
|
612
675
|
else
|
|
613
676
|
@config.name = md5_string
|
|
614
677
|
end
|
|
678
|
+
|
|
615
679
|
Cosmos.marshal_dump(marshal_filename, @config)
|
|
616
680
|
end
|
|
681
|
+
setup_system_meta()
|
|
617
682
|
|
|
618
683
|
@initial_config = @config unless @initial_config
|
|
619
684
|
save_configuration()
|
|
620
685
|
end
|
|
621
686
|
|
|
622
|
-
|
|
687
|
+
def setup_system_meta
|
|
688
|
+
# Ensure SYSTEM META is defined and defined correctly
|
|
689
|
+
begin
|
|
690
|
+
tlm_meta = @telemetry.packet('SYSTEM', 'META')
|
|
691
|
+
cmd_meta = @commands.packet('SYSTEM', 'META')
|
|
692
|
+
item = tlm_meta.get_item('PKTID')
|
|
693
|
+
raise "PKTID Incorrect" unless (item.bit_size == 8) && (item.bit_offset == 0)
|
|
694
|
+
item = cmd_meta.get_item('PKTID')
|
|
695
|
+
raise "PKTID Incorrect" unless (item.bit_size == 8) && (item.bit_offset == 0)
|
|
696
|
+
item = tlm_meta.get_item('CONFIG')
|
|
697
|
+
raise "CONFIG Incorrect" unless (item.bit_size == 256) && (item.bit_offset == 8)
|
|
698
|
+
item = cmd_meta.get_item('CONFIG')
|
|
699
|
+
raise "CONFIG Incorrect" unless (item.bit_size == 256) && (item.bit_offset == 8)
|
|
700
|
+
item = tlm_meta.get_item('COSMOS_VERSION')
|
|
701
|
+
raise "CONFIG Incorrect" unless (item.bit_size == 240) && (item.bit_offset == 264)
|
|
702
|
+
item = cmd_meta.get_item('COSMOS_VERSION')
|
|
703
|
+
raise "CONFIG Incorrect" unless (item.bit_size == 240) && (item.bit_offset == 264)
|
|
704
|
+
item = tlm_meta.get_item('USER_VERSION')
|
|
705
|
+
raise "CONFIG Incorrect" unless (item.bit_size == 240) && (item.bit_offset == 504)
|
|
706
|
+
item = cmd_meta.get_item('USER_VERSION')
|
|
707
|
+
raise "CONFIG Incorrect" unless (item.bit_size == 240) && (item.bit_offset == 504)
|
|
708
|
+
item = tlm_meta.get_item('RUBY_VERSION')
|
|
709
|
+
raise "CONFIG Incorrect" unless (item.bit_size == 240) && (item.bit_offset == 744)
|
|
710
|
+
item = cmd_meta.get_item('RUBY_VERSION')
|
|
711
|
+
raise "CONFIG Incorrect" unless (item.bit_size == 240) && (item.bit_offset == 744)
|
|
712
|
+
rescue
|
|
713
|
+
Logger.error "SYSTEM META not defined or defined incorrectly - defaulting"
|
|
714
|
+
|
|
715
|
+
cmd_meta = Packet.new('SYSTEM', 'META', :BIG_ENDIAN)
|
|
716
|
+
item = cmd_meta.append_item('PKTID', 8, :UINT, nil, :BIG_ENDIAN, :ERROR, nil, nil, nil, 1)
|
|
717
|
+
item.range = 1..1
|
|
718
|
+
item.default = 1
|
|
719
|
+
item.description = 'Packet Id'
|
|
720
|
+
item = cmd_meta.append_item('CONFIG', 32 * 8, :STRING)
|
|
721
|
+
item.default = ''
|
|
722
|
+
item.description = 'Configuration Name'
|
|
723
|
+
item = cmd_meta.append_item('COSMOS_VERSION', 30 * 8, :STRING)
|
|
724
|
+
item.default = ''
|
|
725
|
+
item.description = 'COSMOS Version'
|
|
726
|
+
item = cmd_meta.append_item('USER_VERSION', 30 * 8, :STRING)
|
|
727
|
+
item.default = ''
|
|
728
|
+
item.description = 'User Project Version'
|
|
729
|
+
item = cmd_meta.append_item('RUBY_VERSION', 30 * 8, :STRING)
|
|
730
|
+
item.default = ''
|
|
731
|
+
item.description = 'Ruby Version'
|
|
732
|
+
@config.commands['SYSTEM'] ||= {}
|
|
733
|
+
@config.commands['SYSTEM']['META'] = cmd_meta
|
|
734
|
+
|
|
735
|
+
tlm_meta = Packet.new('SYSTEM', 'META', :BIG_ENDIAN)
|
|
736
|
+
item = tlm_meta.append_item('PKTID', 8, :UINT, nil, :BIG_ENDIAN, :ERROR, nil, nil, nil, 1)
|
|
737
|
+
item.description = 'Packet Id'
|
|
738
|
+
item = tlm_meta.append_item('CONFIG', 32 * 8, :STRING)
|
|
739
|
+
item.description = 'Configuration Name'
|
|
740
|
+
item = tlm_meta.append_item('COSMOS_VERSION', 30 * 8, :STRING)
|
|
741
|
+
item.description = 'COSMOS Version'
|
|
742
|
+
item = tlm_meta.append_item('USER_VERSION', 30 * 8, :STRING)
|
|
743
|
+
item.description = 'User Project Version'
|
|
744
|
+
item = tlm_meta.append_item('RUBY_VERSION', 30 * 8, :STRING)
|
|
745
|
+
item.description = 'Ruby Version'
|
|
746
|
+
@config.telemetry['SYSTEM'] ||= {}
|
|
747
|
+
@config.telemetry['SYSTEM']['META'] = tlm_meta
|
|
748
|
+
end
|
|
623
749
|
|
|
624
|
-
|
|
750
|
+
# Initialize the meta packet (if given init filename)
|
|
751
|
+
if @meta_init_filename
|
|
752
|
+
parser = ConfigParser.new("http://cosmosrb.com/docs/cmdtlm")
|
|
753
|
+
Cosmos.set_working_dir do
|
|
754
|
+
parser.parse_file(@meta_init_filename) do |keyword, params|
|
|
755
|
+
begin
|
|
756
|
+
item = tlm_meta.get_item(keyword)
|
|
757
|
+
if (item.data_type == :STRING) || (item.data_type == :BLOCK)
|
|
758
|
+
value = params[0]
|
|
759
|
+
else
|
|
760
|
+
value = params[0].convert_to_value
|
|
761
|
+
end
|
|
762
|
+
tlm_meta.write(keyword, value)
|
|
763
|
+
rescue => err
|
|
764
|
+
raise parser.error(err, "ITEM_NAME VALUE")
|
|
765
|
+
end
|
|
766
|
+
end
|
|
767
|
+
end
|
|
768
|
+
end
|
|
769
|
+
|
|
770
|
+
# Setup fixed part of SYSTEM META packet
|
|
771
|
+
tlm_meta.write('PKTID', 1)
|
|
772
|
+
tlm_meta.write('CONFIG', @config.name)
|
|
773
|
+
tlm_meta.write('COSMOS_VERSION', "#{COSMOS_VERSION}")
|
|
774
|
+
tlm_meta.write('USER_VERSION', USER_VERSION) if defined? USER_VERSION
|
|
775
|
+
tlm_meta.write('RUBY_VERSION', "#{RUBY_VERSION}p#{RUBY_PATCHLEVEL}")
|
|
776
|
+
|
|
777
|
+
cmd_meta.buffer = tlm_meta.buffer
|
|
778
|
+
end
|
|
779
|
+
end
|
|
780
|
+
end
|