Class: Roby::DRoby::V5::TaskDumper::DRoby

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

Overview

An intermediate representation of Task 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, arguments, data, **flags) ⇒ DRoby

Create a new DRoby object with the given information



534
535
536
537
# File 'lib/roby/droby/v5/droby_dump.rb', line 534

def initialize(remote_siblings, owners, model, plan_id, arguments, data, **flags)
    super(remote_siblings, owners, model, plan_id)
    @arguments, @data, @flags = arguments, data, flags
end

Instance Attribute Details

#argumentsObject (readonly)

The set of dRoby-formatted arguments



522
523
524
# File 'lib/roby/droby/v5/droby_dump.rb', line 522

def arguments
  @arguments
end

#dataObject (readonly)

The task's internal data



524
525
526
# File 'lib/roby/droby/v5/droby_dump.rb', line 524

def data
  @data
end

#flagsObject (readonly)

A set of boolean flags which describe the task's status. It is a symbol => bool flag where the following parameters are save:

started

if the task has started

finished

if the task has finished

success

if the task has finished with success

mission

if the task is a mission in its plan



531
532
533
# File 'lib/roby/droby/v5/droby_dump.rb', line 531

def flags
  @flags
end

Instance Method Details

#proxy(peer) ⇒ Object

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



541
542
543
544
545
# File 'lib/roby/droby/v5/droby_dump.rb', line 541

def proxy(peer)
    model     = peer.local_object(self.model)
    arguments = peer.local_object(self.arguments)
    model.new(plan: local_plan(peer), **arguments)
end

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

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



549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
# File 'lib/roby/droby/v5/droby_dump.rb', line 549

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

    task.started  = flags[:started]
    task.finished = flags[:finished]
    task.success  = flags[:success]

    if task.mission? != flags[:mission]
        if flags[:mission]
            task.plan.add_mission_task(task)
        else
            task.plan.unmark_mission_task(task)
        end
    end

    unless fresh_proxy
        task.arguments.force_merge!(peer.local_object(arguments))
    end
    task.instance_variable_set("@data", peer.local_object(data))
end