diff --git a/lib/cosmos/tools/cmd_sender/cmd_sender.rb b/lib/cosmos/tools/cmd_sender/cmd_sender.rb index c0c95b826..6aa5e7ac5 100644 --- a/lib/cosmos/tools/cmd_sender/cmd_sender.rb +++ b/lib/cosmos/tools/cmd_sender/cmd_sender.rb @@ -84,6 +84,24 @@ def initialize(options) initialize_menus() initialize_central_widget() complete_initialize() # defined in qt_tool + + # Bring up slash screen for long duration tasks after creation + Splash.execute(self) do |splash| + # Configure CosmosConfig to interact with splash screen + ConfigParser.splash = splash + + System.commands + Qt.execute_in_main_thread(true) do + update_targets() + @target_select.setCurrentText(options.packet[0]) if options.packet + update_commands() + @cmd_select.setCurrentText(options.packet[1]) if options.packet + update_cmd_params() + end + + # Unconfigure CosmosConfig to interact with splash screen + ConfigParser.splash = nil + end end def initialize_actions @@ -245,24 +263,8 @@ def initialize_central_widget layout.addWidget(splitter) central_widget.layout = layout - #Mark this window as the window for popups + # Mark this window as the window for popups set_cmd_tlm_gui_window(self) - - # Bring up slash screen for long duration tasks after creation - Splash.execute(self) do |splash| - # Configure CosmosConfig to interact with splash screen - ConfigParser.splash = splash - - System.commands - Qt.execute_in_main_thread(true) do - update_targets() - update_commands() - update_cmd_params() - end - - # Unconfigure CosmosConfig to interact with splash screen - ConfigParser.splash = nil - end end def menu_states_in_hex(checked) @@ -706,6 +708,15 @@ def self.run (option_parser = nil, options = nil) options.width = 600 options.height = 425 options.title = 'Command Sender' + option_parser.separator "Command Sender Specific Options:" + option_parser.on("-p", "--packet 'TARGET_NAME PACKET_NAME'", "Start with the specified command selected") do |arg| + split = arg.split + if split.length != 2 + puts "Packet must be specified as 'TARGET_NAME PACKET_NAME' in quotes" + exit + end + options.packet = split + end end super(option_parser, options) diff --git a/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb b/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb index 74f017d70..cb460dee0 100644 --- a/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb +++ b/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb @@ -179,7 +179,7 @@ def handle_tab_change(index) when 1 handle_tab('Targets') { @targets_tab.update } when 2 - handle_tab('Packets') { @packets_tab.update(PacketsTab::COMMANDS) } + handle_tab('Commands') { @packets_tab.update(PacketsTab::COMMANDS) } when 3 handle_tab('Telemetry') { @packets_tab.update(PacketsTab::TELEMETRY) } when 4 diff --git a/lib/cosmos/tools/cmd_tlm_server/gui/packets_tab.rb b/lib/cosmos/tools/cmd_tlm_server/gui/packets_tab.rb index 38c21f3b5..8514fae84 100644 --- a/lib/cosmos/tools/cmd_tlm_server/gui/packets_tab.rb +++ b/lib/cosmos/tools/cmd_tlm_server/gui/packets_tab.rb @@ -76,12 +76,12 @@ def populate(name, cmd_tlm, tab_widget) table = Qt::TableWidget.new() table.verticalHeader.hide() table.setRowCount(count) - column_cnt = 4 - column_cnt += 1 if name == TELEMETRY + column_cnt = 5 table.setColumnCount(column_cnt) # Force the last section to fill all available space in the frame #~ table.horizontalHeader.setStretchLastSection(true) headers = ["Target Name", "Packet Name", "Packet Count", "View Raw"] + headers << "View in Command Sender" if name == COMMANDS headers << "View in Packet Viewer" if name == TELEMETRY table.setHorizontalHeaderLabels(headers) @@ -121,24 +121,10 @@ def populate_packets_table(name, cmd_tlm, table) end table.setCellWidget(row, 3, view_raw) - if name == TELEMETRY - if target_name != 'UNKNOWN' and packet_name != 'UNKNOWN' - view_pv = Qt::PushButton.new("View in Packet Viewer") - view_pv.connect(SIGNAL('clicked()')) do - if Kernel.is_windows? - Cosmos.run_process("rubyw tools/PacketViewer -p \"#{target_name} #{packet_name}\" --system #{File.basename(System.initial_filename)}") - elsif Kernel.is_mac? and File.exist?("tools/mac/PacketViewer.app") - Cosmos.run_process("open tools/mac/PacketViewer.app --args -p \"#{target_name} #{packet_name}\" --system #{File.basename(System.initial_filename)}") - else - Cosmos.run_process("ruby tools/PacketViewer -p \"#{target_name} #{packet_name}\" --system #{File.basename(System.initial_filename)}") - end - end - table.setCellWidget(row, 4, view_pv) - else - table_widget = Qt::TableWidgetItem.new(Qt::Object.tr('N/A')) - table_widget.setTextAlignment(Qt::AlignCenter) - table.setItem(row, 4, table_widget) - end + if name == COMMANDS + add_tool_button(table, row, target_name, packet_name, "Command Sender") + elsif name == TELEMETRY + add_tool_button(table, row, target_name, packet_name, "Packet Viewer") end row += 1 @@ -146,5 +132,26 @@ def populate_packets_table(name, cmd_tlm, table) end end + def add_tool_button(table, row, target_name, packet_name, tool_name) + if target_name != 'UNKNOWN' and packet_name != 'UNKNOWN' + view_pv = Qt::PushButton.new("View in #{tool_name}") + view_pv.connect(SIGNAL('clicked()')) do + tool_name = tool_name.split.join.gsub("Command","Cmd") # remove space and convert name + if Kernel.is_windows? + Cosmos.run_process("rubyw tools/#{tool_name} -p \"#{target_name} #{packet_name}\" --system #{File.basename(System.initial_filename)}") + elsif Kernel.is_mac? and File.exist?("tools/mac/#{tool_name}.app") + Cosmos.run_process("open tools/mac/#{tool_name}.app --args -p \"#{target_name} #{packet_name}\" --system #{File.basename(System.initial_filename)}") + else + Cosmos.run_process("ruby tools/#{tool_name} -p \"#{target_name} #{packet_name}\" --system #{File.basename(System.initial_filename)}") + end + end + table.setCellWidget(row, 4, view_pv) + else + table_widget = Qt::TableWidgetItem.new(Qt::Object.tr('N/A')) + table_widget.setTextAlignment(Qt::AlignCenter) + table.setItem(row, 4, table_widget) + end + end + end end # module Cosmos