# encoding: ascii-8bit # Copyright 2014 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 require 'cosmos' require 'cosmos/tools/tlm_grapher/data_objects/data_object' module Cosmos # Represents a data object on an XyGraph for two telemetry items class XyDataObject < DataObject # Value Types VALUE_TYPES = [:RAW, :CONVERTED] # The target name (string) attr_accessor :target_name # The packet name (string) attr_accessor :packet_name # The x item name (string) attr_reader :x_item_name # The y item name (string) attr_reader :y_item_name # The time item name (string) attr_reader :time_item_name # Type of data to collect for x value - :RAW or :CONVERTED attr_accessor :x_value_type # Type of data to collect for y value - :RAW or :CONVERTED attr_accessor :y_value_type # Array of x_values to graph on the line graph attr_accessor :x_values # Array of y values to graph on the line graph attr_accessor :y_values # Array of time values to graph on the line graph attr_accessor :time_values # Hash of x states attr_accessor :x_states # Hash of y states attr_accessor :y_states def initialize super() @target_name = nil @packet_name = nil @x_item_name = nil @y_item_name = nil @time_item_name = nil @x_value_type = :CONVERTED @y_value_type = :CONVERTED @x_values = LowFragmentationArray.new(DEFAULT_ARRAY_SIZE) @y_values = LowFragmentationArray.new(DEFAULT_ARRAY_SIZE) @time_values = LowFragmentationArray.new(DEFAULT_ARRAY_SIZE) @x_states = nil @y_states = nil @during_configuration = false end # Returns the configuration lines used to create this data object def configuration_string string = super() string << " TARGET #{@target_name}\n" if @target_name string << " PACKET #{@packet_name}\n" if @packet_name string << " X_ITEM #{@x_item_name}\n" if @x_item_name string << " Y_ITEM #{@y_item_name}\n" if @y_item_name string << " TIME_ITEM #{@time_item_name}\n" if @time_item_name string << " X_VALUE_TYPE #{@x_value_type}\n" string << " Y_VALUE_TYPE #{@y_value_type}\n" string end # def configuration_string # Handles data object specific keywords def handle_keyword(parser, keyword, parameters) case keyword when 'TARGET' # Expect 1 parameters parser.verify_num_parameters(1, 1, "TARGET ") unless @target_name @target_name = parameters[0].upcase else raise ArgumentError, "Only one TARGET may be associated with an #{self.class}" end when 'PACKET' # Expect 1 parameters parser.verify_num_parameters(1, 1, "PACKET ") unless @packet_name @packet_name = parameters[0].upcase else raise ArgumentError, "Only one PACKET may be associated with an #{self.class}" end when 'X_ITEM' # Expect 1 parameters parser.verify_num_parameters(1, 1, "X_ITEM ") unless @x_item_name @during_configuration = true self.x_item_name = parameters[0] @during_configuration = false else raise ArgumentError, "Only one X_ITEM may be associated with an #{self.class}" end when 'Y_ITEM' # Expect 1 parameters parser.verify_num_parameters(1, 1, "Y_ITEM ") unless @y_item_name @during_configuration = true self.y_item_name = parameters[0] @during_configuration = false else raise ArgumentError, "Only one Y_ITEM may be associated with an #{self.class}" end when 'TIME_ITEM' # Expect 1 parameters parser.verify_num_parameters(1, 1, "TIME_ITEM