Class: Orocos::RubyTasks::StubTaskContext
- Inherits:
-
TaskContext
- Object
- TaskContextBase
- TaskContext
- TaskContext
- Orocos::RubyTasks::StubTaskContext
- Defined in:
- lib/orocos/ruby_tasks/stub_task_context.rb
Defined Under Namespace
Classes: Operation, SendHandle
Constant Summary
Constants inherited from TaskContextBase
TaskContextBase::RUNNING_STATES
Constants included from Namespace
Instance Attribute Summary
Attributes inherited from TaskContext
Attributes inherited from TaskContextBase
#attributes, #configuration_log, #current_state, #ior, #process, #properties, #state_symbols
Instance Method Summary collapse
- #has_operation?(name, with_stubs: true) ⇒ Boolean
- #operation(name) ⇒ Object
- #setup_from_orogen_model(orogen_model) ⇒ Object
Methods inherited from TaskContext
#create_attribute, #create_input_port, #create_output_port, #create_property, #dispose, #exception, from_orogen_model, #has_port?, #initialize, new, #raw_port, #remove_port
Methods inherited from TaskContext
#==, #apply_conf, #apply_conf_file, #attribute, #attribute_names, #callop, #cleanup, #configure, #connect_to, corba_wrap, #create_property_log_stream, #disconnect_from, #do_attribute_names, #do_attribute_read, #do_attribute_read_string, #do_attribute_type_name, #do_attribute_write, #do_attribute_write_string, #do_cleanup, #do_configure, #do_has_operation?, #do_has_port?, #do_operation_call, #do_operation_names, #do_operation_send, #do_port, #do_port_names, #do_property_names, #do_property_read, #do_property_read_string, #do_property_type_name, #do_property_write, #do_property_write_string, #do_real_name, #do_reset_exception, #do_start, #do_state, #do_stop, #has_port?, #initialize, #log_all_configuration, #log_all_ports, #model, new, #operation_argument_types, #operation_names, #operation_return_types, #peek_state, #ping, #port, #port_names, #property, #property_names, #raw_port, #raw_property, #reset_exception, #resolve_connection_from, #resolve_disconnection_from, #rtt_state, #save_conf, #sendop, #start, #state_reader, state_transition_call, #stop, #tid, #to_async, #to_proxy, #to_s, #wait_for_state
Methods inherited from TaskContextBase
#add_default_states, #available_states, #basename, connect_to, #connect_to, #doc, #doc?, #each_attribute, #each_input_port, #each_operation, #each_output_port, #each_port, #each_property, #error?, #error_state?, #exception?, #exception_state?, #fatal_error?, #fatal_error_state?, find_one_running, get, get_provides, #has_attribute?, #has_port?, #has_property?, #implements?, #info, #initialize, #input_port, #input_port_model, #inspect, #method_missing, #model, #model=, #name, #on_localhost?, #output_port, #output_port_model, #peek_current_state, #peek_state, #ports, #pre_operational?, #pretty_print, reachable?, #reachable?, #ready?, #running?, #runtime_error?, #runtime_state?, #state, #state_changed?, #states, #to_h, #to_s, #toplevel_state
Methods included from Namespace
#basename, #map_to_namespace, #namespace, #namespace=, #same_namespace?, #split_name, split_name, validate_namespace_name, #verify_same_namespace
Methods included from PortsSearchable
#find_all_input_ports, #find_all_output_ports, #find_all_ports, #find_input_port, #find_output_port, #find_port
Methods included from TaskContextBaseAbstract
#attribute, #attribute_names, #operation_names, #ping, #port, #port_names, #property, #property_names, #rtt_state
Constructor Details
This class inherits a constructor from Orocos::RubyTasks::TaskContext
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Orocos::TaskContextBase
Instance Method Details
#has_operation?(name, with_stubs: true) ⇒ Boolean
34 35 36 |
# File 'lib/orocos/ruby_tasks/stub_task_context.rb', line 34 def has_operation?(name, with_stubs: true) super(name) || (with_stubs && !!model.find_operation(name)) end |
#operation(name) ⇒ Object
81 82 83 84 85 86 87 88 89 |
# File 'lib/orocos/ruby_tasks/stub_task_context.rb', line 81 def operation(name) super rescue NotFound if model.find_operation(name) Operation.new(name, self) else raise end end |
#setup_from_orogen_model(orogen_model) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/orocos/ruby_tasks/stub_task_context.rb', line 4 def setup_from_orogen_model(orogen_model) setter_operations = Hash.new orogen_model.each_property.each do |prop| if op = prop.setter_operation setter_operations[op.name] = prop end end stubbed_operations = Module.new orogen_model.each_operation do |op| next if has_operation?(op.name, with_stubs: false) if property = setter_operations[op.name] stubbed_operations.class_eval do define_method(op.name) do |value| self.property(property.name).write(value, Time.now, direct: true) true end end else stubbed_operations.class_eval do define_method(op.name) do |*args| end end end end extend stubbed_operations super end |