class OroGen::Spec::Deployment
Instances of this class are used to define a deployment. The deployment is the part in which the TaskContext classes are instanciated and associated with specific Activity classes.
Constants
- KNOWN_LOG_LEVELS
Attributes
The set of connections set up for this deployment. This is a set of [from, to] PortDeployment objects.
The deployment name
The set of peer pairs set up for this deployment. This is a set of [a, b] TaskDeployment objects.
The underlying Project object
The set of tasks that need to be deployed
Public Class Methods
# File lib/orogen/spec/deployment.rb, line 532 def initialize(project = nil, name = nil) @project = project @name = name @install = true @task_activities = Array.new @file_reporters = Hash.new @loggers = Hash.new @connections = Array.new @tcp_reporters = Hash.new @peers = Set.new @corba_enabled = nil @browse = nil @loglevel = nil @transports = Array.new @manually_loaded_types = Set.new @lock_timeout_no_period = nil @lock_timeout_period_factor = nil end
Public Instance Methods
handels theActivity creation order to be sure that all activities are created in the right order
# File lib/orogen/spec/deployment.rb, line 706 def activity_ordered_tasks(ordered=Array.new) oldsize = ordered.size() (task_activities - ordered).each do |task| if !task.master || ordered.include?(task.master) ordered << task end end if ordered.size == task_activities.size return ordered elsif oldsize == ordered.size() activities = task_activities.map do |task| "\n #{task.name} (master: #{task.master ? task.master.name : "none"})" end raise ArgumentError, "I cannot find an order in which to create the deployed tasks of #{name} during deployment" << "Did you created a loop among master and slave activities ?. The #{activities.size} deployed tasks are:#{activities.join("\n ")}" else return activity_ordered_tasks(ordered) end end
# File lib/orogen/spec/deployment.rb, line 736 def add_default_logger project.using_task_library "logger" task("#{name}_Logger", 'logger::Logger') end
Declare that the given tasks are peers
# File lib/orogen/spec/deployment.rb, line 766 def add_peers(a, b) peers << [a, b] self end
Connects the two given ports or tasks
# File lib/orogen/spec/deployment.rb, line 750 def connect(from, to, policy = Hash.new) add_peers from.activity, to.activity if from.kind_of?(Port) if !from.kind_of?(OutputPort) raise ArgumentError, "in connect(a, b), 'a' must be a writer port" elsif !to.kind_of?(InputPort) raise ArgumentError, "in connect(a, b), 'b' must be a reader port" end end connections << [from, to, ConnPolicy.from_hash(policy)] self end
True if this deployment should export its tasks through CORBA.
It is true by default if the CORBA transport is enabled
# File lib/orogen/spec/deployment.rb, line 686 def corba_enabled? if @corba_enabled.nil? transports.include?('corba') else @corba_enabled end end
Force disabling CORBA support even though the CORBA transport is enabled in this deployment
See corba_enabled?
# File lib/orogen/spec/deployment.rb, line 697 def disable_corba; @corba_enabled = false end
Forbid the deployment from loading the given transport
# File lib/orogen/spec/deployment.rb, line 639 def disable_transport(transport_name) @transports.delete(transport_name.to_str) end
Do not install that deployment
# File lib/orogen/spec/deployment.rb, line 523 def do_not_install; @install = false end
Enumerates the tasks defined on this deployment
@yieldparam [TaskDeployment] task a deployed task
# File lib/orogen/spec/deployment.rb, line 671 def each_task(&block) task_activities.each(&block) end
Force enabling CORBA support even though the CORBA transport is not enabled in this deployment
See corba_enabled?
# File lib/orogen/spec/deployment.rb, line 703 def enable_corba; @corba_enabled = true end
Make the deployment load the given transport
# File lib/orogen/spec/deployment.rb, line 643 def enable_transport(transport_name) @transports << transport_name.to_str end
Returns the deployed task that has this name
@return [TaskDeployment,nil] the deployed task model, or nil if
none exists with that name
# File lib/orogen/spec/deployment.rb, line 679 def find_task_by_name(name) task_activities.find { |act| act.name == name } end
# File lib/orogen/spec/deployment.rb, line 787 def get_lock_timeout_no_period @lock_timeout_no_period end
# File lib/orogen/spec/deployment.rb, line 797 def get_lock_timeout_period_factor @lock_timeout_period_factor end
# File lib/orogen/spec/deployment.rb, line 552 def initialize_copy(old) super @task_activities = @task_activities.dup @transports = @transports.dup @peers = @peers.dup @manually_loaded_types = @manually_loaded_types.dup end
# File lib/orogen/spec/deployment.rb, line 571 def inspect to_s end
True if this deployment should be installed
# File lib/orogen/spec/deployment.rb, line 525 def install?; !!@install end
True if we are generating for Linux
# File lib/orogen/spec/deployment.rb, line 528 def linux?; project.linux? end
Manually Request Loading of Types that are not Provided throught the task_contex typekit.
# File lib/orogen/spec/deployment.rb, line 580 def load_type(typename) if !project.imported_typekits_for(typename).map(&:name)[0] raise ArgumentError, "cannot find a typekit defining #{typename}" end @manually_loaded_types << typename end
Set the lock timeout of a thread, which has no period if set, the minimum setting is 1s
# File lib/orogen/spec/deployment.rb, line 793 def lock_timeout_no_period(timeout_in_s) @lock_timeout_no_period = [1,timeout_in_s].max end
Set the mutex timeout for a thread with a given period by a factor of its period if set, the minimum setting is factor 10 (times the period)
# File lib/orogen/spec/deployment.rb, line 804 def lock_timeout_period_factor(factor) @lock_timeout_period_factor = [10,factor.to_i].max end
The set of transports loaded by this deployment for which a transport should be loaded on the RTT itself
# File lib/orogen/spec/deployment.rb, line 628 def rtt_transports result = self.transports result.delete('typelib') result end
Define an master slave avtivity between tasks
# File lib/orogen/spec/deployment.rb, line 727 def set_master_slave_activity(master, slave) slave.slave_of(master) self end
Deploys a new task using the given task context type, and returns the corresponding TaskDeployment object. This instance can be used to configure the task further (for instance specifying the activity). See TaskDeployment documentation for available options.
# File lib/orogen/spec/deployment.rb, line 654 def task(name, klass) if klass.respond_to?(:to_str) task_context = project.task_model_from_name(klass) else task_context = klass end if find_task_by_name(name) raise ArgumentError, "there is already a task #{name} on the deployment #{self.name}" end deployment = TaskDeployment.new(name, task_context) task_activities << deployment deployment end
# File lib/orogen/spec/deployment.rb, line 567 def to_s "#<#{self.class} name=#{name} tasks=#{task_activities.map { |t| "#{t}" }.join(", ")}>" end
The set of transports loaded by this deployment, as an array of names
# File lib/orogen/spec/deployment.rb, line 635 def transports @transports.to_a.sort end
Returns the set of typekits required by this particular deployment (i.e. the tasks that are deployed in it)
# File lib/orogen/spec/deployment.rb, line 589 def used_typekits task_typekits = task_activities.map do |deployed_task| deployed_task.task_model.used_typekits. map(&:name) end.flatten.to_set @manually_loaded_types.each do |type| tk = project.imported_typekits_for(type).map(&:name)[0] if !tk raise InternalError, "could not find manually loaded type \"#{type}\"" end task_typekits << tk end task_typekits.sort.map do |used_name| this_tk = project.find_typekit(used_name) next if this_tk.virtual? if !this_tk raise InternalError, "#{used_name} is a typekit that is listed by one of the tasks of the #{name} deployment, but the oroGen project #{project.name} does not list it" end this_tk end.compact end
# File lib/orogen/spec/deployment.rb, line 575 def uses_qt? task_activities.any?{|t| t.task_model.uses_qt?} end
True if we are generating for Xenomai
# File lib/orogen/spec/deployment.rb, line 530 def xenomai?; project.xenomai? end