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
@@ -22,7 +22,7 @@ module Cosmos
|
|
22
22
|
if no_hazardous
|
23
23
|
Logger.warn "Command #{target_name} #{cmd_name} being sent ignoring hazardous warnings"
|
24
24
|
end
|
25
|
-
Logger.info build_cmd_output_string(target_name, cmd_name, cmd_params, raw)
|
25
|
+
Logger.info System.commands.build_cmd_output_string(target_name, cmd_name, cmd_params, raw)
|
26
26
|
end
|
27
27
|
|
28
28
|
# Send the command and log the results
|
@@ -171,7 +171,7 @@ module Cosmos
|
|
171
171
|
results = $cmd_tlm_server.get_cmd_time(target_name, command_name)
|
172
172
|
if Array === results
|
173
173
|
if results[2] and results[3]
|
174
|
-
results[2] = Time.at(results[2], results[3])
|
174
|
+
results[2] = Time.at(results[2], results[3]).sys
|
175
175
|
end
|
176
176
|
results.delete_at(3)
|
177
177
|
end
|
@@ -15,10 +15,19 @@ module Cosmos
|
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
|
-
def add_cmd_parameter(keyword, value, cmd_params)
|
18
|
+
def add_cmd_parameter(keyword, value, packet, cmd_params)
|
19
19
|
quotes_removed = value.remove_quotes
|
20
|
+
begin
|
21
|
+
type = packet.items[keyword].data_type
|
22
|
+
rescue
|
23
|
+
type = nil
|
24
|
+
end
|
20
25
|
if value == quotes_removed
|
21
|
-
|
26
|
+
if (type == :STRING or type == :BLOCK) and value.upcase.start_with?("0X")
|
27
|
+
cmd_params[keyword] = value.hex_to_byte_string
|
28
|
+
else
|
29
|
+
cmd_params[keyword] = value.convert_to_value
|
30
|
+
end
|
22
31
|
else
|
23
32
|
cmd_params[keyword] = quotes_removed
|
24
33
|
end
|
@@ -36,6 +45,12 @@ module Cosmos
|
|
36
45
|
target_name = first_half[0]
|
37
46
|
cmd_name = first_half[1]
|
38
47
|
cmd_params = {}
|
48
|
+
|
49
|
+
begin
|
50
|
+
packet = System.commands.packet(target_name, cmd_name).clone
|
51
|
+
rescue
|
52
|
+
packet = nil
|
53
|
+
end
|
39
54
|
|
40
55
|
if split_string.length == 2
|
41
56
|
# Extract Command Parameters
|
@@ -60,14 +75,14 @@ module Cosmos
|
|
60
75
|
unless comma
|
61
76
|
raise "Missing comma in command parameters: #{text}" if item != ','
|
62
77
|
end
|
63
|
-
add_cmd_parameter(keyword, value, cmd_params)
|
78
|
+
add_cmd_parameter(keyword, value, packet, cmd_params)
|
64
79
|
keyword = nil
|
65
80
|
value = nil
|
66
81
|
comma = nil
|
67
82
|
end
|
68
83
|
if keyword
|
69
84
|
if value
|
70
|
-
add_cmd_parameter(keyword, value, cmd_params)
|
85
|
+
add_cmd_parameter(keyword, value, packet, cmd_params)
|
71
86
|
else
|
72
87
|
raise "Missing value for last command parameter: #{text}"
|
73
88
|
end
|
data/lib/cosmos/script/limits.rb
CHANGED
@@ -102,6 +102,8 @@ module Cosmos
|
|
102
102
|
result[1][3] = result[1][3].to_s.intern if result[1][3]
|
103
103
|
elsif result[0] == :STALE_PACKET
|
104
104
|
# Nothing extra to do
|
105
|
+
elsif result[0] == :STALE_PACKET_RCVD
|
106
|
+
# Nothing extra to do
|
105
107
|
else
|
106
108
|
result[1] = result[1].to_s.intern
|
107
109
|
end
|
data/lib/cosmos/script/script.rb
CHANGED
@@ -49,7 +49,7 @@ module Cosmos
|
|
49
49
|
$cmd_tlm_server = CmdTlmServer.new(config_file, false, true)
|
50
50
|
else
|
51
51
|
# Start a Json connect to the real CTS server
|
52
|
-
$cmd_tlm_server = JsonDRbObject.new(
|
52
|
+
$cmd_tlm_server = JsonDRbObject.new(System.connect_hosts['CTS_API'], System.ports['CTS_API'])
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -9,15 +9,17 @@
|
|
9
9
|
# attribution addendums as found in the LICENSE.txt
|
10
10
|
|
11
11
|
require 'cosmos/script/extract'
|
12
|
+
require 'cosmos/script/api_shared'
|
12
13
|
|
13
14
|
module Cosmos
|
14
15
|
module Script
|
15
|
-
DEFAULT_TLM_POLLING_RATE = 0.25
|
16
|
-
|
17
16
|
private
|
18
17
|
# Include various methods to extract fields from text
|
19
18
|
include Extract
|
20
19
|
|
20
|
+
# Include additional shared functionality
|
21
|
+
include ApiShared
|
22
|
+
|
21
23
|
def play_wav_file(wav_filename)
|
22
24
|
Cosmos.play_wav_file(wav_filename)
|
23
25
|
end
|
@@ -98,788 +100,6 @@ module Cosmos
|
|
98
100
|
_file_dialog(message, directory, false)
|
99
101
|
end
|
100
102
|
|
101
|
-
# Creates a string with the parameters upcased
|
102
|
-
def _upcase(target_name, packet_name, item_name)
|
103
|
-
"#{target_name.upcase} #{packet_name.upcase} #{item_name.upcase}"
|
104
|
-
end
|
105
|
-
|
106
|
-
# Implementaiton of the various check commands. It yields back to the
|
107
|
-
# caller to allow the return of the value through various telemetry calls.
|
108
|
-
# This method should not be called directly by application code.
|
109
|
-
def _check(*args)
|
110
|
-
target_name, packet_name, item_name, comparison_to_eval = check_process_args(args, 'check')
|
111
|
-
value = yield(target_name, packet_name, item_name)
|
112
|
-
if comparison_to_eval
|
113
|
-
check_eval(target_name, packet_name, item_name, comparison_to_eval, value)
|
114
|
-
else
|
115
|
-
Logger.info "CHECK: #{_upcase(target_name, packet_name, item_name)} == #{value}"
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
# Check the converted value of a telmetry item against a condition
|
120
|
-
# Always print the value of the telemetry item to STDOUT
|
121
|
-
# If the condition check fails, raise an error
|
122
|
-
# Supports two signatures:
|
123
|
-
# check(target_name, packet_name, item_name, comparison_to_eval)
|
124
|
-
# or
|
125
|
-
# check('target_name packet_name item_name > 1')
|
126
|
-
def check(*args)
|
127
|
-
_check(*args) {|tgt,pkt,item| tlm(tgt,pkt,item) }
|
128
|
-
end
|
129
|
-
|
130
|
-
# Check the formatted value of a telmetry item against a condition
|
131
|
-
# Always print the value of the telemetry item to STDOUT
|
132
|
-
# If the condition check fails, raise an error
|
133
|
-
# Supports two signatures:
|
134
|
-
# check(target_name, packet_name, item_name, comparison_to_eval)
|
135
|
-
# or
|
136
|
-
# check('target_name packet_name item_name > 1')
|
137
|
-
def check_formatted(*args)
|
138
|
-
_check(*args) {|tgt,pkt,item| tlm_formatted(tgt,pkt,item) }
|
139
|
-
end
|
140
|
-
|
141
|
-
# Check the formatted with units value of a telmetry item against a condition
|
142
|
-
# Always print the value of the telemetry item to STDOUT
|
143
|
-
# If the condition check fails, raise an error
|
144
|
-
# Supports two signatures:
|
145
|
-
# check(target_name, packet_name, item_name, comparison_to_eval)
|
146
|
-
# or
|
147
|
-
# check('target_name packet_name item_name > 1')
|
148
|
-
def check_with_units(*args)
|
149
|
-
_check(*args) {|tgt,pkt,item| tlm_with_units(tgt,pkt,item) }
|
150
|
-
end
|
151
|
-
|
152
|
-
# Check the raw value of a telmetry item against a condition
|
153
|
-
# Always print the value of the telemetry item to STDOUT
|
154
|
-
# If the condition check fails, raise an error
|
155
|
-
# Supports two signatures:
|
156
|
-
# check(target_name, packet_name, item_name, comparison_to_eval)
|
157
|
-
# or
|
158
|
-
# check('target_name packet_name item_name > 1')
|
159
|
-
def check_raw(*args)
|
160
|
-
_check(*args) {|tgt,pkt,item| tlm_raw(tgt,pkt,item) }
|
161
|
-
end
|
162
|
-
|
163
|
-
def _check_tolerance(*args)
|
164
|
-
target_name, packet_name, item_name, expected_value, tolerance =
|
165
|
-
check_tolerance_process_args(args, 'check_tolerance')
|
166
|
-
value = yield(target_name, packet_name, item_name)
|
167
|
-
range = (expected_value - tolerance)..(expected_value + tolerance)
|
168
|
-
check_str = "CHECK: #{_upcase(target_name, packet_name, item_name)}"
|
169
|
-
range_str = "range #{range.first} to #{range.last} with value == #{value}"
|
170
|
-
if range.include?(value)
|
171
|
-
Logger.info "#{check_str} was within #{range_str}"
|
172
|
-
else
|
173
|
-
message = "#{check_str} failed to be within #{range_str}"
|
174
|
-
if $cmd_tlm_disconnect
|
175
|
-
Logger.error message
|
176
|
-
else
|
177
|
-
raise CheckError, message
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
# Check the converted value of a telmetry item against an expected value with a tolerance
|
183
|
-
# Always print the value of the telemetry item to STDOUT
|
184
|
-
# If the condition check fails, raise an error
|
185
|
-
# Supports two signatures:
|
186
|
-
# check_tolerance(target_name, packet_name, item_name, expected_value, tolerance)
|
187
|
-
# or
|
188
|
-
# check_tolerance('target_name packet_name item_name', expected_value, tolerance)
|
189
|
-
def check_tolerance(*args)
|
190
|
-
_check_tolerance(*args) {|tgt,pkt,item| tlm(tgt,pkt,item) }
|
191
|
-
end
|
192
|
-
|
193
|
-
# Check the raw value of a telmetry item against an expected value with a tolerance
|
194
|
-
# Always print the value of the telemetry item to STDOUT
|
195
|
-
# If the condition check fails, raise an error
|
196
|
-
# Supports two signatures:
|
197
|
-
# check_tolerance_raw(target_name, packet_name, item_name, expected_value, tolerance)
|
198
|
-
# or
|
199
|
-
# check_tolerance_raw('target_name packet_name item_name', expected_value, tolerance)
|
200
|
-
def check_tolerance_raw(*args)
|
201
|
-
_check_tolerance(*args) {|tgt,pkt,item| tlm_raw(tgt,pkt,item) }
|
202
|
-
end
|
203
|
-
|
204
|
-
# Check to see if an expression is true without waiting. If the expression
|
205
|
-
# is not true, the script will pause.
|
206
|
-
def check_expression(exp_to_eval, context = nil)
|
207
|
-
success = cosmos_script_wait_implementation_expression(exp_to_eval, 0, DEFAULT_TLM_POLLING_RATE, context)
|
208
|
-
if success
|
209
|
-
Logger.info "CHECK: #{exp_to_eval} is TRUE"
|
210
|
-
else
|
211
|
-
message = "CHECK: #{exp_to_eval} is FALSE"
|
212
|
-
if $cmd_tlm_disconnect
|
213
|
-
Logger.error message
|
214
|
-
else
|
215
|
-
raise CheckError, message
|
216
|
-
end
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
# Wait on an expression to be true. On a timeout, the script will continue.
|
221
|
-
# Supports multiple signatures:
|
222
|
-
# wait(time)
|
223
|
-
# wait('target_name packet_name item_name > 1', timeout, polling_rate)
|
224
|
-
# wait('target_name', 'packet_name', 'item_name', comparison_to_eval, timeout, polling_rate)
|
225
|
-
def wait(*args)
|
226
|
-
wait_process_args(args, 'wait', :CONVERTED)
|
227
|
-
end
|
228
|
-
|
229
|
-
# Wait on an expression to be true. On a timeout, the script will continue.
|
230
|
-
# Supports multiple signatures:
|
231
|
-
# wait(time)
|
232
|
-
# wait_raw('target_name packet_name item_name > 1', timeout, polling_rate)
|
233
|
-
# wait_raw('target_name', 'packet_name', 'item_name', comparison_to_eval, timeout, polling_rate)
|
234
|
-
def wait_raw(*args)
|
235
|
-
wait_process_args(args, 'wait_raw', :RAW)
|
236
|
-
end
|
237
|
-
|
238
|
-
def _wait_tolerance(raw, *args)
|
239
|
-
type = (raw ? :RAW : :CONVERTED)
|
240
|
-
type_string = 'wait_tolerance'
|
241
|
-
type_string << '_raw' if raw
|
242
|
-
target_name, packet_name, item_name, expected_value, tolerance, timeout, polling_rate = wait_tolerance_process_args(args, type_string)
|
243
|
-
start_time = Time.now
|
244
|
-
success, value = cosmos_script_wait_implementation_tolerance(target_name, packet_name, item_name, type, expected_value, tolerance, timeout, polling_rate)
|
245
|
-
time = Time.now - start_time
|
246
|
-
range = (expected_value - tolerance)..(expected_value + tolerance)
|
247
|
-
wait_str = "WAIT: #{_upcase(target_name, packet_name, item_name)}"
|
248
|
-
range_str = "range #{range.first} to #{range.last} with value == #{value} after waiting #{time} seconds"
|
249
|
-
if success
|
250
|
-
Logger.info "#{wait_str} was within #{range_str}"
|
251
|
-
else
|
252
|
-
Logger.warn "#{wait_str} failed to be within #{range_str}"
|
253
|
-
end
|
254
|
-
time
|
255
|
-
end
|
256
|
-
|
257
|
-
# Wait on an expression to be true. On a timeout, the script will continue.
|
258
|
-
# Supports multiple signatures:
|
259
|
-
# wait_tolerance('target_name packet_name item_name', expected_value, tolerance, timeout, polling_rate)
|
260
|
-
# wait_tolerance('target_name', 'packet_name', 'item_name', expected_value, tolerance, timeout, polling_rate)
|
261
|
-
def wait_tolerance(*args)
|
262
|
-
_wait_tolerance(false, *args)
|
263
|
-
end
|
264
|
-
|
265
|
-
# Wait on an expression to be true. On a timeout, the script will continue.
|
266
|
-
# Supports multiple signatures:
|
267
|
-
# wait_tolerance_raw('target_name packet_name item_name', expected_value, tolerance, timeout, polling_rate)
|
268
|
-
# wait_tolerance_raw('target_name', 'packet_name', 'item_name', expected_value, tolerance, timeout, polling_rate)
|
269
|
-
def wait_tolerance_raw(*args)
|
270
|
-
_wait_tolerance(true, *args)
|
271
|
-
end
|
272
|
-
|
273
|
-
# Wait on a custom expression to be true
|
274
|
-
def wait_expression(exp_to_eval, timeout, polling_rate = DEFAULT_TLM_POLLING_RATE, context = nil)
|
275
|
-
start_time = Time.now
|
276
|
-
success = cosmos_script_wait_implementation_expression(exp_to_eval, timeout, polling_rate, context)
|
277
|
-
time = Time.now - start_time
|
278
|
-
if success
|
279
|
-
Logger.info "WAIT: #{exp_to_eval} is TRUE after waiting #{time} seconds"
|
280
|
-
else
|
281
|
-
Logger.warn "WAIT: #{exp_to_eval} is FALSE after waiting #{time} seconds"
|
282
|
-
end
|
283
|
-
time
|
284
|
-
end
|
285
|
-
|
286
|
-
def _wait_check(raw, *args)
|
287
|
-
type = (raw ? :RAW : :CONVERTED)
|
288
|
-
target_name, packet_name, item_name, comparison_to_eval, timeout, polling_rate = wait_check_process_args(args, 'wait_check')
|
289
|
-
start_time = Time.now
|
290
|
-
success, value = cosmos_script_wait_implementation(target_name, packet_name, item_name, type, comparison_to_eval, timeout, polling_rate)
|
291
|
-
time = Time.now - start_time
|
292
|
-
check_str = "CHECK: #{_upcase(target_name, packet_name, item_name)} #{comparison_to_eval}"
|
293
|
-
with_value_str = "with value == #{value} after waiting #{time} seconds"
|
294
|
-
if success
|
295
|
-
Logger.info "#{check_str} success #{with_value_str}"
|
296
|
-
else
|
297
|
-
message = "#{check_str} failed #{with_value_str}"
|
298
|
-
if $cmd_tlm_disconnect
|
299
|
-
Logger.error message
|
300
|
-
else
|
301
|
-
raise CheckError, message
|
302
|
-
end
|
303
|
-
end
|
304
|
-
time
|
305
|
-
end
|
306
|
-
|
307
|
-
# Wait for the converted value of a telmetry item against a condition or for a timeout
|
308
|
-
# and then check against the condition
|
309
|
-
# Supports two signatures:
|
310
|
-
# wait_check(target_name, packet_name, item_name, comparison_to_eval, timeout, polling_rate)
|
311
|
-
# or
|
312
|
-
# wait_check('target_name packet_name item_name > 1', timeout, polling_rate)
|
313
|
-
def wait_check(*args)
|
314
|
-
_wait_check(false, *args)
|
315
|
-
end
|
316
|
-
|
317
|
-
# Wait for the raw value of a telmetry item against a condition or for a timeout
|
318
|
-
# and then check against the condition
|
319
|
-
# Supports two signatures:
|
320
|
-
# wait_check_raw(target_name, packet_name, item_name, comparison_to_eval, timeout, polling_rate)
|
321
|
-
# or
|
322
|
-
# wait_check_raw('target_name packet_name item_name > 1', timeout, polling_rate)
|
323
|
-
def wait_check_raw(*args)
|
324
|
-
_wait_check(true, *args)
|
325
|
-
end
|
326
|
-
|
327
|
-
def _wait_check_tolerance(raw, *args)
|
328
|
-
type_string = 'wait_check_tolerance'
|
329
|
-
type_string << '_raw' if raw
|
330
|
-
type = (raw ? :RAW : :CONVERTED)
|
331
|
-
target_name, packet_name, item_name, expected_value, tolerance, timeout, polling_rate = wait_tolerance_process_args(args, type_string)
|
332
|
-
start_time = Time.now
|
333
|
-
success, value = cosmos_script_wait_implementation_tolerance(target_name, packet_name, item_name, type, expected_value, tolerance, timeout, polling_rate)
|
334
|
-
time = Time.now - start_time
|
335
|
-
range = (expected_value - tolerance)..(expected_value + tolerance)
|
336
|
-
check_str = "CHECK: #{_upcase(target_name, packet_name, item_name)}"
|
337
|
-
range_str = "range #{range.first} to #{range.last} with value == #{value} after waiting #{time} seconds"
|
338
|
-
if success
|
339
|
-
Logger.info "#{check_str} was within #{range_str}"
|
340
|
-
else
|
341
|
-
message = "#{check_str} failed to be within #{range_str}"
|
342
|
-
if $cmd_tlm_disconnect
|
343
|
-
Logger.error message
|
344
|
-
else
|
345
|
-
raise CheckError, message
|
346
|
-
end
|
347
|
-
end
|
348
|
-
time
|
349
|
-
end
|
350
|
-
|
351
|
-
def wait_check_tolerance(*args)
|
352
|
-
_wait_check_tolerance(false, *args)
|
353
|
-
end
|
354
|
-
|
355
|
-
def wait_check_tolerance_raw(*args)
|
356
|
-
_wait_check_tolerance(true, *args)
|
357
|
-
end
|
358
|
-
|
359
|
-
# Wait on an expression to be true. On a timeout, the script will pause.
|
360
|
-
def wait_check_expression(exp_to_eval,
|
361
|
-
timeout,
|
362
|
-
polling_rate = DEFAULT_TLM_POLLING_RATE,
|
363
|
-
context = nil)
|
364
|
-
start_time = Time.now
|
365
|
-
success = cosmos_script_wait_implementation_expression(exp_to_eval,
|
366
|
-
timeout,
|
367
|
-
polling_rate,
|
368
|
-
context)
|
369
|
-
time = Time.now - start_time
|
370
|
-
if success
|
371
|
-
Logger.info "CHECK: #{exp_to_eval} is TRUE after waiting #{time} seconds"
|
372
|
-
else
|
373
|
-
message = "CHECK: #{exp_to_eval} is FALSE after waiting #{time} seconds"
|
374
|
-
if $cmd_tlm_disconnect
|
375
|
-
Logger.error message
|
376
|
-
else
|
377
|
-
raise CheckError, message
|
378
|
-
end
|
379
|
-
end
|
380
|
-
time
|
381
|
-
end
|
382
|
-
alias wait_expression_stop_on_timeout wait_check_expression
|
383
|
-
|
384
|
-
# Wait for a telemetry packet to be received a certain number of times or timeout
|
385
|
-
def _wait_packet(check,
|
386
|
-
target_name,
|
387
|
-
packet_name,
|
388
|
-
num_packets,
|
389
|
-
timeout,
|
390
|
-
polling_rate = DEFAULT_TLM_POLLING_RATE)
|
391
|
-
type = (check ? 'CHECK' : 'WAIT')
|
392
|
-
initial_count = tlm(target_name, packet_name, 'RECEIVED_COUNT')
|
393
|
-
start_time = Time.now
|
394
|
-
success, value = cosmos_script_wait_implementation(target_name,
|
395
|
-
packet_name,
|
396
|
-
'RECEIVED_COUNT',
|
397
|
-
:CONVERTED,
|
398
|
-
">= #{initial_count + num_packets}",
|
399
|
-
timeout,
|
400
|
-
polling_rate)
|
401
|
-
time = Time.now - start_time
|
402
|
-
if success
|
403
|
-
Logger.info "#{type}: #{target_name.upcase} #{packet_name.upcase} received #{value - initial_count} times after waiting #{time} seconds"
|
404
|
-
else
|
405
|
-
message = "#{type}: #{target_name.upcase} #{packet_name.upcase} expected to be received #{num_packets} times but only received #{value - initial_count} times after waiting #{time} seconds"
|
406
|
-
if check
|
407
|
-
if $cmd_tlm_disconnect
|
408
|
-
Logger.error message
|
409
|
-
else
|
410
|
-
raise CheckError, message
|
411
|
-
end
|
412
|
-
else
|
413
|
-
Logger.warn message
|
414
|
-
end
|
415
|
-
end
|
416
|
-
time
|
417
|
-
end
|
418
|
-
|
419
|
-
def wait_packet(target_name,
|
420
|
-
packet_name,
|
421
|
-
num_packets,
|
422
|
-
timeout,
|
423
|
-
polling_rate = DEFAULT_TLM_POLLING_RATE)
|
424
|
-
_wait_packet(false, target_name, packet_name, num_packets, timeout, polling_rate)
|
425
|
-
end
|
426
|
-
|
427
|
-
# Wait for a telemetry packet to be received a certain number of times or timeout and raise an error
|
428
|
-
def wait_check_packet(target_name,
|
429
|
-
packet_name,
|
430
|
-
num_packets,
|
431
|
-
timeout,
|
432
|
-
polling_rate = DEFAULT_TLM_POLLING_RATE)
|
433
|
-
_wait_packet(true, target_name, packet_name, num_packets, timeout, polling_rate)
|
434
|
-
end
|
435
|
-
|
436
|
-
def _get_procedure_path(procedure_name)
|
437
|
-
# Handle not-giving an extension
|
438
|
-
procedure_name_with_extension = nil
|
439
|
-
procedure_name_with_extension = procedure_name + '.rb' if File.extname(procedure_name).empty?
|
440
|
-
|
441
|
-
path = nil
|
442
|
-
|
443
|
-
# Find filename in search path
|
444
|
-
($:).each do |directory|
|
445
|
-
if File.exist?(directory + '/' + procedure_name) and not File.directory?(directory + '/' + procedure_name)
|
446
|
-
path = directory + '/' + procedure_name
|
447
|
-
break
|
448
|
-
end
|
449
|
-
|
450
|
-
if procedure_name_with_extension and File.exist?(directory + '/' + procedure_name_with_extension)
|
451
|
-
procedure_name = procedure_name_with_extension
|
452
|
-
path = directory + '/' + procedure_name
|
453
|
-
break
|
454
|
-
end
|
455
|
-
end
|
456
|
-
|
457
|
-
# Handle absolute path
|
458
|
-
path = procedure_name if !path and File.exist?(procedure_name)
|
459
|
-
path = procedure_name_with_extension if !path and procedure_name_with_extension and File.exist?(procedure_name_with_extension)
|
460
|
-
|
461
|
-
raise LoadError, "Procedure not found -- #{procedure_name}" unless path
|
462
|
-
path
|
463
|
-
end
|
464
|
-
|
465
|
-
def check_file_cache_for_instrumented_script(path, md5)
|
466
|
-
instrumented_script = nil
|
467
|
-
cached = true
|
468
|
-
use_file_cache = true
|
469
|
-
|
470
|
-
Cosmos.set_working_dir do
|
471
|
-
cache_path = File.join(System.paths['TMP'], 'script_runner')
|
472
|
-
unless File.directory?(cache_path)
|
473
|
-
# Try to create .cache directory
|
474
|
-
begin
|
475
|
-
Dir.mkdir(cache_path)
|
476
|
-
rescue
|
477
|
-
use_file_cache = false
|
478
|
-
end
|
479
|
-
end
|
480
|
-
|
481
|
-
cache_filename = nil
|
482
|
-
if use_file_cache
|
483
|
-
# Check file based instrumented cache
|
484
|
-
flat_path = path.tr("/", "_").gsub("\\", "_").tr(":", "_").tr(" ", "_")
|
485
|
-
flat_path_with_md5 = flat_path + '_' + md5
|
486
|
-
cache_filename = File.join(cache_path, flat_path_with_md5)
|
487
|
-
end
|
488
|
-
|
489
|
-
if use_file_cache and File.exist?(cache_filename)
|
490
|
-
# Use file cached instrumentation
|
491
|
-
File.open(cache_filename, 'r') {|file| instrumented_script = file.read}
|
492
|
-
else
|
493
|
-
cached = false
|
494
|
-
|
495
|
-
# Build instrumentation
|
496
|
-
file_text = ''
|
497
|
-
begin
|
498
|
-
file_text = File.read(path)
|
499
|
-
rescue Exception => error
|
500
|
-
raise "Error reading procedure file : #{path}"
|
501
|
-
end
|
502
|
-
|
503
|
-
instrumented_script = ScriptRunnerFrame.instrument_script(file_text, path, true)
|
504
|
-
|
505
|
-
# Cache instrumentation into file
|
506
|
-
if use_file_cache
|
507
|
-
begin
|
508
|
-
File.open(cache_filename, 'w') {|file| file.write(instrumented_script)}
|
509
|
-
rescue
|
510
|
-
# Oh well, failed to write cache file
|
511
|
-
end
|
512
|
-
end
|
513
|
-
end
|
514
|
-
end
|
515
|
-
[instrumented_script, cached]
|
516
|
-
end
|
517
|
-
|
518
|
-
def start(procedure_name)
|
519
|
-
cached = true
|
520
|
-
path = _get_procedure_path(procedure_name)
|
521
|
-
|
522
|
-
if defined? ScriptRunnerFrame and ScriptRunnerFrame.instance
|
523
|
-
md5 = nil
|
524
|
-
begin
|
525
|
-
md5 = Cosmos.md5_files([path]).hexdigest
|
526
|
-
rescue Exception => error
|
527
|
-
raise "Error calculating md5 on procedure file : #{path}"
|
528
|
-
end
|
529
|
-
|
530
|
-
# Check RAM based instrumented cache
|
531
|
-
instrumented_cache = ScriptRunnerFrame.instrumented_cache[path]
|
532
|
-
instrumented_script = nil
|
533
|
-
if instrumented_cache and md5 == instrumented_cache[1]
|
534
|
-
# Use cached instrumentation
|
535
|
-
instrumented_script = instrumented_cache[0]
|
536
|
-
else
|
537
|
-
instrumented_script, cached = check_file_cache_for_instrumented_script(path, md5)
|
538
|
-
# Cache instrumentation into RAM
|
539
|
-
ScriptRunnerFrame.instrumented_cache[path] = [instrumented_script, md5]
|
540
|
-
end
|
541
|
-
|
542
|
-
Object.class_eval(instrumented_script, path, 1)
|
543
|
-
else # No ScriptRunnerFrame so just start it locally
|
544
|
-
cached = false
|
545
|
-
begin
|
546
|
-
Kernel::load(path)
|
547
|
-
rescue LoadError => error
|
548
|
-
raise LoadError, "Error loading -- #{procedure_name}\n#{error.message}"
|
549
|
-
end
|
550
|
-
end
|
551
|
-
# Return whether we had to load and instrument this file, i.e. it was not cached
|
552
|
-
!cached
|
553
|
-
end
|
554
|
-
|
555
|
-
# Require an additional ruby file
|
556
|
-
def load_utility(procedure_name)
|
557
|
-
not_cached = false
|
558
|
-
if defined? ScriptRunnerFrame and ScriptRunnerFrame.instance
|
559
|
-
saved = ScriptRunnerFrame.instance.use_instrumentation
|
560
|
-
begin
|
561
|
-
ScriptRunnerFrame.instance.use_instrumentation = false
|
562
|
-
not_cached = start(procedure_name)
|
563
|
-
ensure
|
564
|
-
ScriptRunnerFrame.instance.use_instrumentation = saved
|
565
|
-
end
|
566
|
-
else # Just call start
|
567
|
-
not_cached = start(procedure_name)
|
568
|
-
end
|
569
|
-
# Return whether we had to load and instrument this file, i.e. it was not cached
|
570
|
-
# This is designed to match the behavior of Ruby's require and load keywords
|
571
|
-
not_cached
|
572
|
-
end
|
573
|
-
alias require_utility load_utility
|
574
|
-
|
575
|
-
##########################################
|
576
|
-
# Protected Methods
|
577
|
-
##########################################
|
578
|
-
|
579
|
-
def check_process_args(args, function_name)
|
580
|
-
case args.length
|
581
|
-
when 1
|
582
|
-
target_name, packet_name, item_name, comparison_to_eval = extract_fields_from_check_text(args[0])
|
583
|
-
when 4
|
584
|
-
target_name = args[0]
|
585
|
-
packet_name = args[1]
|
586
|
-
item_name = args[2]
|
587
|
-
comparison_to_eval = args[3]
|
588
|
-
else
|
589
|
-
# Invalid number of arguments
|
590
|
-
raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{function_name}()"
|
591
|
-
end
|
592
|
-
return [target_name, packet_name, item_name, comparison_to_eval]
|
593
|
-
end
|
594
|
-
|
595
|
-
def check_tolerance_process_args(args, function_name)
|
596
|
-
case args.length
|
597
|
-
when 3
|
598
|
-
target_name, packet_name, item_name = extract_fields_from_tlm_text(args[0])
|
599
|
-
expected_value = args[1]
|
600
|
-
tolerance = args[2].abs
|
601
|
-
when 5
|
602
|
-
target_name = args[0]
|
603
|
-
packet_name = args[1]
|
604
|
-
item_name = args[2]
|
605
|
-
expected_value = args[3]
|
606
|
-
tolerance = args[4].abs
|
607
|
-
else
|
608
|
-
# Invalid number of arguments
|
609
|
-
raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{function_name}()"
|
610
|
-
end
|
611
|
-
return [target_name, packet_name, item_name, expected_value, tolerance]
|
612
|
-
end
|
613
|
-
|
614
|
-
def _execute_wait(target_name, packet_name, item_name, value_type, comparison_to_eval, timeout, polling_rate)
|
615
|
-
start_time = Time.now
|
616
|
-
success, value = cosmos_script_wait_implementation(target_name, packet_name, item_name, value_type, comparison_to_eval, timeout, polling_rate)
|
617
|
-
time = Time.now - start_time
|
618
|
-
wait_str = "WAIT: #{_upcase(target_name, packet_name, item_name)} #{comparison_to_eval}"
|
619
|
-
value_str = "with value == #{value} after waiting #{time} seconds"
|
620
|
-
if success
|
621
|
-
Logger.info "#{wait_str} success #{value_str}"
|
622
|
-
else
|
623
|
-
Logger.warn "#{wait_str} failed #{value_str}"
|
624
|
-
end
|
625
|
-
end
|
626
|
-
|
627
|
-
def wait_process_args(args, function_name, value_type)
|
628
|
-
time = nil
|
629
|
-
|
630
|
-
case args.length
|
631
|
-
when 0
|
632
|
-
start_time = Time.now
|
633
|
-
cosmos_script_sleep()
|
634
|
-
time = Time.now - start_time
|
635
|
-
Logger.info("WAIT: Indefinite for actual time of #{time} seconds")
|
636
|
-
when 1
|
637
|
-
if args[0].kind_of? Numeric
|
638
|
-
start_time = Time.now
|
639
|
-
cosmos_script_sleep(args[0])
|
640
|
-
time = Time.now - start_time
|
641
|
-
Logger.info("WAIT: #{args[0]} seconds with actual time of #{time} seconds")
|
642
|
-
else
|
643
|
-
raise "Non-numeric wait time specified"
|
644
|
-
end
|
645
|
-
when 2, 3
|
646
|
-
target_name, packet_name, item_name, comparison_to_eval = extract_fields_from_check_text(args[0])
|
647
|
-
timeout = args[1]
|
648
|
-
if args.length == 3
|
649
|
-
polling_rate = args[2]
|
650
|
-
else
|
651
|
-
polling_rate = DEFAULT_TLM_POLLING_RATE
|
652
|
-
end
|
653
|
-
_execute_wait(target_name, packet_name, item_name, value_type, comparison_to_eval, timeout, polling_rate)
|
654
|
-
|
655
|
-
when 5, 6
|
656
|
-
target_name = args[0]
|
657
|
-
packet_name = args[1]
|
658
|
-
item_name = args[2]
|
659
|
-
comparison_to_eval = args[3]
|
660
|
-
timeout = args[4]
|
661
|
-
if args.length == 6
|
662
|
-
polling_rate = args[5]
|
663
|
-
else
|
664
|
-
polling_rate = DEFAULT_TLM_POLLING_RATE
|
665
|
-
end
|
666
|
-
_execute_wait(target_name, packet_name, item_name, value_type, comparison_to_eval, timeout, polling_rate)
|
667
|
-
|
668
|
-
else
|
669
|
-
# Invalid number of arguments
|
670
|
-
raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{function_name}()"
|
671
|
-
end
|
672
|
-
time
|
673
|
-
end
|
674
|
-
|
675
|
-
def wait_tolerance_process_args(args, function_name)
|
676
|
-
case args.length
|
677
|
-
when 4, 5
|
678
|
-
target_name, packet_name, item_name = extract_fields_from_tlm_text(args[0])
|
679
|
-
expected_value = args[1]
|
680
|
-
tolerance = args[2].abs
|
681
|
-
timeout = args[3]
|
682
|
-
if args.length == 5
|
683
|
-
polling_rate = args[4]
|
684
|
-
else
|
685
|
-
polling_rate = DEFAULT_TLM_POLLING_RATE
|
686
|
-
end
|
687
|
-
when 6, 7
|
688
|
-
target_name = args[0]
|
689
|
-
packet_name = args[1]
|
690
|
-
item_name = args[2]
|
691
|
-
expected_value = args[3]
|
692
|
-
tolerance = args[4].abs
|
693
|
-
timeout = args[5]
|
694
|
-
if args.length == 7
|
695
|
-
polling_rate = args[6]
|
696
|
-
else
|
697
|
-
polling_rate = DEFAULT_TLM_POLLING_RATE
|
698
|
-
end
|
699
|
-
else
|
700
|
-
# Invalid number of arguments
|
701
|
-
raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{function_name}()"
|
702
|
-
end
|
703
|
-
return [target_name, packet_name, item_name, expected_value, tolerance, timeout, polling_rate]
|
704
|
-
end
|
705
|
-
|
706
|
-
def wait_check_process_args(args, function_name)
|
707
|
-
case args.length
|
708
|
-
when 2, 3
|
709
|
-
target_name, packet_name, item_name, comparison_to_eval = extract_fields_from_check_text(args[0])
|
710
|
-
timeout = args[1]
|
711
|
-
if args.length == 3
|
712
|
-
polling_rate = args[2]
|
713
|
-
else
|
714
|
-
polling_rate = DEFAULT_TLM_POLLING_RATE
|
715
|
-
end
|
716
|
-
when 5, 6
|
717
|
-
target_name = args[0]
|
718
|
-
packet_name = args[1]
|
719
|
-
item_name = args[2]
|
720
|
-
comparison_to_eval = args[3]
|
721
|
-
timeout = args[4]
|
722
|
-
if args.length == 6
|
723
|
-
polling_rate = args[5]
|
724
|
-
else
|
725
|
-
polling_rate = DEFAULT_TLM_POLLING_RATE
|
726
|
-
end
|
727
|
-
else
|
728
|
-
# Invalid number of arguments
|
729
|
-
raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{function_name}()"
|
730
|
-
end
|
731
|
-
return [target_name, packet_name, item_name, comparison_to_eval, timeout, polling_rate]
|
732
|
-
end
|
733
|
-
|
734
|
-
# sleep in a script - returns true if canceled mid sleep
|
735
|
-
def cosmos_script_sleep(sleep_time = nil)
|
736
|
-
return false if $cmd_tlm_disconnect
|
737
|
-
if defined? ScriptRunnerFrame and ScriptRunnerFrame.instance
|
738
|
-
sleep_time = 30000000 unless sleep_time # Handle infinite wait
|
739
|
-
if sleep_time > 0.0
|
740
|
-
end_time = Time.now + sleep_time
|
741
|
-
until (Time.now >= end_time)
|
742
|
-
sleep(0.01)
|
743
|
-
if ScriptRunnerFrame.instance.pause?
|
744
|
-
ScriptRunnerFrame.instance.perform_pause
|
745
|
-
return true
|
746
|
-
end
|
747
|
-
return true if ScriptRunnerFrame.instance.go?
|
748
|
-
raise StopScript if ScriptRunnerFrame.instance.stop?
|
749
|
-
end
|
750
|
-
end
|
751
|
-
else
|
752
|
-
if sleep_time
|
753
|
-
sleep(sleep_time)
|
754
|
-
else
|
755
|
-
print 'Infinite Wait - Press Enter to Continue: '
|
756
|
-
gets()
|
757
|
-
end
|
758
|
-
end
|
759
|
-
return false
|
760
|
-
end
|
761
|
-
|
762
|
-
def _cosmos_script_wait_implementation(target_name, packet_name, item_name, value_type, timeout, polling_rate)
|
763
|
-
end_time = Time.now + timeout
|
764
|
-
exp_to_eval = yield
|
765
|
-
|
766
|
-
while true
|
767
|
-
work_start = Time.now
|
768
|
-
value = tlm_variable(target_name, packet_name, item_name, value_type)
|
769
|
-
if eval(exp_to_eval)
|
770
|
-
return true, value
|
771
|
-
end
|
772
|
-
break if Time.now >= end_time || $cmd_tlm_disconnect
|
773
|
-
|
774
|
-
delta = Time.now - work_start
|
775
|
-
sleep_time = polling_rate - delta
|
776
|
-
end_delta = end_time - Time.now
|
777
|
-
sleep_time = end_delta if end_delta < sleep_time
|
778
|
-
sleep_time = 0 if sleep_time < 0
|
779
|
-
canceled = cosmos_script_sleep(sleep_time)
|
780
|
-
|
781
|
-
if canceled
|
782
|
-
value = tlm_variable(target_name, packet_name, item_name, value_type)
|
783
|
-
if eval(exp_to_eval)
|
784
|
-
return true, value
|
785
|
-
else
|
786
|
-
return false, value
|
787
|
-
end
|
788
|
-
end
|
789
|
-
end
|
790
|
-
|
791
|
-
return false, value
|
792
|
-
end
|
793
|
-
|
794
|
-
# Wait for a converted telemetry item to pass a comparison
|
795
|
-
def cosmos_script_wait_implementation(target_name, packet_name, item_name, value_type, comparison_to_eval, timeout, polling_rate = DEFAULT_TLM_POLLING_RATE)
|
796
|
-
_cosmos_script_wait_implementation(target_name, packet_name, item_name, value_type, timeout, polling_rate) do
|
797
|
-
"value " + comparison_to_eval
|
798
|
-
end
|
799
|
-
end
|
800
|
-
|
801
|
-
def cosmos_script_wait_implementation_tolerance(target_name, packet_name, item_name, value_type, expected_value, tolerance, timeout, polling_rate = DEFAULT_TLM_POLLING_RATE)
|
802
|
-
_cosmos_script_wait_implementation(target_name, packet_name, item_name, value_type, timeout, polling_rate) do
|
803
|
-
"((#{expected_value} - #{tolerance.abs})..(#{expected_value} + #{tolerance.abs})).include? value"
|
804
|
-
end
|
805
|
-
end
|
806
|
-
|
807
|
-
# Wait on an expression to be true.
|
808
|
-
def cosmos_script_wait_implementation_expression(exp_to_eval, timeout, polling_rate, context)
|
809
|
-
end_time = Time.now + timeout
|
810
|
-
context = ScriptRunnerFrame.instance.script_binding if !context and defined? ScriptRunnerFrame and ScriptRunnerFrame.instance
|
811
|
-
|
812
|
-
while true
|
813
|
-
work_start = Time.now
|
814
|
-
if eval(exp_to_eval, context)
|
815
|
-
return true
|
816
|
-
end
|
817
|
-
break if Time.now >= end_time
|
818
|
-
|
819
|
-
delta = Time.now - work_start
|
820
|
-
sleep_time = polling_rate - delta
|
821
|
-
end_delta = end_time - Time.now
|
822
|
-
sleep_time = end_delta if end_delta < sleep_time
|
823
|
-
sleep_time = 0 if sleep_time < 0
|
824
|
-
canceled = cosmos_script_sleep(sleep_time)
|
825
|
-
|
826
|
-
if canceled
|
827
|
-
if eval(exp_to_eval, context)
|
828
|
-
return true
|
829
|
-
else
|
830
|
-
return nil
|
831
|
-
end
|
832
|
-
end
|
833
|
-
end
|
834
|
-
|
835
|
-
return nil
|
836
|
-
end
|
837
|
-
|
838
|
-
def check_eval(target_name, packet_name, item_name, comparison_to_eval, value)
|
839
|
-
string = "value " + comparison_to_eval
|
840
|
-
check_str = "CHECK: #{_upcase(target_name, packet_name, item_name)} #{comparison_to_eval}"
|
841
|
-
value_str = "with value == #{value}"
|
842
|
-
if eval(string)
|
843
|
-
Logger.info "#{check_str} success #{value_str}"
|
844
|
-
else
|
845
|
-
message = "#{check_str} failed #{value_str}"
|
846
|
-
if $cmd_tlm_disconnect
|
847
|
-
Logger.error message
|
848
|
-
else
|
849
|
-
raise CheckError, message
|
850
|
-
end
|
851
|
-
end
|
852
|
-
end
|
853
|
-
|
854
|
-
def build_cmd_output_string(target_name, cmd_name, cmd_params, raw = false)
|
855
|
-
if raw
|
856
|
-
output_string = 'cmd_raw("'
|
857
|
-
else
|
858
|
-
output_string = 'cmd("'
|
859
|
-
end
|
860
|
-
output_string << target_name + ' ' + cmd_name
|
861
|
-
if cmd_params.nil? or cmd_params.empty?
|
862
|
-
output_string << '")'
|
863
|
-
else
|
864
|
-
params = []
|
865
|
-
cmd_params.each do |key, value|
|
866
|
-
if value.class == String
|
867
|
-
if value.convert_to_value.class == String
|
868
|
-
value = value.inspect
|
869
|
-
if value.length > 256
|
870
|
-
value = value[0..255] + "...'"
|
871
|
-
end
|
872
|
-
value.tr!('"',"'")
|
873
|
-
end
|
874
|
-
end
|
875
|
-
params << "#{key} #{value}"
|
876
|
-
end
|
877
|
-
params = params.join(", ")
|
878
|
-
output_string << ' with ' + params + '")'
|
879
|
-
end
|
880
|
-
return output_string
|
881
|
-
end
|
882
|
-
|
883
103
|
def prompt_for_hazardous(target_name, cmd_name, hazardous_description)
|
884
104
|
message = "Warning: Command #{target_name} #{cmd_name} is Hazardous. "
|
885
105
|
message << "\n#{hazardous_description}\n" if hazardous_description
|