Class: Roby::EventConstraints::UnboundTaskPredicate::FollowedBy

Inherits:
BinaryCommutativePredicate show all
Defined in:
lib/roby/event_constraints.rb

Overview

Representation of UnboundPredicateSupport#followed_by

See documentation from UnboundTaskPredicate

Instance Attribute Summary

Attributes inherited from BinaryCommutativePredicate

#predicates

Instance Method Summary collapse

Methods inherited from BinaryCommutativePredicate

#==, #each_atomic_predicate, #has_atomic_predicate?, #initialize, #required_events

Methods inherited from Roby::EventConstraints::UnboundTaskPredicate

#and, #compile, #evaluate, #initialize, #negate, #or, #pretty_print, #to_unbound_task_predicate

Constructor Details

This class inherits a constructor from Roby::EventConstraints::UnboundTaskPredicate::BinaryCommutativePredicate

Instance Method Details

#codeObject



799
800
801
802
803
804
# File 'lib/roby/event_constraints.rb', line 799

def code
    this_event  = predicates[0].event_name
    other_event = predicates[1].event_name
    "(task_#{this_event} && task_#{other_event} && "\
    "(task_#{other_event}.time > task_#{this_event}.time))"
end

#explain_false(task) ⇒ Object



757
758
759
760
761
762
763
764
765
766
767
# File 'lib/roby/event_constraints.rb', line 757

def explain_false(task)
    return if evaluate(task)

    this_generator  = task.event(predicates[0].event_name)
    other_generator = task.event(predicates[1].event_name)
    if !this_generator.last
        Explanation.new(false, self, [this_generator])
    else
        Explanation.new(false, self, [other_generator])
    end
end

#explain_static(task) ⇒ Object



769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
# File 'lib/roby/event_constraints.rb', line 769

def explain_static(task)
    return unless static?(task)

    if predicates[0].static?(task)
        this_generator = task.event(predicates[0].event_name)
        if !predicates[0].evaluate(task) || evaluate(task)
            Explanation.new(nil, self, [this_generator])
        else # first event emitted, second event cannot be emitted (static)
            other_generator = task.event(predicates[1].event_name)
            Explanation.new(nil, self, [other_generator])
        end
    else
        other_generator = task.event(predicates[1].event_name)
        Explanation.new(nil, self, [other_generator])
    end
end

#explain_true(task) ⇒ Object



749
750
751
752
753
754
755
# File 'lib/roby/event_constraints.rb', line 749

def explain_true(task)
    return unless evaluate(task)

    this_event  = task.event(predicates[0].event_name).last
    other_event = task.event(predicates[1].event_name).last
    Explanation.new(true, self, [this_event, other_event])
end

#static?(task) ⇒ Boolean

Returns:

  • (Boolean)


786
787
788
789
790
791
792
793
794
795
796
797
# File 'lib/roby/event_constraints.rb', line 786

def static?(task)
    event0 = task.event(predicates[0].event_name)
    event1 = task.event(predicates[1].event_name)

    if event0.unreachable?
        !predicates[0].evaluate(task) || # stays false as pred[0] can't emit
            evaluate(task) || # stays true as pred[0] can't emit
            predicates[1].static?(task) # pred1 can't change value
    elsif event1.unreachable?
        !evaluate(task)
    end
end

#to_sObject



806
807
808
# File 'lib/roby/event_constraints.rb', line 806

def to_s
    "#{predicates[0].event_name}.followed_by(#{predicates[1].event_name})"
end