Module: Syskit::Models::TaskContext
- Includes:
- Component, OrogenBase, PortAccess
- Included in:
- TaskContext
- Defined in:
- lib/syskit/models/task_context.rb
Overview
This module contains the model-level API for the task context models
It is used to extend every subclass of Syskit::TaskContext
Constant Summary
Constants included from Component
Instance Attribute Summary collapse
-
#configuration_manager ⇒ TaskConfigurationManager
Returns the configuration management object for this task model.
-
#extension_file ⇒ String
Path to the extension file that got loaded to extend this model.
-
#orogen_model ⇒ Object
This component's oroGen model.
Attributes included from Component
Instance Method Summary collapse
-
#all_state_event ⇒ Array<Object>
The union, along the class hierarchy, of all the values stored in state_event.
- #apply_block(&block) ⇒ Object
- #clear_registration_as_constant ⇒ Object
-
#define_from_orogen(orogen_model, register: false) ⇒ Object
Creates a subclass of TaskContext that represents the given task specification.
- #each_event_port(&block) ⇒ Object
-
#each_state_event {|element| ... } ⇒ Object
Enumerates all objects registered in state_event.
-
#make_state_events ⇒ {Symbol=>Symbol}
Generates a hash of oroGen-level state names to Roby-level event names.
-
#merge_service_model(service_model, port_mappings) ⇒ Object
Merge the service model into self.
-
#needs_stub?(component) ⇒ Boolean
Checks if a given component implementation needs to be stubbed.
-
#new_submodel(options = Hash.new, &block) ⇒ Object
Create a new TaskContext model.
-
#root_model ⇒ Object
Set this class up to represent an oroGen root model.
-
#setup_submodel(submodel, orogen_model: nil, orogen_model_name: submodel.name, **options) ⇒ void
Sets up self on the basis of Component#supermodel.
-
#state_events ⇒ Object
A state_name => event_name mapping that maps the component's state names to the event names that should be emitted when it enters a new state.
- #worstcase_processing_time(value) ⇒ Object
Methods included from OrogenBase
#find_model_by_orogen, #find_model_from_orogen_name, #has_model_for?, #model_for
Methods included from PortAccess
#each_input_port, #each_output_port, #each_port, #find_input_port, #find_output_port, #find_port, #find_through_method_missing, #has_dynamic_input_port?, #has_dynamic_output_port?, #has_input_port?, #has_output_port?, #has_port?, #has_through_method_missing?, #port_by_name
Methods included from Component
#all_data_service, #all_dynamic_service, #all_stub_module, #apply_missing_dynamic_services_from, #as, #as_plan, #bind, #can_merge?, #clear_model, #component_model?, #compute_port_mappings, #concrete_model?, #connected?, #create_dynamic_instantiation_context, #create_private_specialization, #create_proxy_task, #create_proxy_task_model, #data_service, #data_services, #deregister_placeholder_model, #deregister_submodels, #driver_for, #dynamic_service, #dynamic_services, #each_com_bus_driver_service, #each_data_service, #each_dynamic_service, #each_input_port, #each_master_driver_service, #each_output_port, #each_port, #each_required_dynamic_service, #each_required_model, #each_root_data_service, #each_slave_data_service, #each_stub_module, #ensure_model_is_specialized, #find_all_data_services_from_type, #find_data_service_from_type, #find_directional_port_mapping, #find_input_port, #find_matching_service, #find_output_port, #find_placeholder_model, #find_port, #find_through_method_missing, #fullfills?, #has_through_method_missing?, #if_already_present, #implicit_fullfilled_model, #instanciate, #instanciate_dynamic_input_port, #instanciate_dynamic_output_port, #merge, #method_missing, #placeholder?, #port_mappings_for, #port_mappings_for_task, #prefer_deployed_tasks, #prepare_stub, #private_specialization=, #private_specialization?, #promote_data_service, #promote_dynamic_service, #provides, #provides_dynamic, #proxy_task_model, #register_placeholder_model, #require_dynamic_service, #resolve, #selected_for, #self_port?, #self_port_to_component_port, #specialization_counter, #specialize, #stub, #stub_module, #supermodel, #to_component_model, #try_bind, #try_resolve, #use_conf, #use_deployments, #with_arguments, #with_conf, #with_dynamic_service
Methods included from DataService
Methods included from Base
#dependency_injection_names, #pretty_print, #short_name, #to_instance_requirements, #to_s
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Syskit::Models::Component
Instance Attribute Details
#configuration_manager ⇒ TaskConfigurationManager
Returns the configuration management object for this task model
178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/syskit/models/task_context.rb', line 178 def configuration_manager if !@configuration_manager if !concrete_model? manager = concrete_model.configuration_manager else manager = TaskConfigurationManager.new(Roby.app, self) manager.reload end @configuration_manager = manager end @configuration_manager end |
#extension_file ⇒ String
Returns path to the extension file that got loaded to extend this model
36 37 38 |
# File 'lib/syskit/models/task_context.rb', line 36 def extension_file @extension_file end |
#orogen_model ⇒ Object
This component's oroGen model
112 113 114 |
# File 'lib/syskit/models/task_context.rb', line 112 def orogen_model @orogen_model end |
Instance Method Details
#all_state_event ⇒ Array<Object>
The union, along the class hierarchy, of all the values stored in state_event
123 |
# File 'lib/syskit/models/task_context.rb', line 123 inherited_attribute(:state_event, :state_events, map: true) { Hash.new } |
#apply_block(&block) ⇒ Object
137 138 139 140 |
# File 'lib/syskit/models/task_context.rb', line 137 def apply_block(&block) evaluation = DataServiceModel::BlockInstanciator.new(self) evaluation.instance_eval(&block) end |
#clear_registration_as_constant ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/syskit/models/task_context.rb', line 43 def clear_registration_as_constant super if name = self.name return if name !~ /^OroGen::/ name = name.gsub(/^OroGen::/, '') begin if constant("::#{name}") == self spacename = self.spacename.gsub(/^OroGen::/, '') constant("::#{spacename}").send(:remove_const, basename) end rescue NameError false end end end |
#define_from_orogen(orogen_model, register: false) ⇒ Object
Creates a subclass of TaskContext that represents the given task specification. The class is registered as Roby::Orogen::ProjectName::ClassName.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/syskit/models/task_context.rb', line 88 def define_from_orogen(orogen_model, register: false) if model = find_model_by_orogen(orogen_model) # already defined, probably because of dependencies return model end superclass = orogen_model.superclass if !superclass # we are defining a root model supermodel = self else supermodel = find_model_by_orogen(superclass) || define_from_orogen(superclass, register: register) end klass = supermodel.new_submodel(orogen_model: orogen_model) if register && orogen_model.name OroGen.syskit_model_toplevel_constant_registration = Roby.app.backward_compatible_naming? klass.name = OroGen.register_syskit_model(klass) end klass end |
#each_event_port(&block) ⇒ Object
166 167 168 |
# File 'lib/syskit/models/task_context.rb', line 166 def each_event_port(&block) orogen_model.each_event_port(&block) end |
#each_state_event {|element| ... } ⇒ Object
Enumerates all objects registered in state_event
123 |
# File 'lib/syskit/models/task_context.rb', line 123 inherited_attribute(:state_event, :state_events, map: true) { Hash.new } |
#make_state_events ⇒ {Symbol=>Symbol}
Generates a hash of oroGen-level state names to Roby-level event names
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/syskit/models/task_context.rb', line 64 def make_state_events with_superclass = !supermodel || !supermodel.respond_to?(:orogen_model) || (supermodel.orogen_model != orogen_model.superclass) orogen_model.each_state(with_superclass: with_superclass) do |name, type| event_name = name.snakecase.downcase.to_sym if type == :toplevel event event_name, terminal: (name == 'EXCEPTION' || name == 'FATAL_ERROR') else event event_name, terminal: (type == :exception || type == :fatal_error) if type == :fatal forward event_name => :fatal_error elsif type == :exception forward event_name => :exception elsif type == :error forward event_name => :runtime_error end end self.state_events[name.to_sym] = event_name end end |
#merge_service_model(service_model, port_mappings) ⇒ Object
Merge the service model into self
This is mainly used during dynamic service instantiation, to update the underlying ports and trigger model based on the service's orogen model
196 197 198 199 |
# File 'lib/syskit/models/task_context.rb', line 196 def merge_service_model(service_model, port_mappings) Syskit::Models.merge_orogen_task_context_models( orogen_model, [service_model.orogen_model], port_mappings) end |
#needs_stub?(component) ⇒ Boolean
Checks if a given component implementation needs to be stubbed
39 40 41 |
# File 'lib/syskit/models/task_context.rb', line 39 def needs_stub?(component) super || component.orocos_task.kind_of?(Orocos::RubyTasks::StubTaskContext) end |
#new_submodel(options = Hash.new, &block) ⇒ Object
Create a new TaskContext model
133 134 135 |
# File 'lib/syskit/models/task_context.rb', line 133 def new_submodel( = Hash.new, &block) super end |
#root_model ⇒ Object
Set this class up to represent an oroGen root model
115 116 117 118 |
# File 'lib/syskit/models/task_context.rb', line 115 def root_model @orogen_model = Models.create_orogen_task_context_model make_state_events end |
#setup_submodel(submodel, orogen_model: nil, orogen_model_name: submodel.name, **options) ⇒ void
This method returns an undefined value.
Sets up self on the basis of Component#supermodel
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/syskit/models/task_context.rb', line 146 def setup_submodel(submodel, orogen_model: nil, orogen_model_name: submodel.name, **) unless orogen_model orogen_model = self.orogen_model.class.new( Roby.app.default_orogen_project, orogen_model_name, subclasses: self.orogen_model) orogen_model.extended_state_support end submodel.orogen_model = orogen_model super submodel.make_state_events end |
#state_events ⇒ Object
A state_name => event_name mapping that maps the component's state names to the event names that should be emitted when it enters a new state.
123 |
# File 'lib/syskit/models/task_context.rb', line 123 inherited_attribute(:state_event, :state_events, map: true) { Hash.new } |
#worstcase_processing_time(value) ⇒ Object
162 163 164 |
# File 'lib/syskit/models/task_context.rb', line 162 def worstcase_processing_time(value) orogen_model.worstcase_processing_time(value) end |