Class: Roby::Coordination::Models::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/roby/coordination/models/event.rb

Overview

A representation of an event on the execution context’s task

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(task, symbol) ⇒ Event

Returns a new instance of Event.



13
14
15
# File 'lib/roby/coordination/models/event.rb', line 13

def initialize(task, symbol)
    @task, @symbol = task, symbol.to_sym
end

Instance Attribute Details

#symbolSymbol (readonly)

Returns the event’s symbol.

Returns:

  • (Symbol)

    the event’s symbol



11
12
13
# File 'lib/roby/coordination/models/event.rb', line 11

def symbol
  @symbol
end

#taskCoordination::Models::Task (readonly)

Returns The task this event is defined on.

Returns:



9
10
11
# File 'lib/roby/coordination/models/event.rb', line 9

def task
  @task
end

Instance Method Details

#==(other) ⇒ Object



22
23
24
25
26
# File 'lib/roby/coordination/models/event.rb', line 22

def ==(other)
    other.kind_of?(self.class) &&
        other.symbol == symbol &&
        other.task == task
end

#forward_to(root_event) ⇒ Object

When running in this event’s state, forward this event to the given root task event



30
31
32
33
34
35
36
37
38
# File 'lib/roby/coordination/models/event.rb', line 30

def forward_to(root_event)
    unless root_event.task.respond_to?(:coordination_model)
        raise NotRootEvent, "can only forward to a root event"
    end

    root_event.task.coordination_model.parse_names
    root_event.task.coordination_model
        .forward task, self, root_event
end

#new(execution_context) ⇒ Coordination::Base::Event

Returns:

  • (Coordination::Base::Event)


18
19
20
# File 'lib/roby/coordination/models/event.rb', line 18

def new(execution_context)
    Coordination::Event.new(execution_context, self)
end

#to_sObject



40
41
42
# File 'lib/roby/coordination/models/event.rb', line 40

def to_s
    "#{task}.#{symbol}_event"
end