cosmos 3.9.2 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,55 @@
|
|
1
|
+
# encoding: ascii-8bit
|
2
|
+
|
3
|
+
# Copyright 2014 Ball Aerospace & Technologies Corp.
|
4
|
+
# All Rights Reserved.
|
5
|
+
#
|
6
|
+
# This program is free software; you can modify and/or redistribute it
|
7
|
+
# under the terms of the GNU General Public License
|
8
|
+
# as published by the Free Software Foundation; version 3 with
|
9
|
+
# attribution addendums as found in the LICENSE.txt
|
10
|
+
|
11
|
+
require 'cosmos'
|
12
|
+
require 'cosmos/tools/tlm_viewer/widgets/widget'
|
13
|
+
|
14
|
+
module Cosmos
|
15
|
+
|
16
|
+
# SpacerWidget class
|
17
|
+
#
|
18
|
+
class SpacerWidget < Qt::Widget
|
19
|
+
include Widget
|
20
|
+
|
21
|
+
def initialize(parent_layout, width, height, hpolicy="MINIMUM", vpolicy="MINIMUM")
|
22
|
+
super()
|
23
|
+
if parent_layout
|
24
|
+
spacer_item = Qt::SpacerItem.new(width.to_i,
|
25
|
+
height.to_i,
|
26
|
+
size_policy(hpolicy),
|
27
|
+
size_policy(vpolicy))
|
28
|
+
parent_layout.addItem(spacer_item)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def size_policy(str)
|
33
|
+
case str.upcase
|
34
|
+
when 'FIXED'
|
35
|
+
return Qt::SizePolicy::Fixed
|
36
|
+
when 'MINIMUM'
|
37
|
+
return Qt::SizePolicy::Minimum
|
38
|
+
when 'MAXIMUM'
|
39
|
+
return Qt::SizePolicy::Maximum
|
40
|
+
when 'PREFERRED'
|
41
|
+
return Qt::SizePolicy::Preferred
|
42
|
+
when 'EXPANDING'
|
43
|
+
return Qt::SizePolicy::Expanding
|
44
|
+
when 'MINIMUMEXPANDING'
|
45
|
+
return Qt::SizePolicy::MinimumExpanding
|
46
|
+
when 'IGNORED'
|
47
|
+
return Qt::SizePolicy::Ignored
|
48
|
+
else
|
49
|
+
return Qt::SizePolicy::Minimum
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end # module Cosmos
|
@@ -20,15 +20,16 @@ module Cosmos
|
|
20
20
|
include Widget
|
21
21
|
include LayoutWidget
|
22
22
|
|
23
|
-
def initialize(parent_layout = nil, vSpacing = 3)
|
23
|
+
def initialize(parent_layout = nil, vSpacing = 3, vPack = true)
|
24
24
|
super()
|
25
25
|
setSpacing(vSpacing.to_i)
|
26
26
|
parent_layout.addLayout(self) if parent_layout
|
27
|
+
@v_pack = ConfigParser::handle_true_false(vPack)
|
27
28
|
end
|
28
29
|
|
29
30
|
def process_settings
|
30
31
|
super()
|
31
|
-
addStretch(1)
|
32
|
+
addStretch(1) if @v_pack
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
@@ -20,17 +20,18 @@ module Cosmos
|
|
20
20
|
include Widget
|
21
21
|
include LayoutWidget
|
22
22
|
|
23
|
-
def initialize(parent_layout = nil, title = "", vSpacing = 3)
|
23
|
+
def initialize(parent_layout = nil, title = "", vSpacing = 3, vPack = true)
|
24
24
|
super()
|
25
25
|
box = Qt::GroupBox.new(title.to_s)
|
26
26
|
setSpacing(vSpacing.to_i)
|
27
27
|
box.setLayout(self)
|
28
28
|
parent_layout.addWidget(box) if parent_layout
|
29
|
+
@v_pack = ConfigParser::handle_true_false(vPack)
|
29
30
|
end
|
30
31
|
|
31
32
|
def process_settings
|
32
33
|
super()
|
33
|
-
addStretch(1)
|
34
|
+
addStretch(1) if @v_pack
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
@@ -11,6 +11,7 @@
|
|
11
11
|
require 'cosmos'
|
12
12
|
require 'cosmos/gui/dialogs/tlm_details_dialog'
|
13
13
|
require 'cosmos/gui/dialogs/tlm_edit_dialog'
|
14
|
+
require 'cosmos/gui/dialogs/tlm_graph_dialog'
|
14
15
|
|
15
16
|
module Cosmos
|
16
17
|
|
@@ -153,6 +154,12 @@ module Cosmos
|
|
153
154
|
@settings.each do |setting_name, setting_values|
|
154
155
|
begin
|
155
156
|
case setting_name
|
157
|
+
when 'TEXTALIGN'
|
158
|
+
sheet << "qproperty-alignment:Align#{setting_values[0].capitalize}"
|
159
|
+
when 'PADDING'
|
160
|
+
sheet << "padding:#{setting_values[0]}"
|
161
|
+
when 'MARGIN'
|
162
|
+
sheet << "margin:#{setting_values[0]}"
|
156
163
|
when 'BACKCOLOR'
|
157
164
|
case setting_values.size
|
158
165
|
when 1 # color name
|
@@ -215,8 +222,9 @@ module Cosmos
|
|
215
222
|
packets = System.telemetry.latest_packets(@target_name, @item_name)
|
216
223
|
offset = 0
|
217
224
|
packets.each do |packet|
|
218
|
-
|
219
|
-
|
225
|
+
dialog = TlmDetailsDialog.new(nil, @target_name, packet.packet_name, @item_name)
|
226
|
+
dialog.move(dialog.x + offset, dialog.y + offset)
|
227
|
+
@dialogs << dialog
|
220
228
|
offset += 30
|
221
229
|
end
|
222
230
|
else
|
@@ -236,13 +244,7 @@ module Cosmos
|
|
236
244
|
|
237
245
|
graph = Qt::Action.new("Graph #{@target_name} #{@packet_name} #{@item_name}", menu)
|
238
246
|
graph.connect(SIGNAL('triggered()')) do
|
239
|
-
|
240
|
-
Cosmos.run_process("rubyw tools/TlmGrapher -i \"#{@target_name} #{@packet_name} #{@item_name}\" --system #{File.basename(System.initial_filename)}")
|
241
|
-
elsif Kernel.is_mac? and File.exist?("tools/mac/TlmGrapher.app")
|
242
|
-
Cosmos.run_process("open tools/mac/TlmGrapher.app --args -i \"#{@target_name} #{@packet_name} #{@item_name}\" --system #{File.basename(System.initial_filename)}")
|
243
|
-
else
|
244
|
-
Cosmos.run_process("ruby tools/TlmGrapher -i \"#{@target_name} #{@packet_name} #{@item_name}\" --system #{File.basename(System.initial_filename)}")
|
245
|
-
end
|
247
|
+
TlmGraphDialog.new(self, target_name, packet_name, item_name)
|
246
248
|
end
|
247
249
|
menu.addAction(graph)
|
248
250
|
|
@@ -251,7 +253,5 @@ module Cosmos
|
|
251
253
|
point.dispose
|
252
254
|
menu.dispose
|
253
255
|
end
|
254
|
-
|
255
256
|
end
|
256
|
-
|
257
|
-
end # module Cosmos
|
257
|
+
end
|
data/lib/cosmos/top_level.rb
CHANGED
@@ -70,15 +70,17 @@ module Cosmos
|
|
70
70
|
$VERBOSE = saved_verbose
|
71
71
|
end
|
72
72
|
|
73
|
-
# Searches for the
|
73
|
+
# Searches for the /config/system and /config/targets directories to define
|
74
|
+
# the USERPATH constant
|
74
75
|
#
|
75
|
-
# @param start_dir [String] Path to start the search for
|
76
|
-
# search will continue by moving up
|
77
|
-
# reached.
|
76
|
+
# @param start_dir [String] Path to start the search for the /config/system
|
77
|
+
# and /config/targets directories. The search will continue by moving up
|
78
|
+
# directories until the root directory is reached.
|
78
79
|
def self.define_user_path(start_dir = Dir.pwd)
|
79
80
|
current_dir = File.expand_path(start_dir)
|
80
81
|
while true
|
81
|
-
if File.exist?(File.join(current_dir, '
|
82
|
+
if File.exist?(File.join(current_dir, 'config', 'system')) and
|
83
|
+
File.exist?(File.join(current_dir, 'config', 'targets'))
|
82
84
|
disable_warnings do
|
83
85
|
Cosmos.const_set(:USERPATH, current_dir)
|
84
86
|
end
|
@@ -113,7 +115,7 @@ module Cosmos
|
|
113
115
|
Cosmos.const_set(:USERPATH, ENV['COSMOS_USERPATH'])
|
114
116
|
end
|
115
117
|
else
|
116
|
-
# Give up and assume we are in the tools directory
|
118
|
+
# Give up and assume we are in the tools directory
|
117
119
|
disable_warnings do
|
118
120
|
Cosmos.const_set(:USERPATH, File.expand_path(File.join(File.dirname($0), '..')))
|
119
121
|
end
|
@@ -572,7 +574,7 @@ module Cosmos
|
|
572
574
|
retry_count = 0
|
573
575
|
begin
|
574
576
|
yield
|
575
|
-
rescue
|
577
|
+
rescue => error
|
576
578
|
Logger.error "#{name} thread unexpectedly died. Retries: #{retry_count} of #{retry_attempts}"
|
577
579
|
Logger.error error.formatted
|
578
580
|
retry_count += 1
|
@@ -589,30 +591,38 @@ module Cosmos
|
|
589
591
|
# convention of having a single class per file where the class name is camel
|
590
592
|
# cased and filename is lowercase with underscores.
|
591
593
|
#
|
592
|
-
# @param
|
594
|
+
# @param class_name_or_class_filename [String] The name of the class or the file which contains the
|
593
595
|
# Ruby class to require
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
return klass
|
596
|
+
# @param log_error [Boolean] Whether to log an error if we can not require
|
597
|
+
# the class
|
598
|
+
def self.require_class(class_name_or_class_filename, log_error = true)
|
599
|
+
if class_name_or_class_filename.downcase[-3..-1] == '.rb' or (class_name_or_class_filename[0] == class_name_or_class_filename[0].downcase)
|
600
|
+
class_filename = class_name_or_class_filename
|
601
|
+
class_name = class_filename.filename_to_class_name
|
601
602
|
else
|
602
|
-
|
603
|
+
class_name = class_name_or_class_filename
|
604
|
+
class_filename = class_name.class_name_to_filename
|
603
605
|
end
|
606
|
+
return class_name.to_class if class_name.to_class and defined? class_name.to_class
|
607
|
+
self.require_file(class_filename, log_error)
|
608
|
+
klass = class_name.to_class
|
609
|
+
raise "Ruby class #{class_name} not found" unless klass
|
610
|
+
klass
|
604
611
|
end
|
605
612
|
|
606
613
|
# Requires a file with a standard error message if it fails
|
607
614
|
#
|
608
615
|
# @param filename [String] The name of the file to require
|
609
|
-
|
616
|
+
# @param log_error [Boolean] Whether to log an error if we can not require
|
617
|
+
# the class
|
618
|
+
def self.require_file(filename, log_error = true)
|
610
619
|
begin
|
611
620
|
require filename
|
612
621
|
rescue Exception => err
|
613
|
-
msg = "Unable to require #{filename} due to #{err.message}.
|
614
|
-
|
615
|
-
|
622
|
+
msg = "Unable to require #{filename} due to #{err.message}. "\
|
623
|
+
"Ensure #{filename} is in the COSMOS lib directory."
|
624
|
+
Logger.error msg if log_error
|
625
|
+
raise $!, msg, $!.backtrace
|
616
626
|
end
|
617
627
|
end
|
618
628
|
|
@@ -705,8 +715,8 @@ module Cosmos
|
|
705
715
|
if owner and owner.respond_to? :graceful_kill
|
706
716
|
if Thread.current != thread
|
707
717
|
owner.graceful_kill
|
708
|
-
end_time = Time.now + graceful_timeout
|
709
|
-
while thread.alive? && ((end_time - Time.now) > 0)
|
718
|
+
end_time = Time.now.sys + graceful_timeout
|
719
|
+
while thread.alive? && ((end_time - Time.now.sys) > 0)
|
710
720
|
sleep(timeout_interval)
|
711
721
|
end
|
712
722
|
else
|
@@ -719,8 +729,8 @@ module Cosmos
|
|
719
729
|
# Graceful failed
|
720
730
|
Logger.warn "Failed to gracefully kill thread:\n Caller Backtrace:\n #{caller().join("\n ")}\n \n Thread Backtrace:\n #{thread.backtrace.join("\n ")}\n\n"
|
721
731
|
thread.kill
|
722
|
-
end_time = Time.now + hard_timeout
|
723
|
-
while thread.alive? && ((end_time - Time.now) > 0)
|
732
|
+
end_time = Time.now.sys + hard_timeout
|
733
|
+
while thread.alive? && ((end_time - Time.now.sys) > 0)
|
724
734
|
sleep(timeout_interval)
|
725
735
|
end
|
726
736
|
end
|
data/lib/cosmos/utilities/crc.rb
CHANGED
@@ -8,13 +8,32 @@
|
|
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 'cosmos/ext/crc'
|
11
|
+
require 'cosmos/ext/crc' if RUBY_ENGINE == 'ruby' and !ENV['COSMOS_NO_EXT']
|
12
12
|
|
13
13
|
module Cosmos
|
14
14
|
|
15
15
|
# Abstract base class which {Crc16}, {Crc32} and {Crc64} use. Do NOT use this
|
16
16
|
# class directly but instead use one of the subclasses.
|
17
17
|
class Crc
|
18
|
+
BIT_REVERSE_TABLE = [
|
19
|
+
0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
|
20
|
+
0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8,
|
21
|
+
0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4,
|
22
|
+
0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC,
|
23
|
+
0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2,
|
24
|
+
0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA,
|
25
|
+
0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6,
|
26
|
+
0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE,
|
27
|
+
0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1, 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1,
|
28
|
+
0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9,
|
29
|
+
0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5,
|
30
|
+
0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD,
|
31
|
+
0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3,
|
32
|
+
0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB,
|
33
|
+
0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7, 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7,
|
34
|
+
0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF
|
35
|
+
]
|
36
|
+
|
18
37
|
# @return [Integer] The polynomial used when calcuating the CRC
|
19
38
|
attr_reader :poly
|
20
39
|
# @return [Integer] Seed value used to start the calulation
|
@@ -38,20 +57,33 @@ module Cosmos
|
|
38
57
|
@seed = seed
|
39
58
|
@xor = xor
|
40
59
|
@reflect = reflect
|
41
|
-
|
60
|
+
if RUBY_ENGINE == 'ruby' and !ENV['COSMOS_NO_EXT']
|
61
|
+
@table = ''
|
62
|
+
else
|
63
|
+
@table = []
|
64
|
+
end
|
42
65
|
|
43
66
|
# Determine which class we're using: Crc16, Crc32, Crc64
|
44
|
-
|
45
|
-
case
|
67
|
+
@bit_size = self.class.name[-2..-1].to_i
|
68
|
+
case @bit_size
|
46
69
|
when 16
|
47
70
|
pack = 'S'
|
71
|
+
filter_mask = 0xFFFF
|
48
72
|
when 32
|
49
73
|
pack = 'I'
|
74
|
+
filter_mask = 0xFFFFFFFF
|
50
75
|
when 64
|
51
76
|
pack = 'Q'
|
77
|
+
filter_mask = 0xFFFFFFFFFFFFFFFF
|
52
78
|
end
|
53
|
-
|
54
|
-
|
79
|
+
if RUBY_ENGINE == 'ruby' and !ENV['COSMOS_NO_EXT']
|
80
|
+
(0..255).each do |index|
|
81
|
+
@table << [compute_table_entry(index, @bit_size)].pack(pack)
|
82
|
+
end
|
83
|
+
else
|
84
|
+
(0..255).each do |index|
|
85
|
+
@table << (compute_table_entry(index, @bit_size) & filter_mask)
|
86
|
+
end
|
55
87
|
end
|
56
88
|
end
|
57
89
|
|
@@ -64,6 +96,76 @@ module Cosmos
|
|
64
96
|
# to use the default seed set in the constructor.
|
65
97
|
# @return [Integer] The CRC value
|
66
98
|
|
99
|
+
def bit_reverse_8(value)
|
100
|
+
BIT_REVERSE_TABLE[value & 0xFF]
|
101
|
+
end
|
102
|
+
|
103
|
+
def bit_reverse_16(value)
|
104
|
+
(BIT_REVERSE_TABLE[value & 0xFF] << 8) |
|
105
|
+
(BIT_REVERSE_TABLE[(value >> 8) & 0xFF])
|
106
|
+
end
|
107
|
+
|
108
|
+
def bit_reverse_32(value)
|
109
|
+
(BIT_REVERSE_TABLE[value & 0xFF] << 24) |
|
110
|
+
(BIT_REVERSE_TABLE[(value >> 8) & 0xFF] << 16) |
|
111
|
+
(BIT_REVERSE_TABLE[(value >> 16) & 0xFF] << 8) |
|
112
|
+
(BIT_REVERSE_TABLE[(value >> 24) & 0xFF])
|
113
|
+
end
|
114
|
+
|
115
|
+
def bit_reverse_64(value)
|
116
|
+
(BIT_REVERSE_TABLE[value & 0x00000000000000FF] << 56) |
|
117
|
+
(BIT_REVERSE_TABLE[(value >> 8) & 0x00000000000000FF] << 48) |
|
118
|
+
(BIT_REVERSE_TABLE[(value >> 16) & 0x00000000000000FF] << 40) |
|
119
|
+
(BIT_REVERSE_TABLE[(value >> 24) & 0x00000000000000FF] << 32) |
|
120
|
+
(BIT_REVERSE_TABLE[(value >> 32) & 0x00000000000000FF] << 24) |
|
121
|
+
(BIT_REVERSE_TABLE[(value >> 40) & 0x00000000000000FF] << 16) |
|
122
|
+
(BIT_REVERSE_TABLE[(value >> 48) & 0x00000000000000FF] << 8) |
|
123
|
+
(BIT_REVERSE_TABLE[(value >> 56) & 0x00000000000000FF])
|
124
|
+
end
|
125
|
+
|
126
|
+
if RUBY_ENGINE != 'ruby' or ENV['COSMOS_NO_EXT']
|
127
|
+
def calc(data, seed = @seed)
|
128
|
+
crc = seed
|
129
|
+
|
130
|
+
case @bit_size
|
131
|
+
when 16
|
132
|
+
right_shift = 8
|
133
|
+
filter_mask = 0xFFFF
|
134
|
+
final_bit_reverse = method(:bit_reverse_16)
|
135
|
+
when 32
|
136
|
+
right_shift = 24
|
137
|
+
filter_mask = 0xFFFFFFFF
|
138
|
+
final_bit_reverse = method(:bit_reverse_32)
|
139
|
+
when 64
|
140
|
+
right_shift = 56
|
141
|
+
filter_mask = 0xFFFFFFFFFFFFFFFF
|
142
|
+
final_bit_reverse = method(:bit_reverse_64)
|
143
|
+
end
|
144
|
+
|
145
|
+
if @reflect
|
146
|
+
data.each_byte do |byte|
|
147
|
+
crc = ((crc << 8) & filter_mask) ^ @table[(crc >> right_shift) ^ bit_reverse_8(byte)]
|
148
|
+
end
|
149
|
+
|
150
|
+
if @xor
|
151
|
+
return final_bit_reverse.call(crc ^ filter_mask)
|
152
|
+
else
|
153
|
+
return final_bit_reverse.call(crc)
|
154
|
+
end
|
155
|
+
else
|
156
|
+
data.each_byte do |byte|
|
157
|
+
crc = ((crc << 8) & filter_mask) ^ @table[(crc >> right_shift) ^ byte]
|
158
|
+
end
|
159
|
+
|
160
|
+
if @xor
|
161
|
+
return crc ^ filter_mask
|
162
|
+
else
|
163
|
+
return crc
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
67
169
|
protected
|
68
170
|
|
69
171
|
# Compute a single entry in the crc lookup table
|
data/lib/cosmos/utilities/csv.rb
CHANGED
@@ -11,7 +11,6 @@
|
|
11
11
|
require 'csv'
|
12
12
|
|
13
13
|
module Cosmos
|
14
|
-
|
15
14
|
# Reads in a comma separated values (CSV) configuration file and
|
16
15
|
# allows access via the Hash bracket syntax. It allows the user to write
|
17
16
|
# back data to the configuration file to store state.
|
@@ -43,6 +42,47 @@ module Cosmos
|
|
43
42
|
@hash[index]
|
44
43
|
end
|
45
44
|
|
45
|
+
# Convenience method to access a value by key and convert it to a boolean.
|
46
|
+
# The csv value must be 'TRUE' or 'FALSE' (case doesn't matter)
|
47
|
+
# and will be converted to Ruby true or false values.
|
48
|
+
#
|
49
|
+
# @param item [String] Key to access the value
|
50
|
+
# @param index [Integer] Which value to return
|
51
|
+
# @return [Boolean] Single value converted to a boolean (true or false)
|
52
|
+
def bool(item, index = 0)
|
53
|
+
raise "#{item} not found" unless keys.include?(item)
|
54
|
+
case @hash[item][index].upcase
|
55
|
+
when 'TRUE'
|
56
|
+
true
|
57
|
+
when 'FALSE'
|
58
|
+
false
|
59
|
+
else
|
60
|
+
raise "#{item} value of #{@hash[item][index]} not boolean. Must be 'TRUE' 'or 'FALSE'."
|
61
|
+
end
|
62
|
+
end
|
63
|
+
alias boolean bool
|
64
|
+
|
65
|
+
# Convenience method to access a value by key and convert it to an integer
|
66
|
+
#
|
67
|
+
# @param item [String] Key to access the value
|
68
|
+
# @param index [Integer] Which value to return
|
69
|
+
# @return [Integer] Single value converted to an integer
|
70
|
+
def int(item, index = 0)
|
71
|
+
raise "#{item} not found" unless keys.include?(item)
|
72
|
+
@hash[item][index].to_i
|
73
|
+
end
|
74
|
+
alias integer int
|
75
|
+
|
76
|
+
# Convenience method to access a value by key and convert it to a float
|
77
|
+
#
|
78
|
+
# @param item [String] Key to access the value
|
79
|
+
# @param index [Integer] Which value to return
|
80
|
+
# @return [Float] Single value converted to a float
|
81
|
+
def float(item, index = 0)
|
82
|
+
raise "#{item} not found" unless keys.include?(item)
|
83
|
+
@hash[item][index].to_f
|
84
|
+
end
|
85
|
+
|
46
86
|
# Creates a copy of the CSV file passed into the constructor. The file will
|
47
87
|
# be prefixed by the current date and time to create a unique filename.
|
48
88
|
# By default this file is created in the COSMOS/logs directory. Subsequent
|
@@ -52,10 +92,22 @@ module Cosmos
|
|
52
92
|
# @param path [String] Path location to create the archive file. If nil the
|
53
93
|
# file will be created in COSMOS/logs.
|
54
94
|
def create_archive(path = nil)
|
55
|
-
|
95
|
+
close_archive() if @archive
|
56
96
|
path = System.paths['LOGS'] if path.nil?
|
57
|
-
|
58
|
-
|
97
|
+
|
98
|
+
attempt = nil
|
99
|
+
while true
|
100
|
+
name = File.build_timestamped_filename([File.basename(@filename, '.csv'), attempt], '.csv')
|
101
|
+
@archive_file = File.join(path, name)
|
102
|
+
if File.exist?(@archive_file)
|
103
|
+
attempt ||= 0
|
104
|
+
attempt += 1
|
105
|
+
else
|
106
|
+
break
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
@archive = File.open(@archive_file, "w")
|
59
111
|
@hash.each do |key, values|
|
60
112
|
@archive.puts "#{key},#{values.join(',')}"
|
61
113
|
end
|
@@ -63,21 +115,23 @@ module Cosmos
|
|
63
115
|
end
|
64
116
|
|
65
117
|
# Write the archive file created by #{CSV#create_archive}. This method will
|
66
|
-
# append a
|
67
|
-
# array into a CSV entry.
|
118
|
+
# append a row to the archive file by joining writing the value.
|
68
119
|
#
|
69
|
-
# @param [Array]
|
70
|
-
|
71
|
-
|
72
|
-
@archive
|
120
|
+
# @param value [Objct|Array] Simply value to write to the end of the
|
121
|
+
# archive or array of values which will be written out as CSV
|
122
|
+
def write_archive(value)
|
123
|
+
create_archive() unless @archive
|
124
|
+
if value.is_a? Array
|
125
|
+
@archive.puts value.join(',')
|
126
|
+
else
|
127
|
+
@archive.puts value
|
128
|
+
end
|
73
129
|
end
|
74
130
|
|
75
|
-
# Closes the archive file created by #{CSV#create_archive}.
|
76
|
-
# called, {#write_archive} will throw an exception.
|
131
|
+
# Closes the archive file created by #{CSV#create_archive}.
|
77
132
|
def close_archive
|
78
133
|
@archive.close
|
79
134
|
@archive = nil
|
80
135
|
end
|
81
|
-
|
82
|
-
end # class Csv
|
136
|
+
end
|
83
137
|
end
|