Class: Roby::Task::DRoby
- Inherits:
-
PlanObject::DRoby
- Object
- BasicObject::DRoby
- PlanObject::DRoby
- Roby::Task::DRoby
- Includes:
- LoggedTask
- Defined in:
- lib/roby/distributed/proxy.rb,
lib/roby/log/notifications.rb,
lib/roby/log/relations.rb
Overview
An intermediate representation of Task objects suitable to be sent to our peers.
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
The set of dRoby-formatted arguments.
-
#data ⇒ Object
readonly
The task’s internal data.
-
#displayed_state ⇒ Object
readonly
Returns the value of attribute displayed_state.
-
#flags ⇒ Object
readonly
A set of boolean flags which describe the task’s status.
-
#last_event ⇒ Object
Returns the value of attribute last_event.
-
#mission ⇒ Object
Returns the value of attribute mission.
Attributes included from LoggedPlanObject
Attributes inherited from PlanObject::DRoby
Attributes inherited from BasicObject::DRoby
Instance Method Summary collapse
- #current_state ⇒ Object
- #display(display, graphics_item) ⇒ Object
- #display_name(display) ⇒ Object
-
#initialize(remote_siblings, owners, model, plan, arguments, data, flags) ⇒ DRoby
constructor
Create a new DRoby object with the given information See also PlanObject::DRoby.new.
-
#proxy(peer) ⇒ Object
Create a new proxy which maps the object of
peerrepresented by this communication intermediate. -
#to_s ⇒ Object
:nodoc:.
-
#update(peer, task) ⇒ Object
Updates an already existing proxy using the information contained in this object.
- #update_graphics(display, graphics_item) ⇒ Object
Methods included from LoggedTask
#display_create, #display_time_end, #display_time_start, #dot_label, #layout_events
Methods included from LoggedPlanObject
#apply_layout, #dot_label, #to_dot
Methods inherited from PlanObject::DRoby
#display_create, #display_events, #display_parent
Methods inherited from BasicObject::DRoby
#owners_to_s, #remote_siblings_to_s, #sibling_on
Constructor Details
#initialize(remote_siblings, owners, model, plan, arguments, data, flags) ⇒ DRoby
Create a new DRoby object with the given information See also PlanObject::DRoby.new
243 244 245 246 |
# File 'lib/roby/distributed/proxy.rb', line 243 def initialize(remote_siblings, owners, model, plan, arguments, data, flags) super(remote_siblings, owners, model, plan) @arguments, @data, @flags = arguments, data, flags end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
The set of dRoby-formatted arguments
230 231 232 |
# File 'lib/roby/distributed/proxy.rb', line 230 def arguments @arguments end |
#data ⇒ Object (readonly)
The task’s internal data
232 233 234 |
# File 'lib/roby/distributed/proxy.rb', line 232 def data @data end |
#displayed_state ⇒ Object (readonly)
Returns the value of attribute displayed_state.
191 192 193 |
# File 'lib/roby/log/relations.rb', line 191 def displayed_state @displayed_state end |
#flags ⇒ Object (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
239 240 241 |
# File 'lib/roby/distributed/proxy.rb', line 239 def flags @flags end |
#last_event ⇒ Object
Returns the value of attribute last_event.
171 172 173 |
# File 'lib/roby/log/relations.rb', line 171 def last_event @last_event end |
#mission ⇒ Object
Returns the value of attribute mission.
4 5 6 |
# File 'lib/roby/log/notifications.rb', line 4 def mission @mission end |
Instance Method Details
#current_state ⇒ Object
181 182 183 184 185 186 187 188 189 |
# File 'lib/roby/log/relations.rb', line 181 def current_state new_state = if plan && plan.finalized_tasks.include?(self) :finalized else [:success, :finished, :started, :pending]. find { |flag| flags[flag] } end new_state || :pending end |
#display(display, graphics_item) ⇒ Object
204 205 206 207 208 |
# File 'lib/roby/log/relations.rb', line 204 def display(display, graphics_item) update_graphics(display, graphics_item) super layout_events(display) end |
#display_name(display) ⇒ Object
173 174 175 176 177 178 179 |
# File 'lib/roby/log/relations.rb', line 173 def display_name(display) name = display.filter_prefixes(model.ancestors[0][0].dup) if display.show_ownership name << "\n#{owners_to_s}" end name end |
#proxy(peer) ⇒ Object
Create a new proxy which maps the object of peer represented by this communication intermediate.
254 255 256 257 258 259 260 261 262 |
# File 'lib/roby/distributed/proxy.rb', line 254 def proxy(peer) arguments = peer.local_object(self.arguments) peer.local_object(model).new(arguments) do Roby::Distributed.updated_objects << self end ensure Roby::Distributed.updated_objects.delete(self) end |
#to_s ⇒ Object
:nodoc:
248 249 250 |
# File 'lib/roby/distributed/proxy.rb', line 248 def to_s # :nodoc: "#<dRoby:#{model.ancestors.first.first}#{remote_siblings_to_s} plan=#{plan} owners=#{owners_to_s} arguments=#{arguments}>" end |
#update(peer, task) ⇒ Object
Updates an already existing proxy using the information contained in this object.
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
# File 'lib/roby/distributed/proxy.rb', line 266 def update(peer, task) super task.started = flags[:started] task.finished = flags[:finished] task.success = flags[:success] if task.mission? != flags[:mission] plan = peer.local_object(self.plan) || Roby.plan if plan.owns?(task) if flags[:mission] plan.insert(task) else plan.discard(task) end else task.mission = flags[:mission] end end task.arguments.merge!(peer.proxy(arguments)) task.instance_variable_set("@data", peer.proxy(data)) end |
#update_graphics(display, graphics_item) ⇒ Object
192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/roby/log/relations.rb', line 192 def update_graphics(display, graphics_item) new_state = current_state if displayed_state != new_state graphics_item.brush = Qt::Brush.new(Log::TASK_BRUSH_COLORS[new_state]) graphics_item.pen = Qt::Pen.new(Log::TASK_PEN_COLORS[new_state]) displayed_state = new_state end graphics_item.text.plain_text = display_name(display).to_s end |