Class: Roby::StateEvent

Inherits:
EventGenerator show all
Defined in:
lib/roby/state/events.rb

Overview

A state event is an event which emits when some parameters over the state are reached. See DeltaEvent and TimePointEvent.

Direct Known Subclasses

DeltaEvent, StateConditionEvent

Instance Attribute Summary

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

#relation_graphs

Attributes inherited from DistributedObject

#local_owner_id, #owners

Instance Method Summary collapse

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_failed, #emit_without_propagation, #emitting, #filter, #finalized!, #fire, #fired, #forward, #forward_once, #forward_to, #forward_to_once, #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

#droby_id, #initialize_copy

Methods included from DRoby::V5::DRobyConstant::Dump

#droby_dump

Methods included from DRoby::V5::EventGeneratorDumper

#droby_dump

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(*args, &block) ⇒ StateEvent

Returns a new instance of StateEvent.



112
113
114
115
116
# File 'lib/roby/state/events.rb', line 112

def initialize(*args, &block)
    @disabled = nil
    @armed = true
    super
end

Instance Method Details

#disableObject

Call to disable this event. When the state events are disabled, they will no more emit.



145
# File 'lib/roby/state/events.rb', line 145

def disable; @disabled = true end

#disabled?Boolean

True if this event is currently disabled

Returns:

  • (Boolean)


136
# File 'lib/roby/state/events.rb', line 136

def disabled?; @disabled end

#emit(*context) ⇒ Object

Emit only if the event is armed



148
149
150
151
152
153
154
155
156
# File 'lib/roby/state/events.rb', line 148

def emit(*context) # :nodoc:
    if armed?
        begin
            super
        ensure
            @armed = false
        end
    end
end

#enable(reset = true) ⇒ Object

Call to reenable this event. If reset is true, the event is reset at the same time.



139
140
141
142
# File 'lib/roby/state/events.rb', line 139

def enable(reset = true)
    @disabled = false
    self.reset if reset
end

#enabled?Boolean

True if this event is currently active

Returns:

  • (Boolean)


134
# File 'lib/roby/state/events.rb', line 134

def enabled?; !@disabled end

#resetObject

After this call, the event will be emitted the next time its state condition is met, regardless of the fact that it has already been emitted or not

See also #armed?



129
130
131
# File 'lib/roby/state/events.rb', line 129

def reset
    @armed = true
end