Class: Cosmos::LimitsMonitor::LimitsWidget

Inherits:
Qt::Widget show all
Defined in:
lib/cosmos/tools/limits_monitor/limits_monitor.rb

Overview

LimitsWidget displays either a stale packet using the Label widget or more commonly an out of limits item using the Labelvaluelimitsbar Widget.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, target_name, packet_name, item_name) ⇒ LimitsWidget

Returns a new instance of LimitsWidget.



357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
# File 'lib/cosmos/tools/limits_monitor/limits_monitor.rb', line 357

def initialize(parent, target_name, packet_name, item_name)
  super(parent)
  @layout = Qt::HBoxLayout.new
  @layout.setSpacing(0)
  @layout.setContentsMargins(0,0,0,0)
  setLayout(@layout)

  item = [target_name, packet_name, item_name]
  if item_name
    @value = LabelvaluelimitsbarWidget.new(@layout, target_name, packet_name, item_name)
    @value.set_setting('COLORBLIND', [@colorblind])
    @value.process_settings
  else
    @value = LabelWidget.new(layout, "#{target_name} #{packet_name} is STALE")
  end

  @ignore_button = Qt::PushButton.new('Ignore')
  @ignore_button.connect(SIGNAL('clicked()')) { parent.ignore(self, item) }
  @layout.addWidget(@ignore_button)
end

Instance Attribute Details

#valueWidget

Returns The widget which displays the value.

Returns:

  • (Widget)

    The widget which displays the value



351
352
353
# File 'lib/cosmos/tools/limits_monitor/limits_monitor.rb', line 351

def value
  @value
end

Instance Method Details

#disposeObject

Dispose of the widget



396
397
398
399
400
401
# File 'lib/cosmos/tools/limits_monitor/limits_monitor.rb', line 396

def dispose
  @ignore_button.dispose
  @value.dispose
  @layout.dispose
  super()
end

#set_colorblind(enabled) ⇒ Object

Enable or disable Colorblind mode



388
389
390
391
392
393
# File 'lib/cosmos/tools/limits_monitor/limits_monitor.rb', line 388

def set_colorblind(enabled)
  if LabelvaluelimitsbarWidget === @value
    @value.set_setting('COLORBLIND', [enabled])
    @value.process_settings
  end
end

#set_values(value, limits_state, limits_set) ⇒ Object

Update the widget’s value, limits_state, and limits_set



379
380
381
382
383
384
385
# File 'lib/cosmos/tools/limits_monitor/limits_monitor.rb', line 379

def set_values(value, limits_state, limits_set)
  if LabelvaluelimitsbarWidget === @value
    @value.value = value
    @value.limits_state = limits_state
    @value.limits_set = limits_set
  end
end