Skip to content

Commit

Permalink
Merge pull request #175 from BallAerospace/add_view_in_cmd_sender
Browse files Browse the repository at this point in the history
#174 Add packet option to Command Sender. Add View in Command Sender to CTS
  • Loading branch information
jmthomas committed Jul 21, 2015
2 parents 5d519e5 + bc2dfdf commit e839fe6
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 38 deletions.
45 changes: 28 additions & 17 deletions lib/cosmos/tools/cmd_sender/cmd_sender.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
47 changes: 27 additions & 20 deletions lib/cosmos/tools/cmd_tlm_server/gui/packets_tab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -121,30 +121,37 @@ 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
end
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

0 comments on commit e839fe6

Please sign in to comment.