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]
- DART_REDUCTIONS =
DART Reductions
[:NONE, :MINUTE, :HOUR, :DAY]
- DART_REDUCED_TYPES =
DART Reduced Types
[:AVG, :MIN, :MAX, :STDDEV]
Constants inherited from DataObject
DataObject::COLOR_LIST, DataObject::DEFAULT_ARRAY_SIZE, DataObject::PRUNE_HYSTERISIS_PERCENTAGE
Instance Attribute Summary collapse
-
#dart_reduced_type ⇒ Object
DART Reduced Type.
-
#dart_reduction ⇒ Object
DART Reduction.
-
#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?(edited_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.
-
#process_values(x_value, y_value, time_value = nil) ⇒ Object
Add a set of values to the data object.
-
#processed_items ⇒ Object
Returns an array of items used by 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, #invalid_value?, #popup_modifier, #process_dart
Constructor Details
#initialize ⇒ XyDataObject
Returns a new instance of XyDataObject.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 69 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 @dart_reduction = :NONE @dart_reduced_type = :AVG @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
#dart_reduced_type ⇒ Object
DART Reduced Type
52 53 54 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 52 def dart_reduced_type @dart_reduced_type end |
#dart_reduction ⇒ Object
DART Reduction
49 50 51 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 49 def dart_reduction @dart_reduction end |
#packet_name ⇒ Object
The packet name (string)
31 32 33 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 31 def packet_name @packet_name end |
#target_name ⇒ Object
The target name (string)
28 29 30 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 28 def target_name @target_name end |
#time_item_name ⇒ Object
The time item name (string)
40 41 42 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 40 def time_item_name @time_item_name end |
#time_values ⇒ Object
Array of time values to graph on the line graph
61 62 63 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 61 def time_values @time_values end |
#x_item_name ⇒ Object
The x item name (string)
34 35 36 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 34 def x_item_name @x_item_name end |
#x_states ⇒ Object
Hash of x states
64 65 66 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 64 def x_states @x_states end |
#x_value_type ⇒ Object
Type of data to collect for x value - :RAW or :CONVERTED
43 44 45 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 43 def x_value_type @x_value_type end |
#x_values ⇒ Object
Array of x_values to graph on the line graph
55 56 57 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 55 def x_values @x_values end |
#y_item_name ⇒ Object
The y item name (string)
37 38 39 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 37 def y_item_name @y_item_name end |
#y_states ⇒ Object
Hash of y states
67 68 69 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 67 def y_states @y_states end |
#y_value_type ⇒ Object
Type of data to collect for y value - :RAW or :CONVERTED
46 47 48 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 46 def y_value_type @y_value_type end |
#y_values ⇒ Object
Array of y values to graph on the line graph
58 59 60 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 58 def y_values @y_values end |
Instance Method Details
#configuration_string ⇒ Object
Returns the configuration lines used to create this data object
92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 92 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 << " DART_REDUCTION #{@dart_reduction}\n" string << " DART_REDUCED_TYPE #{@dart_reduced_type}\n" string end |
#copy ⇒ Object
Creates a copy of the data object with settings but without data
298 299 300 301 302 303 304 305 306 307 308 309 310 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 298 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.dart_reduction = @dart_reduction data_object.dart_reduced_type = @dart_reduced_type data_object end |
#edit_safe?(edited_data_object) ⇒ Boolean
Determines if changes can be made to the data object without affecting data
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 315 def edit_safe?(edited_data_object) if @target_name != edited_data_object.target_name or @packet_name != edited_data_object.packet_name or @x_item_name != edited_data_object.x_item_name or @y_item_name != edited_data_object.y_item_name or @time_item_name != edited_data_object.time_item_name or @x_value_type != edited_data_object.x_value_type or @y_value_type != edited_data_object.y_value_type or @dart_reduction != edited_data_object.dart_reduction or @dart_reduced_type != edited_data_object.dart_reduced_type false else super(edited_data_object) end end |
#export ⇒ Object
Exports the data objects data
289 290 291 292 293 294 295 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 289 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
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 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 107 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 when 'DART_REDUCTION' # Expect 1 parameter parser.verify_num_parameters(1, 1, "DART_REDUCTION <NONE, MINUTE, HOUR, DAY>") dart_reduction = parameters[0].upcase.intern if DART_REDUCTIONS.include?(dart_reduction) @dart_reduction = dart_reduction else raise ArgumentError, "Unknown DART_REDUCTION value: #{dart_reduction}" end when 'DART_REDUCED_TYPE' # Expect 1 parameter parser.verify_num_parameters(1, 1, "DART_REDUCED_TYPE <AVG, MIN, MAX, STDDEV>") dart_reduced_type = parameters[0].upcase.intern if DART_REDUCED_TYPES.include?(dart_reduced_type) @dart_reduced_type = dart_reduced_type else raise ArgumentError, "Unknown DART_REDUCED_TYPE value: #{dart_reduced_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
270 271 272 273 274 275 276 277 278 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 270 def name if @target_name and @packet_name and @y_item_name and @x_item_name str = "#{@target_name} #{@packet_name} #{@y_item_name} VS #{@x_item_name}" str << " <#{@dart_reduction} #{dart_reduced_type}>" if @dart_reduction != :NONE str else "" end end |
#process_packet(packet, count) ⇒ Object
Processes a packet associated with this data object
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 227 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 time_value = nil time_value = packet.read(@time_item_name) if @time_item_name process_values(x_value, y_value, time_value) rescue Exception => error handle_process_exception(error, "#{@target_name} #@packet_name} #{@x_item_name} or #{@y_item_name}") end end |
#process_values(x_value, y_value, time_value = nil) ⇒ Object
Add a set of values to the data object
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 251 def process_values(x_value, y_value, time_value = nil) begin # Bail on the values if they are NaN or nil as we can't graph them return if invalid_value?(x_value) || invalid_value?(y_value) @x_values << x_value @y_values << y_value @time_values << time_value if time_value @plot.redraw_needed = true # Prune Data prune_to_max_points_saved() rescue Exception => error handle_process_exception(error, "#{@target_name} #{@packet_name} #{@x_item_name} or #{@y_item_name}") end end |
#processed_items ⇒ Object
Returns an array of items used by this data object
216 217 218 219 220 221 222 223 224 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 216 def processed_items items = [] if @target_name and @packet_name items << [@target_name, @packet_name, @x_item_name, @x_value_type, nil, @dart_reduction, @dart_reduced_type] items << [@target_name, @packet_name, @y_item_name, @y_value_type, nil, @dart_reduction, @dart_reduced_type] items << [@target_name, @packet_name, @time_item_name, :CONVERTED, nil, @dart_reduction, :AVG] if @time_item_name end items end |
#processed_packets ⇒ Object
Returns the packet processed by this data object
207 208 209 210 211 212 213 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 207 def processed_packets if @target_name and @packet_name [[@target_name, @packet_name]] else [] end end |
#reset ⇒ Object
Resets the data object
281 282 283 284 285 286 |
# File 'lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb', line 281 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 |