module Syskit::Models::TaskContext
This module contains the model-level API for the task context models
It is used to extend every subclass of Syskit::TaskContext
Attributes
Override this model's default configuration manager
@return [String] path to the extension file that got loaded to
extend this model
This component's oroGen model
Public Instance Methods
# File lib/syskit/models/task_context.rb, line 153 def apply_block(&block) evaluation = DataServiceModel::BlockInstanciator.new(self) evaluation.instance_eval(&block) end
# File lib/syskit/models/task_context.rb, line 59 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
Returns the configuration management object for this task model
@return [TaskConfigurationManager]
# File lib/syskit/models/task_context.rb, line 190 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
Creates a subclass of TaskContext that represents the given task specification. The class is registered as Roby::Orogen::ProjectName::ClassName.
# File lib/syskit/models/task_context.rb, line 104 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
Clears all registered submodels
On TaskContext, it also clears all orogen-to-syskit model mappings
# File lib/syskit/models/task_context.rb, line 46 def deregister_submodels(set) super if @proxy_task_models set.each do |m| if m.respond_to?(:proxied_data_services) proxy_task_models.delete(m.proxied_data_services.to_set) end end end true end
# File lib/syskit/models/task_context.rb, line 178 def each_event_port(&block) orogen_model.each_event_port(&block) end
Generates a hash of oroGen-level state names to Roby-level event names
@return [{Symbol=>Symbol}]
# File lib/syskit/models/task_context.rb, line 80 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 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
# File lib/syskit/models/task_context.rb, line 208 def merge_service_model(service_model, port_mappings) Syskit::Models.merge_orogen_task_context_models( orogen_model, [service_model.orogen_model], port_mappings) end
Checks if a given component implementation needs to be stubbed
# File lib/syskit/models/task_context.rb, line 39 def needs_stub?(component) super || component.orocos_task.kind_of?(Orocos::RubyTasks::StubTaskContext) end
Create a new TaskContext model
@option options [String] name (nil) forcefully set a name for the model.
This is only useful for "anonymous" models, i.e. models that are never assigned in the Ruby constant hierarchy
@option options [Orocos::Spec::TaskContext, Orocos::ROS::Spec::Node] #orogen_model (nil) the
oroGen model that should be used. If not given, an empty model is created, possibly with the name given to the method as well.
# File lib/syskit/models/task_context.rb, line 149 def new_submodel(options = Hash.new, &block) super end
Set this class up to represent an oroGen root model
# File lib/syskit/models/task_context.rb, line 131 def root_model @orogen_model = Models.create_orogen_task_context_model make_state_events end
Sets up self on the basis of {#supermodel}
@param [String] name an optional name for this submodel @return [void]
# File lib/syskit/models/task_context.rb, line 162 def setup_submodel(submodel, orogen_model: nil, **options) if !orogen_model orogen_model = self.orogen_model.class.new( Roby.app.default_orogen_project, submodel.name, subclasses: self.orogen_model) orogen_model.extended_state_support end submodel.orogen_model = orogen_model super submodel.make_state_events end
# File lib/syskit/models/task_context.rb, line 174 def worstcase_processing_time(value) orogen_model.worstcase_processing_time(value) end