Sha256: c9ad4dea394a28888531795aa73cb9c2806f938b6768bcd68a4d0ea9de3eae7c
Contents?: true
Size: 1.68 KB
Versions: 30
Compression:
Stored size: 1.68 KB
Contents
# 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_viewer/widgets/widget' require 'cosmos/gui/line_graph/line_graph' module Cosmos class LinegraphWidget < LineGraph include Widget def initialize(parent_layout, target_name, packet_name, item_name, num_samples = 100, width = 300, height = 200, value_type = :CONVERTED) super(target_name, packet_name, item_name, value_type) setFixedSize(width.to_i, height.to_i) self.title = "#{@target_name} #{@packet_name} #{@item_name}" self.show_y_grid_lines = true self.unix_epoch_x_values = false @num_samples = num_samples.to_i @data = [] parent_layout.addWidget(self) if parent_layout end def self.takes_value? return true end def value=(data) if data.is_a?(Array) data2 = data.map(&:to_f) data2.reject!{|val| val.nan? or val.infinite?} @data.push(data2).flatten! else data2 = data.to_f if !data2.infinite? and !data2.nan? @data << data2 end end if @data.length > @num_samples @data = @data.last(@num_samples) end if not @data.empty? self.clear_lines self.add_line('line', @data) self.graph end end end # Disable tooltip so that graph can be moused-over def get_tooltip_text return nil end end # module Cosmos
Version data entries
30 entries across 30 versions & 1 rubygems