Class: Roby::DRoby::V5::EventGeneratorDumper::DRoby

Inherits:
PlanObjectDumper::DRoby show all
Defined in:
lib/roby/droby/v5/droby_dump.rb

Overview

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

Instance Attribute Summary collapse

Attributes inherited from PlanObjectDumper::DRoby

#model, #plan_id

Attributes inherited from DistributedObjectDumper::DRoby

#owners, #remote_siblings

Instance Method Summary collapse

Methods inherited from PlanObjectDumper::DRoby

#local_plan

Constructor Details

#initialize(remote_siblings, owners, model, plan_id, controlable, emitted) ⇒ DRoby

Create a DRoby object with the given information. See also PlanObject::DRoby



339
340
341
342
# File 'lib/roby/droby/v5/droby_dump.rb', line 339

def initialize(remote_siblings, owners, model, plan_id, controlable, emitted)
    super(remote_siblings, owners, model, plan_id)
    @controlable, @emitted = controlable, emitted
end

Instance Attribute Details

#controlableObject (readonly)

True if the generator is controlable



332
333
334
# File 'lib/roby/droby/v5/droby_dump.rb', line 332

def controlable
  @controlable
end

#emittedObject (readonly)

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



335
336
337
# File 'lib/roby/droby/v5/droby_dump.rb', line 335

def emitted
  @emitted
end

Instance Method Details

#proxy(peer) ⇒ Object

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



346
347
348
349
350
351
352
# File 'lib/roby/droby/v5/droby_dump.rb', line 346

def proxy(peer)
    local_object = peer.local_object(model).new(plan: local_plan(peer))
    if controlable
        local_object.command = -> {}
    end
    local_object
end

#update(peer, proxy, fresh_proxy: false) ⇒ Object

Updates an already existing proxy using the information contained in this object.



356
357
358
359
360
361
362
# File 'lib/roby/droby/v5/droby_dump.rb', line 356

def update(peer, proxy, fresh_proxy: false)
    super

    if emitted && !proxy.emitted?
        proxy.instance_eval { @emitted = true }
    end
end