Class: Roby::TaskEventGenerator::DRoby

Inherits:
Object
  • Object
show all
Defined in:
lib/roby/distributed/proxy.rb

Overview

An intermediate representation of TaskEventGenerator objects suitable to be sent to our peers.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controlable, happened, task, symbol) ⇒ DRoby

Create a new DRoby object with the given information



175
176
177
178
179
180
# File 'lib/roby/distributed/proxy.rb', line 175

def initialize(controlable, happened, task, symbol)
    @controlable = controlable
    @happened = happened
    @task   = task
    @symbol = symbol
end

Instance Attribute Details

#controlableObject (readonly)

True if the generator is controlable



164
165
166
# File 'lib/roby/distributed/proxy.rb', line 164

def controlable
  @controlable
end

#happenedObject (readonly)

True if the generator has already emitted once at the time TaskEventGenerator#droby_dump has been called.



167
168
169
# File 'lib/roby/distributed/proxy.rb', line 167

def happened
  @happened
end

#symbolObject (readonly)

The event name



172
173
174
# File 'lib/roby/distributed/proxy.rb', line 172

def symbol
  @symbol
end

#taskObject (readonly)

An object representing the task of this generator on our remote peer.



170
171
172
# File 'lib/roby/distributed/proxy.rb', line 170

def task
  @task
end

Instance Method Details

#proxy(peer) ⇒ Object

Create a new proxy which maps the object of peer represented by this communication intermediate.



192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/roby/distributed/proxy.rb', line 192

def proxy(peer)
    task = peer.local_object(self.task)
    unless task.has_event?(symbol)
 Roby::Distributed.debug { "ignoring #{self}: #{symbol} is not known on #{task}" }
 Roby::Distributed.ignore!
    end
    event = task.event(symbol)
    
    if happened && !event.happened?
 event.instance_eval { @happened = true }
    end
    event
end

#to_sObject

:nodoc:



182
183
184
185
186
187
188
# File 'lib/roby/distributed/proxy.rb', line 182

def to_s # :nodoc:
    if task.respond_to?(:model)
 "#<dRoby:#{task.model.ancestors.first.first}/#{symbol}#{task.remote_siblings_to_s} task_arguments=#{task.arguments} plan=#{task.plan} owners=#{task.owners_to_s}>"
    else
 "#<dRoby:#{task}/#{symbol}>"
    end
end