Class: Cosmos::BlockWidget
- Inherits:
-
TextboxWidget
- Object
- Qt::TextEdit
- TextboxWidget
- Cosmos::BlockWidget
- Defined in:
- lib/cosmos/tools/tlm_viewer/widgets/block_widget.rb
Instance Attribute Summary
Attributes included from AgingWidget
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
- #format_value(data) ⇒ Object
-
#initialize(parent_layout, target_name, packet_name, item_name, width = 200, height = 100, format_string = "%02X", bytes_per_word = 4, words_per_row = 4, addr_format = nil, value_type = :RAW) ⇒ BlockWidget
constructor
A new instance of BlockWidget.
Methods inherited from TextboxWidget
Methods included from AgingWidget
included, #process_aging_settings, #setup_aging, #value=
Methods included from Widget
#context_menu, #get_tooltip_text, included, #process_settings, #set_setting, #set_subsetting, #shutdown, #update_widget
Methods inherited from Qt::TextEdit
Constructor Details
#initialize(parent_layout, target_name, packet_name, item_name, width = 200, height = 100, format_string = "%02X", bytes_per_word = 4, words_per_row = 4, addr_format = nil, value_type = :RAW) ⇒ BlockWidget
Returns a new instance of BlockWidget.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/cosmos/tools/tlm_viewer/widgets/block_widget.rb', line 21 def initialize (parent_layout, target_name, packet_name, item_name, width = 200, height = 100, format_string = "%02X", bytes_per_word = 4, words_per_row = 4, addr_format = nil, value_type = :RAW) super(parent_layout, target_name, packet_name, item_name, width, height, value_type) @format_string = format_string.to_s @bytes_per_word = bytes_per_word.to_i @words_per_row = words_per_row.to_i @bytes_per_row = @bytes_per_word * @words_per_row @addr_format = ConfigParser.handle_nil(addr_format) @addr_format << ' ' if @addr_format setFont(Cosmos.get_default_font) end |
Instance Method Details
#format_value(data) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/cosmos/tools/tlm_viewer/widgets/block_widget.rb', line 32 def format_value(data) text = "" space = ' ' new_line = "\n" byte_count = 0 addr = 0 data.each_byte do |value| if @addr_format and byte_count == 0 text << sprintf(@addr_format, addr) addr += @bytes_per_row end text << sprintf(@format_string, value) byte_count += 1 if (byte_count % @bytes_per_row) == 0 byte_count = 0 text << new_line elsif (byte_count % @bytes_per_word) == 0 text << space end end text end |