Class: Cosmos::HousekeepingDataObjectEditor

Inherits:
LinegraphDataObjectEditor show all
Defined in:
lib/cosmos/tools/tlm_grapher/data_object_editors/housekeeping_data_object_editor.rb

Overview

Provides dialog box content to create/edit housekeeping data objects.

Instance Attribute Summary

Attributes inherited from DataObjectEditor

#frame

Instance Method Summary collapse

Methods inherited from LinegraphDataObjectEditor

#handle_add_button, #handle_delete_button

Constructor Details

#initialize(parent) ⇒ HousekeepingDataObjectEditor

Returns a new instance of HousekeepingDataObjectEditor.



23
24
25
# File 'lib/cosmos/tools/tlm_grapher/data_object_editors/housekeeping_data_object_editor.rb', line 23

def initialize(parent)
  super(parent)
end

Instance Method Details

#get_data_objectObject

Get the data object from the editor



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/cosmos/tools/tlm_grapher/data_object_editors/housekeeping_data_object_editor.rb', line 120

def get_data_object
  data_object = super()
  data_object.set_item(@telemetry_chooser.target_name,
                       @telemetry_chooser.packet_name,
                       @telemetry_chooser.item_name)
  data_object.time_item_name = @time_item_name.string
  formatted_time_item_name = @formatted_time_item_name.string
  if formatted_time_item_name.strip.empty?
    data_object.formatted_time_item_name = nil
  else
    data_object.formatted_time_item_name = formatted_time_item_name
  end
  data_object.value_type = @value_type.symbol
  data_object.analysis = @analysis.symbol
  data_object.analysis_samples = @analysis_samples.value
  if @show_limits_lines
    data_object.show_limits_lines = ConfigParser.handle_true_false(@show_limits_lines.string)
  else
    data_object.show_limits_lines = false
  end
  data_object
end

#handle_show_limits_lines_changed(choice) ⇒ Object

Handle the show limits line item changing



144
145
146
147
148
149
150
# File 'lib/cosmos/tools/tlm_grapher/data_object_editors/housekeeping_data_object_editor.rb', line 144

def handle_show_limits_lines_changed(choice)
  if choice == 'TRUE'
    @limits_lines.show
  else
    @limits_lines.hide
  end
end

#set_data_object(data_object) ⇒ Object



27
28
29
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/cosmos/tools/tlm_grapher/data_object_editors/housekeeping_data_object_editor.rb', line 27

def set_data_object(data_object)
  if data_object
    # We are editing data, so make a copy
    data_object = data_object.copy
  else
    # We are creating a new data object
    data_object = HousekeepingDataObject.new

    # Default item to first available in system definition
    packet = System.telemetry.first_non_hidden
    item_name = packet.sorted_items[0].name
    data_object.set_item(packet.target_name, packet.packet_name, item_name)
  end

  local_layout = Qt::VBoxLayout.new
  local_layout.setContentsMargins(0,0,0,0)

  # Telemetry Chooser for housekeeping item
  @telemetry_chooser = TelemetryChooser.new(self, Qt::Vertical, true, false, true)
  @telemetry_chooser.update
  @telemetry_chooser.set_item(data_object.target_name, data_object.packet_name, data_object.item_name)
  @telemetry_chooser.target_changed_callback = method(:target_packet_changed_callback)
  @telemetry_chooser.packet_changed_callback = method(:target_packet_changed_callback)
  @telemetry_chooser.item_changed_callback = method(:item_changed_callback)
  @telemetry_chooser.target_label.text = '*Target:'
  @telemetry_chooser.packet_label.text = '*Packet:'
  @telemetry_chooser.item_label.text   = '*Item:'
  local_layout.addWidget(@telemetry_chooser)

  # Chooser for time item
  time_item_names = @telemetry_chooser.item_names
  @time_item_name = ComboboxChooser.new(self, '*Time Item:', time_item_names)
  if data_object.time_item_name
    @time_item_name.set_current(data_object.time_item_name)
  else
    @time_item_name.set_current('RECEIVED_TIMESECONDS')
  end
  local_layout.addWidget(@time_item_name)

  # Chooser for formatted time item
  formatted_time_item_names = @telemetry_chooser.item_names
  formatted_time_item_names.unshift(' ')
  @formatted_time_item_name = ComboboxChooser.new(self, '*Formatted Time Item:', formatted_time_item_names)
  if data_object.formatted_time_item_name
    @formatted_time_item_name.set_current(data_object.formatted_time_item_name)
  else
    @formatted_time_item_name.set_current(' ')
  end
  local_layout.addWidget(@formatted_time_item_name)

  # Chooser for value type
  @value_type = ComboboxChooser.new(self, '*Value Type:', HousekeepingDataObject::VALUE_TYPES.map {|x| x.to_s})
  @value_type.set_current(data_object.value_type.to_s) if data_object.value_type
  local_layout.addWidget(@value_type)

  # Chooser for analysis type
  @analysis = ComboboxChooser.new(self, '*Analysis Type:', HousekeepingDataObject::ANALYSIS_TYPES.map {|x| x.to_s})
  @analysis.set_current(data_object.analysis.to_s) if data_object.analysis
  local_layout.addWidget(@analysis)

  # Integer Field for analysis samples
  @analysis_samples = IntegerChooser.new(self, '*Analysis Samples:', 0, 2)
  @analysis_samples.value = data_object.analysis_samples if data_object.analysis_samples
  local_layout.addWidget(@analysis_samples)
  @layout.addLayout(local_layout)

  packet, item = System.telemetry.packet_and_item(data_object.target_name,
                                                  data_object.packet_name,
                                                  data_object.item_name)
  if item.limits.values
    choices = ['TRUE', 'FALSE']
    @show_limits_lines = ComboboxChooser.new(self, 'Show Limits Lines:', choices)
    @show_limits_lines.set_current(data_object.show_limits_lines.to_s.upcase)
    @show_limits_lines.sel_command_callback = method(:handle_show_limits_lines_changed)
    local_layout.addWidget(@show_limits_lines)

    @limits_lines = Qt::ColorListWidget.new(self)
    data_object.limits_lines.each do |value, color|
      @limits_lines.addItemColor(value, color)
    end
    @limits_lines.set_read_only
    @limits_lines.resize_to_contents
    @limits_lines.hide unless data_object.show_limits_lines
    @layout.addWidget(@limits_lines)
  else
    @show_limits_lines = nil
    @limits_lines = nil
  end

  super(data_object)
end