class Roby::EventConstraints::UnboundTaskPredicate::SingleEvent

Subclass of UnboundTaskPredicate to handle single event generators

This is the class that is e.g. returned by UnboundPredicateSupport#to_unbound_task_predicate

Attributes

event_name[R]

The generator name as a symbol

required_events[R]

The set of events required to compute this predicate. This is used by UnboundTaskPredicate#compile

Public Class Methods

new(event_name) click to toggle source
Calls superclass method
# File lib/roby/event_constraints.rb, line 769
def initialize(event_name)
    @event_name = event_name
    @required_events = [event_name].to_set
    super()
end

Public Instance Methods

==(pred) click to toggle source
# File lib/roby/event_constraints.rb, line 775
def ==(pred); pred.kind_of?(SingleEvent) && pred.event_name == event_name end
code() click to toggle source

Code generation to create the overall evaluated predicate

# File lib/roby/event_constraints.rb, line 778
def code
    if @deadline
        return "task_#{event_name} && (task_#{event_name}.time.to_f > #{@deadline.to_f})"
    else
        "!!task_#{event_name}"
    end
end
explain_false(task) click to toggle source
# File lib/roby/event_constraints.rb, line 795
def explain_false(task)
    generator = task.event(event_name)
    if !generator.emitted?
        Explanation.new(false, self, [generator])
    end
end
explain_static(task) click to toggle source
# File lib/roby/event_constraints.rb, line 801
def explain_static(task)
    event = task.event(event_name)
    if event.last
        Explanation.new(true, self, [event.last])
    elsif event.unreachable?
        Explanation.new(nil, self, [event])
    end
end
explain_true(task) click to toggle source

Returns an Explanation object that explains why self is true. Note that it is valid only if evaluate(task) actually returned true (it will silently return an invalid explanation if evaluate(task) returns false).

# File lib/roby/event_constraints.rb, line 790
def explain_true(task)
    if event = task.event(event_name).last
        Explanation.new(true, self, [event])
    end
end
followed_by(event) click to toggle source
# File lib/roby/event_constraints.rb, line 827
def followed_by(event)
    FollowedBy.new(self, event.to_unbound_task_predicate)
end
from_now() click to toggle source
# File lib/roby/event_constraints.rb, line 818
def from_now
    @deadline = Time.now
    self
end
never() click to toggle source
# File lib/roby/event_constraints.rb, line 814
def never
    Never.new(self)
end
not_followed_by(event) click to toggle source
# File lib/roby/event_constraints.rb, line 823
def not_followed_by(event)
    NotFollowedBy.new(self, event.to_unbound_task_predicate)
end
static?(task) click to toggle source
# File lib/roby/event_constraints.rb, line 809
def static?(task)
    event = task.event(event_name)
    evaluate(task) || event.unreachable?
end
to_s() click to toggle source
# File lib/roby/event_constraints.rb, line 831
def to_s; "#{event_name}?" end