Class: Roby::StateConditionEvent
- Inherits:
-
StateEvent
- Object
- DistributedObject
- PlanObject
- EventGenerator
- StateEvent
- Roby::StateConditionEvent
- Defined in:
- lib/roby/state/events.rb
Overview
Implementation of StateSpace#trigger_when
Instance Attribute Summary collapse
-
#condition ⇒ Object
readonly
Returns the value of attribute condition.
-
#state_space ⇒ Object
readonly
Returns the value of attribute state_space.
-
#variable_path ⇒ Object
readonly
Returns the value of attribute variable_path.
Attributes inherited from EventGenerator
#command, #event_model, #history, #unreachability_reason, #unreachable_handlers
Attributes inherited from PlanObject
#addition_time, #executable, #execution_engine, #finalization_handlers, #finalization_time, #model, #plan, #promise_executor, #removed_at
Attributes included from Transaction::Proxying::Cache
#transaction_forwarder_module, #transaction_proxy_module
Attributes included from Relations::DirectedRelationSupport
Attributes inherited from DistributedObject
Instance Method Summary collapse
-
#initialize(state_space = nil, variable_path = [], condition = nil) ⇒ StateConditionEvent
constructor
A new instance of StateConditionEvent.
- #poll ⇒ Object
Methods inherited from StateEvent
#disable, #disabled?, #emit, #enable, #enabled?, #reset
Methods inherited from EventGenerator
#&, #achieve_asynchronously, #achieve_with, #add_child_object, #call, #call_handlers, #call_unreachable_handlers, #call_without_propagation, #called, #calling, #cancel, #check_call_validity, #check_call_validity_after_calling, #check_emission_validity, #clear_pending, #controlable?, #create_transaction_proxy, #default_command, #delay, #each_precondition, #emit, #emit_failed, #emit_without_propagation, #emitting, #filter, #finalized!, #fire, #fired, #forward, #forward_once, #forward_to, #forward_to_once, #forwarded_to?, #garbage!, #happened?, #if_unreachable, #initialize_copy, #initialize_replacement, #last, #mark_unreachable!, match, #match, #model, #name, #new, #on, #once, #pending, #plan=, #precondition, #pretty_print, #realize_with, #related_events, #related_tasks, #replace_by, #signal, #signals, #signals_once, #to_event, #to_execution_exception, #to_execution_exception_matcher, #unreachable!, #unreachable_without_propagation, #until, #when_unreachable, #|
Methods included from DRoby::Identifiable
Methods included from DRoby::V5::DRobyConstant::Dump
#droby_dump, #droby_marshallable?
Methods included from DRoby::V5::EventGeneratorDumper
Methods included from GUI::RelationsCanvasEventGenerator
#display, #display_create, #display_name, #display_time_end, #display_time_start, priorities, style, styles
Methods included from GUI::RelationsCanvasPlanObject
#display, #display_create, #display_events, #display_name, #display_parent
Methods inherited from PlanObject
#add_child_object, #apply_relation_changes, #as_plan, #can_finalize?, #commit_transaction, #concrete_model, #connection_space, #each_finalization_handler, #each_in_neighbour_merged, #each_out_neighbour_merged, #each_plan_child, #engine, #executable?, #finalized!, #finalized?, #forget_peer, #fullfills?, #garbage!, #garbage?, #initialize_copy, #initialize_replacement, #merged_relations, #promise, #read_write?, #real_object, #remotely_useful?, #replace_by, #replace_subplan_by, #root_object, #root_object?, #subscribed?, #transaction_proxy?, #transaction_stack, #update_on?, #updated_by?, #when_finalized
Methods included from Models::PlanObject
#child_plan_object, #finalization_handler, #match, #when_finalized
Methods included from GUI::GraphvizPlanObject
#apply_layout, #dot_label, #to_dot
Methods included from Relations::DirectedRelationSupport
#[], #[]=, #add_child_object, #add_parent_object, #child_object?, #child_objects, #clear_vertex, #each_child_object, #each_in_neighbour, #each_out_neighbour, #each_parent_object, #each_relation, #each_relation_graph, #each_relation_sorted, #each_root_relation_graph, #enum_child_objects, #enum_parent_objects, #enum_relations, #leaf?, #parent_object?, #parent_objects, #related_object?, #related_objects, #relation_graph_for, #relations, #remove_child_object, #remove_children, #remove_parent_object, #remove_parents, #remove_relations, #root?, #sorted_relations
Methods inherited from DistributedObject
#add_owner, #clear_owners, #initialize_copy, #owned_by?, #remove_owner
Constructor Details
#initialize(state_space = nil, variable_path = [], condition = nil) ⇒ StateConditionEvent
Returns a new instance of StateConditionEvent.
177 178 179 180 181 |
# File 'lib/roby/state/events.rb', line 177 def initialize(state_space = nil, variable_path = [], condition = nil) @state_space, @variable_path, @condition = state_space, variable_path, condition super(false) end |
Instance Attribute Details
#condition ⇒ Object (readonly)
Returns the value of attribute condition.
175 176 177 |
# File 'lib/roby/state/events.rb', line 175 def condition @condition end |
#state_space ⇒ Object (readonly)
Returns the value of attribute state_space.
175 176 177 |
# File 'lib/roby/state/events.rb', line 175 def state_space @state_space end |
#variable_path ⇒ Object (readonly)
Returns the value of attribute variable_path.
175 176 177 |
# File 'lib/roby/state/events.rb', line 175 def variable_path @variable_path end |
Instance Method Details
#poll ⇒ Object
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/roby/state/events.rb', line 183 def poll return unless armed? if !variable_path.empty? value = variable_path.inject(state_space) do |value, element| result = if value.respond_to?("#{element}?") if value.send("#{element}?") value.send(element) end elsif value.respond_to?(element) value.send(element) end unless result break end result end if value && condition.call(value) emit end elsif condition.call emit end end |