Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tlm screen api #652

Merged
19 commits merged into from
Nov 16, 2017
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo/config/tools/cmd_tlm_server/cmd_tlm_server.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ BACKGROUND_TASK example_background_task.rb
STOPPED
BACKGROUND_TASK limits_groups.rb 5 # Initial delay to allow interfaces to connect

COLLECT_METADATA
#COLLECT_METADATA
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason this got commented out?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every time I start CmdTlmServer it pops up and annoys me. I could be convinced to put it back as the default with a good argument.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only mention because #655 found a bug in the basic install because we we NOT using it. As long as it's part of the AHK test I'm ok leaving it out.

32 changes: 32 additions & 0 deletions demo/procedures/replay_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
set_line_delay(0)
set_replay_mode(true)
filenames = get_output_logs_filenames()
replay_select_file(filenames[-1])
status = 'Analyzing'
while status =~ /Analyzing/
status, playback_delay, filename, file_start, file_current, file_end, file_index, file_max_index = replay_status
wait(1)
end
100.times do
replay_step_forward()
end
100.times do
replay_step_back()
end
replay_move_end()
replay_move_index(file_max_index / 2)
replay_move_start()
replay_set_playback_delay(0.1)
replay_play()
wait(2)
replay_set_playback_delay(0.125)
wait(5)
replay_set_playback_delay(-1.0)
wait(2)
replay_set_playback_delay(nil)
wait(4)
replay_stop()
replay_reverse_play()
wait(5)
cmd_tlm_clear_counters()
cmd_tlm_reload()
1 change: 1 addition & 0 deletions lib/cosmos/gui/qt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ def self.check_log_configuration(packet_log_reader, log_filename)
end
end
end
return config_change_success, change_error
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/cosmos/interfaces/protocols/fixed_protocol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def read_packet(packet)

# Identifies an unknown buffer of data as a Packet. The raw data is
# returned but the packet that matched is recorded so it can be set in the
# post_read_packet callback.
# read_packet callback.
#
# @return [String|Symbol] The identified packet data or :STOP if more data
# is required to build a packet
Expand Down Expand Up @@ -82,7 +82,7 @@ def identify_and_finish_packet
return :STOP if @data.length < identified_packet.defined_length
end
# Set some variables so we can update the packet in
# post_read_packet
# read_packet
@received_time = Time.now.sys
@target_name = identified_packet.target_name
@packet_name = identified_packet.packet_name
Expand Down
12 changes: 12 additions & 0 deletions lib/cosmos/script/cmd_tlm_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,5 +196,17 @@ def unsubscribe_server_messages(id)
def get_server_message(id, non_block = false)
return $cmd_tlm_server.get_server_message(id, non_block)
end

def cmd_tlm_reload
return $cmd_tlm_server.cmd_tlm_reload
end

def cmd_tlm_clear_counters
return $cmd_tlm_server.cmd_tlm_clear_counters
end

def get_output_logs_filenames(filter = '*tlm.bin')
return $cmd_tlm_server.get_output_logs_filenames(filter)
end
end
end
60 changes: 60 additions & 0 deletions lib/cosmos/script/replay.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# encoding: ascii-8bit

# Copyright 2017 Ball Aerospace & Technologies Corp.
# All Rights Reserved.
#
# This program is free software; you can modify and/or redistribute it
# under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 3 with
# attribution addendums as found in the LICENSE.txt

module Cosmos

module Script
private

def replay_select_file(filename, packet_log_reader = "DEFAULT")
$cmd_tlm_server.replay_select_file(filename, packet_log_reader)
end

def replay_status
$cmd_tlm_server.replay_status
end

def replay_set_playback_delay(delay)
$cmd_tlm_server.replay_set_playback_delay(delay)
end

def replay_play
$cmd_tlm_server.replay_play
end

def replay_reverse_play
$cmd_tlm_server.replay_reverse_play
end

def replay_stop
$cmd_tlm_server.replay_stop
end

def replay_step_forward
$cmd_tlm_server.replay_step_forward
end

def replay_step_back
$cmd_tlm_server.replay_step_back
end

def replay_move_start
$cmd_tlm_server.replay_move_start
end

def replay_move_end
$cmd_tlm_server.replay_move_end
end

def replay_move_index(index)
$cmd_tlm_server.replay_move_index(index)
end
end
end
22 changes: 20 additions & 2 deletions lib/cosmos/script/script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
require 'cosmos/io/json_drb_object'
require 'cosmos/tools/cmd_tlm_server/cmd_tlm_server'
require 'cosmos/script/cmd_tlm_server'
require 'cosmos/script/replay'
require 'cosmos/script/commands'
require 'cosmos/script/telemetry'
require 'cosmos/script/limits'
Expand All @@ -20,6 +21,7 @@

$cmd_tlm_server = nil
$cmd_tlm_disconnect = false
$cmd_tlm_replay_mode = false

module Cosmos
class CheckError < RuntimeError; end
Expand All @@ -39,6 +41,7 @@ module Script
# Called when this module is mixed in using "include Cosmos::Script"
def self.included(base)
$cmd_tlm_disconnect = false
$cmd_tlm_replay_mode = false
$cmd_tlm_server = nil
initialize_script_module()
end
Expand All @@ -48,8 +51,12 @@ def initialize_script_module(config_file = CmdTlmServer::DEFAULT_CONFIG_FILE)
# Start up a standalone CTS in disconnected mode
$cmd_tlm_server = CmdTlmServer.new(config_file, false, true)
else
# Start a Json connect to the real CTS server
$cmd_tlm_server = JsonDRbObject.new(System.connect_hosts['CTS_API'], System.ports['CTS_API'])
# Start a Json connect to the real server
if $cmd_tlm_replay_mode
$cmd_tlm_server = JsonDRbObject.new(System.connect_hosts['REPLAY_API'], System.ports['REPLAY_API'])
else
$cmd_tlm_server = JsonDRbObject.new(System.connect_hosts['CTS_API'], System.ports['CTS_API'])
end
end
end

Expand All @@ -72,5 +79,16 @@ def script_disconnect
$cmd_tlm_server.disconnect if $cmd_tlm_server && !$cmd_tlm_disconnect
end

def set_replay_mode(replay_mode)
if replay_mode != $cmd_tlm_replay_mode
$cmd_tlm_replay_mode = replay_mode
initialize_script_module()
end
end

def get_replay_mode
$cmd_tlm_replay_mode
end

end
end
14 changes: 14 additions & 0 deletions lib/cosmos/script/tools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,20 @@ def show_backtrace(value = true)
end
end

###########################
# Telemetry Screen methods
###########################

# Get the organized list of available telemetry screens
def get_screen_list(config_filename = nil, force_refresh = false)
$cmd_tlm_server.get_screen_list(config_filename, force_refresh)
end

# Get a specific screen definition
def get_screen_definition(screen_full_name, config_filename = nil, force_refresh = false)
$cmd_tlm_server.get_screen_definition(screen_full_name, config_filename, force_refresh)
end

end # module Script

end # module Cosmos
Loading