Class: Cosmos::TrendbarWidget
Constant Summary
collapse
- MAX_TREND_SECONDS =
3600.0
Instance Attribute Summary
Attributes included from Widget
#item, #item_name, #limits_set, #limits_state, #packet, #packet_name, #polling_period, #screen, #settings, #target_name, #value, #value_type
Instance Method Summary
collapse
#paint_implementation, takes_value?
#calculate_widths, #get_limits, #paintEvent
Methods included from Widget
#context_menu, included, #set_setting, #set_subsetting, #shutdown, #update_widget
Constructor Details
#initialize(parent_layout, target_name, packet_name, item_name, value_type = :CONVERTED, trend_seconds = 60.0, width = 160, height = 25, trend_value_handle = nil) ⇒ TrendbarWidget
Returns a new instance of TrendbarWidget.
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/cosmos/tools/tlm_viewer/widgets/trendbar_widget.rb', line 23
def initialize (parent_layout, target_name, packet_name, item_name, value_type = :CONVERTED, trend_seconds = 60.0, width = 160, height = 25, trend_value_handle = nil)
@trend_seconds = trend_seconds.to_f
@trend_seconds = MAX_TREND_SECONDS if @trend_seconds > MAX_TREND_SECONDS
super(parent_layout, target_name, packet_name, item_name, value_type, width, height)
@trend_value_handle = ConfigParser.handle_nil(trend_value_handle)
@samples_received = 0
@trend_delta = nil
@trend_points = 1
@trend_data = [0]
end
|
Instance Method Details
#additional_drawing(dc) ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'lib/cosmos/tools/tlm_viewer/widgets/trendbar_widget.rb', line 76
def additional_drawing (dc)
trendline_pos = (@x_pad + ((@trend_data[@trend_points]) - @low_value) / @bar_scale * @bar_width).to_i
trendline_pos = @x_pad if trendline_pos < @x_pad
trendline_pos = @bar_width + @x_pad if trendline_pos > @x_pad + @bar_width
bar_y_mid = @height / 2
radius = 0.175 * @bar_height
if @samples_received > @trend_points
if @trend_value_handle
trend_val = @value - @trend_data[@trend_points]
@trend_value_handle.setText(sprintf("%0.2f", trend_val))
end
dc.addLineColor(trendline_pos, bar_y_mid, @line_pos, bar_y_mid)
dc.addEllipseColorFill(trendline_pos - 2, bar_y_mid - radius/2, radius*2, radius*2)
end
end
|
#adjust_trend_points_and_data ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/cosmos/tools/tlm_viewer/widgets/trendbar_widget.rb', line 58
def adjust_trend_points_and_data
@trend_points = ((1.0 / @polling_period.to_f) * @trend_seconds).to_i + 1
@trend_data = [0] * @trend_points
@trend_points -= 1
@trend_points = 0 if @trend_points < 0
end
|
#get_tooltip_text ⇒ Object
70
71
72
73
74
|
# File 'lib/cosmos/tools/tlm_viewer/widgets/trendbar_widget.rb', line 70
def get_tooltip_text
tooltip_text = super()
tooltip_text += "\nTrending Value = (Current Value) - (Value #{@trend_seconds} Seconds Ago)"
return tooltip_text
end
|
#polling_period=(polling_period) ⇒ Object
40
41
42
43
|
# File 'lib/cosmos/tools/tlm_viewer/widgets/trendbar_widget.rb', line 40
def polling_period=(polling_period)
super(polling_period)
adjust_trend_points_and_data()
end
|
#process_settings ⇒ Object
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
# File 'lib/cosmos/tools/tlm_viewer/widgets/trendbar_widget.rb', line 108
def process_settings
super()
if @settings.include?('TREND_SECONDS')
@trend_seconds = @settings['TREND_SECONDS'][0].to_f
if @trend_seconds > MAX_TREND_SECONDS
@trend_seconds = MAX_TREND_SECONDS
end
adjust_trend_points_and_data()
end
end
|
#value=(data) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/cosmos/tools/tlm_viewer/widgets/trendbar_widget.rb', line 45
def value= (data)
@value = data.to_f
@samples_received += 1
@trend_data.pop
@trend_data.insert(0, @value)
update()
end
|