Class: Cosmos::HousekeepingDataObjectAdder

Inherits:
Qt::Widget show all
Defined in:
lib/cosmos/tools/tlm_grapher/data_object_adders/housekeeping_data_object_adder.rb

Overview

Widget for adding a housekeeping data object to a plot

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, orientation = Qt::Horizontal) ⇒ HousekeepingDataObjectAdder

Returns a new instance of HousekeepingDataObjectAdder.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/cosmos/tools/tlm_grapher/data_object_adders/housekeeping_data_object_adder.rb', line 30

def initialize(parent, orientation = Qt::Horizontal)
  super(parent)
  @overall_frame = Qt::VBoxLayout.new
  @overall_frame.setContentsMargins(0,0,0,0)

  @search_layout = Qt::HBoxLayout.new
  @search_label = Qt::Label.new("Add Housekeeping Data Object: ", self)
  @search_box = FullTextSearchLineEdit.new(self)
  @search_box.setStyleSheet("padding-right: 20px;padding-left: 5px;background: url(#{File.join(Cosmos::PATH, 'data', 'search-14.png')});background-position: right;background-repeat: no-repeat;")
  @search_box.completion_list = System.telemetry.all_item_strings(false, nil)
  @search_box.callback = lambda do |tlm|
    split_tlm = tlm.split(" ")
    if split_tlm.length == 3
      target_name = split_tlm[0].upcase
      packet_name = split_tlm[1]
      item_name = split_tlm[2]
      begin
        System.telemetry.packet_and_item(target_name, packet_name, item_name)
        add_data_object(target_name, packet_name, item_name)
      rescue
        # Does not exist
      end
    end
  end
  @search_layout.addWidget(@search_label)
  @search_layout.addWidget(@search_box)
  @overall_frame.addLayout(@search_layout)
  setLayout(@overall_frame)
  @add_data_object_callback = nil
end

Instance Attribute Details

#add_data_object_callbackObject

Callback called when the add button is pressed - call(data_object)



25
26
27
# File 'lib/cosmos/tools/tlm_grapher/data_object_adders/housekeeping_data_object_adder.rb', line 25

def add_data_object_callback
  @add_data_object_callback
end

Instance Method Details

#add_data_object(target_name, packet_name, item_name) ⇒ Object

Adds a data object when the add button is pressed



67
68
69
70
71
# File 'lib/cosmos/tools/tlm_grapher/data_object_adders/housekeeping_data_object_adder.rb', line 67

def add_data_object(target_name, packet_name, item_name)
  data_object = HousekeepingDataObject.new
  data_object.set_item(target_name, packet_name, item_name)
  @add_data_object_callback.call(data_object) if @add_data_object_callback
end

#updateObject

Update choices



62
63
64
# File 'lib/cosmos/tools/tlm_grapher/data_object_adders/housekeeping_data_object_adder.rb', line 62

def update
  # Do nothing for now
end