class Vizkit::SyskitActionItem

Constants

STATE_COLORS

Mapping from action states to colors

Attributes

action[R]
arguments[R]
job_id[RW]
name[R]
state[R]

Public Class Methods

new(action, arguments) click to toggle source
Calls superclass method Vizkit::VizkitItem.new
# File lib/vizkit/vizkit_items.rb, line 1216
def initialize(action, arguments)
    @action = action
    @base_name = @action.name
    @arguments = arguments

    @name = generate_name(@base_name, arguments)
    @state = :model

    super(@name)

    set_selectable(false)
    update_view
end

Public Instance Methods

finished?() click to toggle source
# File lib/vizkit/vizkit_items.rb, line 1260
def finished?
    @state == :success || @state == :failed || @state == :finalized
end
generate_name(base_name, arguments) click to toggle source

Creates string of base name and arguments

# File lib/vizkit/vizkit_items.rb, line 1252
def generate_name(base_name, arguments)
    formatted_arguments = arguments.map do |key,value|
        value = value.inspect if value.respond_to?(:to_str)
        "#{key} => #{value || "(no default)"}"
    end
    "#{base_name}(#{formatted_arguments.join(", ")})"
end
update_state(new_state) click to toggle source
# File lib/vizkit/vizkit_items.rb, line 1236
def update_state(new_state)
    # This is not made a constant at class level as we don't want vizkit
    # to depend on roby by default !
    roby_to_vizkit_states = Hash[
        Roby::Interface::JOB_MONITORED => :pending,
        Roby::Interface::JOB_STARTED_PLANNING => :pending,
        Roby::Interface::JOB_READY   => :planned,
        Roby::Interface::JOB_STARTED => :running,
        Roby::Interface::JOB_FAILED  => :failed,
        Roby::Interface::JOB_SUCCESS => :successful,
        Roby::Interface::JOB_FINALIZED => :finalized]
    @state = roby_to_vizkit_states[new_state]
    update_view
end
update_view() click to toggle source

Updates the item display. Checks for state change and updates color, tooltip, etc.

# File lib/vizkit/vizkit_items.rb, line 1231
def update_view
    set_foreground(Qt::Brush.new(STATE_COLORS[state]))
    set_tool_tip("State: #{state}")
end