Skip to content

Commit

Permalink
re #245. Handle infinite and nan in tlmviewer graph widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmelt committed May 11, 2016
1 parent 204ac49 commit 2070c55
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
9 changes: 7 additions & 2 deletions lib/cosmos/tools/tlm_viewer/widgets/linegraph_widget.rb
Expand Up @@ -34,9 +34,14 @@ def self.takes_value?

def value=(data)
if data.is_a?(Array)
@data.push(data.map(&:to_f)).flatten!
data2 = data.map(&:to_f)
data2.reject!{|val| val.nan? or val.infinite?}
@data.push(data2).flatten!
else
@data << data.to_f
data2 = data.to_f
if !data2.infinite? and !data2.nan?
@data << data2
end
end

if @data.length > @num_samples
Expand Down
27 changes: 15 additions & 12 deletions lib/cosmos/tools/tlm_viewer/widgets/timegraph_widget.rb
Expand Up @@ -66,21 +66,24 @@ def value=(data)
# Don't regraph old data
return if @time[-1] == t_sec

# create time array
@time << t_sec
data2 = data.to_f
if data2.infinite? or data2.nan?
# create time array
@time << t_sec

# create data array and graph
@data << data.to_f
# create data array and graph
@data << data2

# truncate data if necessary
if @data.length > @num_samples
@data = @data[1..-1]
@time = @time[1..-1]
end
# truncate data if necessary
if @data.length > @num_samples
@data = @data[1..-1]
@time = @time[1..-1]
end

self.clear_lines
self.add_line('line', @data, @time)
self.graph
self.clear_lines
self.add_line('line', @data, @time)
self.graph
end
end

end
Expand Down

0 comments on commit 2070c55

Please sign in to comment.