Class: Cosmos::XyDataObject
- Inherits:
-
DataObject
- Object
- DataObject
- Cosmos::XyDataObject
- Defined in:
- lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb
Overview
Represents a data object on an XyGraph for two telemetry items
Direct Known Subclasses
Constant Summary collapse
- VALUE_TYPES =
Value Types
[:RAW, :CONVERTED]
Constants inherited from DataObject
DataObject::COLOR_LIST, DataObject::DEFAULT_ARRAY_SIZE, DataObject::PRUNE_HYSTERISIS_PERCENTAGE
Instance Attribute Summary collapse
-
#packet_name ⇒ Object
The packet name (string).
-
#target_name ⇒ Object
The target name (string).
-
#time_item_name ⇒ Object
The time item name (string).
-
#time_values ⇒ Object
Array of time values to graph on the line graph.
-
#x_item_name ⇒ Object
The x item name (string).
-
#x_states ⇒ Object
Hash of x states.
-
#x_value_type ⇒ Object
Type of data to collect for x value - :RAW or :CONVERTED.
-
#x_values ⇒ Object
Array of x_values to graph on the line graph.
-
#y_item_name ⇒ Object
The y item name (string).
-
#y_states ⇒ Object
Hash of y states.
-
#y_value_type ⇒ Object
Type of data to collect for y value - :RAW or :CONVERTED.
-
#y_values ⇒ Object
Array of y values to graph on the line graph.
Attributes inherited from DataObject
#assigned_color, #color, #data_object_type, #error, #first_x_value, #max_points_saved, #plot
Instance Method Summary collapse
-
#configuration_string ⇒ Object
Returns the configuration lines used to create this data object.
-
#copy ⇒ Object
Creates a copy of the data object with settings but without data.
-
#edit_safe?(editted_data_object) ⇒ Boolean
Determines if changes can be made to the data object without affecting data.
-
#export ⇒ Object
Exports the data objects data.
-
#handle_keyword(parser, keyword, parameters) ⇒ Object
Handles data object specific keywords.
-
#initialize ⇒ XyDataObject
constructor
A new instance of XyDataObject.
-
#name ⇒ Object
Returns the name of this data object.
-
#process_packet(packet, count) ⇒ Object
Processes a packet associated with this data object.
-
#processed_packets ⇒ Object
Returns the packet processed by this data object.
-
#reset ⇒ Object
Resets the data object.
Methods inherited from DataObject
#edit, #handle_process_exception, #popup_modifier
Constructor Details
#initialize ⇒ XyDataObject
Returns a new instance of XyDataObject.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 58 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 |
Instance Attribute Details
#packet_name ⇒ Object
The packet name (string)
26 27 28 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 26 def packet_name @packet_name end |
#target_name ⇒ Object
The target name (string)
23 24 25 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 23 def target_name @target_name end |
#time_item_name ⇒ Object
The time item name (string)
35 36 37 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 35 def time_item_name @time_item_name end |
#time_values ⇒ Object
Array of time values to graph on the line graph
50 51 52 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 50 def time_values @time_values end |
#x_item_name ⇒ Object
The x item name (string)
29 30 31 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 29 def x_item_name @x_item_name end |
#x_states ⇒ Object
Hash of x states
53 54 55 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 53 def x_states @x_states end |
#x_value_type ⇒ Object
Type of data to collect for x value - :RAW or :CONVERTED
38 39 40 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 38 def x_value_type @x_value_type end |
#x_values ⇒ Object
Array of x_values to graph on the line graph
44 45 46 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 44 def x_values @x_values end |
#y_item_name ⇒ Object
The y item name (string)
32 33 34 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 32 def y_item_name @y_item_name end |
#y_states ⇒ Object
Hash of y states
56 57 58 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 56 def y_states @y_states end |
#y_value_type ⇒ Object
Type of data to collect for y value - :RAW or :CONVERTED
41 42 43 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 41 def y_value_type @y_value_type end |
#y_values ⇒ Object
Array of y values to graph on the line graph
47 48 49 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 47 def y_values @y_values end |
Instance Method Details
#configuration_string ⇒ Object
Returns the configuration lines used to create this data object
79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 79 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 |
#copy ⇒ Object
Creates a copy of the data object with settings but without data
242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 242 def copy data_object = super() data_object.target_name = @target_name.clone if @target_name data_object.packet_name = @packet_name.clone if @packet_name data_object.x_item_name = @x_item_name.clone if @x_item_name data_object.y_item_name = @y_item_name.clone if @y_item_name data_object.time_item_name = @time_item_name.clone if @time_item_name data_object.x_value_type = @x_value_type data_object.y_value_type = @y_value_type data_object end |
#edit_safe?(editted_data_object) ⇒ Boolean
Determines if changes can be made to the data object without affecting data
257 258 259 260 261 262 263 264 265 266 267 268 269 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 257 def edit_safe?(editted_data_object) if @target_name != editted_data_object.target_name or @packet_name != editted_data_object.packet_name or @x_item_name != editted_data_object.x_item_name or @y_item_name != editted_data_object.y_item_name or @time_item_name != editted_data_object.time_item_name or @x_value_type != editted_data_object.x_value_type or @y_value_type != editted_data_object.y_value_type false else super(editted_data_object) end end |
#export ⇒ Object
Exports the data objects data
233 234 235 236 237 238 239 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 233 def export if @time_item_name [[name().clone, 'Time'].concat(@time_values), [name().clone, 'X'].concat(@x_values), [name().clone, 'Y'].concat(@y_values)] else [[name().clone, 'X'].concat(@x_values), [name().clone, 'Y'].concat(@y_values)] end end |
#handle_keyword(parser, keyword, parameters) ⇒ Object
Handles data object specific keywords
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 92 def handle_keyword(parser, keyword, parameters) case keyword when 'TARGET' # Expect 1 parameters parser.verify_num_parameters(1, 1, "TARGET <Target Name>") 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 <Packet Name>") 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 <X Item Name>") 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 <Y Item Name>") 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 <Time Item Name>") if @time_item_name and not @y_item_name raise ArgumentError, "Only one TIME_ITEM may be associated with an #{self.class}" else self.time_item_name = parameters[0] end when 'X_VALUE_TYPE' # Expect 1 parameter parser.verify_num_parameters(1, 1, "X_VALUE_TYPE <RAW or CONVERTED>") value_type = parameters[0].upcase.intern if VALUE_TYPES.include?(value_type) @x_value_type = value_type else raise ArgumentError, "Unknown X_VALUE_TYPE value: #{value_type}" end when 'Y_VALUE_TYPE' # Expect 1 parameter parser.verify_num_parameters(1, 1, "Y_VALUE_TYPE <RAW or CONVERTED>") value_type = parameters[0].upcase.intern if VALUE_TYPES.include?(value_type) @y_value_type = value_type else raise ArgumentError, "Unknown Y_VALUE_TYPE value: #{value_type}" end else # Unknown keywords are passed to parent data object super(parser, keyword, parameters) end # case keyword end |
#name ⇒ Object
Returns the name of this data object
216 217 218 219 220 221 222 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 216 def name if @target_name and @packet_name and @y_item_name and @x_item_name "#{@target_name} #{@packet_name} #{@y_item_name} VS #{@x_item_name}" else "" end end |
#process_packet(packet, count) ⇒ Object
Processes a packet associated with this data object
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 181 def process_packet(packet, count) begin # Retrieve x, y, and time values from packet if @x_value_type == :RAW x_value = packet.read(@x_item_name, :RAW) else x_value = packet.read(@x_item_name) end if @y_value_type == :RAW y_value = packet.read(@y_item_name, :RAW) else y_value = packet.read(@y_item_name) end # Bail on the values if they are NaN or nil as we can't graph them return if x_value.nil? || y_value.nil? || (x_value.respond_to?(:nan?) && x_value.nan?) || (y_value.respond_to?(:nan?) && y_value.nan?) time_value = packet.read(@time_item_name) if @time_item_name @x_values << x_value @y_values << y_value @time_values << time_value if @time_item_name @plot.redraw_needed = true # Prune Data prune_to_max_points_saved() rescue Exception => error handle_process_exception(error, "#{packet.target_name} #{packet.packet_name} #{@x_item_name} or #{@y_item_name}") end end |
#processed_packets ⇒ Object
Returns the packet processed by this data object
172 173 174 175 176 177 178 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 172 def processed_packets if @target_name and @packet_name [[@target_name, @packet_name]] else [] end end |
#reset ⇒ Object
Resets the data object
225 226 227 228 229 230 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 225 def reset super() @x_values = LowFragmentationArray.new(DEFAULT_ARRAY_SIZE) @y_values = LowFragmentationArray.new(DEFAULT_ARRAY_SIZE) @time_values = LowFragmentationArray.new(DEFAULT_ARRAY_SIZE) if @time_item_name end |